On Feb 20, 2009, at 6:46 PM, Andrea Valle wrote:
Hi to all,
wandering amidst patterns...
I'd like to do something exactly after an event in Pbind has occured.
Substantially the same thing the doneAction:2 does for synths, but not
for synths.
"When dur is passed, do this."
Hmm. What's the way?
I can think of a couple of ways.
You could .collect the pattern, and in the collect function, schedule an
action to happen at the right time.
Pbind(...).collect({ |ev|
thisThread.clock.sched(timeUntilPostAction, { myAction });
ev
}).play;
(The collect function should return the event unmodified.)
Or, use a finish function in the event. finish is a user supplied
function that normally gives you a hook to do some further processing on
the event values before the event type is called, but nothing prevents
you from using it to schedule something.
Pbind(
...,
\finish, { thisThread.clock.sched(timeUntilPostAction, { myAction }) }
).play;
Or, slightly faster:
Pbind(
...
).play(protoEvent: Event.default.put(\finish, {
thisThread.clock.sched(timeUntilPostAction, { myAction }) }));
The other question is, do you want the event's environment variables to
be available in your scheduled function? If so...
Pbind(...).collect({ |ev|
thisThread.clock.sched(timeUntilPostAction, { ev.use(myAction) });
ev
}).play;
Or:
Pbind(
...
).play(protoEvent: Event.default.put(\finish, {
thisThread.clock.sched(timeUntilPostAction, inEnvir { myAction })
}));
hjh
: H. James Harkins
: jamshark70@xxxxxxxxxxxxxxxxx
: http://www.dewdrop-world.net
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:
"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal." -- Whitman