[chuck-users] sporking shreds, advancing time
vb
vboehm at gmx.ch
Sun Oct 8 06:17:41 EDT 2006
> Sorry if I underestimated what you were aiming at.
hehe, my aim is to understand chuck...:)
so here comes another simplified situation:
i have a little function that's, supposed to play a Sine tone. as
function arguments i pass the freq and the duration to play.
now i want to call this function *regularly*, let's say every second.
depending on the note duration, i want to have overlaying notes.
one could say i have a "global" time, scheduling an action every
second and i have a "local" time, the duration of the note. i would
like to find out how to handle this situation generally in chuck.
here is an example i have come up with, sporking the function, which
works nice.
just would like to know if that's the way to go, or wether there are
simpler/better ways to do it.
thanks for any comments.
volker.
// my lame example:
Gain g => dac;
fun void playNote(float freq, dur duration) {
SinOsc s => g;
s.freq(freq);
Std.rand2f(0.1, 0.8) => s.gain;
duration=>now;
s =< g;
}
while( true ) {
now => time now1;
spork ~ playNote(Std.rand2f(300,600), Std.rand2f(2, 8)::second);
//playNote(Std.rand2f(100,1000), Std.rand2f(2, 8)); //calling the
function without sporking it won't work...
1::second=>now;
<<<"time interval",(now-now1)/ms>>>;
}
More information about the chuck-users
mailing list