PbindFx multichannel expansion

Hey, im trying to have two synth nodes routed to two different output channels. synth A should go to output channels [0, 1] and synth B should go to output channels [2, 3]. they should both be hard panned (A to the left speaker and B to the right speaker).
In addition i would like to use PbindFx to apply a Comb Filter Fx with the possibility of sequencing different settings for Synth node A and Synth node B independently. when i apply the Comb Filter Fx with PbindFx its not working because of either a bus mismatch or they both end up on output channels [0, 1]. I would also like to use two different external control LFOs to modulate the phase of the Synths (which is not making so much sense with this \test SynthDef, but with the actual one it does). any ideas? thanks a lot :slight_smile:

(
SynthDef(\test, {
	var gainEnv = EnvGen.kr(Env.perc(0.01,0.4), doneAction: Done.freeSelf);
	var sig = SinOsc.ar(\freq.kr(150), \phase.kr(0)!2);
	sig = sig * gainEnv;
	sig = Pan2.ar(sig, \pan.kr(0), \amp.kr(0.25));
	Out.ar(\out.kr(0), sig);
}).add;	

SynthDef.new(\combL, {
	arg mix=(-0.5), decay=1, delHz=0.55, delStereoRatio=0.9, delMin=0.001, delMax=0.4;
	var sig, comb;
	sig = In.ar(\in.kr(0!2), 2);
	delHz = delHz * [1,delStereoRatio];
	comb = CombL.ar(
		sig,
		delMax,
		LFPar.kr(delHz,[0,pi/2]).exprange(delMin,delMax),
		decay,
	);
	sig = XFade2.ar(sig, comb, mix);
	Out.ar(\out.kr(0), sig);
}).add;
)

(
p = Pbind(
	\instrument, \test,
	
	\dur, 0.5,
	\midinote, [60, 71],
	
	\phase, [ ~bus[\ctrl][0], ~bus[\ctrl][1] ].collect(_.asMap),
	
	\amp, 0.20,
	\pan, [(-1.0), 1],
	\out, [0, 2],
	\group, ~mainGrp,
	
);
)

(
x = { Out.kr(~bus[\ctrl][0], LFTri.ar(0.5).linexp(-1, 1, 1, 2)) }.play;
y = { Out.kr(~bus[\ctrl][1], LFTri.ar(2).linexp(-1, 1, 3, 4)) }.play;
q = p.play;
)

(
q.stop;
x.free;
y.free;
)

(
p = PbindFx([
	\instrument, \test,
	
	\dur, 0.5,
	\midinote, [60, 71],
	
	\amp, 0.20,
	
	\pan, [(-1.0), 1],
	\out, [0, 2],
	
	\fxOrder, [1]
],[
	\fx, \combL,
	
	\in, [0, 2],
	
	\mix, 0.5,
	\amp, 1,
	\delStereoRatio, 0.9,
	\delHz, 0.05,
	\delMin, 0.1,
	\delMax, Pkey(\delMin) + 0.01,
	
	\out, [0, 2],
	
	\decay, 1,
	\cleanupDelay, Pkey(\decay)
]
);

q = p.play;
)

q.stop;

s.meter;

still wasnt able to figure it out. any ideas? :slight_smile:

The reason for the PbindFx error message is a mistake in the multichannel structure of your source synth:

So the overall output (after Pan2) is not plain stereo.

Apart from that, the way you want to work with buses on top of PbindFx cannot simply be done with passing arrays to \out. The multichannel connections of PbindFx are established automatically, they cannot be overriden in this way. Concerning the implementation, It’s complicated enough to deal with the former, so the expected “multi-multichannel” expanding of ‘out’ is not supported.
However, such a multichannel expansion can be done by using several PbindFx in parallel. Different variants for such a strategy are described in PbindFx’s helpfile Ex.3.

(
SynthDef(\test, {
	arg out = 0;
	var gainEnv = EnvGen.kr(Env.perc(0.01,0.4), doneAction: 2);
	var sig = SinOsc.ar(\freq.kr(150), \phase.kr(0));
	sig = sig * gainEnv;
	sig = Pan2.ar(sig, \pan.kr(0), \amp.kr(0.25));
	Out.ar(out, sig);
}).add;	

SynthDef(\combL, {
	arg out = 0, in = 0, mix=(-0.5), decay=1, delHz=0.55, delStereoRatio=0.9, delMin=0.001, delMax=0.4;
	var sig = In.ar(in, 2), comb;
	delHz = delHz * [1,delStereoRatio];
	comb = CombL.ar(
		sig,
		delMax,
		LFPar.kr(delHz,[0,pi/2]).exprange(delMin,delMax),
		decay,
	);
	sig = XFade2.ar(sig, comb, mix);
	Out.ar(out, sig);
}).add;
)



(
~bus = { Bus.control(s, 1) } ! 2;

p = [
	\instrument, \test,
	\dur, 0.5,
	\phase, ~bus.collect(_.asMap),

	\amp, 0.20,
	\pan, 1,
	\fxOrder, 1
];


b = [
	\fx, \combL,
		
	\mix, 0.5,
	\amp, 1,
	\delStereoRatio, 0.9,
	\delHz, 0.05,
	\delMin, 0.1,
	\delMax, Pkey(\delMin) + 0.01,
	
	\decay, 1,
	\cleanupDelay, Pkey(\decay),
];

x = { Out.kr(~bus[0], LFTri.ar(0.5).linexp(-1, 1, 1, 2)) }.play;
y = { Out.kr(~bus[1], LFTri.ar(2).linexp(-1, 1, 3, 4)) }.play;

Ppar([
	PbindFx(Pbind(*p ++ [\out, 0, \midinote, 60]), b),
	PbindFx(Pbind(*p ++ [\out, 2, \midinote, 71]), b)
]).trace.play
)


s.scope(4)

Please note that, for several reasons, I won’t be able to follow the forum on a regular base in the foreseeable future.

thank you very much for the explanation. i will have a look at the other examples from the help file as well :slight_smile: