Play routine in loop?

Hi, how can I make this routine play forever, like in /, inf/?

(
t = TempoClock(80/60);
{
Pbind(
		\note, Pseq([4, 6, 9], 32),
\dur, 1/6,
\amp, Pseq([0.05, 0.03], 32)
).play(t);
10.wait;

	Pbind(
		\note, Pseq([[7, 9, 8]], 2),
\dur, 2,
\amp, 0.1,
).play(t);
4.wait;

	Pbind(
		\note, Pseq([7, 3, 8], 5),
\dur, Pseq([2, Rest(0.1)], 32),
\amp, 0.1,
).play(t);
}.fork(t);
)
// prefer to assign to a variable, so you can stop it by `r.stop`
r = {
    loop {  // <<-- here
        ... your stuff...
        ... make sure there's at least one `.wait` in here
    }
}.fork;

hjh

1 Like

Dear oxxo,

your Pseq will produce 32 or 2 or 5 values respectively, thus stopping
the pattern after that number of events.

See Bruno Ruviaro’s excellent tutorial “A gentle introduction to
SuperCollider” Section 13.7: “A Pbind stops playing when the
shortest internal pattern has finished playing (as de- termined by the
repeats argument of each internal pattern).”

Unless you have already read it, there is also a Rest for Patterns. See
Bruno’s tutorial Section 14.6. “Rests”.

From you code I understand that you want the three Patterns to
play after each other, and loop the entire section. Let me paste a few
possible solutions how to assemble patterns by nesting them in other
pattern classes:

// define two boring patterns of finite length
~p1 = Pbind(\degree, Pseq([1,2,3], repeats:3), \dur, 0.3);
~p2 = Pbind(\degree, Pseq([8,7,6], repeats:3), \dur, 0.1);

// start them, since they have a finite length, patterns stop by
// themselves.
~p1.play;
~p2.play;

// chaining patterns of finite length with optional number of repeats
Pseq([~p1, ~p2]).play;
Pseq([~p1, ~p2], repeats: 3).play;
Pseq([~p1, ~p2], repeats: inf).play;

// patterns in parallel, will end when the longest pattern has ended
Ppar([~p1, ~p2]).play;

// patterns in parallel, with start times
Ptpar([0, ~p1, 1, ~p2]).play;

// repeat a pattern
Pn(~p2, repeats: 2).play;

// limit number of events produced
Pfin(count: 5, pattern: ~p1).play; // five events from ~p1

// play a pattern for a finite time
Pfindur(dur: 1, pattern: ~p2).play; // one second of ~p2

Bruno’s tutorial recommends looking at Pspawner as well.

all the best, P

Thanks to the 2 of you, Im rewieving the codes with calm.