|
How to manage ASIO drivers |
![]() ![]()
|
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 DJ Studio enumerates output devices (sound cards) supporting the DirectSound protocol: in order to let Active DJ Studio 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 (*).
The call to the InitDriversType method is mandatory before performing calls to the InitDJSystem, GetOutputDevicesCount and GetOutputDeviceDesc 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 output devices through the GetOutputDevicesCount and GetOutputDeviceDesc methods. 4. ResetControl method
After having initialized the type of driver(s) in use through the InitDriversType method, it will be possible enumerating available output devices through the GetOutputDevicesCount and GetOutputDeviceDesc methods: depending upon the drivers set, these methods will return the overall list of available output devices (DirectSound + ASIO) so it will be possible setting them inside the nOutputx parameters of the InitDJSystem method. At a later time you can obtain the driver in use by a specific output device through the GetOutputDeviceDriverType 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 that implements the ASIO COM object:
The call to the ASIO.DeviceStart method is mandatory in order to perform playback of the loaded sound on a specific ASIO device. You can know if a specific ASIO device is already started through the ASIO.DeviceIsStarted method. After starting an ASIO device, it will be possible performing the following tasks:
An interesting feature of ASIO devices is the channel mirroring, a capability that allows replicating the same sound on more output channels of the same ASIO device; this can be obtained with a specific setting of the nChannelMode parameter of the ASIO.DeviceStart method:
With regards to playback of loaded sounds, it's important to note that the possibility to redirect the sound stream to output devices having different nature (ASIO or DirectSound) has been maintained. In order to achieve this feature we had the need to internally create an embedded "Stream Mixer" for each output device; this approach is quite similar to what has been described inside the How to use custom Stream Mixers tutorial but in this case you don't need to allocate a new custom Stream Mixer through your own code because the control will automatically allocate it for you. Below you can see the architecture applied:
In case the output of Player 0 and/or Player1 should be redirected to a different output device, the StreamOutputDeviceSet method would automatically disconnect the PCM stream from the internal Stream Mixer of the current output device and will reconnect it to the internal Stream Mixer of the new output device.
As for custom Stream Mixers described inside the How to use custom Stream Mixers tutorial, also in this case the Stream Mixer owns a unique identifier that can be obtained through the StreamMixerGetIdFromOutput method: through this unique identifier you can apply further effects to the mixed streams, for example you could apply a custom DSP or modify the Preamplifier volume: for this purpose the unique identifier can be used in place of the nPlayer parameter for all of the methods that will modify the output stream, like volume-related methods and all of the methods described inside the How to apply special effects to a playing sound tutorial. For obvious reasons, respect to custom Stream Mixers, you cannot redirect the mixed stream in output from the Stream Mixer to a different output device.
As seen on the graphic above, as for custom Stream Mixers, the Mixed stream being sent to the output device can be redirected to one of the following destinations:
IMPORTANT NOTE ABOUT PERFORMANCES: When the output of the stream mixer is sent to the recorder control and/or to a streaming server, a too much low latency set into the ASIO driver could cause unwanted gargling on the audio stream: in this specific case it's recommended that the latency of the ASIO driver is set to 512 samples per second or higher.
Samples of usage of ASIO drivers in Visual C++ 6 and Visual Basic 6 can be found inside the following samples installed with the product's setup package: - AsioList - AsioSpeakersManager - AsioVideoPlayer - AsioStreamMixer (requires the installation of Active Sound Suite)
(*) The possibility for a certain output device to support both DirectSound and ASIO at the same time could be compromised if the specific driver in use shouldn't be able to manage the situation: usually in these cases, quite limited in our experience, it will be only possible playing back the loaded sound through the ASIO protocol.
|