Hi,
It seems as if Splay.ar ([])
is taking over the stereo field so I can’t use Out.ar(0, Pan2.ar (sig, pos));
Is there an alternative or work around?
Hi,
It seems as if Splay.ar ([])
is taking over the stereo field so I can’t use Out.ar(0, Pan2.ar (sig, pos));
Is there an alternative or work around?
can you post the offending code?
Usually Splay and Pan2 is either or. Splay takes an array of signals (usually more than 2) and spreads the signals across the stereo field. You have some control, like the total stereo width, but you have no individual control over the exact panning of each (usually mono) signal. Pan2 on the other hand takes a mono signal and pans it over the stereo field. So let’s say you have 4 mono signals you want to output to a stereo bus, usually you would choose either to feed all 4 signals to Splay.ar OR to do individual panning of each signal using Pan2.
You would only want to do this: Out.ar(0, Pan2.ar (sig, pos)) if sig is a mono signal. If you already have a stereo signal, for instance after feeding signals into Splay and you want to lean the whole signal left or right while maintaining stereo width you would use Balance2 or just use the built in ‘center’ arg in Splay to pan, so your last line could be Out.ar(0, Splay.ar(sig, spread, level, center) or you could name the args more to my liking (:)), Splay.ar(sig, spread, amp, pan).
There is also a center
argument in Splay
. Compare:
(
{
var sig = SinOsc.ar(Array.series(6, 50, 7).midicps, mul: 0.1);
sig = Splay.ar(sig, center: SinOsc.kr(0.2));
}.play;
)
(
{
var sig = SinOsc.ar(Array.series(6, 50, 7).midicps, mul: 0.1);
sig = Splay.ar(sig);
Balance2.ar(sig[0], sig[1], SinOsc.kr(0.2));
}.play;
)
Thanks for clarifying.
I’m employing Splay in a quirky way I guess.
var sig = Splay.ar([LFTri.ar([freq, freq*\md1.ir(1.01)], 0.4),LFTri.ar(freq*1.01, 0.4)],1)
I hadn’t closely examined the fact that I have several stereo array which limits the output stage. The center argument is also nullified.
I wasn’t originally working with the stereo aspect of Splay but more of the multi Osc aspect.
Thanks for the examples. This is a very straightforward usage.
Im probably using Splay in a very limited way.
Yes – Splay expects a flat array of signals, but you’re providing a nested array.
You might not have noticed because of writing everything on a single line, hiding the structure. Using indentation to show the structure makes it more clear.
(
SynthDef(\test, {
var freq = 440;
var sig = Splay.ar([
LFTri.ar([
freq, freq * \md1.ir(1.01)
], 0.4),
LFTri.ar(freq*1.01, 0.4)
].debug("splay input"), 1);
Out.ar(0, sig.debug("splay output"))
}).dumpUGens;
)
// comment: nope, this isn't what Splay wants
splay input: [[a LFTri, a LFTri], a LFTri]
splay output: [[a BinaryOpUGen, a BinaryOpUGen], [a BinaryOpUGen, a BinaryOpUGen]]
Tracing through the UGens – let’s label the LFTris:
test
[0_Control, scalar, nil]
[1_*, scalar, [440, 0_Control[0]]]
// B is panned full left
[2_LFTri, audio, [1_*, 0.4]]
[3_Pan2, audio, [2_LFTri, -1.0, 1.0]]
// A is panned full left
[4_LFTri, audio, [440, 0.4]]
[5_Pan2, audio, [4_LFTri, -1.0, 1.0]]
// C is panned full right
[6_LFTri, audio, [444.4, 0.4]]
[7_Pan2, audio, [6_LFTri, 1.0, 1.0]]
// A and C pans are mixed together
[8_+, audio, [5_Pan2[0], 7_Pan2[0]]]
[9_*, audio, [8_+, 0.70710678118655]]
[10_+, audio, [5_Pan2[1], 7_Pan2[1]]]
[11_*, audio, [10_+, 0.70710678118655]]
// C is *again* panned full right (due to multichannel expansion)
[12_Pan2, audio, [6_LFTri, 1.0, 1.0]]
// and mixed with B (this is left)
[13_+, audio, [3_Pan2[0], 12_Pan2[0]]]
[14_*, audio, [13_+, 0.70710678118655]]
// now, because there's a nested array for Out,
// the channels are mixed, but not in the way you expect
// L = A+C left, R = B left + C left (because of [0] in 8 and 13)
[15_Out, audio, [0, 9_*, 14_*]]
// B+C right
[16_+, audio, [3_Pan2[1], 12_Pan2[1]]]
[17_*, audio, [16_+, 0.70710678118655]]
// L = A+C right, R = B+C right
[18_Out, audio, [0, 11_*, 17_*]]
When you have Out.ar(0, [[a, b], [c, d]])
, you might think you’re going to get, left = a+c, right = b+d, but you really get left = a+b, right = c+d – and stereo imaging will be corrupted at that point.
Short version: If you give Splay a nested array, it’s probably not going to do what you want.
The solutions are: 1/ either make sure the array is flat, or 2/ explicitly mix down the multiple Splays. (Don’t try to do both at once.)
Flatten: You’ll get A left, B center, C right.
(
SynthDef(\test, {
var freq = 440;
var sig = Splay.ar([
LFTri.ar([
freq, freq * \md1.ir(1.01)
], 0.4),
LFTri.ar(freq*1.01, 0.4)
].flat.debug("splay input"), 1);
Out.ar(0, sig.debug("splay output, mixed"))
}).dumpUGens;
)
Explicit mixing: left channels stay left, right channels stay right.
(
SynthDef(\test, {
var freq = 440;
var sig = Splay.ar([
LFTri.ar([
freq, freq * \md1.ir(1.01)
], 0.4),
LFTri.ar(freq*1.01, 0.4)
].debug("splay input"), 1);
Out.ar(0, sig.sum.debug("splay output, mixed"))
}).dumpUGens;
)
hjh
Thank you.
I had been going for the stereo beating and modulation oscillators. Weeks later I kind of forgot that it’s already a stereo cluster.
I’m definitely going to start over without a stereo array such as in the examples from PitchTrebler’s reply. I will also work on the formatting so I don’t forget the obvious;)
I flattened the nested array
spread = 0
center = \pos.ir
It does the trick without Pan2
Thanks again for the help!