Class AsioOut
ASIO Out Player — the original NAudio 2.x entry point for ASIO playback, recording, and duplex.
Implemented in NAudio 3 as a thin facade over AsioDevice: lifecycle, capabilities,
drain-on-dispose, and synchronization-context dispatch all flow through that class, while AsioOut
keeps its raw IntPtr-based AudioAvailable contract for back-compat consumers.
public class AsioOut : IWavePlayer, IDisposable, IWaveLatency
- Inheritance
-
AsioOut
- Implements
- Inherited Members
- Extension Methods
Remarks
New code should target AsioDevice directly. It exposes per-channel Span<float>
for recording and duplex, an explicit Init* mode selection, non-contiguous channel-array routing,
and a supported Reinitialize() path for handling
DriverResetRequest.
Legacy translations:
- Init(IWaveProvider) → InitPlayback(AsioPlaybackOptions)
- InitRecordAndPlayback(IWaveProvider, int, int) with a non-null provider → InitDuplex(AsioDuplexOptions)
- InitRecordAndPlayback(IWaveProvider, int, int) with a null provider → InitRecording(AsioRecordingOptions)
Constructors
AsioOut()
Initializes a new instance of the AsioOut class with the first available ASIO Driver.
public AsioOut()
AsioOut(int)
Opens an ASIO output device
public AsioOut(int driverIndex)
Parameters
driverIndexintDevice number (zero based)
AsioOut(string)
Initializes a new instance of the AsioOut class with the driver name.
public AsioOut(string driverName)
Parameters
driverNamestringName of the device.
Properties
AutoStop
Automatically stop when the end of the input stream is reached Disable this if auto-stop is causing hanging issues
public bool AutoStop { get; set; }
Property Value
AverageLatency
The steady-state latency from a sample being queued for output to it being emitted by the audio hardware, assuming uninterrupted playback. This is a property of the buffer configuration and the driver, not of the current playback state.
public TimeSpan AverageLatency { get; }
Property Value
Remarks
Derived from the driver's reported output latency in samples (ASIOgetLatencies).
Computed lazily from cached values — no work is done on the ASIO callback thread.
ChannelOffset
By default the first channel on the input WaveProvider is sent to the first ASIO output. This option sends it to the specified channel number. Warning: make sure you don't set it higher than the number of available output channels - the number of source channels. n.b. Future NAudio may modify this
public int ChannelOffset { get; set; }
Property Value
CurrentLatency
The time that has elapsed since the sample currently emerging from the hardware was queued for output. In steady state this is approximately equal to AverageLatency; it differs during start-up, after an underrun, or when the host is filling buffers irregularly. Implementations that cannot meaningfully distinguish from the average are permitted to return AverageLatency.
public TimeSpan CurrentLatency { get; }
Property Value
Remarks
Returns AverageLatency. ASIO swaps fixed-size buffers at perfectly regular intervals, so the live latency is always equal to the steady-state latency to within half a buffer. Reporting an instrumented value would require timestamping the buffer-switch callback, which we deliberately avoid to keep the real-time path free of extra work.
DriverInputChannelCount
The maximum number of input channels this ASIO driver supports
public int DriverInputChannelCount { get; }
Property Value
DriverName
Driver Name
public string DriverName { get; }
Property Value
DriverOutputChannelCount
The maximum number of output channels this ASIO driver supports
public int DriverOutputChannelCount { get; }
Property Value
FramesPerBuffer
The number of samples per channel, per buffer.
public int FramesPerBuffer { get; }
Property Value
HasReachedEnd
A flag to let you know that we have reached the end of the input file Useful if AutoStop is set to false You can monitor this yourself and call Stop when it is true
public bool HasReachedEnd { get; }
Property Value
InputChannelOffset
Input channel offset (used when recording), allowing you to choose to record from just one specific input rather than them all
public int InputChannelOffset { get; set; }
Property Value
NumberOfInputChannels
The number of input channels we are currently recording from (Must be less than or equal to DriverInputChannelCount)
public int NumberOfInputChannels { get; }
Property Value
NumberOfOutputChannels
The number of output channels we are currently using for playback (Must be less than or equal to DriverOutputChannelCount)
public int NumberOfOutputChannels { get; }
Property Value
OutputWaveFormat
The WaveFormat this device is using for playback
public WaveFormat OutputWaveFormat { get; }
Property Value
PlaybackLatency
Gets the latency (in samples) of the playback driver
public int PlaybackLatency { get; }
Property Value
PlaybackState
Playback State
public PlaybackState PlaybackState { get; }
Property Value
Volume
Sets the volume (1.0 is unity gain) Not supported for ASIO Out. Set the volume on the input stream instead
[Obsolete("this function will be removed in a future NAudio as ASIO does not support setting the volume on the device")]
public float Volume { get; set; }
Property Value
Methods
AsioInputChannelName(int)
Get the input channel name
public string AsioInputChannelName(int channel)
Parameters
channelintchannel index (zero based)
Returns
- string
channel name
AsioOutputChannelName(int)
Get the output channel name
public string AsioOutputChannelName(int channel)
Parameters
channelintchannel index (zero based)
Returns
- string
channel name
Dispose()
Dispose
public void Dispose()
~AsioOut()
Releases unmanaged resources and performs other cleanup operations before the AsioOut is reclaimed by garbage collection.
protected ~AsioOut()
GetDriverNames()
Gets the names of the installed ASIO Driver.
public static string[] GetDriverNames()
Returns
- string[]
an array of driver names
Init(IWaveProvider)
Initialises to play
public void Init(IWaveProvider waveProvider)
Parameters
waveProviderIWaveProviderSource audio source
InitRecordAndPlayback(IWaveProvider, int, int)
Initialises to play, with optional recording
public void InitRecordAndPlayback(IWaveProvider waveProvider, int recordChannels, int recordOnlySampleRate)
Parameters
waveProviderIWaveProviderSource audio source - set to null for record only
recordChannelsintNumber of channels to record
recordOnlySampleRateintSpecify sample rate here if only recording, ignored otherwise
IsSampleRateSupported(int)
Determines whether this driver supports the specified sample rate.
public bool IsSampleRateSupported(int sampleRate)
Parameters
sampleRateintThe samplerate to check.
Returns
- bool
trueif the specified sample rate is supported otherwise,false.
Pause()
Pauses playback
public void Pause()
Play()
Starts playback
public void Play()
ShowControlPanel()
Shows the control panel
public void ShowControlPanel()
Stop()
Stops playback
public void Stop()
isSupported()
Determines whether ASIO is supported.
public static bool isSupported()
Returns
- bool
trueif ASIO is supported; otherwise,false.
Events
AudioAvailable
When recording, fires whenever recorded audio is available
public event EventHandler<AsioAudioAvailableEventArgs> AudioAvailable
Event Type
DriverResetRequest
Occurs when the driver settings are changed by the user, e.g. in the control panel.
public event EventHandler DriverResetRequest
Event Type
PlaybackStopped
Playback Stopped
public event EventHandler<StoppedEventArgs> PlaybackStopped