Ambisonics

This extension handles ambisoncis streams: encoding, decoding, conversions.

  1. Effects
  2. Code samples

Effects

Ambisonics To Binaural

Renders ambisonics streams as binaural.

I/O Channel count Sub channel count  
in N M  
out N 2 (BINAURAL)  

Construction

  • ambFormat (const char) : Use this parameter to specify the kind of Ambisonics stream you will be sending to the effect. Available values are: ACN_SN3D_ORDER1, ACN_SN3D_ORDER2 and ACN_SN3D_ORDER3. Streams must be normalized and order using ACN SN3D convention.

Usage:

context.createEffect(EFFECT_ID, BUS_ID, AmbisonicsToBinaural, "AMBISONICS_THIRD_ORDER");

Parameters

Runtime
  • listener_rotation (vec3, multivalued) : rotation of audio listener

    This parameter will contain N values, with N equal to the number of listeners.

    Parameter is mapped by default to listener/%list_id/rotation

    Usage with default vars and patterns:

    float playerRot[] = {1.0, 2.0, 3.0};
    context.setParameter("listener/1/rotation", playerRot);
    



Ambisonics Encoder

Encodes mono sources to ambisonics.

I/O Channel count Sub channel count  
in N 1  
out N M  

Construction

  • ambFormat (const char) : Use this parameter to specify the kind of Ambisonics stream you want as effect output. Available values are: ACN_SN3D_ORDER1, ACN_SN3D_ORDER2, ACN_SN3D_ORDER3, TBE.

Usage:

context.createEffect(EFFECT_ID, BUS_ID, AmbisonicsEncoder, "TBE");

Parameters

Runtime
  • src_position (vec3, multivalued) : position of audio source

    This parameter will contain N values, with N equal to the number of channels reaching effect’s input.

    Parameter is mapped by default to source/%src_id/position

    Usage with default vars and patterns:

    float sourcePos[] = {1.0, 2.0, 3.0};
    context.setParameter("source/9/position", sourcePos);
    
  • listener_position (vec3, multivalued) : position of audio listener

    This parameter will contain N values, with N equal to the number of listeners.

    Parameter is mapped by default to listener/%list_id/position

    Usage with default vars and patterns:

    float playerPos[] = {1.0, 2.0, 3.0};
    context.setParameter("listener/1/position", playerPos);
    



Ambisonics Order Manipulation

Converts ambisonics to different ambisonics ordering/normalization.

I/O Channel count Sub channel count  
in N M  
out N O  

Construction

  • inAmbFormat (const char) : Input ambisonics type. Available values are: ACN_SN3D_ORDER1, ACN_SN3D_ORDER2, ACN_SN3D_ORDER3, TBE.

  • outAmbFormat (const char) : Output ambisonics type. Available values are: ACN_SN3D_ORDER1, ACN_SN3D_ORDER2, ACN_SN3D_ORDER3, TBE.

Usage:

context.createEffect(EFFECT_ID, BUS_ID, AmbisonicsOrderManipulation, "ACN_SN3D_ORDER3", "TBE");



Code samples

For more code samples, see Ambisonics samples

Ambisonics to Binaural

This sample renders an ambisonics stream in binaural.

[...]

enm:int{hoaFileIn=0,audioOut=1,bus,hoaDecoderEffect};

AudiostackContext context;
context.setLicenseKeyFromFile("LICENSE_FILE.aslc");

context.createInput(hoaFileIn,SyncAudioFileReader,0,0,16);	// 16 channel -> 3rd order ambisonics
context.setParameter("sync_source/0/file", "path/to/hoa3.wav");
context.setParameter("sync_source/0/loop", true);
context.setParameter("sync_source/0/start_on_awake", true);
context.setParameter("sync_source/0/nb_channel",16);

context.createBus(bus);
context.createEffect(hoaDecoderEffect, bus, AmbisonicsToBinaural,"ACN_SN3D_ORDER3");

context.createOutput(audioOut,WindowsCoreAudioOutput,true);

context.connect(hoaFileIn, bus);
context.connect(bus, audioOut);

context.play();

float listRot[3];
listRot[0] = 0.0f;
listRot[1] = 0.0f;
listRot[2] = 0.0f;

char c;
do {
	std::cout<<"Press q or d to rotate listener."<<std::endl;
	std::cout<<"Press x to exit."<<std::endl;
	std::cin >> c;
	switch(c){
	case 'q':
		listRot[1] -= 5.0f;
		break;
	case 'd':
		listRot[1] += 5.0f;
		break;
	}
	context.setParameter("listener/1/rotation",listRot);

}while(c != 'x');

context.stop();

[...]

For more code samples, see Ambisonics samples