Hey everyone. I am having some unexpected difficulty in trying to process a sound file using NRT and the DiskIN ugen. The resulting file is empty, even though it has the correct length, channels etc. Any hints on why? I suspect it’s got something to do with the buffer allocation, perhaps even something embarrasing!
prATK2Ambix{
var targetFormat = \ambix;
var score;
var synthdefname = "hoaatk2ambix_o%".format(order).asSymbol;
var fileprefix = targetFormat.asString ++ "_";
var outFileName = path.pathOnly +/+ fileprefix ++ path.fileName;
var synthfunc = {|out=0, fileBuffer|
var hoa = DiskIn.ar(numChannels:order.asHoaOrder.size, bufnum:fileBuffer, loop:0);
hoa = HoaNFCtrl.ar(
in: hoa,
encRadius: AtkHoa.refRadius,
decRadius: 10.0,
order: order
);
// exchange normalisation: N3D to SN3D
hoa = HoaDecodeMatrix.ar(
in: hoa,
hoaMatrix: HoaMatrixDecoder.newFormat(format: targetFormat, order: order)
);
Out.ar(bus: out, channelsArray: hoa);
};
var opts = ServerOptions.new
.numOutputBusChannels_(soundfile.numChannels)
.maxSynthDefs_(100000)
.memSize_(65536 * 4)
.numInputBusChannels_(soundfile.numChannels);
fork{
var cond = Condition.new;
var server = Server("nrt%".format(Date.getDate.stamp), options: opts);
var bufnum = 999;
// HOAFX.loadSynthDefs(order:order);
score = Score([
// Allocate and read buffer for sound file
[0.0, '/b_alloc', bufnum, soundfile.numFrames, soundfile.numChannels],
[0.0, '/b_read', bufnum, path.fullPath, 0, -1, 0, 1],
// Make synthdef
[0.0, ['/d_recv',
SynthDef(synthdefname, synthfunc).asBytes
]],
// Run synth
[0.0, Synth.basicNew(synthdefname, server, 1000).newMsg(args: [\fileBuffer, bufnum])],
// Close file
[soundfile.duration, '/b_close', bufnum],
// End process
[soundfile.duration, nil]
]);
"Starting file processing. This might take a bit of time...".postln;
score.recordNRT(
outputFilePath: outFileName,
inputFilePath: soundfile.path,
sampleRate: soundfile.sampleRate,
headerFormat: soundfile.headerFormat,
sampleFormat: soundfile.sampleFormat,
options: server.options,
duration: soundfile.duration ,
action: {
cond.unhang();
"Done processing".postln;
defer{
var donewin, donelay, donebutton;
donewin = Window.new("Done");
donebutton = Button.new(donewin).states_([["Open folder"]]).action_({path.pathOnly.openOS()});
donelay = VLayout(StaticText.new(donewin).string_("Done processing file!"), donebutton);
donewin.layout_(donelay);
donewin.front();
}
}
);
"Waiting for process to finish".postln;
cond.hang;
}
}