Accord.DirectSound.AudioCaptureDevice.Start C# (CSharp) Méthode

Start() public méthode

Start audio source.
Starts audio source and return execution to caller. audio source object creates background thread and notifies about new frames with the help of NewFrame event.
public Start ( ) : void
Résultat void
        public void Start()
        {
            if (thread == null)
            {
                framesReceived = 0;
                bytesReceived = 0;

                // create events
                stopEvent = new ManualResetEvent(false);

                // create and start new thread
                thread = new Thread(WorkerThread);
                thread.Name = device.ToString();
                thread.Start();
            }
        }

Usage Example

        /// <summary>
        ///   Starts recording. Only works if the player has
        ///   already been started and is grabbing frames.
        /// </summary>
        /// 
        public void StartRecording()
        {
            if (IsRecording || !IsPlaying) return;

            Rectangle area = CaptureRegion;
            string fileName = newFileName();

            int height = area.Height;
            int width = area.Width;
            int framerate = 1000 / screenStream.FrameInterval;
            int videoBitRate = 10 * 1000 * 1000;
            int audioBitRate = 320 * 1000;

            OutputPath = Path.Combine(main.CurrentDirectory, fileName);
            RecordingStartTime = DateTime.MinValue;
            videoWriter = new VideoFileWriter();

            if (CaptureAudioDevice != null)
            {
                audioDevice = new AudioCaptureDevice(CaptureAudioDevice.Guid);
                audioDevice.Format = SampleFormat.Format16Bit;
                audioDevice.SampleRate = Settings.Default.SampleRate;
                audioDevice.DesiredFrameSize = 4096;
                audioDevice.NewFrame += audioDevice_NewFrame;
                audioDevice.Start();

                videoWriter.Open(OutputPath, width, height, framerate, VideoCodec.H264, videoBitRate,
                    AudioCodec.MP3, audioBitRate, audioDevice.SampleRate, 1);
            }
            else
            {
                videoWriter.Open(OutputPath, width, height, framerate, VideoCodec.H264, videoBitRate);
            }

            HasRecorded = false;
            IsRecording = true;
        }
All Usage Examples Of Accord.DirectSound.AudioCaptureDevice::Start