I’m new to SuperCollider, so any advice is much appreciated. My question is: is it true that any message sent to a function with several statements is executed on the last statement only? Thanks!
(
x = {
SinOsc.ar(200, 0, [0.5, 0.5]);
SinOsc.ar(400, 0, [0.5, 0.5]);
}.play;
) //plays only the 400Hz tone, and…
(
x = {
SinOsc.ar(400, 0, [0.5, 0.5]);
SinOsc.ar(200, 0, [0.5, 0.5]);
}.play;
) //plays only the 200Hz tone. Why is that exactly?
If you define a function, the last line determines what is returned from the function. In your case you call “play” on the return value of a function that returns a single SinOsc.
If you wanted to hear both simultaneously, you could add them up:
I messed around with SC a very great deal before I really understood this, so your question is absolutely justified
Btw, you can have both of your sines by enclosing them in brackets and separating with a comma instead of semicolon. Then they are interpreted as the two halves of a single, 2-channel signal. Also have a look at Mix and Splay to combine several signals into one.