SCDoc: Use proper static string constants instead of comparing string literals.
[supercollider.git] / SCClassLibrary / JITLib / Patterns / extRoutine.sc
blobec4a085ba0e57e30614ad661472d856f60aef799
1 +Pattern {
2         lock { arg n=1;
3                 ^Pfin(n.asStream, this.asStream)
4         }
8 +Stream {
10         fastForward { arg by, tolerance=0, inevent;
11                 var t = 0, delta = 0, event;
12                 if(by <= 0) { ^0.0 };
13                 inevent = inevent ?? { Event.default };
14                 while { t.roundUp(tolerance) < by }
15                 {
16                         event = this.next(inevent.copy);
17                         if(event.isNil) { ("end of stream. Time left:" + (by - t)).inform; ^t - by };
19                         event = event.copy.put(\freq, \rest);
20                         event.play;
21                         delta = event.delta;
22                         if(delta.isNil) { ("end of stream. Time left:" + (by - t)).inform; ^t - by };
24                         t = t + delta;
26                 };
27                 ^t - by // time left to next event
28         }
33 + EventStreamPlayer {
35         xplay { arg fadeTime, argClock, doReset = false, quant=1.0;
36                 if (doReset, { this.reset });
37                 clock = argClock ? clock ? TempoClock.default;
38                 stream = PfadeIn(originalStream, fadeTime).asStream;
39                 clock.play(this, quant);
40         }
41         xstop { arg fadeTime;
42                 stream = PfadeOut(stream, fadeTime).asStream;
43         }
47 +PauseStream {
49         xplay { arg fadeTime, argClock, doReset = false, quant=1.0;
50                 this.play(argClock, doReset, quant);
51         }
52         xstop { // stop after fade?
53                 this.stop;
54         }