internal static AppShellInitializerResult Initialize(DataAvailable.DACProperties DACProperties)
        {
            DataAvail.Serialization.FileSerializationStream.DeafaultDirectory = DACProperties.LayoutsFolder;

            DataAvail.Data.DbContext.IDbContext dbContext = null;
            
            switch(DACProperties.AdapterType)
            {
                case DataAvailable.DACDataAdapterType.Oracle:
                    //dbContext = new DataAvail.DevArt.Data.Oracle.DbContext();
                    break;
                case DataAvailable.DACDataAdapterType.MSSQL:
                    dbContext = new DataAvail.DevArt.Data.MSSQL.DbContext();
                    break;
                case DataAvailable.DACDataAdapterType.SQLite:
                    dbContext = new DataAvail.DevArt.Data.SQLite.DbContext();
                    break;
            }

            dbContext.ObjectCreator.Connection.ConnectionString = DACProperties.ConnectionString;
            DataAvail.Data.DbContext.DbContext.CurrentContext = dbContext;
            DataAvail.XtraBinding.Controllers.Controller.properties.TempFolder = DACProperties.TempFolder;

            PrepareDirectories(DACProperties.TempFolder);

            return Initialize(DACProperties.Model, DACProperties.ModelView, DACProperties.ModelSecurity, DACProperties.CalculatorManager);
        }
Example #2
0
        void Procedure(int Handle, int Channel, IntPtr Buffer, int Length, IntPtr User)
        {
            var buffer = GetBuffer(Length);

            Marshal.Copy(Buffer, buffer, 0, Length);

            Task.Run(() => DataAvailable?.Invoke(this, new DataAvailableEventArgs(buffer, Length)));
        }
 public void Close()
 {
     if (port != null && port.IsOpen)
     {
         port.Close();
     }
     notify = null;
 }
        private void Procedure(int handle, int channel, IntPtr buffer, int length, IntPtr user)
        {
            var newBuffer = GetBuffer(length);

            Marshal.Copy(buffer, newBuffer, 0, length);

            Task.Run(() => DataAvailable?.Invoke(this, new DataAvailableEventArgs(newBuffer, length)));
        }
Example #5
0
        void AudioProviderOnDataAvailable(object Sender, DataAvailableEventArgs DataAvailableEventArgs)
        {
            _audioEncoder.EnsureBufferIsSufficient(ref _encodedBuffer, DataAvailableEventArgs.Length);

            var encodedLength = _audioEncoder.Encode(DataAvailableEventArgs.Buffer, 0, DataAvailableEventArgs.Length, _encodedBuffer, 0);

            DataAvailable?.Invoke(this, new DataAvailableEventArgs(_encodedBuffer, encodedLength));
        }
Example #6
0
        private void AudioThread()
        {
            while (!_abort.WaitOne(20) && !MainForm.ShuttingDown)
            {
                int dataLength = _audioStream.Read(_audioBuffer, 0, _audioBuffer.Length);
                if (DataAvailable != null)
                {
                    _waveProvider.AddSamples(_audioBuffer, 0, dataLength);

                    if (Listening)
                    {
                        WaveOutProvider.AddSamples(_audioBuffer, 0, dataLength);
                    }

                    //forces processing of volume level without piping it out
                    var sampleBuffer = new float[dataLength];
                    int read         = _sampleChannel.Read(sampleBuffer, 0, dataLength);

                    DataAvailable?.Invoke(this, new DataAvailableEventArgs((byte[])_audioBuffer.Clone(), read));
                }
            }


            try
            {
                if (_sensor != null)
                {
                    _sensor.AudioSource?.Stop();

                    _sensor.Stop();
                    _sensor.SkeletonFrameReady -= SensorSkeletonFrameReady;
                    _sensor.ColorFrameReady    -= SensorColorFrameReady;
                    _sensor.DepthFrameReady    -= SensorDepthFrameReady;

                    _sensor.Dispose();

                    _sensor = null;
                }
            }
            catch
            {
                // ignored
            }

            if (_sampleChannel != null)
            {
                _sampleChannel.PreVolumeMeter -= SampleChannelPreVolumeMeter;
            }

            if (_waveProvider != null && _waveProvider.BufferedBytes > 0)
            {
                _waveProvider.ClearBuffer();
            }

            Listening = false;

            PlayingFinished?.Invoke(this, new PlayingFinishedEventArgs(_res));
        }
Example #7
0
 public void Close()
 {
     Log.WriteLine("NetDriver closing");
     this.running = false;
     this.thread.Interrupt();
     this.thread.Join();
     this.notify = null;
     Log.WriteLine("NetDriver closed");
 }
