aboutsummaryrefslogtreecommitdiff
path: root/BUG7/instruments.udo
blob: 6c3bb317f5f427221a0bb62c45ed6919845d1267 (plain)
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
#ifndef UDO_INSTRUMENTS
#define UDO_INSTRUMENTS ##
/*
	Debugger - Unfixed Bugs : BUG #7

	Sound generators
	Names should correspond to those used in BID file, prepended with play_
*/


#include "wavetables.udo"
#include "bussing.udo"
#include "bid.udo"


gi3031index = 1
instr play_3031
	iamp = bid_getparameter(p4, p5, 2)

	
	inote1 = table(gi3031index, gibid_chordfn, 0, 0, 1) 
	if (gi3031index < 5) then
		gi3031index += 1
	else
		gi3031index = 1
	endif

	ifilter = random(20, 40)

	ifrq1 = 440 * exp(log(2) * (ifilter - 69) / 12)	; filter start freq.
	kamp linseg 1, p3*0.8, 1, p3*0.2, 0
	kcps init cpsmidinn(inote1)
	kffrq port 0, 60/150, ifrq1		; filter frequency
	a1 phasor kcps		; oscillator
	a1 = 1 - 2 * a1

	a1x butterbp a1, kffrq, kcps * 1.0			; filters
	a1x =  a1x * (2 + kffrq / kcps)	; correct amplitude
	a1 = a1x + a1 * 0.25 ; 0.5
	a1 butterlp a1, kffrq

	a1 = taninv(a1 * 2.5 * iamp)	; distortion ; 2.5

	keqf limit kffrq * 4, 10, sr * 0.48	; EQ frequency
	a1 pareq a1 * 0.6, keqf, 4.0, 1.0, 2
	a1 pareq a1, 50, 1.3, 0.6
	a1 pareq a1, 130, 0.6, 0.6
	a1 = a1 * kamp * 0.8
	;a1 *= line(0, p3, 1)
	aL, aR pan2 a1, random(0.3, 0.7)
	bus_mix("delay1", aL*0.3, aR*0.3)
	bus_mix("master", aL, aR)
endin


gi3032index = 3
instr play_3032
	iamp = bid_getparameter(p4, p5, 2)

	
	inote1 = table(gi3032index, gibid_chordfn, 0, 0, 1) 
	if (gi3032index < 9) then
		gi3032index += 1
	else
		gi3032index = 3
	endif

	ifilter = random(20, 40)

	ifrq1 = 440 * exp(log(2) * (ifilter - 69) / 12)	; filter start freq.
	kamp linseg 1, p3*0.8, 1, p3*0.2, 0
	kcps init cpsmidinn(inote1)
	kffrq port 0, 60/150, ifrq1		; filter frequency
	a1 phasor kcps		; oscillator
	a1 = 1 - 2 * a1

	a1x butterbp a1, kffrq, kcps * 1.0			; filters
	a1x =  a1x * (2 + kffrq / kcps)	; correct amplitude
	a1 = a1x + a1 * 0.25 ; 0.5
	a1 butterlp a1, kffrq

	a1 = taninv(a1 * 2.5 * iamp)	; distortion ; 2.5

	keqf limit kffrq * 4, 10, sr * 0.48	; EQ frequency
	a1 pareq a1 * 0.6, keqf, 4.0, 1.0, 2
	a1 pareq a1, 50, 1.3, 0.6
	a1 pareq a1, 130, 0.6, 0.6
	a1 = a1 * kamp * 0.8
	;a1 *= line(0, p3, 1)
	aL, aR pan2 a1, random(0.3, 0.7)
	bus_mix("delay1", aL*0.3, aR*0.3)
	bus_mix("master", aL, aR)
endin

instr play_clap
	iamp = bid_getparameter(p4, p5, 2) * random(0.4, 1) * 0.8
	aL noise 1, 0.3
	aR noise 1, 0.4
	aL butterbp aL, random(1200, 1800), random(800, 1200)
	aR butterbp aR, random(1200, 1800), random(800, 1200)
	aL taninv aL*7
	aR taninv aR*7
	
	kamp linseg 2, p3*0.1, 0, p3*0.1, 2, p3*0.1, 0, p3*0.1, 1.5, p3*0.1, 0, p3*0.1, 1, p3*0.4, 0
	aL *= kamp * iamp
	aR *= kamp * iamp
	bus_mix("clap", aL, aR)
	
endin



instr play_hat1
	iamp = bid_getparameter(p4, p5, 2)
	idel1 = random(0.005, 0.02)
	idel2 = random(0.005, 0.02)
	xtratim(max(idel1, idel2))

	kfreq = 380 + oscil(50, 23);550 ;line 600, p3, 600
	aenv expsega .1, .0005, 1.5, p3 - .0005, .01
	asqr1 oscil 1, kfreq, gifnSquare, -1
	asqr2 oscil 1, kfreq*1.4471, gifnSquare, -1
	asqr3 oscil 1, kfreq*1.6170, gifnSaw, -1
	asqr4 oscil 1, kfreq*1.9265, gifnSaw, -1
	asqr5 oscil 1, kfreq*4.5028, gifnSine, -1
	asqr6 oscil 1, kfreq*3.6637, gifnSine, -1
	a808L sum asqr1, asqr2, asqr3
	a808R sum asqr4, asqr5, asqr6
	a808L butterhp a808L, 4270
	a808R butterhp a808R, 4270
	aoutL = a808L * aenv * iamp
	aoutR = a808R * aenv * iamp
	aL delay aoutL, idel1
	aR delay aoutR, idel2
	bus_mix("hat1", aL, aR)
endin


