ASIO (pro soundcard)

ASIO (Audio Stream Input/Output) is a computer sound card driver protocol. It enables to address inputs and outputs from many professional sound card.

You can use ASIO extension to address many hardware IO (eg, outputing signal to multiple listeners or array of speakers). ASIO is also a low latency procotol and maybe used to get the best audio experience.

Like in other audio softwares, only one ASIO driver can be used at a time. You can create many AsioInput and AsioOutput, but they will all access the same driver.

  1. Inputs
  2. Outputs
  3. Helpers
  4. Samples

Inputs

Asio Input

Provides access to multiple inputs from a connected sound card with ASIO support.

I/O Channel count Sub channel count
out 1 M (see construction)

Construction

  • audioSlot (const char*) : a string composed of the driver name and a list of input names. The input will have as many subchannels as input names in the list.

    Generic usage:

    context.createInput(ID,AsioInput,"DRIVER_NAME:IN_1_NAME,IN_2_NAME");
    

    Sample usage for a Focusrite sound card creating a two subchannels input:

    context.createInput(ID,AsioInput,"Focusrite USB 2.0 Audio Driver:Input 3,Input 4");
    
  • audioSlot (AudioSlot&) : an AudioSlot object representing the driver and the list of inputs (see AudioSlot).

    Requires revision

Parameters

ΓΈ

Global parameters used by this IO :

  • application/buffer_size


Outputs

Asio Output

Provides access to multiple outputs from a connected sound card with ASIO support.

It can be used to output multi-speaker output, or multiple headphones.

I/O Channel count Sub channel count
in N M (see construction)

Construction

  • audioSlot (const char*): a string composed of the driver name and a list of output names. The output will have as many subchannels as output names in the list.

    Generic usage:

    context.createOutput(ID,AsioOutput,"DRIVER_NAME:OUT_1_NAME,OUT_2_NAME");
    

    Usage for a Focusrite sound card creating a two subchannels output:

    context.createOutput(ID,AsioOutput,"Focusrite USB 2.0 Audio Driver:Output 1,Output 2");
    
  • audioSlot (AudioSlot&) : an AudioSlot object representing the driver and the list of outputs (see AudioSlot).

    Requires revision

Parameters

Runtime
  • master_gain (float) : master gain of this output (amplitude).

    This parameter is mapped by default to listener/%list_id/master_gain.

    Usage :

    context.setParameter("listener/2/master_gain",0.5f)
    

Global parameters used by this IO :

  • application/buffer_size


Classes

Audio Driver List

Construction

AudioDriverList();

Creates a driver list.

Methods

unsigned int getNbDrivers()

Returns the number of asio drivers installed on your system.

const char* getDriverName(unsigned int _driverId)

Returns the name of the requested driver.

const char* getDefaultDriver() 

Returns the name of the first available ASIO driver on your system. If no driver is available, it returns nullptr.

Usage:

AudioDriverList myList; 

const unsigned int nbDrivers = myList.getNbDrivers();
std::cout << nbDrivers << "available on your system.\n";

for(unsigned int i = 0; i < nbDrivers; ++i){
	std::cout << "Driver " << i <<", name: " << myList.getDriverName(i) << std::endl;
}

Audio Driver

Construction

AudioDriver(const char* _driverName)

Creates a driver, using the ASIO driver matching _driverName. Please note that only one AudioDriver can be instanciated simultaneously.

bool isDriverLoaded()

Returns true if driver is properly created, false otherwise. You can also catch exceptions raised in constructor.

const char* getDriverName()

Returns the name of the represented ASIO driver (provided at construction).

unsigned int getNbInputs()

Returns the number of inputs available on the connected soundcard

unsigned int getNbOutputs()

Returns the number of outputs available on the connected soundcard

const char* getInputName(unsigned int _inputId)

Returns the name of the nth input

const char* getOuputName(unsigned int _outputId)

Returns the name of the nth output

void getAvailableBufferSize(unsigned int& _current, unsigned int& _min, unsigned int& _max, unsigned int& _preferred)

Provides buffer length available on connected soundcard.

float getSampleRate()

Returns operating samplerate of your soundcard.

bool hasInput(const char* _inputName)

Returns true if _inputName is an available input

bool hasOuput(const char* _outputName)

Returns true if _outputName is an available output


Usage:

AudioDriver myDriver("Dante Virtual Soundcard (x64)"); 

unsigned int nbInputs = myDriver.getNbInputs();
std::cout << "Current asio driver has " << nbInputs << " inputs."<<std::endl;
for(unsigned int inIdx = 0; inIdx < nbInputs; ++inIdx){
	std::cout << "\t" << inIdx << " - " << myDriver.getInputName(inIdx) <<std::endl;
}

Audio Slot

Requires revision




Code samples

For more code samples, see ASIO samples

Note: Our Asio Inspector program, provided with Aspic Audiostack, enables you to get info about available asio drivers on your computer.

ASIO Basics

This sample spatialize hello input for one listener with 2 speakers on an asio device.

[...]

enm:int{hello=0,asioOut=1,bus,spatEffect};

AudiostackContext context;
context.setLicenseKeyFromFile("LICENSE_FILE.aslc");
AsioInterface::Load(context->impl);

context.createInput(hello,HelloInput);
context.createOutput(asioOut,AsioOutput,"DRIVER_NAME:OUT1_NAME,OUT2_NAME");
// Use Asio Inspector provided with our installer to get the name of your asio driver and outputs

context.createBus(bus);
context.createEffect(spatEffect,bus,BinauralSpatializationAspic);

context.connect(hello, bus);
context.connect(bus,asioOut);

context.setParameter("application/buffer_size",512U);

context.play();

float sourcePos[]   =   {0.0, 0.0, -1.0};
float listenerPos[] =   {0.0, 0.0, 1.0};
float listenerRot[] =   {0.0, 0.0, 0.0};
context.setParameter("listener/1/position",listenerPos);
context.setParameter("source/0/position",sourcePos);

char c;
do{
	std::cout<<"Press r or l to rotate the listener, press q to exit"<<std::endl;
	std::cin>>c;

	switch(c){
	case 'l':
		listenerRot[1]-=10;
		context.setParameter("listener/1/rotation",listenerRot);
		break;
	case 'r':
		listenerRot[1]+=10;
		context.setParameter("listener/1/rotation",listenerRot);
		break;
	}
}while(c!='q');

context.stop();

[...]

For more code samples, see ASIO samples