Example #8
0
        private void OnSoundDataAvailable(object sender, DataAvailableEventArgs dataAvailableEventArgs)
        {
            int readCount;

            while ((readCount = _stream.Read(_readBuffer, 0, _readBuffer.Length)) > 0)
            {
                DataAvailable?.Invoke(_readBuffer, 0, readCount);
            }
        }
Example #9
0
 static void OnDataAvailable(object sender, WaveInEventArgs e)
 {
     DataAvailable?.Invoke(sender, new StreamingAudioBufferAvailableEventArgs(e.Buffer, e.BytesRecorded));
     //if (waveFile != null)
     //{
     //	waveFile.Write(e.Buffer, 0, e.BytesRecorded);
     //	waveFile.Flush();
     //}
 }
Example #10
0
 public void Close()
 {
     logger.DebugFormat("NetDriver closing");
     running = false;
     thread.Interrupt();
     thread.Join();
     notify = null;
     logger.DebugFormat("NetDriver closed");
 }
Example #11
0
 public void Close()
 {
     Log.WriteLine("NetDriver closing");
     running = false;
     thread.Interrupt();
     thread.Join();
     notify = null;
     Log.WriteLine("NetDriver closed");
 }
 public void Close()
 {
     logger.DebugFormat("NetDriver closing");
     running = false;
     thread.Interrupt();
     thread.Join();
     notify = null;
     logger.DebugFormat("NetDriver closed");
 }
Example #13
0
        bool RecordProcedure(int handle, IntPtr ptr, int length, IntPtr user)
        {
            var buffer = GetBuffer(length);

            Marshal.Copy(ptr, buffer, 0, length);

            DataAvailable?.Invoke(this, new DataAvailableEventArgs(buffer, length));

            return(true);
        }
Example #14
0
        bool RecordProcedure(int Handle, IntPtr Ptr, int Length, IntPtr User)
        {
            var buffer = GetBuffer(Length);

            Marshal.Copy(Ptr, buffer, 0, Length);

            DataAvailable?.Invoke(this, new DataAvailableEventArgs(buffer, Length));

            return(true);
        }
Example #15
0
        private void ProcessStereoData(object sender, WaveInEventArgs e)
        {
            WaveBuffer buffer = new(e.Buffer) { ByteBufferCount = e.BytesRecorded };
            int        count  = buffer.FloatBufferCount;

            for (int i = 0; i < count; i += _capture.WaveFormat.Channels)
            {
                DataAvailable?.Invoke(buffer.FloatBuffer[i], buffer.FloatBuffer[i + 1]);
            }
        }
Example #16
0
 private void Timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     if (socket.Available())
     {
         currentData = Read();
         if (currentData != null)
         {
             DataAvailable.Invoke(currentData, null);
         }
     }
 }
 public void AudioDeviceDataAvailable(object sender, DataAvailableEventArgs e)
 {
     try
     {
         DataAvailable?.Invoke(this, new NewDataAvailableArgs((byte[])e.RawData.Clone()));
     }
     catch (Exception ee)
     {
         Logger.Error("AudioDeviceDataAvailable error occured:" + ee.Message);
     }
 }
Example #18
0
        void Processing(IntPtr Buffer, int Length)
        {
            if (_buffer == null || _buffer.Length < Length)
            {
                _buffer = new byte[Length];
            }

            Marshal.Copy(Buffer, _buffer, 0, Length);

            DataAvailable?.Invoke(this, new DataAvailableEventArgs(_buffer, Length));
        }
Example #19
0
        private void ProcessMonoData(object sender, WaveInEventArgs e)
        {
            WaveBuffer buffer = new(e.Buffer) { ByteBufferCount = e.BytesRecorded };
            int        count  = buffer.FloatBufferCount;

            // Handle mono by passing the same data for left and right
            for (int i = 0; i < count; i++)
            {
                DataAvailable?.Invoke(buffer.FloatBuffer[i], buffer.FloatBuffer[i]);
            }
        }
Example #20
0
        void Procedure(int Handle, int Channel, IntPtr Buffer, int Length, IntPtr User)
        {
            if (_buffer == null || _buffer.Length < Length)
            {
                _buffer = new byte[Length];
            }

            Marshal.Copy(Buffer, _buffer, 0, Length);

            DataAvailable?.Invoke(this, new DataAvailableEventArgs(_buffer, Length));
        }
        public void SubscribeToPosition(int positionId, string column)
        {
            _context.Post(state => {
                _positionSubscriptions.Add(positionId, column);

                var da = new DataAvailableEventArgs();
                da.PositionValues.Add((positionId, column), _positionSubscriptions.Get(positionId, column).GetValue());

                DataAvailable?.Invoke(this, da);
            }, null);
        }
        public void SubscribeToSystemValue(SystemProperty property)
        {
            _context.Post(state => {
                _systemValueSubscriptions.Add(property, GetSystemValueProperty(property));

                var da = new DataAvailableEventArgs();
                da.SystemValues.Add(property, _systemValueSubscriptions[property].GetValue());

                DataAvailable?.Invoke(this, da);
            }, null);
        }
