2 PatternConductor provides interactive control of patterns. When a Conductor
3 is stopped it flushes its queue, immediately ending any notes left hanging by
10 var <>patterns, <>event, <>quant, <>eventStreamPlayers;
11 var <>clock, <tempo, <>defaultPauseTempo, <>defaultStopTempo;
12 *new { |patterns, event, quant|
14 .patterns_(patterns.asArray)
15 .event_(event ? Event.default)
16 .quant_(quant ? 0).tempo_(1).defaultPauseTempo_(1e-8).defaultStopTempo_(1e+8);
21 Routine.run({ this.prPlay }, 64, TempoClock.default, quant)
25 if (clock.notNil) { this.stop };
27 clock = TempoClock(tempo);
28 eventStreamPlayers = patterns.collect { | p | p.asEventStreamPlayer(event) };
29 eventStreamPlayers.do { | p | p.play(clock, false, 0) };
31 pause { | pauseTempo| clock.tempo = pauseTempo ? defaultPauseTempo }
32 resume { clock.tempo = tempo }
37 eventStreamPlayers.do { | p | p.stop };
38 clock.tempo = stopTempo ? defaultStopTempo;
39 Task({ while {oldClock.queue.size >= 2 } { yield(1) }; oldClock.stop }).play(clock);
41 eventStreamPlayers = nil;
42 CmdPeriod.remove(this);
47 if (clock.notNil) { clock.tempo_(tempo) };
49 cmdPeriod { clock = nil }