File: extEnv.sc

package info (click to toggle)
supercollider 1%3A3.4.5-1wheezy1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 26,972 kB
  • sloc: cpp: 116,645; lisp: 64,914; ansic: 10,725; python: 3,548; perl: 766; ruby: 487; sh: 152; makefile: 117; xml: 13
file content (31 lines) | stat: -rw-r--r-- 941 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//As a pattern, an Env defines a function of time sampled at the time positions when it is called.
//Sample functions of time can describe attributes such as dynamics, chord progressions, etc that occur over time but can be articulated with different rhythmic patterns.


+Env {
	embedInStream { arg inval;
		var startTime;
		startTime = thisThread.endBeat ? thisThread.beats;
		thisThread.endBeat = this.times.sum + startTime;
		loop {
			inval = yield(this.at(thisThread.beats - startTime));
		}
	}
	
	asStream {
		^Routine({ arg inval; this.embedInStream(inval) })
	}

	asSignal { arg length = 400;
		var duration, signal, ratio;
		duration = times.sum;
		ratio = duration/(length - 1);
		signal = Signal(length);
		length.do({ arg i; signal.add(this.at(i * ratio)) });
		^signal;
	}

	plot { arg size = 400, bounds, minval, maxval, parent;
		this.asSignal(size).plot(bounds: bounds, minval: minval, maxval: maxval, parent: parent);
	}
}