Assign variables to functions

As it is now , I am having fun making stuff iff the code + play message is still in parentheses
Whenver I remove these and just keep the { } function , I can’t decalre a variable to it , which is necessary for making synthdefs
The first three lines of code play when clicking becasue I used ({ }) to encapsulate

The lines of code from 9-12 are using only the function { } and can only be played when cursor selecting
I need to sort this one really
w = { line of code }
w.free; nothing happens
I am pulling my hair out on this one because I can’t take it any further from here

Guys , can anyone just paste this code in the editor and select the last parenthese and executeand see if it works .

    ( { var depthChange, vibrato;
depthChange = Line.kr(0, 5, 3);
vibrato = SinOsc.ar(freq: 5,  mul: depthChange, add: 440);
SinOsc.ar(  vibrato,   mul: 0.5) }.play )

Okay, seems to work for me - I hope that helps.

w = { ... stuff ... };
// the result of this is "a Function"

x = w.play;
// the result of this is "Synth(some number)"

The function states what to play, but it doesn’t play anything. Therefore you also can’t stop the function, because the function doesn’t do.

The Synth does the playing. This is the thing you should free.

So, then:

w.free;  // no, this does nothing

x.free;  // yes, this frees the synth

// and after successfully freeing x

x.play;  // no, this Synth is already dead, there's no resurrection

x = w.play;  // yes, you can make a new Synth from the old function

hjh