Stopping an event with infinite duration


#1

Is there a nice way to stop an event with infinite duration?
p = Pbind(\dur, inf).play; p.stop; obviously doesn’t work.

Also tried
p = Pbind( \callback, {|ev| i = ev[\id]}, \dur, inf ).play;

and then explicitly stopping the node with another event:
(type: \off, id: i).play;

This works but i was wondering if there might be a better way. Or is this the way?


#2
  1. Put the synths in a group that you created:

    g = Group.new;
    p = Pbind(..., \group, g, ...).play;
    
  2. When it’s time to stop them, do g.set(\gate, 0).

BTW inf scheduling ends up not scheduling anything. (The task will never wake up, so SC cleverly does not waste space in the queue for it.)

t = TempoClock.default;

t.dumpQueue;  // from ddwCommon quark, not in core
nil, priority 0
   nil  <<-- empty

t.sched(inf, { "hi".postln });
t.dumpQueue;
nil, priority 0
   nil  <<-- still empty

hjh


#3

Thanks! Yes, groups works in general of course. I this particular case i have several patterns sharing the same group where the idea was to have the possibility of “manually” starting and stopping synth nodes without leaving the pattern paradigm.


#4

these days i’ve moved increasingly towards dropping events/patterns entirely due to these sorts of limitations, instead using just Synth and Routine. up to you of course, but something to consider.


#5

Usually it’s the Pattern’s job to start synths (though of course this could be circumvented). Could you maybe specify a bit, what the Pattern / EventStreamPlayer should do instead ? Do you mean a kind of unmuting / muting EvenStreamPlayers ?


#6

Hm, do they have to share the same group?

Another option is a nested group structure.

~masterGroup = Group.new;
~groupA = Group.head(~masterGroup);
~groupB = Group.after(~groupA);
~groupC = Group.after(~groupB);
...

Then there is one group for everything, but you have access to all the nodes for one pattern under ~groupA, etc.

hjh


#7

Well, “have to” is a strong expression. :wink: I could probably redo it using groups. The project i’m working on is based on Pbindefs and a live-coding framework using preProcessor. I thought: “what if i just want to play a long texture or sample?”, and kind of liked the idea of just replacing a \dur pattern with an inf to achieve this. Seemed simple and straightforward. Maybe this is a bad idea? I mean, it seems to work with the \callback and \off event solution i posted above, but it might have bad consequences yet to be discovered…


#8

I don’t think there is much of a downside.

There would be a downside if the scheduler put entries into the queue that would never be removed by waking up. Then there would be a risk of filling up the queue with actions that will never happen. But SC prevents that by simply not scheduling things that will not wake up (no object leaks in the queue).

Then it’s up to you to take care of the nodes (topic of this thread :wink: ).

hjh