Xeno-rat
Loading...
Searching...
No Matches
NAudio.Wave.Asio.AsioDriver Class Reference

Main AsioDriver Class. To use this class, you need to query first the GetAsioDriverNames() and then use the GetAsioDriverByName to instantiate the correct AsioDriver. This is the first AsioDriver binding fully implemented in C#! More...

Collaboration diagram for NAudio.Wave.Asio.AsioDriver:

Classes

class  AsioDriverVTable
 Internal VTable structure to store all the delegates to the C++ COM method. More...
 

Public Member Functions

bool Init (IntPtr sysHandle)
 Initializes the ASIO driver with the specified system handle.
 
string GetDriverName ()
 Retrieves the name of the ASIO driver.
 
int GetDriverVersion ()
 Gets the version of the driver.
 
string GetErrorMessage ()
 Retrieves the error message from the ASIO driver and returns it as a string.
 
void Start ()
 Starts the ASIO driver.
 
AsioError Stop ()
 Stops the ASIO driver and returns any error that occurred during the operation.
 
void GetChannels (out int numInputChannels, out int numOutputChannels)
 Retrieves the number of input and output channels available.
 
AsioError GetLatencies (out int inputLatency, out int outputLatency)
 Retrieves the input and output latencies of the ASIO driver.
 
void GetBufferSize (out int minSize, out int maxSize, out int preferredSize, out int granularity)
 Retrieves the buffer size information from the ASIO driver.
 
bool CanSampleRate (double sampleRate)
 Checks if the specified sample rate is supported by the ASIO driver.
 
double GetSampleRate ()
 Retrieves the sample rate from the ASIO driver.
 
void SetSampleRate (double sampleRate)
 Sets the sample rate for the ASIO driver.
 
void GetClockSources (out long clocks, int numSources)
 Retrieves the clock sources and outputs the result in the clocks parameter.
 
void SetClockSource (int reference)
 Sets the clock source for the ASIO driver.
 
void GetSamplePosition (out long samplePos, ref Asio64Bit timeStamp)
 Retrieves the current sample position and timestamp.
 
AsioChannelInfo GetChannelInfo (int channelNumber, bool trueForInputInfo)
 Retrieves the information about the specified channel.
 
void CreateBuffers (IntPtr bufferInfos, int numChannels, int bufferSize, ref AsioCallbacks callbacks)
 Creates buffers for audio input and output.
 
AsioError DisposeBuffers ()
 Disposes the ASIO buffers and frees the allocated memory.
 
void ControlPanel ()
 Opens the control panel for the ASIO driver.
 
void Future (int selector, IntPtr opt)
 Calls the ASIO driver's future function with the specified selector and options.
 
AsioError OutputReady ()
 Checks if the output is ready and returns an AsioError.
 
void ReleaseComAsioDriver ()
 Releases the COM object associated with the ASIO driver.
 

Static Public Member Functions

static string[] GetAsioDriverNames ()
 Retrieves the names of ASIO drivers installed on the system.
 
static AsioDriver GetAsioDriverByName (String name)
 Retrieves the ASIO driver with the specified name.
 
static AsioDriver GetAsioDriverByGuid (Guid guid)
 Retrieves an ASIO driver based on the specified GUID.
 

Private Member Functions

 AsioDriver ()
 
void HandleException (AsioError error, string methodName)
 Handles the exception for the ASIO method.
 
void InitFromGuid (Guid asioGuid)
 Initializes the ASIO driver from the given GUID and sets up the virtual table for method calls.
 
static int CoCreateInstance (ref Guid clsid, IntPtr inner, uint context, ref Guid uuid, out IntPtr rReturnedComObject)
 Creates a new instance of a COM object with the specified class identifier (CLSID).
 

Private Attributes

IntPtr pAsioComObject
 
IntPtr pinnedcallbacks
 
AsioDriverVTable asioDriverVTable
 

Detailed Description

Main AsioDriver Class. To use this class, you need to query first the GetAsioDriverNames() and then use the GetAsioDriverByName to instantiate the correct AsioDriver. This is the first AsioDriver binding fully implemented in C#!

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

Constructor & Destructor Documentation

◆ AsioDriver()

NAudio.Wave.Asio.AsioDriver.AsioDriver ( )
inlineprivate
Here is the caller graph for this function:

