Ndef output leaks into busses

Hi there!
I have a setup that is configured in this way:

Two groups, a source group and an fx group placed after the source group.
In the fx group I run a bunch of fx synths (for comb filter, flanger, reverb etc.). Those synth are always running on my server.

Here is a simplified version of it.

(
s.newBusAllocators;
~comBus = Bus.audio(s, 2);
~revBus = Bus.audio(s, 2);

s.waitForBoot({
	SynthDef.new(\rev,{
		arg in = 0, out=0, room= 0.3,mix= 0.3, damp = 0.5;
		var sig;
		sig = In.ar(in, 2);
		sig = FreeVerb2.ar(sig[0],sig[1], Lag.kr(mix, 2), Lag.kr(room, 2),damp);
		Out.ar(out, sig)
	}).add;
	
	SynthDef.new(\comb, {
		arg in= 0, out= 0;
		var sig, comb;
		sig = In.ar(in, 2);
		comb = CombC.ar(sig, \maxDelTime.kr(1), Lag.kr(\delTime.kr(0.2), 0.2), \decTime.kr(6));
		sig = sig.blend(comb, \wet.kr(0.3));
		sig = Pan2.ar(sig,0);
		Out.ar(out, sig)
	}).add;
	
	SynthDef.new(\saw, {
		arg freq = 60, amp = 0.2, ffreq = 1200, pos = 0, atk = 0.1, dec = 0.3, sus = 0.5, rel = 1,        gate = 1, rq = 1;
		var sig, env;
		sig = Saw.ar(freq);
		sig = MoogFF.ar(sig, freq * 2); //MouseY controlla la frequeza di taglio del filtro
		env = EnvGen.ar(Env.adsr(atk, dec, sus, rel), gate, doneAction:2);
		sig = sig * env * amp;
		sig = Pan2.ar(sig, pos);
		Out.ar(0, sig)
	}).add;
	
	
	~makeNodes = {
		
		// Groups
		~fxGroup = Group.new(s.defaultGroup, \addAfter);
		
		
		//Effects
		~comb = Synth(\comb, [\in, ~comBus, \out, ~revBus]);
		~reverb = Synth(\rev, [\in, ~revBus, \out, 0], ~comb, \addAfter);
	};
	s.sync;
	
	~makeNodes.();
	
	s.sync
})
)

The problem is that if i try to use Ndef, the output of the that process is written to one of the busses that I reserved for the fx synths.

If I run

Ndef(\x, {SinOsc.ar(mul: 0.2) * Env.perc(0.01, 0.01).ar(0, Impulse.ar(0.5))});

I can hear the output of that Ndef running into my effects, (comb + reverb) even if I did not run

Ndef(\x).play;

Apparently the output of Ndef(\x) is written to the first bus available, since 0 and 1 are usually hardware outputs and 2,3 are hardware input, so it goes to number 4, which is the one that I’m using for comb filter(which is connected to reverb by ~revBus, then reverb goes into hardware output).
evaluating this

~comBus

post window says : → Bus(audio, 4, 2, localhost)

This is not what I want!
I would like to have the option of using Ndef and if needed to route the output to and fx synth.

My question is:
Is there a way to prevent Ndefs, (and Proxy Space or NodeProxy) to use busses that I already reserved for other processes, like fx synths etc.

Thank you, any help is very much appreciated!

I think this SynthDef has a bug: it begins with a stereo signal (In.ar with 2 channels), and then you pan the two channels individually, giving you two stereo pairs. These are then spread out for a total of 3 output channels.

Balance2 is a better choice for stereo input → stereo output.

hjh

Thank you for your reply, @jamshark70. I did’t realized that!
I tried your solution but I think is not solving my problem.

I made a simplified version of my previous code in order to exclude other variables. If you evaluate Ndef(\x) you will hear it going through the comb filter effect.
Looking at the audio scope you will see that the output of the Ndef is going to busses 5 and 6 (the ones that I reserved for the comb filter synth input).

Thank you very much for your help!

(
s.newBusAllocators;
~comBus = Bus.audio(s, 2);


s.waitForBoot({

//fx_SynthDefs

	SynthDef.new(\comb, {
		arg in= 0, out= 0;
		var sig, combL, combR;
		sig = In.ar(in, 2);
		combL = CombC.ar(sig[0], \maxDelTime.kr(1), Lag.kr(\delTime.kr(0.2), 0.2), \decTime.kr(6));
		combR = CombC.ar(sig[1], \maxDelTime.kr(1), Lag.kr(\delTime.kr(0.2), 0.2), \decTime.kr(6));
		sig = sig.blend(combL + combR, \wet.kr(0.3));
		sig = Balance2.ar(sig[0],sig[1], 0);
		Out.ar(out, sig)
	}).add;

	~makeNodes = {

		// Groups
		~fxGroup = Group.new(s.defaultGroup, \addAfter);


		//Effects
		~comb = Synth(\comb, [\in, ~comBus, \out, 0], ~fxGroup, \addToHead);
		~reverb = Synth(\rev, [\in, ~revBus, \out, 0], ~comb, \addAfter);
	};
	s.sync;

	~makeNodes.();
})
)


Ndef(\x, {SinOsc.ar(mul: 1!2) * Env.perc(0.01, 0.1).ar(0, Impulse.ar(0.5))})


Could it perhaps be your \rev SynthDef? The code above is incomplete. I can’t reproduce the error, but this may be the problem …

Oh… totally missed it the first time.

When you boot the server, it erases the old allocators.

That is: Do not allocate buses before booting the server, only after.

// Nope, not like this:

s.newBusAllocators;
~comBus = Bus.audio(s, 2);
~revBus = Bus.audio(s, 2);

s.waitForBoot({
    ...
});

// YES, like this:
s.waitForBoot({
    ~comBus = Bus.audio(s, 2);
    ...
});

hjh

1 Like

@julian Thank you for your reply! sorry, but I forgot to delete this line from my code.

~reverb = Synth(\rev, [\in, ~revBus, \out, 0], ~comb, \addAfter);

I wanted to post a stripped down version of my previous code, using only one effect Synth in order to highlight the problem. That’s why I excluded the \rev SynthDef.

@jamshark70 YES! that Works! I didn’t know that booting the server erases the previous bus allocations.

Many thanks to both of you for showing interest in my problem and offering your precious help.

best wishes,