(
~order = 3;
~hoaNumChannels = (~order+1).pow(2);
s.scope(2); // let's use only two channels as we will monitor it with headphones
)
(
~hoaSignal = NodeProxy.new(s, \audio, ~hoaNumChannels);
~hoaSignal.source = {HOAEncoder.ar(~order, SoundIn.ar(0), // this picks up the Microphone
0, // no azimuth movement
SinOsc.ar(0.3, 0, 90), // changing elevation
plane_spherical:1, // we want it to be a spherical wave
radius:SinOsc.ar(0.4, 0, 2, 2) // and change the radius
)};
~hoaSignal.fadeTime = 1;
)
// Then we make a node that rotates this signal in the x/y plane.
// This is the node that we want to record from, that's why we use a RecNodeProxy:
// code::
(
~hoaTransformer = RecNodeProxy.new(s, \audio, ~hoaNumChannels);
~hoaTransformer.source = {
var in;
in = \in.ar(0!~hoaNumChannels); HOATransRotateAz.ar(~order, in, SinOsc.ar(0.5, 0, pi ));
};
~hoaTransformer.fadeTime = 1;
)
HOADecLebedev26.loadHrirFilters(s);
(
~decoderOrder = 2; // let's reduce the order
~decoderNumChannels = (~decoderOrder+1).pow(2);
~decoder = NodeProxy.new(s, \audio, 2);
~decoder.source = {
var in;
in = \in.ar(0!~decoderNumChannels); HOADecLebedev26.ar(~decoderOrder, in, hrir_Filters:1);
};
~decoder.fadeTime = 1;
~decoder.play(0, 2);
~hoaSignal <>> ~hoaTransformer <>> ~decoder;
)
~hoaTransformer.open(thisProcess.platform.userHomeDir++"/HOArecordingTest.wav", "wav", "float"); // lets record it in float
~hoaTransformer.record // start recording (paused)
~hoaTransformer.unpause // unpause
~hoaTransformer.pause // pause again
~hoaTransformer.close // close the file
~buffer2Normalize = Buffer.read(s, thisProcess.platform.userHomeDir++"/HOArecordingTest.wav");
~buffer2Normalize.normalize.write(thisProcess.platform.userHomeDir++"/HOArecordingTestN.wav", "wav", "int16"); // and safe it as "int16" to safe space
~hoaSoundFile = Buffer.read(s, thisProcess.platform.userHomeDir++"/HOArecordingTestN.wav");
(
~hoaSignal.source = { HPF.ar(PlayBuf.ar( ~hoaSoundFile.numChannels, ~hoaSoundFile, loop:1 ), 100) };
~hoaTransformer.source = {var in; in = \in.ar(0!~hoaNumChannels); in }; )
File.delete(thisProcess.platform.userHomeDir++"/HOArecordingTest.wav");
File.delete(thisProcess.platform.userHomeDir++"/HOArecordingTestN.wav");