title:: HOA Tutorial Exercise 10 summary:: Some decoders for standard speaker arrays. categories:: Libraries>HOA related:: Guides/HOAguide, Tutorials/HOA_Tutorial_Overview STRONG:: Previous::: link::Tutorials/Exercise_09_HOA_interfacing_VBAP_and_Ambisonics:: STRONG:: Next::: link::Tutorials/Exercise_11_HOA_NRT_using_scores_and_Buffers:: Below are some simple examples that show how to play back a multichannel soundfile in HOA b-format and listen to it through headphones. The 3rd order field recordings have been made with the Eigenmike Link::https://mhacoustics.com/products:: with the kind support ofthe Centre for Interdisciplinary Research in Music Media and Technology, housed at the Schulich School of Music at McGill University (CIRMMT) Link:: http://www.cirmmt.org/:: a microphone array with 32 capsules. In case you have not done so yet: let's start the sound server, which we configure first to get more audio buses and to have 36 output channels. code:: s.quit; // quit the server first if it is still running with another configuration. ( ServerOptions.devices; s = Server.local; Server.local = Server.default; o = Server.local.options; // Get the local server's options o.numInputBusChannels = 2; // Set Input to number of Inputs o.numOutputBusChannels = 36; // lets start after chan 36 so as not to see the mic input o.numAudioBusChannels = 2048; o.blockSize = 512; o.numWireBufs = 1024 * 16; o.memSize = 2.pow(18); o.sampleRate = 48000; s.makeWindow; s.boot; ) :: Start the oscilloscope showing all the channels for the selected order of the B-format. code:: ( ~order = 3; ~hoaNumChannels = (~order+1).pow(2); s.scope(5); // let's use 5 as we play back via ITU 5.0 ) :: Let's load some 16 channels 3rd order soundfiles, the filenames indicate the channel ordering as well as the normalization (ACN, N3D): code:: ~hoaSoundFile = Buffer.read(s, HOA.soundsDir++"/eigen_ACN_N3D_Montreal_Metro_cello.wav"); ~hoaSoundFile = Buffer.read(s, HOA.soundsDir++"/eigen_ACN_N3D_Montreal_Metro.wav"); ~hoaSoundFile = Buffer.read(s, HOA.soundsDir++"/eigen_ACN_N3D_CIRMMT_Foyer_short.wav"); ~hoaSoundFile = Buffer.read(s, HOA.soundsDir++"/eigen_ACN_N3D_Montreal_LePlateau_Backyard.wav"); ~hoaSoundFile.numChannels; :: Let's make a node that can play back the 3rd order HOA sound file. code:: ( ~toaSignal = NodeProxy.new(s, \audio, ~hoaNumChannels); ~toaSignal.source = { HPF.ar(PlayBuf.ar( ~hoaSoundFile.numChannels, ~hoaSoundFile, loop:1 ), 100) }; ~toaSignal.fadeTime = 1; ) :: Let's make two more nodes that generate 2nd and 1st order HOA sounds to go with it. code:: ( ~soaSignal = NodeProxy.new(s, \audio, 9); ~soaSignal.source = { HOAEncoder.ar(2, Ringz.ar(LFSaw.ar(6, mul:BrownNoise.ar(0.2)).pow(3), 220, 0.8) , az: SinOsc.ar(0.5) ) }; ~soaSignal.fadeTime = 1; ~foaSignal = NodeProxy.new(s, \audio, 4); ~foaSignal.source = { HOAEncoder.ar(1, Ringz.ar(LFSaw.ar(4, mul:BrownNoise.ar(0.2)).pow(3), 880* 1.5, 0.8), az: SinOsc.ar(1) ) }; ~foaSignal.fadeTime = 1; ) :: Let's use a 5.0 allrad decoder watch in the scope how the back channels have a higher gain o make up for the missing channel in the back center and to keep the energy in the back constant. Play with the crossover frequency of the decoder as as with the low / high frequency balance. code:: ( // creating all the 1st 2nd and 3rd order signals ~toaDecoder = NodeProxy.new(s, \audio, 5); ~toaDecoder.source = {var in; in = \in.ar(0!~hoaNumChannels); HOADec5_0.ar(3, in, lf_hf:0, xover:400) }; ~toaDecoder.fadeTime = 1; ~soaDecoder = NodeProxy.new(s, \audio, 5); ~soaDecoder.source = {var in; in = \in.ar(0!9); HOADec5_0.ar(2, in, lf_hf:0, xover:400) }; ~soaDecoder.fadeTime = 1; ~foaDecoder = NodeProxy.new(s, \audio, 5); ~foaDecoder.source = {var in; in = \in.ar(0!4); HOADec5_0.ar(1, in, lf_hf:0, xover:400) }; ~foaDecoder.fadeTime = 1; ~out = NodeProxy.new(s, \audio, 5); ~out.source = {var in; in = \in.ar(0!5); in }; ~out.fadeTime = 1; ~out.play(0, 5); ) ( // routing them into the decoder ~toa5 = ~toaSignal <>> ~toaDecoder; ~soa5 = ~soaSignal <>> ~soaDecoder; ~foa5 = ~foaSignal <>> ~foaDecoder; ) ( // mixing the decoded speaker signal ~mixOrders = ProxySubmix(\mixer); ~mixOrders.ar(5); ~mixOrders.addMix(~toa5).addMix(~soa5).addMix(~foa5); ) :: And then we connect them to the ~out: code:: ~mixOrders <>> ~out; :: STRONG:: Previous::: link::Tutorials/Exercise_09_HOA_interfacing_VBAP_and_Ambisonics:: STRONG:: Next::: link::Tutorials/Exercise_11_HOA_NRT_using_scores_and_Buffers::