Class AsioDriverExt
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
driverAsioDriverA 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
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
ResetRequestCallback
Reset Request Callback
public Action ResetRequestCallback
Field Value
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
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
numberOfOutputChannelsintThe number of outputs channels.
numberOfInputChannelsintThe number of input channel.
useMaxBufferSizeboolif set to
true[use max buffer size] else use Prefered size
Returns
CreateBuffers(int, int, int)
Creates the buffers for playing, requesting a specific buffer size.
public int CreateBuffers(int numberOfOutputChannels, int numberOfInputChannels, int requestedBufferSize)
Parameters
numberOfOutputChannelsintThe number of outputs channels.
numberOfInputChannelsintThe number of input channel.
requestedBufferSizeintDesired ASIO buffer size in frames. Must be within BufferMinSize..BufferMaxSize and respect BufferGranularity.
Returns
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
IsSampleRateSupported(double)
Determines whether the specified sample rate is supported.
public bool IsSampleRateSupported(double sampleRate)
Parameters
sampleRatedoubleThe sample rate.
Returns
- bool
trueif [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
outputChannelsint[]Physical output channel indices. Each must be in
[0, NbOutputChannels).inputChannelsint[]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
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
referenceint
SetSampleRate(double)
Sets the sample rate.
public void SetSampleRate(double sampleRate)
Parameters
sampleRatedoubleThe 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
samplePositionlongFrames since the driver started.
systemTimeNanosecondslongHost system time in nanoseconds corresponding to
samplePosition.