instr play_hat2
	iamp = bid_getparameter(p4, p5, 2) * 0.7
	kfreq line 880, p3, 400
	aenv expsega .1, .0005, 1.5, p3 - .0005, .01
	asqr1 oscil 1, kfreq, gifnSquare, -1
	asqr2 oscil 1, kfreq*1.4471, gifnSquare, -1
	asqr3 oscil 1, kfreq*1.6170, gifnSquare, -1
	asqr4 oscil 1, kfreq*1.9265, gifnSquare, -1
	asqr5 oscil 1, kfreq*2.5028, gifnSquare, -1
	asqr6 oscil 1, kfreq*2.6637, gifnSquare, -1
	a808L sum asqr4, asqr5, asqr6
	a808R sum asqr1, asqr2, asqr3
	a808L butterhp a808L, 3270
	a808R butterhp a808R, 3270
	aL = a808L * aenv * iamp
	aR = a808R * aenv * iamp
	bus_mix("master", aL, aR*0.7)
endin


instr rim
	icps = p4 ;1000
	iamp = p5
	acps expon icps, 0.0025, icps * 0.5
	acps = acps + icps
	iamp = iamp * 0.3
	a1a phasor acps, 0	
	a1b phasor acps, random(0, 1)
	afmenv expon 1.0, 0.02, 0.4
	a1 = (a1a-a1b)*random(1, 10)*afmenv
	acps = acps*(1.0+a1)
	a0 oscil3 1.0, acps
	aenv expon 1.0, 0.005, 0.5
	a0 limit 4.0*a0*aenv, -1.0, 1.0
	a0 butterhp a0, 230
	aL, aR pan2 a0*iamp, random(0.3, 0.8)
	bus_mix("rim", aL, aR)
	bus_mix("delay1", butterlp(aL*0.6, 2000), butterlp(aR*0.6, 2000))
endin


instr blip1
	iup = p4
	iamp = p5
	inote1 = table(p4+3, gibid_chordfn, 0, 0, 1) + iup
	inote2 = table(p4+5, gibid_chordfn, 0, 0, 1) + iup
	a1 oscil 0.7, cpsmidinn(inote1)
	a2 oscil 0.7, cpsmidinn(inote2)
	kamp linseg 1, p3*0.2, 0, p3*0.8, 0
	a1 *= kamp
	a2 *= kamp
	a1 butterhp a1, 250
	a2 butterhp a2, 250
	a1 butterhp a1, 250
	a2 butterhp a2, 250
	aL1, aR1 pan2 a1, random(0, 1)
	aL2, aR2 pan2 a2, random(0, 1)
	bus_mix("master", aL1+aL2, aR1+aR2)
	bus_mix("delay1", butterlp(aL1*0.5, 4000), butterlp(aR2*0.5, 4000))
endin

instr play_rim
	iamp = bid_getparameter(p4, p5, 2)
	if (random(0, 1) > 0.6) then
		event_i "i", "rim", 0, 0.4, 3000, iamp
	endif
	if (random(0, 1) > 0.6) then
		event_i "i", "rim", 0, 0.4, 1000, iamp
	endif
	if (random(0, 1) > 0.6) then
		event_i "i", "rim", 0, 0.4, 2000, iamp
	endif
	if (random(0, 1) > 0.6) then
		event_i "i", "rim", 0, 0.4, 2500, iamp
	endif
	if (random(0, 1) > 0.6) then
		event_i "i", "rim", 0, 0.4, 3500, iamp
	endif
	if (random(0, 1) > 0.6) then
		event_i "i", "blip1", 0, random(0.01, 0.1), 48, iamp
	endif
	if (random(0, 1) > 0.6) then
		event_i "i", "blip1", 0, random(0.01, 0.1), 24, iamp
	endif
	if (random(0, 1) > 0.6) then
		event_i "i", "blip1", 0, random(0.01, 0.1), 36, iamp
	endif
endin



instr play_kick	; 808 style kick
	iamp = bid_getparameter(p4, p5, 2)

	idist = 0.5 ;= (i(gksection) == 1) ? 0.55 : 0.35
	xtratim 0.1
	krelease release
	ktune init -1.5
	kmul transeg 0.2, p3*0.5, -15, 0.01, p3*0.5, 0, 0
	kbend transeg 0.5, 1.2, -4, 0, 1, 0, 0
	asig gbuzz 0.5, 50*octave(ktune)*semitone(kbend), 20, 1, kmul, gifnCosine
	aenv linseg 0, p3*0.8, 1, p3*0.2, 0
	gkpump = k(aenv)
	asig = asig*aenv
	aenv linseg 0, 0.07, 1
	acps expsega 400, 0.07, 0.001, 1, 0.001
	amix = (asig*0.7)*1*iamp
	gkpump = min(rms(amix) * 7, 1)
	aout1 pareq amix, 100, 0.01, 0.7
	aout1 distort aout1, idist, gifnSquare
	aout1 pareq aout1, 50, 2, 0.4
	aout1 pareq aout1, 190, 0.7, 0.6
	aout1 butterlp aout1, 140
	aout1 *= 2
	bus_mix("kick", aout1, aout1)
endin

instr play_koffer
	iamp = bid_getparameter(p4, p5, 2)
	ifreq = cpsmidinn(tab_i(ftlen(gibid_chordfn) - 2, gibid_chordfn)+12)
	aL buzz 2, ifreq, random(7, 12), gifnSquare
	aL butterhp aL, 500
	aR buzz 2, ifreq, random(7, 12), gifnSquare
	aR butterhp aR, 500
	kamp linseg 0, p3*0.2, 1, p3*0.1, 0, p3*0.7, 0
	aL *= kamp 
	aR *= kamp 
	
	bus_mix("koffer", aL, aR)
endin



#end