Table of Contents

Class WaveIn

Namespace
NAudio.Wave
Assembly
NAudio.WinMM.dll

WaveIn recording device using event callbacks

public class WaveIn : IWaveIn, IDisposable, IWaveLatency
Inheritance
WaveIn
Implements
Derived
Inherited Members

Constructors

WaveIn()

Prepares a Wave input device for recording

public WaveIn()

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

TimeSpan

Remarks

Computed as (NumberOfBuffers - 0.5) × BufferMilliseconds: in steady state every queued buffer plus half of the one currently being filled by the driver sits between the microphone and the application.

BufferMilliseconds

Milliseconds for the buffer. Recommended value is 100ms

public int BufferMilliseconds { get; set; }

Property Value

int

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

TimeSpan

Remarks

Returns the wall-clock age of the freshest sample the application has received: the elapsed time since the most recent buffer was delivered. This is a sawtooth that reads ~0 at the moment of delivery and rises to ~BufferMilliseconds just before the next one arrives, averaging half a buffer over the cycle. Falls back to AverageLatency before the first buffer is delivered.

DeviceCount

Returns the number of Wave In devices available in the system

public static int DeviceCount { get; }

Property Value

int

DeviceNumber

The device number to use

public int DeviceNumber { get; set; }

Property Value

int

NumberOfBuffers

Number of Buffers to use (usually 2 or 3)

public int NumberOfBuffers { get; set; }

Property Value

int

WaveFormat

WaveFormat we are recording in

public WaveFormat WaveFormat { get; set; }

Property Value

WaveFormat

Methods

Dispose()

Dispose method

public void Dispose()

Dispose(bool)

Dispose pattern

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

~WaveIn()

Finalizer. Only called when user forgets to call Dispose()

protected ~WaveIn()

GetCapabilities(int)

Retrieves the capabilities of a waveIn device

public static WaveInCapabilities GetCapabilities(int devNumber)

Parameters

devNumber int

Device to test

Returns

WaveInCapabilities

The WaveIn device capabilities

GetMixerLine()

Gets the mixer line for this recording device

public MixerLine GetMixerLine()

Returns

MixerLine

GetPosition()

Gets the current position in bytes from the wave input device. (calls directly into waveInGetPosition)

public long GetPosition()

Returns

long

Position in bytes

StartRecording()

Start recording

public void StartRecording()

StopRecording()

Stop recording

public void StopRecording()

Events

DataAvailable

Indicates recorded data is available

public event EventHandler<WaveInEventArgs> DataAvailable

Event Type

EventHandler<WaveInEventArgs>

RecordingStopped

Indicates that all recorded data has now been received.

public event EventHandler<StoppedEventArgs> RecordingStopped

Event Type

EventHandler<StoppedEventArgs>