NRT and literal array arguments

Hi
I try to generate a sound file via NRT. The instruments uses literal arrays as input arguments. And I have a text file with commands that I run. It works in realtime SuperCollider via OSC but in NRT it just silently stops rendering. Any ideas what could be wrong?

This is the instrument.

SynthDef(\bankOfOsc, {
	arg dur = 1, freqs = #[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
	amps = #[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
	phases = #[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], out = 0;
	var sig;
	Line.kr(dur:dur, doneAction:2);
	sig = Klang.ar(`[freqs, amps, phases ]);
	Out.ar(out, sig);
}).add.store('global', synthsDir );

This is the one example call.

[0.0, [\s_new, \bankOfOsc, -1, 0, 1004, \out, 74, \dur, 5.185676258002328, \freqs, [184.997, 523.251, 861.505, 1199.759, 1538.013, 1876.267, 2214.521, 2552.775, 2891.029, 3229.283, 3567.537, 3905.791, 4244.045, 4582.299, 4920.553], \amps, [0.318, 0.000, 0.106, 0.080, 0.000, 0.000, 0.045, 0.000, 0.000, 0.032, 0.029, 0.000, 0.024, 0.000, 0.021], \phases, [0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000]]]

This is how I render it.

(
var server, score;

server = Server(\nrt,
    options: ServerOptions.new
	.sampleRate_(96000)
    .numOutputBusChannels_(14)
	.maxNodes_(4096)
    .numInputBusChannels_(2));

score = Score.newFromFile("/path/to/testfile.txt");

score.recordNRT(
    outputFilePath: "/path/to/sound/file.caf".standardizePath,
    headerFormat: "CAF",
    sampleFormat: "float",
    options: server.options,
	duration: 210,
    action: { "done".postln }
);

server.remove;
)

I use SuperCollider 3.12.0 and mac OS 13.1

Thanks in advance.

When you use an array in a Synth or Event argument list, it’s automatically preprocessed to delimit the arrays in a way that’s… strange but it’s how we do it, and when it’s formatted automatically, it’s transparent to the user.

When you’re writing the OSC message directly, you need to call this preprocessing manually.

[0.0, 
    [
        \s_new, \bankOfOsc, -1, 0, 1004, \out, 74, \dur, 5.185676258002328,
        \freqs, [184.997, 523.251, 861.505, 1199.759, 1538.013, 1876.267, 2214.521, 2552.775, 2891.029, 3229.283, 3567.537, 3905.791, 4244.045, 4582.299, 4920.553],
        \amps, [0.318, 0.000, 0.106, 0.080, 0.000, 0.000, 0.045, 0.000, 0.000, 0.032, 0.029, 0.000, 0.024, 0.000, 0.021], \phases, [0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000, 0.000]
    ].asOSCArgArray  // <<-- here
]

hjh

Awesome. It worked. Thanks.

Cool :grin:

That’s a bit of fine print that pretty much nobody is going to discover on their own. It doesn’t figure prominently in the NRT guide help file because most of the examples use Synth.basicNew().newMsg style, which will automatically format the arrays properly. We probably should add a note about that.

hjh

Ah, ok. That makes sense. NRT, for me is very useful. Especially if you want to render something and import it into a DAW. Again, thanks for the help. I actually mixed the music and released it!