-
Notifications
You must be signed in to change notification settings - Fork 0
/
mioSynth.csd
275 lines (243 loc) · 11.2 KB
/
mioSynth.csd
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
273
274
275
/*
******* mioSynth *******
by Yeshi Silvano Namkhai
************************
rep: https://github.com/YeshiNamkhai/mioSynth
web: https://my-hexagon.com
*/
<Cabbage>
form caption("mioSynth") size(785, 300), colour("black"), pluginId("def1") ;style("legacy")
keyboard bounds(0, 199, 790, 100)
;VCO
groupbox bounds(4, 8, 160, 118) text("VCO 1")
groupbox bounds(166, 8, 160, 118) text("VCO 2")
combobox bounds(176, 38, 72, 30) text("saw", "pulse", "triangle") channel("wav2")
combobox bounds(14, 38, 72, 30) text("saw", "pulse", "triangle") channel("wav1")
rslider bounds(89, 38, 30, 30) range(0.05, 0.95, 0.5, 1, 0.05) channel("pwm1") trackerColour(0, 118, 255, 255) identChannel("pwm1i") active(0) alpha(0.3) popupText("duty/rate")
rslider bounds(251, 38, 30, 30) range(0.05, 0.95, 0.5, 1, 0.05) channel("pwm2") trackerColour(0, 118, 255, 255) identChannel("pwm2i") active(0) alpha(0.3) popupText("duty/rate")
label bounds(125, 33, 28, 11) text("LFO")
label bounds(287, 33, 28, 11) text("LFO")
button bounds(125, 47, 28, 10) channel("lfo1t") text("off", "on") colour:1(255, 0, 0, 255) identChannel("lfo1i")
button bounds(287, 47, 28, 10) channel("lfo2t") text("off", "on") colour:1(255, 0, 0, 255) identChannel("lfo2i")
button bounds(125, 58, 28, 10) channel("lfo1v") text("off", "on") colour:1(255, 0, 0, 255) identChannel("lfo1i")
button bounds(287, 58, 28, 10) channel("lfo2v") text("off", "on") colour:1(255, 0, 0, 255) identChannel("lfo2i")
rslider bounds(110, 74, 45, 45) range(0, 1, 0.5, 1, 0.1) channel("mix1") trackerColour(246, 118, 38, 255) text("Mix")
rslider bounds(272, 74, 45, 45) range(0, 1, 0.5, 1, 0.1) channel("mix2") trackerColour(246, 118, 38, 255) text("Mix")
rslider bounds(14, 74, 45, 45) range(-36, 36, 0, 1, 1) channel("oct1") trackerColour(0, 118, 255, 255) text("Oct")
rslider bounds(62, 74, 45, 45) range(-25, 25, 0, 1, 1) trackerColour(0, 118, 255, 255) channel("fin1") text("Fine")
rslider bounds(176, 74, 45, 45) range(-36, 36, 0, 1, 1) channel("oct2") trackerColour(0, 118, 255, 255) text("Oct")
rslider bounds(224, 74, 45, 45) range(-25, 25, 0, 1, 1) channel("fin2") trackerColour(0, 118, 255, 255) text("Fine")
;Noise
groupbox bounds(4, 127, 123, 67) text("Noise")
combobox bounds(14, 152, 71, 30) text("white", "pink") channel("noise")
rslider bounds(86, 152, 30, 30) range(0, 1, 0, 1, 0.01) channel("mix3") trackerColour(246, 118, 38, 255)
label bounds(85, 182, 31, 10) text("Mix")
;LFO
groupbox bounds(128, 127, 82, 67) text("LFO")
rslider bounds(136, 152, 30, 30) range(0.5, 20, 2, 1, 0.01) channel("trem") trackerColour(55, 55, 118, 255) popupText("tremolo rate")
rslider bounds(168, 152, 30, 30) range(0.5, 20, 2, 1, 0.01) channel("vibr") trackerColour(55, 55, 118, 255) popupText("vibrato rate")
label bounds(128, 182, 81, 10) text("Tremolo Vibrato")
;Reverb
groupbox bounds(211, 127, 115, 67) text("Reverb")
rslider bounds(252, 152, 30, 30) range(0, 1, 0.5, 1, 0.001) channel("room") trackerColour(0, 118, 255, 255)
rslider bounds(286, 152, 30, 30) range(0, 1, 0.5, 1, 0.001) channel("mix4") trackerColour(246, 118, 38, 255) popupText("dry/wet")
button bounds(220, 158, 26, 18) channel("rev") text("off", "on") colour:1(255, 0, 0, 255)
label bounds(247, 182, 73, 10) text("Room Mix")
;VCF
groupbox bounds(327, 8, 133, 186) text("VCF")
rslider bounds(340, 38, 54, 54) range(0, 22050, 22050, 0.5, 0.001) text("CutOff") channel("cut")
rslider bounds(396, 38, 54, 54) range(0, 1, 0, 1, 0.001) text("Res") channel("res")
vslider bounds(340, 98, 25, 87) range(0.001, 1, 0.001, 1, 0.001) text("A") channel("attF")
vslider bounds(368, 98, 25, 87) range(0, 1, 0, 1, 0.001) text("D") channel("decF")
vslider bounds(396, 98, 25, 87) range(0, 1, 0.7, 1, 0.001) text("S") channel("susF")
vslider bounds(424, 98, 25, 87) range(0, 1, 0, 1, 0.001) text("R") channel("relF")
;VCA
groupbox bounds(460, 8, 132, 186) text("VCA")
vslider bounds(472, 38, 25, 87) range(0.002, 1, 0.002, 1, 0.001) text("A") channel("attA") trackerColour(246, 118, 38, 255)
vslider bounds(500, 38, 25, 87) range(0, 1, 0, 1, 0.001) text("D") channel("decA") trackerColour(246, 118, 38, 255)
vslider bounds(528, 38, 25, 87) range(0, 1, 0.7, 1, 0.001) text("S") channel("susA") trackerColour(246, 118, 38, 255)
vslider bounds(556, 38, 25, 87) range(0, 1, 0, 1, 0.001) text("R") channel("relA") trackerColour(246, 118, 38, 255)
rslider bounds(528, 130, 54, 54) range(0, 1, 0.7, 1, 0.001) text("Master") channel("vol") trackerColour(246, 118, 38, 255)
rslider bounds(472, 130, 54, 54) range(0, 1, 0.5, 1, 0.001) text("Pan") channel("pan") trackerColour(0, 0, 0, 255)
;Patch
groupbox bounds(594, 8, 185, 186) text("Patch")
combobox bounds(603, 158, 102, 25), , populate("*.snaps") channel("patch")
filebutton bounds(712, 158, 56, 25), channel("save"), text("Save", "Save"), mode("snapshot")
button bounds(729, 136, 39, 15) text("Show", "Show") colour:1(255, 0, 0, 255) channel("show")
infobutton bounds(603, 136, 39, 15) text("Help") file("mioSynth.html") channel("help")
button bounds(687, 136, 39, 15) text("Midi", "Midi") colour:1(255, 0, 0, 255) channel("midi")
button bounds(645, 136, 39, 15) text("Mono", "Poly") colour:1(255, 0, 0, 255) channel("mono")
signaldisplay bounds(604, 32, 165, 100) colour("green") displayType("waveform") channel("signaldisplay72"), signalVariable("aLp")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5 --displays
</CsOptions>
<CsInstruments>
; Initialize the global variables.
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
gkNote init 0
instr 1
iMod chnget "mono"
gkNote init p4
if iMod==0 && gkNote != 0 && gkNote != p4 then
turnoff
endif
iMid chnget "midi"
if iMid==1 then ;midi
iCc1 = 16 ;CC rotary
iCc2 = 17 ;CC slider
iCc3 = 18 ;CC master
iFat ctrl7 1, iCc2, 0.001, 1
chnset iFat, "attF"
iFde ctrl7 2, iCc2, 0, 1
chnset iFde, "decF"
iFsu ctrl7 3, iCc2, 0, 1
chnset iFsu, "susF"
iFre ctrl7 4, iCc2, 0, 1
chnset iFre, "relF"
iAat ctrl7 5, iCc2, 0.001, 1
chnset iAat, "attA"
iAde ctrl7 6, iCc2, 0, 1
chnset iAde, "decA"
iAsu ctrl7 7, iCc2, 0, 1
chnset iAsu, "susA"
iAre ctrl7 8, iCc2, 0, 1
chnset iAre, "relA"
kVol ctrl7 2, iCc3, 0, 1
chnset kVol, "vol"
kPan ctrl7 1, iCc3, 0, 1
chnset kPan, "pan"
kPw1 ctrl7 1, iCc1, 0.05, 0.95
chnset kPw1 ,"pwm1"
kOc1 ctrl7 2, iCc1, -36, 36
chnset kOc1 ,"oct1"
kFn1 ctrl7 3, iCc1, -25, 25
chnset kFn1 ,"fin1"
kMx1 ctrl7 4, iCc1, 0, 1
chnset kMx1 ,"mix1"
kPw2 ctrl7 5, iCc1, 0.05, 0.95
chnset kPw2 ,"pwm2"
kOc2 ctrl7 6, iCc1, -36, 36
chnset kOc2 ,"oct2"
kFn2 ctrl7 7, iCc1, -25, 25
chnset kFn2 ,"fin2"
kMx2 ctrl7 8, iCc1, 0, 1
chnset kMx2 ,"mix2"
else ;widget
iAat chnget "attA"
iAde chnget "decA"
iAsu chnget "susA"
iAre chnget "relA"
iFat chnget "attF"
iFde chnget "decF"
iFsu chnget "susF"
iFre chnget "relF"
kVol chnget "vol"
kPan chnget "pan"
kPw1 chnget "pwm1"
kPw2 chnget "pwm2"
kFn1 chnget "fin1"
kFn2 chnget "fin2"
kMx1 chnget "mix1"
kMx2 chnget "mix2"
kOc1 chnget "oct1"
kOc2 chnget "oct2"
endif
kCut chnget "cut"
kRes chnget "res"
kNse chnget "noise"
kMx3 chnget "mix3"
kSiz chnget "size"
kMx4 chnget "mix4"
iRev chnget "rev"
iWf1 chnget "wav1"
iWf2 chnget "wav2"
iL1t chnget "lfo1t"
iL2t chnget "lfo2t"
iL1v chnget "lfo1v"
iL2v chnget "lfo2v"
kTrm chnget "trem"
kVbr chnget "vibr"
iDis chnget "show"
if iDis==1 then
;use this for table
Str1 sprintf "f1 0 33 -2 %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %i %i %i %i %.3f %.3f", iAat, iAde, iAsu, iAre, kPw1, kPw2, kMx1, kMx2, kOc1, kOc2, kFn1, kFn2, kCut, kRes
;use this for notes
;aStr1 sprintf "i1 + . %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %i %i %i %i %.3f %.3f", p4, p5, iAat, iAde, iAsu, iAre, kPw1, kPw2, kMx1, kMx2, kOc1, kOc2, kFn1, kFn2, kCut, kRes
Str2 sprintf " %.3f %.3f %.3f %.3f %.3f %.3f %i %.3f %.3f %.3f %i %i %i %i %i %i %i %.3f %.3f", iFat, iFde, iFsu, iFre, kVol, kPan, kNse, kMx3, kSiz, kMx4, iRev, iWf1, iWf2, iL1t, iL2t, iL1v, iL2v, kTrm, kVbr
Str strcat Str1, Str2
puts Str, 1
endif
if iWf1==1 then ;saw
iWf1 = 0
elseif iWf1==2 then ;pulse
chnset "alpha(1),active(1)", "pwm1i"
elseif iWf1==3 then ;triangle
iWf1 = 12
endif
if iWf2==1 then ;saw
iWf2 = 0
elseif iWf2==2 then ;pulse
chnset "alpha(1),active(1)", "pwm2i"
elseif iWf2==3 then ;triangle
iWf2 = 12
endif
if iWf1!=2 then
chnset "alpha(0.3),active(0)", "pwm1i"
endif
if iWf2!=2 then
chnset "alpha(0.3),active(0)", "pwm2i"
endif
kAen madsr iAat, iAde, iAsu, iAre ;ADSR-->VCA
kFen madsr iFat, iFde, iFsu, iFre ;ADSR-->VCF
kLft lfo p5, kTrm
kLfv lfo p5, kVbr
if iL1t==1 && iL1v==1 then
aVco1 vco2 p5*kLft, (p4+kLfv)+(p4+kLfv)*semitone(kOc1)+(p4+kLfv)*semitone(kFn1)/100, iWf1, kPw1
elseif iL1t==1 && iL1v==0 then
aVco1 vco2 p5*kLft, p4+p4*semitone(kOc1)+p4*semitone(kFn1)/100, iWf1, kPw1
elseif iL1t==0 && iL1v==1 then
aVco1 vco2 p5, (p4+kLfv)+(p4+kLfv)*semitone(kOc1)+(p4+kLfv)*semitone(kFn1)/100, iWf1, kPw1
else
aVco1 vco2 p5, p4+p4*semitone(kOc1)+p4*semitone(kFn1)/100, iWf1, kPw1
endif
if iL2t==1 && iL2v==1 then
aVco2 vco2 p5*kLft, (p4+kLfv)+(p4+kLfv)*semitone(kOc2)+(p4+kLfv)*semitone(kFn2)/100, iWf2, kPw2
elseif iL2t==1 && iL2v==0 then
aVco2 vco2 p5*kLft, p4+p4*semitone(kOc2)+p4*semitone(kFn2)/100, iWf2, kPw2
elseif iL2t==0 && iL2v==1 then
aVco2 vco2 p5, (p4+kLfv)+(p4+kLfv)*semitone(kOc2)+(p4+kLfv)*semitone(kFn2)/100, iWf2, kPw2
else
aVco2 vco2 p5, p4+p4*semitone(kOc2)+p4*semitone(kFn2)/100, iWf2, kPw2
endif
aOscs =aVco1*kMx1+aVco2*kMx2
if kNse==1 then ; white noise
aRand rand p5
aOscs +=aRand*kMx3
elseif kNse==2 then ;pink noise
aPink pinker
aOscs +=aPink*kMx3
endif
aLp moogladder aOscs, kCut*kFen, kRes*kFen ;VCF
aLp balance aLp, aOscs
aLp clip aLp,0,0.999
if iRev==1 then
aL, aR freeverb aLp, aLp, kSiz, 0, sr, 0
amixL ntrpol aLp, aL, kMx4 ;Dry/Wet L
amixR ntrpol aLp, aR, kMx4 ;Dry/Wet R
outs amixL*kAen*kVol*(1-kPan), amixR*kAen*kVol*kPan
else
outs aLp*kAen*kVol*(1-kPan), aLp*kAen*kVol*kPan
endif
display aLp, 0.25, 1
endin
</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
</CsScore>
</CsoundSynthesizer>