Update "Wait" or "Yield" delay interval dynamically

classic Classic list List threaded Threaded
3 messages Options
Zuu
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Update "Wait" or "Yield" delay interval dynamically

Zuu
It must be doable, but I cant find any example or tutorial where this is shown. Saying "dynamic" I mean controlling those values with Ugens or Hid/MIDI devices in stead of evaluating the code every time after changes has been made.

// "Wait" example
Task({ { "I'm loopy".postln; 1.wait;}.loop }).start;


// "yield" example
(
r = Routine.new({{ "help-EnvGen".postln; 0.1.yield; }.loop });
SystemClock.play(r);
)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Update "Wait" or "Yield" delay interval dynamically

madamdata
~waitTime = 0.5;

r = Routine{
loop{
"hello!".postln;
~wait.Time.wait;
}
};

r.play;

//midi control
MIDIFunc.new({|cv, ccNum|
~waitTime = [0.01, 1.5].asSpec.map(cv/127); //map midi cc [0-127] to[ 0.01 - 1.5] seconds (don't do 0.wait!! this will crash SC)
}, yourccNum);

for UGen control, you have to set up a synth with SendReply.kr to send OSC messages back to the language with some UGen's current value. Then set up an OSCFunc just like above to read the OSC message and use the UGen value to set ~waitTime.

Zuu
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Update "Wait" or "Yield" delay interval dynamically

Zuu
Hi, I can't see anything wrong, except this mistake "~wait.Time.wait" in your example. Are you sure it somehow affects wait time? Of course I have connected MIDI with "MIDIIn.connectAll" and specified or not a note.
Loading...