Chaining patterns / events

Hi all,

Is there a good way of chaining patterns or events, such that the ending of one triggers the start of another? I’m basically trying to sequence assorted Pbinds of indeterminate length. Thanks.

I think the answer will depend on what you mean by “of indeterminate length”. Do you mean that the outer sequence shouldn’t need to know about the lengths of its inner sequences, that the lengths of those inner sequences are not hard-coded but are generated when they’re evaluated, that the lengths of the inner sequences may be different for each cycle of the outer sequence, or something else?

In the simplest case, you can just use Pseq to step through an Array of Event Patterns, as long as those Patterns have finite lengths:

(
    ~foo = Pbind(\degree, Pseq([0, 7], 4), \dur, 0.1);
    ~bar = Pbind(\degree, Pseq([3, 5], 5), \dur, 0.1);
    ~baz = Pseq([~foo, ~bar], inf).play
)

Thanks, Pseq certainly solves my immediate issue, but what I really want is something that triggers on pattern completion, like a kind of cueing system. I basically want a bottom-up as opposed to a top-down approach; to be able to delegate control over the global sequence to the inner event patterns themselves, rather than having to have an outer ‘manager’ like Pseq. I get that I might be thinking of things in a way that’s not particularly idiomatic to SC, and can probably get essentially the same functionality by reframing the ideas. But I thought it might be worth a shot

You can easily construct a queing system:

(
var current, addTail, startNext; 
current = List.new;
addTail = { |pat, func| Pseq([pat, (play:func,dur:0)]) };
startNext = { if(current.notEmpty) { current.removeAt(0).play } };
~queue = { |pat|
	var patWithTail = addTail.(pat, startNext);
	current.add(patWithTail);
};
~startNext = startNext;
)


(
~queue.(Pbind(\note, Pseq([0, 5, 7], 1), \dur, 0.4));
~queue.(Pbind(\note, Pseq([0, 1, 1, 4], 1), \dur, 0.25));
)


~startNext.value;

2 Likes

Maybe Pfindur / Pseq.