Adding Multiple Synths to a NRT Score

Hi there, everyone.

I’m trying to get a handle on NRT Synthesis, since it’s been coming up on the mailing list a bit lately. At the moment, I’m confused about something, though - how to load multiple SynthDefs. The following code seems to fail:

(
x = Pbind(
\instrument, Pseq([\one, \two, \three], inf),
\freq, Pwhite(100, 1000, inf),
\dur, Pseq([1/8, 1/8, Pwhite(0.005, 0.1, 1)], inf),
\amp, 1
).asScore(duration: 3*60, timeOffset:0.001);

x.add([0.0, [\d_recv,

SynthDef("one",
	{|freq|
		var sig = SinOsc.ar(freq)*EnvGen.ar(Env.perc(0.01, 0.1), doneAction:2);
		Out.ar(0, sig)
}).asBytes;

	SynthDef("two",
	{|freq|
		var sig = LFTri.ar(freq)*EnvGen.ar(Env.perc(0.01, 0.1), doneAction:2);
		Out.ar(0, sig)
}).asBytes;

	SynthDef("three",
	{|freq|
		var sig = LFSaw.ar(freq)*EnvGen.ar(Env.perc(0.01, 0.1), doneAction:2);
		Out.ar(0, sig)
}).asBytes;

]]);

x.recordNRT(outputFilePath: “/Users/of/Desktop/longddso.aif”,
options: ServerOptions.new.numOutputBusChannels_(2), duration: 3*60,
action: { “finished”.postln });
)

Try adding them one at a time, or as a comma separated bundle. I think one at a time should be easier.
Right now, all the SD bytes are being jammed together into something scsynth can’t parse.

This is an improvement - thank you, Josh. The only problem is that now I get an
ERROR: makeSynthMsgWithTags: buffer overflow. (The actual SynthDefs I’m using are much larger than the example above.)

I’m not quite sure where the buffer comes into play, but I’m assuming I’m just trying to send too much OSC… but is there a way to increase the overall size and capacity?

How big are your synthdefs? And as a sanity check - have you tried adding them to the live server?

The solution for very big synthdefs with the live server is to write them to disk and then send a message to the server to load them (using writeDefFile, load, or send). I’m not sure if that’s an option with NRT as well, but that might be something to look into.

Right, it is, and .store includes all in once, preparing also for pattern usage. E.g.

Oh cool. I’m planning to write a section of the new tutorial on NRT, so it’s good to have a definitive answer on that.

They’re definitely not quite “sane”, but I can load them on the live server - even if I can’t play them well in real-time. I think part of the appeal of NRT is being able to do things you wouldn’t be able to do in real-time, right?

.store seems to work - but is there a way to get a better sense of what the limits are? Occasionally, I also see memory allocation running out during an NRT process also - granted, I’m usually doing something wrong in those cases - but how does one get a sense of the memory they’re using in such a process and what the limits are?

Now that I’m testing it a bit more, .store doesn’t quite seem to work as I expected. I saved all of the SynthDefs using .store, and call them via the Pbind for NRT processing, but they sound entirely different. Is there another component to calling them back?

Yes, but what is this in your use case, that couldn’t be done in RT ?

Difficult to say with no additional info or code posted. I can only guess, could it be something goes wrong with buffers in NRT mode ?

Essentially, it’s a single, fairly long SynthDef that I instantiate half a dozen times, so that it cross-modulates with other versions of itself - this uses a number of external audio busses that are loaded onto the Server. I haven’t used the protocol of setting up an dedicated server for NRT yet - but perhaps that’s worth trying?

As it gets increasingly complex, the CPU is less able to handle playing it smoothly - and I’d like to expand it further and potentially faster.

Where might buffers enter the mix?