Table of Contents

Struct AsioProcessBuffers

Namespace
NAudio.Wave
Assembly
NAudio.Asio.dll

Per-callback view of input and output audio for a duplex AsioDevice session. Passed by reference to the user's AsioProcessCallback.

public readonly ref struct AsioProcessBuffers
Inherited Members

Remarks

This is a ref struct: it lives on the stack and cannot outlive the buffer-switch callback. All spans returned from it point into library-owned or driver-owned memory and are invalidated the moment the callback returns. Do not capture any of these values across callbacks.

Properties

Frames

Number of audio frames per channel in this callback.

public int Frames { get; }

Property Value

int

InputChannelCount

Number of input channels selected at init time.

public int InputChannelCount { get; }

Property Value

int

OutputChannelCount

Number of output channels selected at init time.

public int OutputChannelCount { get; }

Property Value

int

SamplePosition

Position of the first frame in this buffer, in frames since the driver started, as reported by the driver. Zero if the driver did not report a position for this callback.

public long SamplePosition { get; }

Property Value

long

SampleRate

Sample rate the driver is currently running at, in Hz.

public int SampleRate { get; }

Property Value

int

Speed

Varispeed factor reported by the driver (1.0 = nominal). Most drivers report 1.0; non-1.0 values appear when the driver is doing pull-up/pull-down (29.97 vs 30 fps film transfer) or external rate adaptation.

public double Speed { get; }

Property Value

double

SystemTimeNanoseconds

Host system time, in nanoseconds, corresponding to SamplePosition. This pins the audio clock to the host clock at one precise instant per buffer — use it for A/V sync, drift correction against Stopwatch, or aligning multiple ASIO devices. Zero if the driver did not report a timestamp for this callback.

public long SystemTimeNanoseconds { get; }

Property Value

long

TimeCode

SMPTE/MTC time code from an external source (LTC input, MTC over MIDI, etc.) corresponding to this buffer. null when no external time-code source is connected — the common case.

public AsioTimeCodeInfo? TimeCode { get; }

Property Value

AsioTimeCodeInfo?

Methods

GetInput(int)

Gets a read-only span of converted float samples for the specified input channel.

public ReadOnlySpan<float> GetInput(int channelIndex)

Parameters

channelIndex int

Zero-based index into the selected-inputs array, not the physical channel index. Valid range: 0 to InputChannelCount - 1.

Returns

ReadOnlySpan<float>

A span of length Frames. Valid only for the duration of the callback.

GetOutput(int)

Gets a writable span for the specified output channel. Samples are converted to the driver's native format on callback return.

public Span<float> GetOutput(int channelIndex)

Parameters

channelIndex int

Zero-based index into the selected-outputs array, not the physical channel index. Valid range: 0 to OutputChannelCount - 1.

Returns

Span<float>

A span of length Frames. Unwritten frames are zeroed by the library before conversion.

RawInput(int)

Zero-copy access to the specified input channel in the driver's native sample format.

public AsioRawInputBuffer RawInput(int channelIndex)

Parameters

channelIndex int

Zero-based index into the selected-inputs array.

Returns

AsioRawInputBuffer

RawOutput(int)

Zero-copy access to the specified output channel in the driver's native sample format. Writing through this buffer bypasses float-to-native conversion and the unwritten-output clearing — the caller becomes responsible for writing every frame in this channel for this callback.

public AsioRawOutputBuffer RawOutput(int channelIndex)

Parameters

channelIndex int

Zero-based index into the selected-outputs array.

Returns

AsioRawOutputBuffer