Correct use of

{[440, 660, 110], mul:0.3)), 200.rand/200-1)}.play;

The above code works, but for some reason it feels wrong. I sense there must be a more concise way of dealing with arrays to create multiple SinOscs. My question: is there a more concise and elegant way of writing this? Or is it conceptually sound?

Thanks, Dom

It is one good way of doing it, another way of getting the same result is to use .sum which is what Mix does. I moved the * 0.3 out of the mul arg and applied it to the sum instead, just to save a nickel CPU wise, although in this case it doesn’t really matter.

{[440, 660, 110]).sum * 0.3, 200.rand/200-1)}.play;

The expression


gives you values in the range [-1, 0]. second arg takes a value in the range [-1, 1], so the signal will always be panned more or less to the left. A shorter syntax would be to substitute it with -1.0.rand.

{[440, 660, 110]).sum * 0.3, -1.0.rand)}.play;

with the only difference being that -1.0.rand has a higher resolution than 200.rand/200-1, but the difference is so tiny than the results will be indistinguishable. In either case, the value will only be calculated once, when the function is played. In case you want the pan position to modulate, you should use a ugen - you probably know this already, just pointing it out in case.