# Play sequence after sequence repeat

Hi, sorry for the basic question.

I was fiddling with two note sequences in two different Pbinds: if I evaluate the file in SC, they start at the same time. I’d like to start the second one after some time. What is the right way to do it?

I simply have a SynthDef and two Pbinds, nothing else.

The Pbind is like this one:

``````Pbind(
\note, Pseq([[3, 2, 6, 6, 2, 3, 3, 2, 2, 1, 1], 3),
\dur, 0.50,
\amp, 0.70,
\octave, 4,
\instrument, \bass,
).play;
``````

More specifically, here we have 3 repeats: I want the second Pbind sequence to start playing when the second repeat begins, so the first Pbind sequence must not stop, it should continue playing till its natural end. Is this possible?

I couldn’t find a way to get the value of the current repeat.

Thanks anyone

``````Pseq([
Pbind(...),
Pbind(...)
], 1).play
``````

e.g.,

``````Pseq([
Pbind(\a, 1, \dur, Pseq([1, 1, 1])),
Pbind(\a, 2, \dur, Pseq([0.5, 0.5, 0.5]))
]).trace.play
``````

Or better yet…

``````Pdef(\first, Pbind(...));
Pdef(\second, Pbind(...));
Pseq([ Pdef(\first), Pdef(\second) ]).play
``````

@jordan Uhm, no, maybe I was not able to explain my problem well. I try again.

The solution you are suggesting is basically “play the first Pbind, then, when the first Pbind stops its three repeats, start playing the second Pbind”.

My problem is a little bit different and it could be summarized as follows: start playing the first Pbind: when the first repeat of the first Pbind ends, start the second Pbind, but keep the first Pbind playing.

I hope I managed to make my intentions clearer

I can’t think of a way to do that exactly as you want, instead I’d do this…

``````Pseq([
Pdef(\One), // does one repeat
Ppar([
Pn(Pdef(\One), 2), // the other two
Pdef(\Two)
])
])
``````
1 Like

If the duration of the first repeat is known when the first Pbind fires (no randomness in the dur values) you can schedule the playing of the Pbind with sched or schedAbs.

``````(
var notes1 = [3, 2, 6, 6, 2, 3, 3, 2, 2, 1, 1];
var notes2 = [0, 1, 2, 3];
var t = TempoClock(1.5); // tempo in bps = 90 bpm, arbitrarily chosen here
var pb1 = Pbind(
\note, Pseq(notes1, 3),
\dur, 0.50,
\amp, 0.70,
\octave, 4,
);
var pb2 = Pbind(\dur, 0.5, \note, Pseq(notes2, 5), \amp, 0.7);
t.sched(0, { pb1.play(t) });
t.sched(notes1.size * 0.5, { pb2.play(t) });
)
``````
1 Like

@jordan This perfectly works (I changed temporarily your Pdefs with Pbinds, but it worked the way I wanted it to work)

Cool. I previously tried something like this (less smart than this, anyway), but I wasn’t satisfied.

I would have liked Pbind to feature a method that would allow me to know its current repeat count (or even that it could fire some ended_repeat event or something like that)

You can probably edit the event type to get that behaviour… however, you can do really dumb things if you set the duration to zero…

``````Pdef(\a, Pbind(
\dur, 1,
\value, Pseq([1,2,3])
))

~mk_on_finish = { |pattern, func|
Pseq([
pattern,
Pbind(\dur, Pseq([0]) ) <> Pbind(\on_finish, Pfunc(func))
])
}

~mk_on_finish.(Pdef(\a), { 'do something here'.postln;  }).trace.play
``````

Not saying you should do this, and it doesn’t work with the repeats as you wanted, only at the end of the pattern… but it is an option.

1 Like