Table of Contents

Class AudioCaptureClient

Namespace
NAudio.CoreAudioApi
Assembly
NAudio.Wasapi.dll

Audio Capture Client

public class AudioCaptureClient : IDisposable
Inheritance
AudioCaptureClient
Implements
Inherited Members

Methods

Dispose()

Dispose

public void Dispose()

GetBuffer(out int, out AudioClientBufferFlags)

Gets a pointer to the buffer

public nint GetBuffer(out int numFramesToRead, out AudioClientBufferFlags bufferFlags)

Parameters

numFramesToRead int

Number of frames to read

bufferFlags AudioClientBufferFlags

Buffer flags

Returns

nint

Pointer to the buffer

GetBuffer(out int, out AudioClientBufferFlags, out long, out long)

Gets a pointer to the buffer

public nint GetBuffer(out int numFramesToRead, out AudioClientBufferFlags bufferFlags, out long devicePosition, out long qpcPosition)

Parameters

numFramesToRead int
bufferFlags AudioClientBufferFlags
devicePosition long
qpcPosition long

Returns

nint

Pointer to the buffer

GetBufferLease(int)

Gets a read-only Span over the WASAPI capture buffer. The returned lease must be disposed (which calls ReleaseBuffer) before the next call to GetBuffer. Read audio data directly from Buffer to avoid copies.

public CaptureBufferLease GetBufferLease(int bytesPerFrame)

Parameters

bytesPerFrame int

Bytes per frame (WaveFormat.BlockAlign)

Returns

CaptureBufferLease

A lease that provides a read-only Span and releases the buffer on dispose

GetNextPacketSize()

Gets the size of the next packet

public int GetNextPacketSize()

Returns

int

ReleaseBuffer(int)

Release buffer

public void ReleaseBuffer(int numFramesRead)

Parameters

numFramesRead int

Number of frames read