Ejemplo n.º 1
0
        public unsafe void Play()
        {
            if (this._wavePlayer == null && this._waveDuplex == null)
            {
                this._isPlaying = true;
                try
                {
                    switch (this._inputType)
                    {
                    case InputType.SoundCard:
                        if (this._inputDevice == this._outputDevice)
                        {
                            this._waveDuplex = new WaveDuplex(this._inputDevice, this._inputSampleRate, this._inputBufferSize, this.DuplexFiller);
                        }
                        else
                        {
                            this._iqCircularBuffer    = new ComplexCircularBuffer(this._inputBufferSize, 6);
                            this._audioCircularBuffer = new FloatCircularBuffer(this._outputBufferSize, 2);
                            this._waveRecorder        = new WaveRecorder(this._inputDevice, this._inputSampleRate, this._inputBufferSize, this.RecorderFiller);
                            this._wavePlayer          = new WavePlayer(this._outputDevice, this._outputSampleRate, this._outputBufferSize / 2, this.PlayerFiller);
                            this._dspThread           = new Thread(this.DSPProc);
                            this._dspThread.Start();
                        }
                        break;

                    case InputType.WaveFile:
                        this._iqCircularBuffer    = new ComplexCircularBuffer(this._inputBufferSize, 6);
                        this._audioCircularBuffer = new FloatCircularBuffer(this._outputBufferSize, 2);
                        this._wavePlayer          = new WavePlayer(this._outputDevice, this._outputSampleRate, this._outputBufferSize / 2, this.PlayerFiller);
                        this._waveReadThread      = new Thread(this.WaveFileFiller);
                        this._waveReadThread.Start();
                        this._dspThread = new Thread(this.DSPProc);
                        this._dspThread.Start();
                        break;

                    case InputType.Plugin:
                        this._iqCircularBuffer    = new ComplexCircularBuffer(this._inputBufferSize, 6);
                        this._audioCircularBuffer = new FloatCircularBuffer(this._outputBufferSize, 2);
                        this._wavePlayer          = new WavePlayer(this._outputDevice, this._outputSampleRate, this._outputBufferSize / 2, this.PlayerFiller);
                        if (this._frontend is IIQStreamController)
                        {
                            ((IIQStreamController)this._frontend).Start(this.FrontendFiller);
                        }
                        this._dspThread = new Thread(this.DSPProc);
                        this._dspThread.Start();
                        break;
                    }
                    if (this._dspThread != null)
                    {
                        this._dspThread.Name = "DSP Thread";
                    }
                }
                catch
                {
                    this._isPlaying = false;
                    throw;
                }
            }
        }
Ejemplo n.º 2
0
 public void Stop()
 {
     this._isPlaying = false;
     if (this._inputType == InputType.Plugin && this._frontend is IIQStreamController)
     {
         ((IIQStreamController)this._frontend).Stop();
         this._frontend = null;
     }
     if (this._iqCircularBuffer != null)
     {
         this._iqCircularBuffer.Close();
     }
     if (this._audioCircularBuffer != null)
     {
         this._audioCircularBuffer.Close();
     }
     if (this._wavePlayer != null)
     {
         this._wavePlayer.Dispose();
         this._wavePlayer = null;
     }
     if (this._waveRecorder != null)
     {
         this._waveRecorder.Dispose();
         this._waveRecorder = null;
     }
     if (this._waveDuplex != null)
     {
         this._waveDuplex.Dispose();
         this._waveDuplex = null;
     }
     this._inputSampleRate = 0.0;
     if (this._waveReadThread != null)
     {
         this._waveReadThread.Join();
         this._waveReadThread = null;
     }
     if (this._dspThread != null)
     {
         this._dspThread.Join();
         this._dspThread = null;
     }
     if (this._waveFile != null)
     {
         this._waveFile.Dispose();
         this._waveFile = null;
     }
     this._iqCircularBuffer    = null;
     this._audioCircularBuffer = null;
     this._dspOutBuffer        = null;
 }