public void Play() { if (_wavePlayer != null || _waveDuplex != null) { return; } switch (_inputType) { case InputType.SoundCard: if (_inputDevice == _outputDevice) { _waveDuplex = new WaveDuplex(_inputDevice, _inputSampleRate, _inputBufferSize, DuplexFiller); } else { _iqStream = new ComplexFifoStream(BlockMode.BlockingRead); _audioStream = new FloatFifoStream(BlockMode.BlockingWrite, _outputBufferSize); _waveRecorder = new WaveRecorder(_inputDevice, _inputSampleRate, _inputBufferSize, RecorderFiller); _wavePlayer = new WavePlayer(_outputDevice, _outputSampleRate, _outputBufferSize / 2, PlayerFiller); _dspThread = new Thread(DSPProc); _dspThread.Start(); } break; case InputType.WaveFile: _iqStream = new ComplexFifoStream(BlockMode.BlockingRead); _audioStream = new FloatFifoStream(BlockMode.BlockingWrite, _outputBufferSize); _wavePlayer = new WavePlayer(_outputDevice, _outputSampleRate, _outputBufferSize / 2, PlayerFiller); _waveReadThread = new Thread(WaveFileFiller); _waveReadThread.Start(); _dspThread = new Thread(DSPProc); _dspThread.Start(); break; case InputType.Plugin: _iqStream = new ComplexFifoStream(BlockMode.BlockingRead); _audioStream = new FloatFifoStream(BlockMode.BlockingWrite, _outputBufferSize); _wavePlayer = new WavePlayer(_outputDevice, _outputSampleRate, _outputBufferSize / 2, PlayerFiller); _frontend.Start(FrontendFiller); _dspThread = new Thread(DSPProc); _dspThread.Start(); break; } }
public void Play() { if (_wavePlayer != null || _waveDuplex != null) { return; } #region Stream Hooks if (_streamHookManager != null) { _streamHookManager.InitStreams(_inputBufferSize, _outputBufferSize); if (_streamHookManager.HaveIqObservers) { _streamHookManager.StartIQObserverThread(_inputBufferSize); } _streamHookManager.OutputSampleRate = _outputSampleRate; _streamHookManager.InputSampleRate = _inputSampleRate; } #endregion Utils.Log($"play() input type: {_inputType}"); switch (_inputType) { case InputType.SoundCard: if (_inputDevice == _outputDevice) { _waveDuplex = new WaveDuplex(_inputDevice, _inputSampleRate, _inputBufferSize, DuplexFiller); } else { _iqStream = new ComplexFifoStream(BlockMode.BlockingRead); _audioStream = _streamHookManager == null ? new FloatFifoStream(BlockMode.BlockingWrite, _outputBufferSize) : _streamHookManager.FirstAudioStream; _waveRecorder = new WaveRecorder(_inputDevice, _inputSampleRate, _inputBufferSize, RecorderFiller); _wavePlayer = new WavePlayer(_outputDevice, _outputSampleRate, _outputBufferSize / 2, PlayerFiller); _dspThread = new Thread(DSPProc); _dspThread.Start(); } break; case InputType.WaveFile: _iqStream = new ComplexFifoStream(BlockMode.BlockingRead); _audioStream = _streamHookManager == null ? new FloatFifoStream(BlockMode.BlockingWrite, _outputBufferSize) : _streamHookManager.FirstAudioStream; _wavePlayer = new WavePlayer(_outputDevice, _outputSampleRate, _outputBufferSize / 2, PlayerFiller); _waveReadThread = new Thread(WaveFileFiller); _waveReadThread.Start(); _dspThread = new Thread(DSPProc); _dspThread.Start(); break; case InputType.Plugin: _iqStream = new ComplexFifoStream(BlockMode.BlockingRead); _audioStream = _streamHookManager == null ? new FloatFifoStream(BlockMode.BlockingWrite, _outputBufferSize) : _streamHookManager.FirstAudioStream; _wavePlayer = new WavePlayer(_outputDevice, _outputSampleRate, _outputBufferSize / 2, PlayerFiller); _frontend.Start(FrontendFiller); _dspThread = new Thread(DSPProc); _dspThread.Start(); break; } Utils.Log($"_dspThread: {_dspThread.ManagedThreadId}"); if (_streamHookManager != null) { _streamHookManager.Start(); } }