Member Function Documentation

◆ CanSampleRate()

bool NAudio.Wave.Asio.AsioDriver.CanSampleRate ( double sampleRate)
inline

Checks if the specified sample rate is supported by the ASIO driver.

Parameters
sampleRateThe sample rate to be checked.
Returns
True if the sample rate is supported; otherwise, false.
Exceptions
AsioExceptionThrown when an error occurs while checking the sample rate.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CoCreateInstance()

static int NAudio.Wave.Asio.AsioDriver.CoCreateInstance ( ref Guid clsid,
IntPtr inner,
uint context,
ref Guid uuid,
out IntPtr rReturnedComObject )
private

Creates a new instance of a COM object with the specified class identifier (CLSID).

Parameters
clsidThe CLSID of the object to be created.
innerA pointer to the controlling IUnknown interface if the object is being created as part of an aggregate, or IntPtr.Zero otherwise.
contextThe execution context in which the code is to run.
uuidThe IID of the interface on the object that the caller wants to communicate with.
rReturnedComObjectWhen this method returns, contains a reference to the created object.
Returns
An HRESULT value indicating success or failure.
Here is the caller graph for this function:

◆ ControlPanel()

void NAudio.Wave.Asio.AsioDriver.ControlPanel ( )
inline

Opens the control panel for the ASIO driver.

This method opens the control panel for the ASIO driver using the ASIO driver VTable.

Exceptions
ExceptionThrows an exception if there is an error while opening the control panel.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreateBuffers()

void NAudio.Wave.Asio.AsioDriver.CreateBuffers ( IntPtr bufferInfos,
int numChannels,
int bufferSize,
ref AsioCallbacks callbacks )
inline

Creates buffers for audio input and output.

Parameters
bufferInfosPointer to buffer information.
numChannelsThe number of audio channels.
bufferSizeThe size of the buffer.
callbacksReference to the AsioCallbacks structure.
Exceptions
AsioExceptionThrown if there is an error creating the buffers.

This method creates buffers for audio input and output using the provided buffer information, number of channels, buffer size, and AsioCallbacks structure. It allocates memory for the callbacks, marshals the structure, and handles any exceptions that may occur during the buffer creation process.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DisposeBuffers()

AsioError NAudio.Wave.Asio.AsioDriver.DisposeBuffers ( )
inline

Disposes the ASIO buffers and frees the allocated memory.

Returns
The result of disposing the ASIO buffers.

This method disposes the ASIO buffers and frees the allocated memory.

Here is the caller graph for this function:

◆ Future()

void NAudio.Wave.Asio.AsioDriver.Future ( int selector,
IntPtr opt )
inline

Calls the ASIO driver's future function with the specified selector and options.

Parameters
selectorThe selector for the future function.
optThe options to be passed to the future function.
Exceptions
AsioExceptionThrown if there is an error calling the ASIO driver's future function.
Here is the call graph for this function:

◆ GetAsioDriverByGuid()

static AsioDriver NAudio.Wave.Asio.AsioDriver.GetAsioDriverByGuid ( Guid guid)
inlinestatic

Retrieves an ASIO driver based on the specified GUID.

Parameters
guidThe GUID of the ASIO driver to retrieve.
Returns
An instance of the AsioDriver class initialized with the specified GUID.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAsioDriverByName()

static AsioDriver NAudio.Wave.Asio.AsioDriver.GetAsioDriverByName ( String name)
inlinestatic

Retrieves the ASIO driver with the specified name.

Parameters
nameThe name of the ASIO driver to retrieve.
Returns
The ASIO driver with the specified name .
Exceptions
ArgumentExceptionThrown when the specified name does not exist in the registry.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAsioDriverNames()

static string[] NAudio.Wave.Asio.AsioDriver.GetAsioDriverNames ( )
inlinestatic

Retrieves the names of ASIO drivers installed on the system.

Returns
An array of strings containing the names of the ASIO drivers installed on the system.

This method retrieves the names of ASIO drivers by accessing the registry key "SOFTWARE\\ASIO" under the Local Machine hive. It initializes an empty string array and populates it with the names of the subkeys under the "SOFTWARE\\ASIO" registry key. If the registry key does not exist or is inaccessible, an empty array is returned.

Here is the caller graph for this function:

◆ GetBufferSize()

