Ambisonics (rendering, encoding)
This extension handles ambisoncis streams: encoding, decoding, conversions.
Extension doc can be found here.
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();
[...]
Ambisonics encoding and ASIO streaming
This sample encodes a hello input into ambisonics, and outputs this ambisonics to an ASIO driver (for instance to stream to an external decoding system).
[...]
enm:int{helloIn=0,asioOut=1,bus,hoaEncoderEffect};
AudiostackContext context;
context.setLicenseKeyFromFile("LICENSE_FILE.aslc");
context.createInput(helloIn,HelloInput);
context.createBus(bus);
context.createEffect(hoaEncoderEffect, bus, AmbisonicsEncoder,"ACN_SN3D_ORDER3");
context.createOutput(asioOut,AsioOutput,"DRIVERNAME:OUT 1,OUT 2,OUT 3,[...]"); // 16 channel output to stream HOA
context.connect(helloIn, bus);
context.connect(bus, asioOut);
context.play();
do {
std::cin >> c;
switch(c){
// move source and listener with patterns "source/0/position" and "listener/1/position"
}
}while(c != 'x');
context.stop();
[...]