Feedback inside Ndef - problem with bus allocation

I am experimenting with feedback inside Ndefs. Because I want to use multiple outlets, I can’t use LocalIn and LocalOut since the server allows only one instance. I use InFeedback instead which works great:

(
Ndef(\test_feedback1, {
	var b = Bus.audio(s, 2);
	var f = SinOsc.ar(
		[440,441]*(1+InFeedback.ar(b, 2)*0.552), 
		InFeedback.ar(b, 2)*1.548,
		1+(InFeedback.ar(b, 2).abs*1/3.001),
		InFeedback.ar(b, 2)*0.805);
	b.postln;
	Out.ar(b, f);
	f;
} * -42.dbamp
).clock_(t).quant_(1).fadeTime_(1).play
)
Ndef(\test_feedback1).clear(1)

The problem is that every time I evaluate the Ndef, new buses are allocated, while the old ones are still running. Eventually I am running out of bus indexes in the server and the Ndef won’t work anymore.

Is there a better strategy than defining a very large number of buses before booting the server? Perhaps something like freeing the buses from the previous two allocations? I wouldn’t like though to use variables outside the Ndef in order to keep track the bus numbers…

LocalIn / LocalOut support multiple channels:

(
Ndef(\test_feedback1, {
	var fb = LocalIn.ar(2);
	var f = SinOsc.ar(
		[440,441] * (1 + fb * 0.552), 
		fb * 1.548,
		1 + (fb.abs * 1/3.001),
		fb * 0.805);
	LocalOut.ar(f);
	f;
} * -42.dbamp
).clock_(t).quant_(1).fadeTime_(1).play
)
Ndef(\test_feedback1).clear(1)

Thanks, I was making the mistake of inserting multiple instances of LocalIn.ar(2).

That is totally fine for what I want to do for now, but what if there are multiple Ugens in the graph that feedback to each other in all possible ways? Multiple InFeedback with Out and Bus can do that but the bus allocation problem will still persist.

Could there be a possible solution or should one avoid that approach at all? Perhaps multiple pairs of LocalIn / LocalOut with different local index numbers?

You can just determine yourself which channels of the LocalIn do what, they do not have to be used all of them all the time.

var fb = LocalIn(3);
var fb1 = fb[0];
var fb2 = fb[1];
var fb3 = fb[2];

... Your code that uses fb1, fb2 and fb3

LocalOut([result1, result2, result3]);