Why is this not working?

This ain’t working and I wonder why
Assigned a variable to line.ar
SinOsc multiplied by this var. does nothing

(
var hello;var luck; var envy;
envy = Line.ar(0.5,0,1,doneAction:1);
luck = 212;
hello = 214;

{
SinOsc.ar([luck,hello])*envy
}.play;)

1

This one ain’t working either , assigned another SinOsc to a variable and use this for ring mod
2

This is a small gotcha - UGens like Line must be used inside of a SynthDef in order to work. In your case, {}.play is roughly equivalent to:

SynthDef(\something, {
     SinOsc.ar([luck,hello])*envy
}).add;
Synth(\something);

What is inside of the {} is used as your SynthDef - the Line is not created inside of this, which is why you don’t see it working. Actually, I’m a little surprised this doesn’t cause an error.

To get this to work, just make sure to include all your UGens in the same SynthDef or {}.play block:

(
{
var hello, luck, envy;

envy = Line.ar(0.5, 0, 1, doneAction:1);
luck = 212;
hello = 214;

SinOsc.ar([luck,hello]) * envy
}.play;
)

Thanks ,I did something similar yesterday and was sure that it worked
I knew it was a simple solution , really need to thoroughly understand the { ( ) }
Thanks a lot

Two things conspire to confuse folks here. first is that Synthdef does a bunch of magic on the function passed to it, making NamedControl out of args - arguments that are legal in functions are not in SynthDefs etc.

And the .play method for Function amplifies the confusion since a SynthDef is registered and played transparently.

Thought: maybe there should be a mandatory “ugen graph functions” subclass with a different delimiter.

<|f| SinOsc.ar(f,0,0.1)>.play

I don’t know, I think there are lots of cases where it’s important and appropriate to look at a UGen graph Function as a function like any other. In my experience the crucial distinction for new users to learn is between things that are evaluated once at compile time and things that become part of the graph. Arguably the greater ambiguity is the creation of Controls from arguments.

Yes, I personally think that the community would benefit from more easily accessible “post-introductory” information, including about how {}.play is just one of any number of possible abstractions on top of SynthDef and Synth (Ndef/ProxySpace being another, etc). It does seem like there are several distinct “thresholds” for people learning SC. Going from {}.play to SynthDefs is one, understanding Classes is another, and so on, but perhaps that’s unavoidable.

1 Like