Class WasapiCapture
- Namespace
- NAudio.CoreAudioApi
- Assembly
- NAudio.Wasapi.dll
Audio Capture using Wasapi See http://msdn.microsoft.com/en-us/library/dd370800%28VS.85%29.aspx
[Obsolete("Use WasapiRecorderBuilder to create a WasapiRecorder instead. WasapiRecorder provides zero-copy buffers, MMCSS thread priority, IAsyncEnumerable capture, and process-specific loopback.")]
public class WasapiCapture : IWaveIn, IDisposable, IWaveLatency
- Inheritance
-
WasapiCapture
- Implements
- Derived
- Inherited Members
Constructors
WasapiCapture()
Initialises a new instance of the WASAPI capture class
public WasapiCapture()
WasapiCapture(MMDevice)
Initialises a new instance of the WASAPI capture class
public WasapiCapture(MMDevice captureDevice)
Parameters
captureDeviceMMDeviceCapture device to use
WasapiCapture(MMDevice, bool)
Initializes a new instance of the WasapiCapture class.
public WasapiCapture(MMDevice captureDevice, bool useEventSync)
Parameters
captureDeviceMMDeviceThe capture device.
useEventSyncbooltrue if sync is done with event. false use sleep.
WasapiCapture(MMDevice, bool, int)
Initializes a new instance of the WasapiCapture class.
public WasapiCapture(MMDevice captureDevice, bool useEventSync, int audioBufferMillisecondsLength)
Parameters
captureDeviceMMDeviceThe capture device.
useEventSyncbooltrue if sync is done with event. false use sleep.
audioBufferMillisecondsLengthintLength of the audio buffer in milliseconds. A lower value means lower latency but increased CPU usage.
Properties
AverageLatency
The steady-state latency from a sample being queued for output to it being emitted by the audio hardware, assuming uninterrupted playback. This is a property of the buffer configuration and the driver, not of the current playback state.
public TimeSpan AverageLatency { get; }
Property Value
Remarks
The requested capture buffer length. Read at StartRecording() time, so reflects what the engine actually negotiated for the period.
CaptureState
Current Capturing State
public CaptureState CaptureState { get; }
Property Value
CurrentLatency
The time that has elapsed since the sample currently emerging from the hardware was queued for output. In steady state this is approximately equal to AverageLatency; it differs during start-up, after an underrun, or when the host is filling buffers irregularly. Implementations that cannot meaningfully distinguish from the average are permitted to return AverageLatency.
public TimeSpan CurrentLatency { get; }
Property Value
Remarks
Derived from IAudioClient::GetCurrentPadding, which on a capture stream reports
the number of frames available to read — i.e. the age of the oldest captured sample
still in the endpoint buffer. Returns AverageLatency when not recording
or if the audio client has not yet been initialised.
ShareMode
Share Mode - set before calling StartRecording
public AudioClientShareMode ShareMode { get; set; }
Property Value
WaveFormat
Capturing wave format
public virtual WaveFormat WaveFormat { get; set; }
Property Value
Methods
Dispose()
Dispose
public void Dispose()
GetAudioClientStreamFlags()
To allow overrides to specify different flags (e.g. loopback)
protected virtual AudioClientStreamFlags GetAudioClientStreamFlags()
Returns
GetDefaultCaptureDevice()
Gets the default audio capture device
public static MMDevice GetDefaultCaptureDevice()
Returns
- MMDevice
The default audio capture device
StartRecording()
Start Capturing
public void StartRecording()
StopRecording()
Stop Capturing (requests a stop, wait for RecordingStopped event to know it has finished)
public void StopRecording()
Events
DataAvailable
Indicates recorded data is available
public event EventHandler<WaveInEventArgs> DataAvailable
Event Type
RecordingStopped
Indicates that all recorded data has now been received.
public event EventHandler<StoppedEventArgs> RecordingStopped