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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
#ifndef UDO_ADDSUB
#define UDO_ADDSUB ##
/*
Stochastic additive and subtractive instruments
This file is part of the SONICS UDO collection by Richard Knight 2024
License: GPL-2.0-or-later
http://1bpm.net
*/
/*
Subtractive synthesiser
Operating between ifreq and ifreqmax, this recurses with a frequency step of *ifreqstepmult*ifreqstepmultrand and amplitude multiplier iampmult with each step
aout as_subtractive asrc, ifreq, ifreqmax, ifreqstepmult, ifreqstepmultrand, iamp, iampmult
aout output audio
asrc source sound, can be noise or anything less
ifreq minimum frequency
ifreqmax maximum frequency
ifreqstepmult frequency multiplier for each step
ifreqstepmultrand frequency multiplier random for each step
iamp amplitude
iampmult amplitude multiplier random for each step
*/
opcode as_subtractive, a, aiiiiii
asrc, ifreq, ifreqmax, ifreqstepmult, ifreqstepmultrand, iamp, iampmult xin
if (random(0, 1) >= 0.5) then
afreqmult linseg random(0.9, 1.1), p3*0.1, random(0.9, 1.1), p3*0.1, \
random(0.9, 1.1), p3*0.1, random(0.9, 1.1), p3*0.1, \
random(0.9, 1.1), p3*0.1, random(0.9, 1.1), p3*0.1, \
random(0.9, 1.1), p3*0.1, random(0.9, 1.1), p3*0.1, \
random(0.9, 1.1), p3*0.1, random(0.9, 1.1)
else
afreqmult init 1
endif
if (random(0, 1) >= 0.5) then
istartmult = random(0.9, 1.1)
iendmult = random(0.9, 1.1)
if (random(0, 1) >= 0.5) then
afreqmult2 linseg istartmult, p3, iendmult
else
afreqmult2 expseg istartmult, p3, iendmult
endif
afreqmult *= afreqmult2
endif
aamp linseg random(0.1, 0.9), p3*0.1, random(0.1, 0.9), p3*0.1, \
random(0.1, 0.9), p3*0.1, random(0.1, 0.9), p3*0.1, \
random(0.1, 0.9), p3*0.1, random(0.1, 0.9), p3*0.1, \
random(0.1, 0.9), p3*0.1, random(0.1, 0.9), p3*0.1, \
random(0.1, 0.9), p3*0.1, random(0.1, 0.9)
if (random(0, 1) >= 0.5) then
if (random(0, 1) >= 0.5) then
if (random(0, 1) >= 0.5) then
aamp2 linseg 1, p3, 0
else
aamp2 expseg 1, p3, 0.00001
endif
else
if (random(0, 1) >= 0.5) then
aamp2 linseg 0, p3, 1
else
aamp2 expseg 0.00001, p3, 1
endif
endif
aamp *= aamp2
endif
abw linseg random(1, 10), p3*0.1, random(1, 10), p3*0.1, \
random(1, 10), p3*0.1, random(1, 10), p3*0.1, \
random(1, 10), p3*0.1, random(1, 10), p3*0.1, \
random(1, 10), p3*0.1, random(1, 10), p3*0.1, \
random(1, 10), p3*0.1, random(1, 10)
amin init 50
amax init 22000
afreq = max:a(min:a(ifreq * afreqmult, amax), amin)
asub butterbp asrc, afreq, abw
asub butterbp asub, afreq, abw
asub balance asub, asrc
asub *= iamp * aamp
istep = ifreq * ifreqstepmult * random(1, ifreqstepmultrand)
if (istep <= ifreqmax) then
asubr as_subtractive asrc, istep, ifreqmax, ifreqstepmult, ifreqstepmultrand, iamp * iampmult, iampmult
asub += asubr
endif
xout asub
endop
/*
Additive synthesiser
Operating between ifreq and ifreqmax, this recurses with a frequency step of *ifreqstepmult*ifreqstepmultrand and amplitude multiplier iampmult with each step
aout as_additive ifreq, ifreqmax, ifreqstepmult, ifreqstepmultrand, iamp, iampmult [, index=0]
aout output audio
ifreq minimum frequency
ifreqmax maximum frequency
ifreqstepmult frequency multiplier for each step
ifreqstepmultrand frequency multiplier random for each step
iamp amplitude
iampmult amplitude multiplier random for each step
index internal recursion tracking
*/
opcode as_additive, a, iiiiiio
ifreq, ifreqmax, ifreqstepmult, ifreqstepmultrand, iamp, iampmult, index xin
if (random(0, 1) >= 0.5) then
kfreqmult linseg random(0.9, 1.1), p3*0.1, random(0.9, 1.1), p3*0.1, \
random(0.9, 1.1), p3*0.1, random(0.9, 1.1), p3*0.1, \
random(0.9, 1.1), p3*0.1, random(0.9, 1.1), p3*0.1, \
random(0.9, 1.1), p3*0.1, random(0.9, 1.1), p3*0.1, \
random(0.9, 1.1), p3*0.1, random(0.9, 1.1)
else
kfreqmult init 1
endif
kamp linseg random(0.1, 0.9), p3*0.1, random(0.1, 0.9), p3*0.1, \
random(0.1, 0.9), p3*0.1, random(0.1, 0.9), p3*0.1, \
random(0.1, 0.9), p3*0.1, random(0.1, 0.9), p3*0.1, \
random(0.1, 0.9), p3*0.1, random(0.1, 0.9), p3*0.1, \
random(0.1, 0.9), p3*0.1, random(0.1, 0.9)
if (random(0, 1) >= 0.5) then
if (random(0, 1) >= 0.5) then
if (random(0, 1) >= 0.5) then
kamp2 linseg 1, p3, 0
else
kamp2 expseg 1, p3, 0.00001
endif
else
if (random(0, 1) >= 0.5) then
kamp2 linseg 0, p3, 1
else
kamp2 expseg 0.00001, p3, 1
endif
endif
kamp *= kamp2
endif
if (random(0, 1) >= 0.5) then
istartmult = random(0.9, 1.1)
iendmult = random(0.9, 1.1)
if (random(0, 1) >= 0.5) then
kfreqmult2 linseg istartmult, p3, iendmult
else
kfreqmult2 expseg istartmult, p3, iendmult
endif
kfreqmult *= kfreqmult2
endif
aosc oscil iamp * kamp, ifreq * kfreqmult
istep = ifreq * ifreqstepmult * random(1, ifreqstepmultrand)
if (istep <= ifreqmax && index < 256) then ; 256 max recursion guard
aoscr as_additive istep, ifreqmax, ifreqstepmult, ifreqstepmultrand, iamp * iampmult, iampmult, index + 1
aosc += aoscr
endif
xout aosc
endop
#end
|