On Tue, May 17, 2005 at 07:46:58PM -0400, Ivica Bukvic wrote:
> SynthDef("onetwoonetwo",{ arg out=0, freq;
>       w = SCUMWindow.new;
>       w.title = "Slider example";
>       w.initialSize = Size(20, 300);
> 
>     c = SCUMVBox( w );
> 
>     v = SCUMSlider(c, { |v|
>               v.expand = 1;
>               v.fill = 1;
>               v.bgColor = Color.white;
>               v.fgColor = Color.black;
>               v.action = {
>                       freq = v.value * 100;
>               };
>               v.doAction;
>       });
>       w.show;
> 
>       Out.ar(out,
>                SinOsc.ar(freq + 400, 0, 0.5)
>       )
> }).play;
> 
> What I am simply trying to do is to affect the frequency of the sinetone by 
> moving the slider, yet nothing changes when I move the slider.

you're mixing up the server and language contexts. when you
write a synthdef, the code is not executed on the server but
merely used to build a graph of unit generators and compile
it into a binary representation. by assigning `freq' in the
view's action, you set the value at the time the synthdef is
built.

you'll have to split up the code:

s = Server.local.boot;

SynthDef(\testfest, { arg out=0, freq=440;
    Out.ar(out, SinOsc.ar(freq, mul: 0.5))
}).send(s);

z = Synth(\testfest);

(
w = SCUMWindow.new;
w.title = "Slider example";
w.initialSize = Size(20, 300);

c = SCUMVBox(w);
v = SCUMSlider(c, { |v|
    v.expand = 1;
    v.fill = 1;
    v.bgColor = Color.white;
    v.fgColor = Color.black;
    v.action = { z.set(\freq, v.value * 100 + 400) }
    v.doAction;
});

w.show;
)

hth,
<sk>

Attachment: signature.asc
Description: Digital signature

Reply via email to