Correct Pan4 Routing With Effects

Hi all,

I’m puzzled by the behavior I’m getting when trying to put a limiter on a quad signal, using Pan4.ar on both the synth and the limiter. I’ve recreated the issue in the code below, with more details in the comments. Thanks in advance for your assistance and insight!

~limitlbus = Bus.audio(s, 1);
~limitrbus = Bus.audio(s, 1);

(
SynthDef(\limL, {|level=0.6, out=0, xpos=0, ypos=0|
		var in;
		in = In.ar(~limitlbus, 1);
		Out.ar(out, Pan4.ar(Limiter.ar(in, level), xpos, ypos));
	}).add;

SynthDef(\limR, {|level=0.6, out=0, xpos=0, ypos=0|
		var in;
		in = In.ar(~limitrbus, 1);
		Out.ar(out, Pan4.ar(Limiter.ar(in, level), xpos, ypos));
	}).add;

SynthDef(\testSin, {|freq = 440, out = 0, xpos = 0, ypos = 0|
	var osc, env;
	osc = SinOsc.ar(freq);
	env = EnvGen.ar(Env.sine(1.0, 0.1), Done.freeSelf);
	Out.ar(out, Pan4.ar(osc * env, xpos, ypos));
}).add;
)

//In the first block of code below, I would expect the output to alternate between left-front (out 0) and left-rear (out 2). Instead, I get what looks like Pseq([[0, 1, 2, 3], 0], inf).

//However, if I evaluate the second block of code below, the first synth starts alternating between 0 and either 1 or 3, but the second synth never makes any sound. 

//I've also tried using 4-channel buses and only changing the pan positions in the limiter (leaving the testSin pan positions at 0). Neither of these approaches worked either. 

//What am I missing?

(
~fx = Group.tail(s);
~ll = Synth.tail(~fx, \limL);
~lr = Synth.tail(~fx, \limR);

Pbindef(\tsl, \instrument, \testSin, \freq, 220, \xpos, Pn(-1), \ypos, Pseq([-1, 1], inf), \out, ~limitlbus).play;
.
Pbindef(\liml, \instrument, \limL, \type, \set, \id, ~ll, \args, #[], \xpos, Pn(-1), \ypos, Pseq([-1, 1], inf)).play;
)

(
Pbindef(\tsr, \instrument, \testSin, \freq, 440, \xpos, Pn(1), \ypos, Pseq([1, -1], inf), \out, ~limitrbus).play;

Pbindef(\limr, \instrument, \limR, \type, \set, \id, ~lr, \args, #[], \xpos, Pn(1), \ypos, Pseq([1, -1], inf)).play;
)

First thing is to be consistent about the buses. Your sine synth is outputting 4 channels (result of Pan4), but the limiter synths are receiving 1 channel (?) and panning again (?).

I’d suggest one of the following:

  • Sine outputs 1 channel, limiters receive 1 channel and do Pan4.

  • Or, sine does Pan4 and outputs 4 channels, then the limiters receive 4 channels and do no additional panning.

hjh

2 Likes