Table of Contents

Class AsioDriverExt

Namespace
NAudio.Wave.Asio
Assembly
NAudio.Asio.dll

AsioDriverExt is a simplified version of the AsioDriver. It provides an easier way to access the capabilities of the Driver and implement the callbacks necessary for feeding the driver. Implementation inspired from Rob Philpot's with a managed C++ ASIO wrapper BlueWave.Interop.Asio http://www.codeproject.com/KB/mcpp/Asio.Net.aspx

Contributor: Alexandre Mutel - email: alexandre_mutel at yahoo.fr

public class AsioDriverExt
Inheritance
AsioDriverExt
Inherited Members

Constructors

AsioDriverExt(AsioDriver)

Initializes a new instance of the AsioDriverExt class based on an already instantiated AsioDriver instance.

public AsioDriverExt(AsioDriver driver)

Parameters

driver AsioDriver

A AsioDriver already instantiated.

Fields

BufferSizeChangedCallback

Raised when the driver signals kAsioBufferSizeChange. The argument is the new preferred buffer size in frames as reported by the driver. Recovery requires the same Stop → Reinitialize → Start dance as a reset request, so AsioDevice folds this into its DriverResetRequest event.

public Action<int> BufferSizeChangedCallback

Field Value

Action<int>

LatenciesChangedCallback

Raised when the driver signals kAsioLatenciesChanged. No buffer rebuild is required — consumers typically just re-read GetLatencies(out int, out int).

public Action LatenciesChangedCallback

Field Value

Action

ResetRequestCallback

Reset Request Callback

public Action ResetRequestCallback

Field Value

Action

ResyncRequestCallback

Raised when the driver signals kAsioResyncRequest (the driver detected a clock drop / xrun and is asking the host to resynchronise). Informational — no action required.

public Action ResyncRequestCallback

Field Value

Action

Properties

Capabilities

Gets the capabilities of the AsioDriver.

public AsioDriverCapability Capabilities { get; }

Property Value

AsioDriverCapability

The capabilities.

Driver

Gets the driver used.

public AsioDriver Driver { get; }

Property Value

AsioDriver

The ASIOdriver.

FillBufferCallback

Gets or sets the fill buffer callback.

public AsioFillBufferCallback FillBufferCallback { get; set; }

Property Value

AsioFillBufferCallback

The fill buffer callback.

Methods

CreateBuffers(int, int, bool)

Creates the buffers for playing.

public int CreateBuffers(int numberOfOutputChannels, int numberOfInputChannels, bool useMaxBufferSize)

Parameters

numberOfOutputChannels int

The number of outputs channels.

numberOfInputChannels int

The number of input channel.

useMaxBufferSize bool

if set to true [use max buffer size] else use Prefered size

Returns

int

CreateBuffers(int, int, int)

Creates the buffers for playing, requesting a specific buffer size.

public int CreateBuffers(int numberOfOutputChannels, int numberOfInputChannels, int requestedBufferSize)

Parameters

numberOfOutputChannels int

The number of outputs channels.

numberOfInputChannels int

The number of input channel.

requestedBufferSize int

Desired ASIO buffer size in frames. Must be within BufferMinSize..BufferMaxSize and respect BufferGranularity.

Returns

int

DisposeBuffers()

Disposes the driver-allocated buffers without releasing the underlying COM driver. Used by the Reinitialize() path so the same driver instance can be re-configured after a sample-rate or buffer-size change without a full ReleaseDriver() cycle.

public void DisposeBuffers()

GetClockSources()

Enumerates the clock sources reported by the driver (Internal, Word Clock, S/PDIF, ADAT, …).

public AsioClockSource[] GetClockSources()

Returns

AsioClockSource[]

IsSampleRateSupported(double)

Determines whether the specified sample rate is supported.

public bool IsSampleRateSupported(double sampleRate)

Parameters

sampleRate double

The sample rate.

Returns

bool

true if [is sample rate supported]; otherwise, false.

ReleaseDriver()

Releases this instance.

public void ReleaseDriver()

SetChannelMapping(int[], int[])

Selects arbitrary (non-contiguous) physical channel indices for this session. Must be called after CreateBuffers(int, int, bool). The number of entries in each array must match the channel counts passed to CreateBuffers.

public void SetChannelMapping(int[] outputChannels, int[] inputChannels)

Parameters

outputChannels int[]

Physical output channel indices. Each must be in [0, NbOutputChannels).

inputChannels int[]

Physical input channel indices. Each must be in [0, NbInputChannels).

SetChannelOffset(int, int)

Allows adjustment of which is the first output channel we write to

public void SetChannelOffset(int outputChannelOffset, int inputChannelOffset)

Parameters

outputChannelOffset int

Output Channel offset

inputChannelOffset int

Input Channel offset

SetClockSource(int)

Selects the clock source the driver should lock to. The driver may respond with a reset request, which surfaces via AsioDevice.DriverResetRequest.

public void SetClockSource(int reference)

Parameters

reference int

SetSampleRate(double)

Sets the sample rate.

public void SetSampleRate(double sampleRate)

Parameters

sampleRate double

The sample rate.

ShowControlPanel()

Shows the control panel.

public void ShowControlPanel()

Start()

Starts playing the buffers.

public void Start()

Stop()

Stops playing the buffers.

public void Stop()

TryGetSamplePosition(out long, out long)

Asks the driver for the current sample position (frames since Start()) and the host system time (in nanoseconds) at which that position was sampled. Non-throwing — returns false if the driver reports an error. Safe to call from the buffer-switch callback.

public bool TryGetSamplePosition(out long samplePosition, out long systemTimeNanoseconds)

Parameters

samplePosition long

Frames since the driver started.

systemTimeNanoseconds long

Host system time in nanoseconds corresponding to samplePosition.

Returns

bool