… and a second time “oh dear” …
File writing conventions have changed … on my old mac above example works but not on the other machine with OS 10.13.6, we have to specify the path to the osc file now, e.g.:
// helper synthDef to indicate storage of temporary SynthDef of passed function
(
SynthDef(\finishedStore, {
SendReply.ar(Impulse.ar(0), '/finishedStore');
Line.ar(dur: 0.001, doneAction: 2);
Silent.ar
}).store
)
(
~plotNRT = { |function, duration = 1, numChannels = 1|
var soundFile, array;
var synthDef = function.asSynthDef;
var dateString = Date.getDate.stamp;
var renderString = "render_" ++ dateString;
var soundFileName = Platform.recordingsDir +/+ renderString ++ ".aiff";
var options = ServerOptions().numOutputBusChannels = numChannels;
var oscFunc = OSCFunc({ |msg|
// produces score and renders aiff
Score.recordNRT(
[
[0.0, [\s_new, synthDef.name, 1000, 0, 0]],
[duration, [\c_set, 0, 0]]
],
("~/" ++ renderString ++ ".osc").standardizePath,
soundFileName,
options: options,
duration: duration,
// after rendering is finished we can plot
action: {
soundFile = SoundFile.new;
soundFile.openRead(soundFileName);
{
array = FloatArray.newClear(soundFile.numFrames);
soundFile.readData(array);
array.plot;
soundFile.close;
}.defer
}
);
}, '/finishedStore').oneShot;
// triggers synth finishedStore which triggers OSCFunc
synthDef.store(completionMsg: [\s_new, \finishedStore, -1]);
}
)
// plot 10 seconds
// audio file stored in SC recordings directory
~plotNRT.({ LFDNoise3.ar(1) }, 10)
This issue is worse than the other, I’m afraid it is affecting a lot of help files and users’ code in general.