Esempio n. 1
0
        public static void Play(WavFormatManager wfm, WindowMain.PlotGraphsDelegate plotDelegate, WindowMain handle)
        {
            wavePlayer?.Stop();
            wsp?.StopPlotting();
            wavePlayer = new WaveOut();
            wsp        = new WaveStreamProvider(wfm, plotDelegate, handle);

            wavePlayer.DesiredLatency = 80;
            wavePlayer.Init(wsp);
            wavePlayer.Play();
        }
        public WaveStreamProvider(WavFormatManager wfm, WindowMain.PlotGraphsDelegate plotDelegate, Window windowHandle)
        {
            this.plotMethod = plotDelegate;
            this.handle     = windowHandle;

            this.streamFormat = new WaveFormat((int)wfm.GetSampleRate(), 16, wfm.GetNumberOfChannels());

            if (this.streamFormat.Channels == 1)
            {
                this.bufferMono = wfm.ReadAudioMono();
            }
            else
            {
                this.bufferLeft  = wfm.ReadAudioLeft();
                this.bufferRight = wfm.ReadAudioRight();
            }

            currentBufferIndex = 0;

            this.stopThread    = false;
            this.plotterThread = new Thread(new ThreadStart(this.PlotterThreadFunction));
            this.plotterThread.Start();
        }