You don’t. You get 3 channels each with three sine waves in (play) and you a buffer with 3 channels, each with a unique sine wave (asBuffer).
b = {SinOsc.ar([[440,789,535],[ 888,777,666]],mul: [0.01,0.03,0.02])}.scope
SinOsc.ar([[440,789,535],[ 888,777,666]], mul: [0.01,0.03,0.02])
-> [
[ a BinaryOpUGen, a BinaryOpUGen, a BinaryOpUGen ], //[440,789,535] * 0.01
[ a BinaryOpUGen, a BinaryOpUGen, a BinaryOpUGen ], //[888,777,666] * 0.03
[ a BinaryOpUGen, a BinaryOpUGen, a BinaryOpUGen ] //[440,789,535] * 0.02
]
What you get from the UGen is an array of 3 arrays (each with three elements).
When you give this to Out
, the following is inserted…
Mix.ar( SinOsc.ar([[440,789,535],[ 888,777,666]],mul: [0.01,0.03,0.02]) )
-> [ a Sum3, a Sum3, a Sum3 ]
Which is why you get three channels - check scope
to comfirm.
However, when you call asBuffer
the buffer decides to only select the first element from each sub array - what would nested buffers mean anyway?
What exactly are you trying to achieve here? My guess is that you want to apply 0.01 to [440 (left), 888 (right)], 0.03 to [789 (left), 777 (right)], 0.02 to [535 (left), 666 (right)]? … that would look like this…
SinOsc.ar([ [440, 789, 535], [888, 777, 666]], mul: [[0.01, 0.03, 0.02]]).collect{|i| i.sum }
Note the extra brackets around [[0.01, 0.03, 0.02]]
and the collect
, which does:
[
sin(440) * 0.01 + sin(789) * 0.03 + sin(535) * 0.02,
sin(888) * 0.01 + sin(777) * 0.03 + sin(666) * 0.02
]
Now the two are equal…
~f = { SinOsc.ar([ [440, 789, 535], [888, 777, 666]], mul: [[0.01, 0.03, 0.02]]).collect{|i| i.sum } };
n = { ~f.() }.play;
b = { ~f.() }.asBuffer(1);
b.play;
In my opinion, this is mistake in supercollider, when you give a nested array to Out
, it should just error and refuse to compile.