void NAudio.Wave.Asio.AsioDriver.GetBufferSize ( out int minSize,
out int maxSize,
out int preferredSize,
out int granularity )
inline

Retrieves the buffer size information from the ASIO driver.

Parameters
minSizeThe minimum buffer size supported by the ASIO driver.
maxSizeThe maximum buffer size supported by the ASIO driver.
preferredSizeThe preferred buffer size suggested by the ASIO driver.
granularityThe granularity of buffer size adjustments supported by the ASIO driver.

This method retrieves the buffer size information from the ASIO driver using the ASIO driver's pAsioComObject . It handles exceptions using the HandleException method and passes the retrieved buffer size information to the out parameters.

Exceptions
ExceptionThrows an exception if there is an error while retrieving the buffer size information from the ASIO driver.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetChannelInfo()

AsioChannelInfo NAudio.Wave.Asio.AsioDriver.GetChannelInfo ( int channelNumber,
bool trueForInputInfo )
inline

Retrieves the information about the specified channel.

Parameters
channelNumberThe number of the channel for which information is to be retrieved.
trueForInputInfoA boolean value indicating whether to retrieve input information (true) or output information (false).
Returns
The AsioChannelInfo object containing the information about the specified channel.
Exceptions
AsioExceptionThrown if there is an error while retrieving the channel information.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetChannels()

void NAudio.Wave.Asio.AsioDriver.GetChannels ( out int numInputChannels,
out int numOutputChannels )
inline

Retrieves the number of input and output channels available.

Parameters
numInputChannelsThe number of input channels available.
numOutputChannelsThe number of output channels available.
Exceptions
ExceptionThrown if there is an error retrieving the channels.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetClockSources()

void NAudio.Wave.Asio.AsioDriver.GetClockSources ( out long clocks,
int numSources )
inline

Retrieves the clock sources and outputs the result in the clocks parameter.

Parameters
clocksThe output parameter that will contain the retrieved clock sources.
numSourcesThe number of clock sources to retrieve.

This method retrieves the clock sources from the ASIO driver and stores the result in the clocks parameter.

Exceptions
ExceptionThrows an exception if there is an error while retrieving the clock sources from the ASIO driver.
Here is the call graph for this function:

◆ GetDriverName()

string NAudio.Wave.Asio.AsioDriver.GetDriverName ( )
inline

Retrieves the name of the ASIO driver.

Returns
The name of the ASIO driver.
Here is the caller graph for this function:

◆ GetDriverVersion()

int NAudio.Wave.Asio.AsioDriver.GetDriverVersion ( )
inline

Gets the version of the driver.

Returns
The version of the driver.

◆ GetErrorMessage()

string NAudio.Wave.Asio.AsioDriver.GetErrorMessage ( )
inline

Retrieves the error message from the ASIO driver and returns it as a string.

Returns
The error message retrieved from the ASIO driver.
Here is the caller graph for this function:

◆ GetLatencies()

AsioError NAudio.Wave.Asio.AsioDriver.GetLatencies ( out int inputLatency,
out int outputLatency )
inline

Retrieves the input and output latencies of the ASIO driver.

Parameters
inputLatencyThe variable to store the input latency.
outputLatencyThe variable to store the output latency.
Returns
An AsioError representing the result of the operation.

This method retrieves the input and output latencies of the ASIO driver by calling the getLatencies method of the ASIO driver's VTable. The input and output latencies are stored in the inputLatency and outputLatency variables, respectively.

Here is the caller graph for this function:

◆ GetSamplePosition()

void NAudio.Wave.Asio.AsioDriver.GetSamplePosition ( out long samplePos,
ref Asio64Bit timeStamp )
inline

Retrieves the current sample position and timestamp.

Parameters
samplePosThe current sample position.
timeStampThe timestamp associated with the sample position.
Exceptions
ExceptionThrown if there is an error retrieving the sample position and timestamp.
Here is the call graph for this function:

◆ GetSampleRate()

double NAudio.Wave.Asio.AsioDriver.GetSampleRate ( )
inline

Retrieves the sample rate from the ASIO driver.

Returns
The sample rate retrieved from the ASIO driver.

This method retrieves the sample rate from the ASIO driver using the ASIO driver's getSampleRate function. It handles any exceptions that may occur during the retrieval process and returns the retrieved sample rate.

