[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-users] Controlling amp in Task controlled Synths



Hello,

I'm trying to manually control the amplitude of a Synth controlled by a Task. But obviously the slider cannot find the nodes created by the Task.

Since the goal is to have many "auto instrs" playing and to be able to control their individual presence, what would you recommend?

Thanks

Simple ex.:

(
SynthDef(\sinosc,
{arg amp=0.5, freq=110;
 var sound, panner, w, slider,instr, dur;

dur = EnvGen.kr(Env.perc(Rand(1.5,6), Rand(1.5,6), 1), 1.0, doneAction:2); 
w=SCWindow("My Window", Rect(100,500,200,65)); 
slider=SCSlider(w,Rect(10,10,180,30));
instr=Synth(\sinosc);
slider.action_({instr.set(\amp, slider.value);});
w.front;

    sound = FSinOsc.ar(freq, 0.0, amp);
    Out.ar(0, sound*dur);

}).load(s)
)

x = Synth(\sinosc);
x.free

(
r = Task({
    {Synth("sinosc", [\freq, rrand(1, 1000),
    ]);
    rrand(3.0, 6.0).wait;
    }.loop;
}).play
)

r.stop;