Hello Herman, I don't think you need to pass values to the sporked functions. Scoping rules allow the sporked functions to access variables declared in their enclosing class, e.g. 0 => int centralpos; spork ~ doSomething(); spork ~ doSomethingElse(); 2::second => now; 42 => centralpos; 2::second => now; 0 => centralpos; <<<"done">>>; fun void doSomething() { while (true) { if (centralpos == 42) { <<<"hello from doSomething!">>>; } 250::ms => now; } } fun void doSomethingElse() { while (true) { if (centralpos == 42) { <<<"hello from doSomethingElse!">>>; } 500::ms => now; } } Do remember to advance time everywhere or things won't work correctly. Hope this helps! michael
On Feb 21, 2020, at 2:11 AM, herman verbaeten
wrote: Hi,
I'm in big trouble. I'v been trying for a long time now to change an argument in a running function. As you can see in my script i set a certain central pos ("70000")to buf.pos as a central position in my soundbuffer and i let my function LFOtoPOS circle around it.
Once the "spork" instruction has started the process i can't figure out how to addresss the argument "centralpos" to change it on the fly or by another function or parameter. Some help please ...
Kind regards,
Herman ----------------------------------------------------------------------------------------------
me.sourceDir() + "sound.wav" => string filename; if( me.args() ) me.arg(0) => filename;
SndBuf buf => dac;
filename => buf.read;
1 => buf.pos; .5 => buf.gain;
spork ~ LFOtoPOS(70000);
fun void LFOtoPOS(int centralpos) { TriOsc lfo => blackhole; 1 => lfo.freq; centralpos => buf.pos; while (true) { 1::samp => now; (10000*lfo.last())$ int => buf.pos; } }
// time loop while( true ) { 1000::ms => now; }
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu mailto:chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users https://lists.cs.princeton.edu/mailman/listinfo/chuck-users