Exceptions
ExceptionThrown if there is an error while retrieving the sample rate from the ASIO driver.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleException()

void NAudio.Wave.Asio.AsioDriver.HandleException ( AsioError error,
string methodName )
inlineprivate

Handles the exception for the ASIO method.

Parameters
errorThe ASIO error code.
methodNameThe name of the ASIO method being called.
Exceptions
AsioExceptionThrown when the ASIO error code is not ASE_OK or ASE_SUCCESS. The exception message contains the error code, method name, and error message.

This method handles the exception for the ASIO method by checking the error code. If the error code is not ASE_OK or ASE_SUCCESS, it creates and throws an AsioException with the error code, method name, and error message.

Here is the caller graph for this function:

◆ Init()

bool NAudio.Wave.Asio.AsioDriver.Init ( IntPtr sysHandle)
inline

Initializes the ASIO driver with the specified system handle.

Parameters
sysHandleA pointer to the system handle.
Returns
True if the initialization is successful; otherwise, false.

This method initializes the ASIO driver using the provided system handle. It calls the 'init' method of the ASIO driver VTable and returns true if the return value is 1, indicating successful initialization.

Here is the caller graph for this function:

◆ InitFromGuid()

void NAudio.Wave.Asio.AsioDriver.InitFromGuid ( Guid asioGuid)
inlineprivate

Initializes the ASIO driver from the given GUID and sets up the virtual table for method calls.

Parameters
asioGuidThe GUID of the ASIO driver to be initialized.
Exceptions
COMExceptionThrown when unable to instantiate ASIO. Check if STAThread is set.

This method initializes the ASIO driver by querying the virtual table at index 3 and setting up the virtual table for method calls. It uses CoCreateInstance instead of built-in COM-Class instantiation, as the AsioDriver expects the ASIOGuid used for both COM Object and COM interface. The CoCreateInstance works only in STAThread mode. The method modifies the original ASIO Com Object in place by attaching internal delegates to call the methods on the COM Object.

Here is the call graph for this function:

◆ OutputReady()

AsioError NAudio.Wave.Asio.AsioDriver.OutputReady ( )
inline

Checks if the output is ready and returns an AsioError.

Returns
An AsioError indicating the status of the output readiness.
Here is the caller graph for this function:

◆ ReleaseComAsioDriver()

void NAudio.Wave.Asio.AsioDriver.ReleaseComAsioDriver ( )
inline

Releases the COM object associated with the ASIO driver.

This method releases the COM object pAsioComObject associated with the ASIO driver.

Here is the caller graph for this function:

◆ SetClockSource()

void NAudio.Wave.Asio.AsioDriver.SetClockSource ( int reference)
inline

Sets the clock source for the ASIO driver.

Parameters
referenceThe reference value for setting the clock source.
Exceptions
ExceptionThrown when an error occurs while setting the clock source.

This method sets the clock source for the ASIO driver using the provided reference value.

Here is the call graph for this function:

◆ SetSampleRate()

void NAudio.Wave.Asio.AsioDriver.SetSampleRate ( double sampleRate)
inline

Sets the sample rate for the ASIO driver.

Parameters
sampleRateThe sample rate to be set.

This method sets the sample rate for the ASIO driver using the provided sampleRate .

Exceptions
AsioExceptionThrown if there is an error setting the sample rate.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Start()

void NAudio.Wave.Asio.AsioDriver.Start ( )
inline

Starts the ASIO driver.

This method calls the start function of the ASIO driver's VTable to initiate the driver.

Exceptions
ExceptionThrows an exception if there is an error while starting the ASIO driver.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Stop()

AsioError NAudio.Wave.Asio.AsioDriver.Stop ( )
inline

Stops the ASIO driver and returns any error that occurred during the operation.

Returns
An AsioError object representing any error that occurred during the stop operation.
Here is the caller graph for this function:

Member Data Documentation

◆ asioDriverVTable

AsioDriverVTable NAudio.Wave.Asio.AsioDriver.asioDriverVTable
private

◆ pAsioComObject

IntPtr NAudio.Wave.Asio.AsioDriver.pAsioComObject
private

◆ pinnedcallbacks

IntPtr NAudio.Wave.Asio.AsioDriver.pinnedcallbacks
private

The documentation for this class was generated from the following file: