Copyright © 2006-2020 MultiMedia Soft

How to manage ASIO drivers

Previous pageReturn to chapter overviewNext page

ASIO (Audio Stream Input/Output) is a sound card driver protocol for digital audio specified by Steinberg, providing a low-latency and high fidelity interface between a software application and a computer's sound card. ASIO bypasses the normal audio path from the user application through layers of intermediary Windows operating system software, so that the application connects directly to the hardware of the sound card. Each layer that is bypassed means a reduction in latency, the delay between an application sending sound to the sound being reproduced by the sound card.

 

By default Active Sound Recorder enumerates input devices (sound cards) supporting the DirectSound protocol: in order to let Active Sound Recorder enumerating devices supporting ASIO drivers, you need to make a call to the InitDriversType method and to specify which kind of drivers/protocols your application will support and, in case you should need supporting both ASIO and DirectSound at the same time, in which order; if a certain sound card should support both DirectSound and ASIO drivers, it would be enumerated as two different sound cards, one supporting DirectSound and one supporting ASIO.

 

IMPORTANT NOTE: When using the Active Sound Recorder control in conjunction with our Active DJ Studio control, which also contains the InitDriversType method, it should be preferred calling the same InitDriversType method available inside Active DJ Studio so it will automatically affect both input and output devices.

 

 

The call to the InitDriversType method is mandatory before performing calls to the InitRecordingSystem, GetInputDevicesCount and GetInputDeviceDesc methods: if the InitDriversType method should be called at a later time, it would report back an error; if for any reason you should need calling it at a later time, you would need performing the following sequence of calls:

1. ResetEngine method

2. InitDriversType method

3. Eventual new enumeration of input devices through the GetInputDevicesCount and GetInputDeviceDesc methods.

4. ResetControl method

 

After having initialized the type of driver(s) in use through the InitDriversType method, it will be possible enumerating available input devices through the GetInputDevicesCount and GetInputDeviceDesc methods: depending upon the driver set, these methods will return the overall list of available input devices (DirectSound + ASIO) so it will be possible setting them inside the nDeviceIndex parameter of the StartFromAsioDevice method. You can also obtain the driver in use by a specific input device through the GetInputDeviceDriverType method.

 

If the InitDriversType method should be set to initialize the use of ASIO devices, you could access specific ASIO features through methods exposed by the ASIO property which  implements the ASIO COM object:

 

Enumerating available ASIO devices through the ASIO.DeviceGetCount and ASIO.DeviceGetDesc methods: it's important to note that this kind of enumeration will only report existing ASIO devices and not the overall list of available input devices as reported by the GetInputDevicesCount and GetInputDeviceDesc methods.
Obtaining the zero-based index of an ASIO device inside the overall list of available input devices through the ASIO.DeviceGetInputIndex method.
Given the zero-based index of an ASIO device inside the overall list of available output devices, obtaining the zero-based index of the same ASIO device inside the list of available ASIO devices through the ASIO.DeviceGetIndexFromInput method.
For each ASIO device, enumerating the list of available input and output channels through the ASIO.DeviceGetChannelsCount and ASIO.DeviceGetChannelDesc methods.
Displaying the control panel provided by the ASIO driver of a specific device through the ASIO.ControlPanelDisplay method.
Obtaining the absolute pathname of the file containing the ASIO driver of a specific ASIO device through the ASIO.DeviceGetDriverPathname method.
Starting and stopping the usage of a specific ASIO device through the ASIO.DeviceStart and ASIO.DeviceStop methods.

 

The call to the ASIO.DeviceStart method is mandatory in order to be able starting a recording session on a specific ASIO device. You can know if a specific ASIO device is already started through the ASIO.DeviceIsStarted method.

 

IMPORTANT NOTE: When using Active Sound Recorder in conjunction with Active DJ Studio, you should prefer calling this method using the same ASIO.DeviceStart method available inside Active DJ Studio so you would have a better control over the playback mode.

 

After starting an ASIO device, it will be possible performing the following tasks:

 

Starting a recording session on the device through the StartFromAsioDevice method.
Getting and setting the volume for input and output channels through the ASIO.DeviceMasterVolumeGet and ASIO.DeviceMasterVolumeSet methods (applies the same volume level to all channels in one shot) and through the ASIO.DeviceChannelVolumeGet and ASIO.DeviceChannelVolumeSet methods (applies the volume level on a specific channel allowing separate volume level for each channel).
Obtaining the current latency, expressed in samples per second, for input and output channels as reported by the ASIO driver itself.

 

 

When dealing with sound cards having multiple input channels, like the M-Audio Delta 1010LT, there is the possibility to:

 

mix the input of all of the selected channels into one single recording session.
by using multiple instances of Active Sound Recorder, record at the same time each channel (or couple of channels) on a separate destination file.
by outputting the recording session into a single destination file, whose audio format supports multi-channel (like WAV, WMA, Ogg Vorbis, Opus, etc.), store each input channel into a separate channel of the destination file. Fort this purpose, you need to instruct the component to avoid mixing mono channels together and to keep them separated through the ASIO.DeviceRecordParamsSet method, by passing "FALSE" to the bPerformMixOnStereoOut parameter.

 

Let's see these situations with a couple of small snippets of VB6 code.

 

In the first sample we need to record the first 8 input channels of an ASIO device selected from the ComboInputDevices combobox and mix all of the channels inside the same output file:

 

 

' init some variable

Dim nInputChannel as Integer

Dim nTotalChannels as Integer

nFirstInputChannel = 0

nTotalChannels = 8

 

' start the recording session

activeSoundRecorder1.StartFromAsioDevice(ComboInputDevices.ListIndex, _

                   nFirstInputChannel, nTotalChannels, "c:\mydir\output.wav")

 

 

In the second sample we need to record the first 4 input channels of an ASIO device selected from the ComboInputDevices combobox and keep them separated in 4 different output files, for this purpose we will use 4 instances of the component (activeSoundRecorder1, activeSoundRecorder2, activeSoundRecorder3, and activeSoundRecorder4):

 

 

' init some variable

Dim nTotalChannels as Integer

nTotalChannels = 1

 

' start the recording session from channel 0 and save it inside the output1.wav file

activeSoundRecorder1.StartFromAsioDevice(ComboInputDevices.ListIndex, _

                   0, nTotalChannels, "c:\mydir\output1.wav")

' start the recording session from channel 1 and save it inside the output2.wav file

activeSoundRecorder2.StartFromAsioDevice(ComboInputDevices.ListIndex, _

                   1, nTotalChannels, "c:\mydir\output2.wav")

' start the recording session from channel 2 and save it inside the output3.wav file

activeSoundRecorder3.StartFromAsioDevice(ComboInputDevices.ListIndex, _

                   2, nTotalChannels, "c:\mydir\output3.wav")

' start the recording session from channel 3 and save it inside the output4.wav file

activeSoundRecorder4.StartFromAsioDevice(ComboInputDevices.ListIndex, _

                   3, nTotalChannels, "c:\mydir\output4.wav")

 

 

In the third sample we need to record the first 8 input channels of an ASIO device selected from the ComboInputDevices combobox and keep them separated in 4 different output files having each 2 input channels mixed together, for this purpose we will use 4 instances of the component (activeSoundRecorder1, activeSoundRecorder2, activeSoundRecorder3, and activeSoundRecorder4):

 

 

' init some variable

Dim nTotalChannels as Integer

nTotalChannels = 2

 

' start the recording session from channels 0-1 and save it inside the output1.wav file

activeSoundRecorder1.StartFromAsioDevice(ComboInputDevices.ListIndex, _

                   0, nTotalChannels, "c:\mydir\output1.wav")

' start the recording session from channels 2-3 and save it inside the output2.wav file

activeSoundRecorder2.StartFromAsioDevice(ComboInputDevices.ListIndex, _

                   2, nTotalChannels, "c:\mydir\output2.wav")

' start the recording session from channels 4-5 and save it inside the output3.wav file

activeSoundRecorder3.StartFromAsioDevice(ComboInputDevices.ListIndex, _

                   4, nTotalChannels, "c:\mydir\output3.wav")

' start the recording session from channels 6-7 and save it inside the output4.wav file

activeSoundRecorder4.StartFromAsioDevice(ComboInputDevices.ListIndex, _

                   6, nTotalChannels, "c:\mydir\output4.wav")

 

 

In the fourth sample we need to record 6 input channels, starting from channel 2 (so we won't consider channels 0 and 1) of an ASIO device selected from the ComboInputDevices combobox and keep them separated in in one single destination file supporting multi-channel:

 

 

' use custom resampling format 44100 Hz, 6 channels

activeSoundRecorder1.EncodeFormats.ResampleMode = RESAMPLE_MODE_CUSTOM_FORMAT

activeSoundRecorder1.EncodeFormats.ResampleCustomFrequency = 44100

activeSoundRecorder1.EncodeFormats.ResampleCustomChannels = 6

 

' init some variable

Dim nTotalChannels as Integer

nTotalChannels = 6

 

' keep mono channels separated

activeSoundRecorder1.ASIO.DeviceRecordParamsSet (ComboInputDevices.ListIndex, _

                   BOOL_FALSE, ASIO_REC_MONO_BOTH_CHANS)

 

' start the recording session from channel 2 (ignore 0 and 1) and save it inside the output.wav file

activeSoundRecorder1.StartFromAsioDevice(ComboInputDevices.ListIndex, _

                   2, nTotalChannels, "c:\mydir\output1.wav")

 

 

It's important to note that code snippets above simply show how to call the StartFromAsioDevice method and don't show the calls to the InitDriversType method and to the ASIO.DeviceStart method which are in any case mandatory for starting the recording session: finally, don't forget that, when using multiple instances of the component as seen inside some of the available code snippets, the need to call these mandatory methods is only from one single instance of the component, for example from the instance identified by activeSoundRecorder1 because,.once an ASIO device is started, it can be automatically accessed by all of the other instances.

 

 

In case you should simply need to render audio data incoming from one or more input channels to one or more output channels directly, with the advantage of a smaller CPU footprint, a possible alternative to the ASIO.DeviceStart method would to invoke the ASIO.DeviceListenInputStart method: the limitation of this approach would be the fact that you would loose the capability to record or cast incoming audio data. When the ASIO device is started in this way, you may pause direct playback through the ASIO.DeviceListenInputPause method and resume playback through the ASIO.DeviceListenInputResume method.

 

Also in this case, the ASIO device can be stopped through the ASIO.DeviceStop method.

 

 

Samples of usage of ASIO drivers in Visual C++ and Visual Basic 6 can be found inside the following samples installed with the product's setup package:

- AsioList

- AsioSimpleRecorder

- AsioMultiChanRecorder