Skip to content

Instantly share code, notes, and snippets.

@AvneeshSarwate
Created October 20, 2022 15:31
Show Gist options
  • Save AvneeshSarwate/e9513c965108be970572d53b46d9a55b to your computer and use it in GitHub Desktop.
Save AvneeshSarwate/e9513c965108be970572d53b46d9a55b to your computer and use it in GitHub Desktop.
a general pattern template that can be hacked for abstrac sequencing needs
(
t = TempoClock.new;
f = Routine.new({(0..).do({|ind| ind.yield})});
~cat = "meow";
p = Pbind(
/*arbitrary pattern to specify the rhythm - can make it a Pfunc that references external variables
so that the rhythm can be generatively controlled by external data (eg midi or osc or whatever)
*/
\delta, Pfunc({|argEv| var wt = ((f.next+1)*1.0); [argEv, wt].postln; wt.rand}),
/*arbitrary parameters that you can use in each event of the pattern*/
\p1, Pseq((0,1..100), inf, 1),
\p2, Pseq([0, 1, 2, 4], inf),
\p3, Pseq([0, 1, 2, 4], inf),
\cat, ~cat,
/*arbitrary play function to execute each pattern event */
\play, {[~cat, ~p1, ~p2, ~p3, ~delta, t.beats].postln}
).finDur(3).play(t);
//.fin(n) limits the output to n events, finDur(d) for d number of beats
)
//p is now an EventStream that you can start/stop on the fly
p.stop
p.pause //from what i can tell, pause and stop don't do anything different - stop doesn't reset the pattern
p.play
p.reset
p.isPlaying
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment