/* * Instantiates objects for recording, then sleeps for 1 second * to allow the circular audio buffer to partially fill up. */ protected void BeginRecording() { Capture = new WasapiLoopbackCapture(); Capture.DataAvailable += new EventHandler <WaveInEventArgs>(OnDataAvailable); WaveProvider = new OpenBufferedWaveProvider(Capture.WaveFormat); WaveProvider.BufferLength = BUFFER_SIZE; WaveProvider.DiscardOnBufferOverflow = true; SampleProvider = WaveProvider.ToSampleProvider(); Capture.StartRecording(); Console.WriteLine("Successfully started recording."); Thread.Sleep(1000); }
static bool InitRecord(string[] args) { wi = new WasapiLoopbackCapture(); wi.DataAvailable += new EventHandler <WaveInEventArgs>(OnDataAvailable); Console.WriteLine("Bits per sample: {0}", wi.WaveFormat.BitsPerSample); Console.WriteLine("Bits per second: {0}", wi.WaveFormat.AverageBytesPerSecond * 8); Console.WriteLine("Sample Rate: {0}", wi.WaveFormat.SampleRate); bwp = new OpenBufferedWaveProvider(wi.WaveFormat); bwp.BufferLength = BUFFER_SIZE; bwp.DiscardOnBufferOverflow = true; sp = bwp.ToSampleProvider(); wi.StartRecording(); Console.WriteLine("Now Recording on WASAPI Loopback Capture."); return(true); }