Example #23
0
        private void OnDataAvailable(byte[] buffer, int bytesRecorded)
        {
            if (bytesRecorded > 0)
            {
                byte[] data = new byte[bytesRecorded];
                Array.Copy(buffer, data, data.Length);

                DataAvailable?.Invoke(data);

                //DataAvailable?.Invoke(recordBuffer, recordBufferOffset);
            }
        }
Example #24
0
        protected NAudioProvider(IWaveIn WaveIn)
        {
            _waveIn = WaveIn;

            _waveIn.DataAvailable += (S, E) =>
            {
                DataAvailable?.Invoke(this, new DataAvailableEventArgs(E.Buffer, E.BytesRecorded));
            };

            NAudioWaveFormat = WaveIn.WaveFormat;
            WaveFormat       = WaveIn.WaveFormat.ToCaptura();
        }
Example #25
0
 private void DoRecord()
 {
     while (Recording)
     {
         sourceReader.ReadSample(MediaFoundationInterop.MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
         if (callback.NewSample)
         {
             int bytecount = callback.Read(out byte[] data);
             DataAvailable?.Invoke(this, new WaveInEventArgs(data, bytecount));
         }
     }
 }
Example #26
0
        private void SoundInSourceOnDataAvailable(object sender,
                                                  DataAvailableEventArgs dataAvailableEventArgs)
        {
            int read;
            var buffer = new byte[dataAvailableEventArgs.ByteCount];

            while ((read = _captureSource.Read(buffer, 0, buffer.Length)) > 0)
            {
                var notEncodedLength = _notEncodedBuffer?.Length ?? 0;
                var soundBuffer      = new byte[read + notEncodedLength];

                //Fill the soundbuffer with _notEncodedBuffer
                if (notEncodedLength > 0)
                {
                    Buffer.BlockCopy(_notEncodedBuffer, 0, soundBuffer, 0, notEncodedLength);
                }

                //Fill the soundbuffer with the data
                Buffer.BlockCopy(buffer, 0, soundBuffer, notEncodedLength, read);

                var segmentCount = (int)Math.Floor((double)soundBuffer.Length / _bytesPerSegment);

                var segmentsEnd     = segmentCount * _bytesPerSegment;
                var notEncodedCount = soundBuffer.Length - segmentsEnd;
                _notEncodedBuffer = new byte[notEncodedCount];

                Buffer.BlockCopy(soundBuffer, segmentsEnd, _notEncodedBuffer, 0, notEncodedCount);

                if (segmentCount == 0)
                {
                    return;
                }

                var dataBuffers       = new byte[segmentCount][];
                var dataBufferLengths = new int[segmentCount];

                unsafe
                {
                    fixed(byte *soundBufferPtr = soundBuffer)
                    for (int i = 0; i < segmentCount; i++)
                    {
                        int len;

                        dataBuffers[i] = _opusEncoder.Encode(soundBufferPtr + _bytesPerSegment * i, _bytesPerSegment,
                                                             out len);
                        dataBufferLengths[i] = len;
                    }
                }

                DataAvailable?.Invoke(this,
                                      new DataInfoAvailableEventArgs(new VoiceChatDataInfo(dataBuffers, dataBufferLengths)));
            }
        }
        public Task Start()
        {
            Cancellation?.Dispose();
            Cancellation = new CancellationTokenSource();

            var token = Cancellation.Token;

            //start a background task
            Threading.Tasks.FireAndForget(async() =>
            {
                try
                {
                    byte[] buffer = new byte[19200];
                    while (!token.IsCancellationRequested)
                    {
                        int read = await SourceStream.ReadAsync(buffer, 0, buffer.Length, token);
                        if (read == 0)
                        {
                            //end of stream reached
                            Stopped?.Invoke(this, new StreamAudioSourceStoppedEvent()
                            {
                                Cause = StreamAudioSourceStoppedCause.End
                            });
                            return;
                        }
                        DataAvailable?.Invoke(this, new StreamAudioSourceDataEvent()
                        {
                            Buffer = new ArraySegment <byte>(buffer, 0, read),
                            Format = Format
                        });
                    }
                }
                catch (OperationCanceledException)
                {
                    Stopped?.Invoke(this, new StreamAudioSourceStoppedEvent()
                    {
                        Cause = StreamAudioSourceStoppedCause.Stopped
                    });
                }
                catch (Exception ex)
                {
                    Stopped?.Invoke(this, new StreamAudioSourceStoppedEvent()
                    {
                        Cause     = StreamAudioSourceStoppedCause.Exception,
                        Exception = ex
                    });
                    throw;
                }
            });

            return(Task.CompletedTask);
        }
Example #28
0
        bool Procedure(int Handle, IntPtr Buffer, int Length, IntPtr User)
        {
            if (_buffer == null || _buffer.Length < Length)
            {
                _buffer = new byte[Length];
            }

            Marshal.Copy(Buffer, _buffer, 0, Length);

            DataAvailable?.Invoke(_buffer, Length);

            return(true);
        }
Example #29
0
        public void Close()
        {
            if (port != null && port.IsOpen)
            {
                port.Close();
            }

            // rdw:
            lock (notifyLock)
            {
                notify = null;
            }
        }
Example #30
0
        private void RtpChannel_OnFrameReady(RTPFrame frame)
        {
            if (paused)
            {
                return;
            }

            var payload = frame.GetFramePayload();

            received += payload.LongLength;

            DataAvailable?.Invoke(this, new DataEventArgs(payload, payload.Length));
        }
Example #31
0
        bool Procedure(int HRecord, IntPtr Buffer, int Length, IntPtr User)
        {
            if (_buffer == null || _buffer.Length < Length)
            {
                _buffer = new byte[Length];
            }

            Marshal.Copy(Buffer, _buffer, 0, Length);

            DataAvailable?.Invoke(this, new DataAvailableEventArgs(_buffer, Length));

            return(true);
        }
        private void RefreshData()
        {
            if (_computeCount > 0)
            {
                return;
            }

            if (_dataRefreshRequests == 0)
            {
                return;
            }

            //Let Sophis complete its internal calculations
            Sophis.Event.SophisEventManager.Instance.Dispatch();

            _dataRefreshRequests = 0;

            var args = new DataAvailableEventArgs();

            void RefreshPortfolioCells()
            {
                foreach (var cell in _portfolioSubscriptions.GetCells())
                {
                    args.PortfolioValues.Add((cell.FolioId, cell.ColumnName), cell.GetValue());
                }
            }

            void RefreshPositionCells()
            {
                foreach (var cell in _positionSubscriptions.GetCells())
                {
                    args.PositionValues.Add((cell.PositionId, cell.ColumnName), cell.GetValue());
                }
            }

            void RefreshSystemValues()
            {
                foreach (var value in _systemValueSubscriptions)
                {
                    args.SystemValues.Add(value.Key, value.Value.GetValue());
                }
            }

            RefreshPortfolioCells();

            RefreshPositionCells();

            RefreshSystemValues();

            DataAvailable?.Invoke(this, args);
        }
        private void OnAudioAvailable(object sender, AsioAudioAvailableEventArgs e)
        {
            var size = e.SamplesPerBuffer * e.InputBuffers.Length;

            if (_inBuffer == null || _inBuffer.Length < size)
            {
                _inBuffer  = new float[size];
                _outBuffer = new byte[size * 4];
            }
            var samples = e.GetAsInterleavedSamples(_inBuffer);

            Buffer.BlockCopy(_inBuffer, 0, _outBuffer, 0, samples * 4);
            DataAvailable?.Invoke(this, new WaveInEventArgs(_outBuffer, samples * 4));
        }
Example #34
0
 protected void OnGazeDataReceived(double x, double y)
 {
     if (UseSmoothing)
     {
         ApplyKalmanFilters(ref x, ref y);
     }
     if (UseCalibration)
     {
         ApplyCalibration(ref x, ref y);
     }
     DataTimeStamp = DateTime.UtcNow;
     DataPoint     = new Point((int)x, (int)y);
     DataAvailable?.Invoke(this, EventArgs.Empty);
 }
        public void Initialize(DataAvailable.DACProperties DACProperties)
        {
            /*nimpl
            DataAvail.Data.DataSet.Log = new DebugLog();

            DataAvail.XtraBinding.Controllers.Controller.synchronizeInvoke = this;
            DataAvail.XtraBinding.Controllers.Controller.uiCreator = new ControllerUICreator(this);

            DataAvail.XtraBinding.Controllers.Controller.AskExit += new DataAvail.XtraBinding.Controllers.ControllerAskExitHandler(Controller_AskExit);
            DataAvail.XtraBinding.Controllers.Controller.ShowInfo += new DataAvail.XtraBinding.Controllers.ControllerShowInfo(Controller_ShowInfo);
            DataAvail.XtraBinding.Controllers.Controller.AskConfirmation += new DataAvail.XtraBinding.Controllers.ControllerAskConfirmationHandler(Controller_AskConfirmation);

            AppShellInitializer.AppShellInitializerResult result = AppShellInitializer.Initialize(DACProperties);

            _appContext = result.appContext;

            _controllers = result.controllers;

            BuildMenu();        
             */
        }
Example #36
0
 public void SetNotify(DataAvailable notify)
 {
     this.notify = notify;
 }