Table of Contents

Delegate CaptureDataAvailableHandler

Namespace
NAudio.Wave
Assembly
NAudio.Wasapi.dll

Delegate for zero-copy capture data events. The buffer is a ReadOnlySpan<T> directly over the WASAPI buffer — only valid for the duration of the callback.

public delegate void CaptureDataAvailableHandler(ReadOnlySpan<byte> buffer, AudioClientBufferFlags flags, long devicePosition, long qpcPosition)

Parameters

buffer ReadOnlySpan<byte>

The captured audio data. Copy it if you need to keep it.

flags AudioClientBufferFlags

Buffer flags from WASAPI (e.g. Silent).

devicePosition long

The device position (in frames) at the start of this packet, as reported by IAudioCaptureClient::GetBuffer. Useful for detecting gaps and aligning packets.

qpcPosition long

The QPC (QueryPerformanceCounter) value at the time the packet was captured, in 100-nanosecond units. Use it to time-align captured audio against a wall clock.