-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path4.- Complex Examples.scd
More file actions
121 lines (100 loc) · 3 KB
/
4.- Complex Examples.scd
File metadata and controls
121 lines (100 loc) · 3 KB
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
/////////////////////////////////////////////////////
// Scales and Degrees in SuperCollider
/////////////////////////////////////////////////////
// Luis Sanz | Aug 2025 | www.luissanz.ch
/////////////////////////////////////////////////////
////////// 1. SynthDef
(
SynthDef(\tremolo, {
arg freq=500, amp=0.2, atk=1, rel=2, pan=0, trem=2;
var env, sig;
// Percussive envelope
env = EnvGen.kr(Env.perc(atk, rel), doneAction:2);
// Feedback oscillator with tremolo
sig = SinOscFB.ar(freq, 0.9) * SinOsc.ar(trem) * env * amp;
// Stereo output
sig = Pan2.ar(sig, pan);
Out.ar(0, sig);
}).add;
)
/*
Arguments explanation:
freq → pitch in Hz
amp → amplitude
atk, rel → envelope attack and release in seconds
pan → stereo position
trem → tremolo frequency
doneAction:2 → free synth when envelope ends
*/
////////// 2. Pattern Example: \unpredictable
// Define a TempoClock
t = TempoClock(120/60); // 120 bpm
t.tempo_(60/60); // change bpm
// Unpredictable pattern with random melody/chords
(
Pbindef(
\unpredictable,
\instrument, \tremolo,
\scale, Scale.minor,
\degree, Pxrand([0, 1, 2, 3, 4, 5, 6, [-7, -3, 0, 2, 4, 6], 7], inf),
\atk, 0.01,
\rel, Phprand(3.0, 5.0, inf), // use floating-point for smoother releases
\trem, Pkey(\degree) + Pseq([0.1, 0.2, 0.5, 0.7], inf),
\amp, Pseq([Pn(0.6, 0.5), 0.06], inf),
\pan, Pwhite(-0.3, 0.3, inf),
\dur, Pseq([Pseq([0.1,0.2,0.5,0.7], inf), Pn(0.1, 6), 1.3, 1], inf),
).play(t);
)
Pbindef(\unpredictable).stop;
////////// 3. Pattern Example: \predictable
(
Pbindef(
\predictable,
\instrument, \tremolo,
\scale, Scale.minor,
\degree, Pxrand([0,1,2,3,4,5,6,[-7,-3,0,2,4,6],7], inf),
\trem, Pkey(\degree) + Pseq([0.1,0.2,0.5,0.7], inf),
\atk, Pwhite(0.1, 1.0, inf), // floating-point attack
\rel, Pwhite(1.5, 3.0, inf), // floating-point release
\amp, Pseq([Pn(0.6, 0.5), 0.06], inf),
\pan, Pwhite(-0.3, 0.3, inf),
\dur, 0.2,
).play(t);
)
Pbindef(\predictable).stop;
////////// 4. Other Pattern Examples: \erratic & \shimmering
// Erratic pattern: variable rhythm and pan
(
Pbindef(
\erratic,
\instrument, \tremolo,
\degree, Prand([Phprand(-7, 7, 1), Pxrand([0,1,2,3,4,5,6,[-7,-3,0,2,4,6],7],1)], inf),
\scale, Scale.minor,
\trem, Pkey(\degree) + Pseq([0.1,0.2,0.5,0.7], inf),
\dur, Pseq([Pseries(0.02*15,-0.02,15).clip(0.01,1.5), Pseries(0.01,0.01,15)], inf),
\amp, 0.05,
\pan, Prand([Pwhite(-0.8,0.8,1), Pseries(-1,0.08,1).clip(-0.3,0.3)], inf),
).play(t, quant:4);
)
Pbindef(\erratic).stop;
// Shimmering pattern: chords, octaves, tremolo
(
Pbindef(
\shimmering,
\instrument, \tremolo,
\scale, Scale.minor,
\degree, Pxrand([
[0,2,4], [0,3,5], [0,2,4,6],
[-7,-3,0,2], [0,4,7], [2,4,6], [4,6,8]
], inf),
\octave, Pseq([3,4,5,4], inf),
\atk, 0.01,
\rel, Phprand(3.0,5.0,inf),
\trem, Pkey(\degree) * Pseq([0.1,0.2,0.5,0.7], inf),
\amp, Pseq([Pn(0.6,0.5),0.06], inf),
\pan, Pwhite(-0.3,0.3,inf),
\dur, Pseq([Pseq([0.1,0.2,0.5,0.7], inf), Pn(0.1,6), 1.3,1], inf),
\strum, 0.05, // 50 ms strum between notes
).play(t, quant:4);
)
Pbindef(\shimmering).stop;