How to allocate busses in NRT mode?

Hello everyone

I was wondering if anyone knows how to allocate and map busses in NRT mode?

I’m kinda stuck here. The NRT guide mentions the idea but doesn’t show how. Bus doesn’t have an allocMsg or newMsg like Buffer for example. I tried hardwiring like this without luck. Any pointers?


(
var nrtserver = Server(\nrt, options: ServerOptions.new
	// .sampleRate_(samplerate)
	.memSize_(1024*512) // Allocate 512 mb memory
	// .numOutputBusChannels_(hoaOrder.asHoaOrder.size)
	// .numInputBusChannels_(hoaOrder.asHoaOrder.size)
	.maxSynthDefs_(10000)
	.numWireBufs_(1000000)
);
var nodeID = 110101;

// Sound source
SynthDef.new(\sine, {|out=0, freq=100| Out.ar(out, SinOsc.ar(freq.poll(label:\sineFreq))) }).load;

// LFO
SynthDef.new(\lfo, {|out=0, freq=100| Out.kr(out, LFNoise2.kr(freq).exprange(40.0,2000)) }).load;

z = Score.new([
	[0.0,
		Synth.basicNew(\lfo, server: nrtserver, nodeID: nodeID = nodeID +1 ).newMsg(args:[\out, \c202])
	],
	[0.0,
		Synth.basicNew(\sine, server: nrtserver, nodeID: nodeID = nodeID +1 ).newMsg(args:[\freq, \c202])
	]
]);

)

z.play;


Ah I get it now. I need to set my LFO output bus as an integer and then the equivalent integer prefixed with a c for control bus when mapping:

(
var nrtserver = Server(\nrt, options: ServerOptions.new
	// .sampleRate_(samplerate)
	.memSize_(1024*512) // Allocate 512 mb memory
	// .numOutputBusChannels_(hoaOrder.asHoaOrder.size)
	// .numInputBusChannels_(hoaOrder.asHoaOrder.size)
	.maxSynthDefs_(10000)
	.numWireBufs_(1000000)
);
var nodeID = 110101;

// Sound source
SynthDef.new(\sine, {|out=0, freq=100| Out.ar(out, SinOsc.ar(freq.poll(label:\sineFreq))) }).load;

// LFO
SynthDef.new(\lfo, {|out=0, freq=100| Out.kr(out, LFNoise2.kr(freq).exprange(40.0,2000)) }).load;

z = Score.new([
	[0.0,
		Synth.basicNew(\lfo, server: nrtserver, nodeID: nodeID = nodeID +1 ).newMsg(args:[\out, 202])
	],
	[0.0,
		Synth.basicNew(\sine, server: nrtserver, nodeID: nodeID = nodeID +1 ).newMsg(args:[\freq, \c202])
	]
]);

)

z.play;

The whole point of using a temporary Server is that you don’t have to manually manage node/bus/buffer IDs.

I think you can simply do:
Synth.basicNew(\lfo, server: nrtserver).newMsg(args:[\out, \c202])

Similarly, that’s how you would allocate a bus:
~bus = Bus.audio(nrtserver, 2);

No this is another thing that confused me. the output of lfo has to be an integer, eg 202 and the mapping on the frequency input a symbol eg \c202

Sorry, should have been ~bus = Bus.control(nrtserver);

Anyway, the following works:

(
var nrtserver = Server(\nrt, options: ServerOptions.new
	// .sampleRate_(samplerate)
	.memSize_(1024*512) // Allocate 512 mb memory
	// .numOutputBusChannels_(hoaOrder.asHoaOrder.size)
	// .numInputBusChannels_(hoaOrder.asHoaOrder.size)
	.maxSynthDefs_(10000)
	.numWireBufs_(1000000)
);
var bus = Bus.control(nrtserver);
var lfo, sine;

// Sound source
SynthDef.new(\sine, {|out=0, freq=100|
	Out.ar(out, SinOsc.ar(freq.poll(label:\sineFreq)))
}).load;

sine = Synth.basicNew(\sine, server: nrtserver);

// LFO
SynthDef.new(\lfo, {|out=0, freq=100|
	Out.kr(out, LFNoise2.kr(freq).exprange(40.0,2000))
}).load;

lfo = Synth.basicNew(\lfo, server: nrtserver);


z = Score.new([
	[0.0, lfo.newMsg(args:[\out, bus])],
	[0.0, sine.newMsg],
	[0.0, sine.mapMsg(\freq, bus)],
	[10.0, nil]
]);

nrtserver.remove;
)

z.recordNRT("~/nrt_test1.txt".standardizePath, "~/nrt_test1.wav".standardizePath, duration: 10);

z.play;

No manual IDs anywhere!

1 Like

Not a manual ID in sight - thanks, this is much more elegant !

If you were to add the bus in the newMsg of sine, you could do it like this:

[0.0, sine.newMsg(args: [\freq, bus.asMap])

It also works it seems

2 Likes

yes, definitely more elegant

@Spacechild1

Do you a example of how to use HOA IEM plugins with NRT mode that you can share?

Thanks a lot!

@fmiramar Just have a look at the “Non-Realtime Synthesis” section in the VSTPluginController help file. The example is about playing VST instruments, but it can be easily adapted to effect plugins.

1 Like