Out of Splay seems monophonic


#1

In a Pbind, I generate 10 sounds with random pitches. I use Splay to bring everything in stereo, but it seems to me that what I hear is in monophonic. As if all the sounds were not distributed from left to right, but all in the center.

Here is the code:

(
SynthDef(\cloche, {
	|freq=440, amp=0.2, dur=2|
	var sig, env;
	env = EnvGen.kr(Env.perc(attackTime:0.01, releaseTime:dur-(dur/12)), doneAction:2);
	sig = SinOsc.ar(freq, mul:env);
	sig = Splay.ar(sig, spread:1, center:0);
	Out.ar(0, sig*amp);
}).add;
)

(
Pdef(\cloche, Pbind(\instrument, \cloche,
	\freq, Pfunc{{rrand(200, 1000)}!10},
	\dur, 2,
	\amp, 0.2,
	\strum, 0.1
));

c = Pdef(\cloche);
)
c.play;
c.pause;

Is there a way to solve that?


#2

Hi, the problem lies in misunderstanding what is happening.
Every time your Pbind generates an event, a new Synth \cloche is instantiated.
That new synth generates only one signal which the Splay.ar then spreads over the stereo field (and this always results in the center).

What you could do instead is introduce a pan argument in your synthdef, and steer it from the pbind:

(
SynthDef(\cloche, {
	|freq=440, amp=0.2, dur=2, pan=0|
	var sig, env;
	env = EnvGen.kr(Env.perc(attackTime:0.01, releaseTime:dur-(dur/12)), doneAction:2);
	sig = SinOsc.ar(freq, mul:env);
	sig = Pan2.ar(sig, pos:pan);
	Out.ar(0, sig*amp);
}).add;
)

(
Pdef(\cloche, Pbind(\instrument, \cloche,
	\freq, Pfunc{{rrand(200, 1000)}!10},
	\dur, 2,
	\amp, 0.2,
	\strum, 0.1,
    \pan, Pfunc{{rrand(1.neg,1)}}
));

c = Pdef(\cloche);
)
c.play;
c.pause;

#3

Thank you very much,
Just a question: why do you use 1.neg rather than -1 ?


#4

Euhm… no special reason, except perhaps uniformity in notation.
If you try to use a unary minus with a letter, it gives an error, e.g.

(
1-(-1)
)
// correctly results in 2

versus

(
a=1;
a-(-a)
// results in a parsing error
)

On the other hand, both of the following yield the expected results:

(
1-(1.neg)
)

(
a=1;
a-(a.neg)
)

#5

Thank you :slight_smile: