File: Linen.schelp

package info (click to toggle)
supercollider 1%3A3.13.0%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 80,292 kB
  • sloc: cpp: 476,363; lisp: 84,680; ansic: 77,685; sh: 25,509; python: 7,909; makefile: 3,440; perl: 1,964; javascript: 974; xml: 826; java: 677; yacc: 314; lex: 175; objc: 152; ruby: 136
file content (130 lines) | stat: -rw-r--r-- 2,388 bytes parent folder | download | duplicates (4)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
class:: Linen
summary:: Simple linear envelope generator.
categories::  UGens>Envelopes
related:: Classes/EnvGen

Description::

Simple linear envelope generator.


classmethods::

method::kr

argument::gate

This triggers the envelope and holds it open while > 0.

If strong::gate:: < 0, force release with time code:: -1.0 - gate ::. See link::Classes/EnvGen#Forced release::.

argument::attackTime

The duration of the attack portion.


argument::susLevel

The level of the sustain portion.


argument::releaseTime

The duration of the release portion.


argument::doneAction

An integer representing an action to be executed when the
envelope is finished. See
link::Classes/Done::  for
more detail.


Examples::

code::

// trigged
(
SynthDef("help-Linen",{ arg out = 0;
	Out.ar(out,
		Linen.kr(Impulse.kr(2), 0.01, 0.6, 1.0, doneAction: Done.none) * SinOsc.ar(440, 0, 0.1)
	)
}).play;
)

// play once and end the synth
(
SynthDef("help-Linen",{ arg out=0;
	Out.ar(out,
		Linen.kr(Impulse.kr(0), 0.01, 0.6, 1.0, doneAction: Done.freeSelf) * SinOsc.ar(440, 0, 0.1)
	)
}).play;
)

// play once and sustain
(
x = SynthDef("help-Linen",{ arg gate = 1, out = 0; // use gate arg for release
	Out.ar(out,
		Linen.kr(gate, 0.01, 0.6, 1.0, doneAction: Done.freeSelf) * SinOsc.ar(440, 0, 0.1)
	)
}).play;
)
x.release(4); // change the release time

// longer gate, can pass in duration
(
SynthDef("help-Linen",{ arg out = 0, dur = 0.1;
	var gate;
	gate = Trig.kr(1.0, dur);
	Out.ar(out,
		Linen.kr(gate, 0.01, 0.6, 1.0, doneAction: Done.freeSelf) * SinOsc.ar(440, 0, 0.1)
	)
}).play(nil, [\out, 0, \dur, 2.0]);
)



// used below in a Routine varying the releaseTime
(
SynthDef("help-Linen",{ arg out=0,freq=440,attackTime=0.01,susLevel=0.6,releaseTime=0.1;
	Out.ar(out,
		Linen.kr(Impulse.kr(0), attackTime, susLevel, releaseTime, doneAction: Done.freeSelf)
			* SinOsc.ar(freq, 0, 0.1)
	)
}).add;
)

(
// debussey sleeping through math class
x = Pbrown(0.01, 2.0, 0.2, inf).asStream;
Routine({
	loop({
		Synth.grain("help-Linen",[\freq, (rrand(20, 50) * 2).midicps, \releaseTime, x.next]);
		0.25.wait;
	})
}).play(TempoClock.default)
)





(
SynthDef("help-Linen",{ arg out = 0;
	Out.ar(out,

		Linen.kr(Impulse.kr(2),
			0.01,
			// sustain level is polled at time of trigger
			FSinOsc.kr(0.1).range(0, 1),
			1.0,
			doneAction: Done.none)

			* SinOsc.ar(440, 0, 0.1)
	)
}).play;
)

::