Re: [linux-audio-dev] Does anyone have a working example of Supercollider and SCUM GUI where slider or a button does real-time update on the synth

From: stefan kersten <steve@email-addr-hidden-hornz.de>
Date: Wed May 18 2005 - 13:34:17 EEST

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>

Received on Wed May 18 16:15:12 2005

This archive was generated by hypermail 2.1.8 : Wed May 18 2005 - 16:15:13 EEST