コード例 #1
0
        private void output_FramePlayingStarted(object sender, PlayFrameEventArgs e)
        {
            updateTrackbar(e.FrameIndex);

            if (e.FrameIndex + e.Count < decoder.Frames)
            {
                int previous = decoder.Position;
                decoder.Seek(e.FrameIndex);
                Signal s = decoder.Decode(e.Count);
                decoder.Seek(previous);

                updateWaveform(s.ToFloat(), s.Length);
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: haf/Accord.Net
        /// <summary>
        ///   Plays the recorded audio stream.
        /// </summary>
        ///
        private void btnPlay_Click(object sender, EventArgs e)
        {
            // First, we rewind the stream
            stream.Seek(0, SeekOrigin.Begin);

            // Then we create a decoder for it
            decoder = new WaveDecoder(stream);

            // Configure the track bar so the cursor
            // can show the proper current position
            if (trackBar1.Value < decoder.Frames)
            {
                decoder.Seek(trackBar1.Value);
            }
            trackBar1.Maximum = decoder.Samples;

            // Here we can create the output audio device that will be playing the recording
            output = new AudioOutputDevice(this.Handle, decoder.SampleRate, decoder.Channels);

            // Wire up some events
            output.FramePlayingStarted += output_FramePlayingStarted;
            output.NewFrameRequested   += output_NewFrameRequested;
            output.Stopped             += output_PlayingFinished;

            // Start playing!
            output.Play();

            updateButtons();
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: yang033/According.net
        /// <summary>
        ///   Plays the recorded audio stream.
        ///   播放录制的音频流。
        /// </summary>
        ///
        private void BtnPlay_Click(object sender, EventArgs e)
        {
            // First, we rewind the stream
            //【1】首先,我们拨回初始值
            stream.Seek(0, SeekOrigin.Begin);

            // Then we create a decoder for it
            //【2】然后我们为它创建一个解码器
            decoder = new WaveDecoder(stream);

            /*Configure the track bar so the cursorcan show the proper current position
             *【3】 配置跟踪条,使光标可以显示正确的当前位置
             */
            if (trackBar1.Value < decoder.Frames)
            {
                decoder.Seek(trackBar1.Value);
            }
            trackBar1.Maximum = decoder.Samples;

            // Here we can create the output audio device that will be playing the recording
            //【4】在这里我们可以创建将播放录音的输出音频设备
            output = new AudioOutputDevice(this.Handle, decoder.SampleRate, decoder.Channels);

            // 【5】Wire up some events 注册一些事件
            //【5.1】指示帧块已开始执行事件。
            output.FramePlayingStarted += output_FramePlayingStarted;
            output.NewFrameRequested   += output_NewFrameRequested;
            output.Stopped             += output_PlayingFinished;

            // Start playing!
            output.Play();

            updateButtons();
        }
コード例 #4
0
        private void btnPlay_Click(object sender, EventArgs e)
        {
            stream.Seek(0, SeekOrigin.Begin);
            decoder = new WaveDecoder(stream);

            if (trackBar1.Value < decoder.Frames)
            {
                decoder.Seek(trackBar1.Value);
            }
            trackBar1.Maximum = decoder.Samples;

            output = new AudioOutputDevice(this.Handle, decoder.SampleRate, decoder.Channels);
            output.NewFrameRequested   += new EventHandler <NewFrameRequestedEventArgs>(output_NewFrameRequested);
            output.Stopped             += new EventHandler(output_PlayingFinished);
            output.FramePlayingStarted += new EventHandler <PlayFrameEventArgs>(output_FramePlayingStarted);
            output.Play();

            updateButtons();
        }