/// <summary> /// Stop recording audio. /// </summary> public void Stop(SoundRecorder recorder) { if (recorder?.Capturing ?? false) { recorder.Stop(); } }
/// <summary> /// Start capturing audio with default audio input device. /// </summary> /// <param name="sampleRate">The samples rate of sound to use for recording, in samples per second.</param> /// <typeparam name="T">The type of class that will hold recorded audio samples.</typeparam> /// <returns>An instance of <see cref="SoundRecorder{T}"/> to manipulate recording properties and operations.</returns> public SoundRecorder <T> Capture <T>(int sampleRate = 44100) where T : class { if (recorder == null || !recorder.Capturing) { recorder = SoundProcessorFactory.GetRecorder <T>(); recorder.Start(sampleRate); return(recorder as SoundRecorder <T>); } throw new Exception("Cannot start audio capture while another capture is running."); }