Extra "ports" of juce-based plugins using the distrho build system
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

486 lines
23KB

  1. <Cabbage>
  2. form caption("gbuzz Synth") size(875, 375), pluginID("GBuz")
  3. image bounds( 0, 0,875,295), colour("DarkSlateGrey"), outline("MediumSlateBlue"), line(3) ; main panel colouration
  4. ;MAIN
  5. image bounds( 10, 6,495, 90), colour("DarkSlateGrey"), outline("white"), line(2), shape("sharp"),plant("main"){ ;main
  6. label bounds(180, 5,100, 15), text("Main"), fontcolour(white)
  7. rslider bounds( 0, 23, 62, 62), text("Level"), colour(SlateGrey) channel("level"),range(0,20, 10,0.5,0.001), fontcolour(white)
  8. rslider bounds( 60, 23, 62, 62), text("Power"), colour(SlateGrey) channel("mul"), range(0, 0.97, 0.1), fontcolour(white)
  9. rslider bounds(120, 23, 62, 62), text("Lowest"), colour(SlateGrey) channel("lh"), range(1, 40, 3,1,1), fontcolour(white)
  10. rslider bounds(180, 23, 62, 62), text("Number"), colour(SlateGrey) channel("nh"), range(1,200,10,1,1), fontcolour(white)
  11. rslider bounds(240, 23, 62, 62), text("Jitter"), colour(SlateGrey) channel("jitter"),range(0, 1, 0.4), fontcolour(white)
  12. rslider bounds(300, 23, 62, 62), text("Pan"), colour(SlateGrey) channel("pan"),range(0, 1, 0.5), fontcolour(white)
  13. label bounds(368, 19, 90, 11), text("Waveform"), fontcolour(white)
  14. combobox bounds(365, 30, 60, 18), channel("waveform"), value(3), text("cosine", "sine", "user")
  15. label bounds(368, 52, 90, 11), text("User Matrix"), fontcolour(white)
  16. checkbox bounds(368, 63, 10, 10), channel("part1"), FontColour(white), colour("lime"), value(1)
  17. checkbox bounds(378, 63, 10, 10), channel("part2"), FontColour(white), colour("lime"), value(0)
  18. checkbox bounds(388, 63, 10, 10), channel("part3"), FontColour(white), colour("lime"), value(1)
  19. checkbox bounds(398, 63, 10, 10), channel("part4"), FontColour(white), colour("lime"), value(0)
  20. checkbox bounds(408, 63, 10, 10), channel("part5"), FontColour(white), colour("lime"), value(0)
  21. checkbox bounds(418, 63, 10, 10), channel("part6"), FontColour(white), colour("lime"), value(0)
  22. checkbox bounds(368, 73, 10, 10), channel("part7"), FontColour(white), colour("lime"), value(1)
  23. checkbox bounds(378, 73, 10, 10), channel("part8"), FontColour(white), colour("lime"), value(0)
  24. checkbox bounds(388, 73, 10, 10), channel("part9"), FontColour(white), colour("lime"), value(0)
  25. checkbox bounds(398, 73, 10, 10), channel("part10"), FontColour(white), colour("lime"), value(1)
  26. checkbox bounds(408, 73, 10, 10), channel("part11"), FontColour(white), colour("lime"), value(1)
  27. checkbox bounds(418, 73, 10, 10), channel("part12"), FontColour(white), colour("lime"), value(0)
  28. rslider bounds(430, 23, 62, 62), text("Octave"), colour(SlateGrey) channel("octave"),range(-8, 8, -4,1,1), fontcolour(white)
  29. }
  30. ;POLYPHONY
  31. image bounds(510, 6,170, 90), colour("DarkSlateGrey"), outline("white"), line(2), shape("sharp"), plant("polyphony"){ ;polyphony
  32. label bounds( 35, 5,100, 15), text("Polyphony"), fontcolour(white)
  33. button bounds( 10, 24, 70, 25), text("mono", "poly"), channel("monopoly"), value(1), fontcolour("lime")
  34. rslider bounds(110, 26, 60, 60), text("Leg.Time"), channel("LegTim"), range(0.01, 15, 0.05, 0.25, 0.00001), fontcolour(white) colour(SlateGrey)
  35. label bounds( 37, 54, 90, 11), text("Mode"), fontcolour(white)
  36. combobox bounds( 10, 65, 90, 18), channel("PortMode"), value(1), text("Fixed", "Proportional")
  37. }
  38. ;REVERB
  39. image bounds(710,101,120, 90), colour("DarkSlateGrey"), outline("white"), line(2), shape("sharp"), plant("reverb"){ ;reverb
  40. label bounds( 35, 5,100, 15), text("Reverb"), fontcolour(white)
  41. rslider bounds( 0, 23, 60, 60), text("Mix"), channel("RvbMix"), range(0, 1, 0.3), fontcolour(white) colour(SlateGrey)
  42. rslider bounds( 60, 23, 60, 60), text("Size"), channel("RvbSize"), range(0.3, 1, 0.7), fontcolour(white) colour(SlateGrey)
  43. }
  44. ;PITCH BEND
  45. image bounds(685, 6,185, 90), colour("DarkSlateGrey"), outline("white"), line(2), shape("sharp"), plant("pitchbend"){ ;pitch bend
  46. label bounds( 52, 5,100, 15), text("Pitch Bend"), fontcolour(white)
  47. rslider bounds( 0, 23, 60, 60), fontcolour("white"), text("< Bend"), channel("BendDown"), range(-1,0, 0, 1,0.001), colour(SlateGrey)
  48. rslider bounds( 60, 23, 60, 60), fontcolour("white"), text("Bend >"), channel("BendUp"), range(0, 1, 0, 1,0.001), colour(SlateGrey)
  49. rslider bounds(120, 23, 60, 60), fontcolour("white"), text("Bend Rng."), channel("BendRange"), range(1, 24, 12, 1,1), colour(SlateGrey)
  50. }
  51. ;MULTIPLIER ENVELOPE
  52. image bounds( 10,101,305, 90), colour("DarkSlateGrey"), outline("white"), line(2), shape("sharp"), plant("multiplierenvelope"){ ;multiplier envelope
  53. label bounds( 83, 5,160, 15), text("Multiplier Envelope"), fontcolour(white)
  54. rslider bounds( 0, 23, 62, 62), text("Att"), colour(SlateGrey) channel("MAtt"),range(0, 8.000, 0.01, 0.375,0.0001), fontcolour(white)
  55. rslider bounds( 60, 23, 62, 62), text("Lev"), colour(SlateGrey) channel("MLev"),range(0, 1.000, 0.6), fontcolour(white)
  56. rslider bounds(120, 23, 62, 62), text("Dec"), colour(SlateGrey) channel("MDec"),range(0, 8.000, 3, 0.375,0.0001), fontcolour(white)
  57. rslider bounds(180, 23, 62, 62), text("Sus"), colour(SlateGrey) channel("MSus"),range(0, 1.000, 0), fontcolour(white)
  58. rslider bounds(240, 23, 62, 62), text("Rel"), colour(SlateGrey) channel("MRel"),range(0, 8.000, 0.1, 0.375,0.0001), fontcolour(white)
  59. }
  60. ;LOW CUT
  61. image bounds(320,101,125, 90), colour("DarkSlateGrey"), outline("white"), line(2), shape("sharp"), plant("lowcut"){ ;Low Cut
  62. checkbox bounds( 30, 6, 70, 12), text("Low Cut") channel("LowCutOnOff"), FontColour(white), colour("lime")
  63. rslider bounds( 0, 23, 62, 62), text("Low Cut"), colour(SlateGrey) channel("LowCut"),range(0, 30.00, 0,1,0.0011), fontcolour(white)
  64. rslider bounds( 60, 23, 62, 62), text("Lo Poles"), colour(SlateGrey) channel("LowPoles"),range(2, 30, 2,1,1), fontcolour(white)
  65. }
  66. ;HIGH CUT
  67. image bounds(450,101,125, 90), colour("DarkSlateGrey"), outline("white"), line(2), shape("sharp"), plant("highcut"){ ;High Cut
  68. checkbox bounds( 28, 6, 70, 12), text("High Cut") channel("HighCutOnOff"), FontColour(white), colour("lime"), value(1)
  69. rslider bounds( 2, 23, 62, 62), text("High Cut"), colour(SlateGrey) channel("HighCut"),range(1, 100.00, 7,0.25,0.0001), fontcolour(white)
  70. rslider bounds( 62, 23, 62, 62), text("Hi Poles"), colour(SlateGrey) channel("HighPoles"),range(2, 30, 8,1,1), fontcolour(white)
  71. }
  72. ;AMPLITUDE ENVELOPE
  73. image bounds( 10,196,305, 90), colour("DarkSlateGrey"), outline("white"), line(2), shape("sharp"), plant("amplitudeenvelope"){ ;amplitude envelope
  74. label bounds( 83, 5,160, 15), text("Amplitude Envelope"), fontcolour(white)
  75. rslider bounds( 0, 23, 62, 62), text("Att"), colour(SlateGrey) channel("AAtt"),range(0, 8.000, 0, 0.375,0.0001), fontcolour(white)
  76. rslider bounds( 60, 23, 62, 62), text("Lev"), colour(SlateGrey) channel("ALev"),range(0, 1.000, 1), fontcolour(white)
  77. rslider bounds(120, 23, 62, 62), text("Dec"), colour(SlateGrey) channel("ADec"),range(0, 8.000, 3, 0.375,0.0001), fontcolour(white)
  78. rslider bounds(180, 23, 62, 62), text("Sus"), colour(SlateGrey) channel("ASus"),range(0, 1.000, 0), fontcolour(white)
  79. rslider bounds(240, 23, 62, 62), text("Rel"), colour(SlateGrey) channel("ARel"),range(0, 8.000, 0.05, 0.375,0.0001), fontcolour(white)
  80. }
  81. ;MODULATION
  82. image bounds(320,196,485, 90), colour("DarkSlateGrey"), outline("white"), line(2), shape("sharp"), plant("modulation"){ ;MODULATION
  83. label bounds(203, 5,100, 15), text("Modulation"), fontcolour(white)
  84. rslider bounds( 2, 23, 62, 62), text("Mod.Depth"), colour(SlateGrey) channel("mod"), range(0, 1.00, 0.7), fontcolour(white)
  85. rslider bounds( 62, 23, 62, 62), text("Delay"), colour(SlateGrey) channel("VDel"), range(0, 4.00, 0), fontcolour(white)
  86. rslider bounds(122, 23, 62, 62), text("Rise"), colour(SlateGrey) channel("VRis"), range(0, 5.00, 1.5), fontcolour(white)
  87. rslider bounds(182, 23, 62, 62), text("Rate"), colour(SlateGrey) channel("VRate"), range(0,30.00, 2.7), fontcolour(white)
  88. rslider bounds(242, 23, 62, 62), text("Rate Rnd."), colour(SlateGrey) channel("VRatRnd"),range(0, 2.00, 0.5), fontcolour(white)
  89. rslider bounds(302, 23, 62, 62), text("Vib.Dep."), colour(SlateGrey) channel("VibDep"),range(0, 1.00, 0.2), fontcolour(white)
  90. rslider bounds(362, 23, 62, 62), text("Trem.Dep."), colour(SlateGrey) channel("TremDep"),range(0, 0.5, 0.3), fontcolour(white)
  91. rslider bounds(422, 23, 62, 62), text("Tone Dep."), colour(SlateGrey) channel("ToneDep"),range(0, 4.00, 0), fontcolour(white)
  92. }
  93. ;NOISE
  94. image bounds(580,101,125, 90), colour("DarkSlateGrey"), outline("white"), line(2), shape("sharp"), plant("noise"){ ;NOISE
  95. label bounds( 40, 5,100, 15), text("Noise"), fontcolour(white)
  96. rslider bounds( 2, 23, 62, 62), text("Depth"), colour(SlateGrey) channel("NoiseAmp"),range(0,300.00, 0, 1, 0.0001), fontcolour(white)
  97. rslider bounds( 62, 23, 62, 62), text("Damp"), colour(SlateGrey) channel("NoiseDamp"),range(15, 10000, 1000, 0.5, 0.01), fontcolour(white)
  98. }
  99. keyboard pos(0, 295), size(875, 80)
  100. </Cabbage>
  101. <CsoundSynthesizer>
  102. <CsOptions>
  103. -dm0 -n -+rtmidi=null -M0
  104. </CsOptions>
  105. <CsInstruments>
  106. sr = 44100
  107. ksmps = 16
  108. nchnls = 2
  109. 0dbfs = 1 ;MAXIMUM AMPLITUDE
  110. seed 0
  111. massign 0,2
  112. ;Author: Iain McCurdy (2012)
  113. gicos ftgen 0,0,131072,9,1,1,90 ;FUNCTION TABLE THAT STORES A SINGLE CYCLE OF A COSINE WAVE
  114. gisine ftgen 0,0,131072,10,1 ;A SINE WAVE. USED BY THE LFOs.
  115. giwave ftgen 999,0,131073,10,1,0,1 ;USER WAVEFORM
  116. gasendL,gasendR init 0
  117. ;FUNCTION TABLE USED TO RE-MAP THE RELATIONSHIP BETWEEN VELOCITY AND ATTACK TIME
  118. giattscl ftgen 0,0,128,-16,2,128,-10,0.005
  119. giNAttScl ftgen 0,0,128,-16,8,128,-4,0.25
  120. gkactive init 0 ; Will contain number of active instances of instr 3 when legato mode is chosen. NB. notes in release stage will not be regarded as active.
  121. opcode FreqShifter,a,aki
  122. ain,kfshift,ifn xin ;READ IN INPUT ARGUMENTS
  123. areal, aimag hilbert ain ;HILBERT OPCODE OUTPUTS TWO PHASE SHIFTED SIGNALS, EACH 90 OUT OF PHASE WITH EACH OTHER
  124. asin oscili 1, kfshift, ifn, 0
  125. acos oscili 1, kfshift, ifn, 0.25
  126. ;RING MODULATE EACH SIGNAL USING THE QUADRATURE OSCILLATORS AS MODULATORS
  127. amod1 = areal * acos
  128. amod2 = aimag * asin
  129. ;UPSHIFTING OUTPUT
  130. aFS = (amod1 - amod2)
  131. xout aFS ;SEND AUDIO BACK TO CALLER INSTRUMENT
  132. endop
  133. opcode SsplinePort,k,KkkO ;DEFINE OPCODE
  134. knum,kporttime,kcurve,iopt xin ;READ IN INPUT ARGUMENTS
  135. kout init i(knum) ;INITIALISE TO OUTPUT VALUE (PORTAMENTO APPLIED VALUE)
  136. ktrig changed knum ;...GENERATE A TRIGGER IS A NEW NOTE NUMBER IS GENERATED (FROM INSTR. 1)
  137. if ktrig=1 then ;IF A NEW (LEGATO) NOTE HAS BEEN PRESSED
  138. reinit S_CURVE ;BEGIN A REINITIALISATION PASS FROM LABEL
  139. endif ;END OF CONDITIONAL BRANCH
  140. S_CURVE: ;A LABEL. REINITIALISATION BEGINS FROM HERE.
  141. if iopt!=0 then ;IF ABSOLUTE/PROPORTIONAL SWITCH IS ON... (I.E. PROPORTIONAL)
  142. idiff = 1+abs(i(knum)-i(kout)) ;ABSOLUTE DIFFERENCE BETWEEN OLD NOTE AND NEW NOTE IN STEPS (+ 1)
  143. kporttime = kporttime*idiff ;SCALE PORTAMENTO TIME ACCORDING TO THE NOTE GAP
  144. endif ;END OF CONDITIONAL BRANCH
  145. imid = i(kout)+((i(knum)-i(kout))/2) ;SPLINE MID POINT VALUE
  146. isspline ftgentmp 0,0,4096,-16,i(kout),4096*0.5,i(kcurve),imid,(4096/2)-1,-i(kcurve),i(knum) ;GENERATE 'S' SPLINE
  147. kspd = i(kporttime)/kporttime ;POINTER SPEED AS A RATIO (WITH REFERENCE TO THE ORIGINAL DURATION)
  148. kptr init 0 ;POINTER INITIAL VALUE
  149. kout tablei kptr,isspline ;READ VALUE FROM TABLE
  150. kptr limit kptr+((ftlen(isspline)/(i(kporttime)*kr))*kspd), 0, ftlen(isspline)-1 ;INCREMENT THE POINTER BY THE REQUIRED NUMBER OF TABLE POINTS IN ONE CONTROL CYCLE AND LIMIT IT BETWEEN FIRST AND LAST TABLE POINT - FINAL VALUE WILL BE HELD IF POINTER ATTEMPTS TO EXCEED TABLE DURATION
  151. rireturn ;RETURN FROM REINITIALISATION PASS
  152. xout kout ;SEND PORTAMENTOED VALUES BACK TO CALLER INSTRUMENT
  153. endop
  154. instr 1 ; read in widgets
  155. kporttime linseg 0,0.001,0.05
  156. gkmul chnget "mul"
  157. gklh chnget "lh"
  158. gknh chnget "nh"
  159. gkjitter chnget "jitter"
  160. gkwaveform chnget "waveform"
  161. gkoctave chnget "octave"
  162. gkpart1 chnget "part1"
  163. gkpart2 chnget "part2"
  164. gkpart3 chnget "part3"
  165. gkpart4 chnget "part4"
  166. gkpart5 chnget "part5"
  167. gkpart6 chnget "part6"
  168. gkpart7 chnget "part7"
  169. gkpart8 chnget "part8"
  170. gkpart9 chnget "part9"
  171. gkpart10 chnget "part10"
  172. gkpart11 chnget "part11"
  173. gkpart12 chnget "part12"
  174. ktrig changed gkpart1,gkpart2,gkpart3,gkpart4,gkpart5,gkpart6,gkpart7,gkpart8,gkpart9,gkpart10,gkpart11,gkpart12
  175. if ktrig==1 then
  176. reinit USER_WAVEFORM
  177. endif
  178. USER_WAVEFORM:
  179. giwave ftgen 999,0,131073,10,i(gkpart1),i(gkpart2),i(gkpart3),i(gkpart4),i(gkpart5),i(gkpart6),i(gkpart7),i(gkpart8),i(gkpart9),i(gkpart10),i(gkpart11),i(gkpart12) ;USER WAVEFORM
  180. rireturn
  181. gkmonopoly chnget "monopoly"
  182. printk2 gkmonopoly
  183. gkLegTim chnget "LegTim"
  184. gkPortMode chnget "PortMode"
  185. gkpan chnget "pan"
  186. gklevel chnget "level"
  187. gkRvbMix chnget "RvbMix"
  188. gkRvbSize chnget "RvbSize"
  189. gkMAtt chnget "MAtt" ; multiplier envelope
  190. gkMLev chnget "MLev"
  191. gkMDec chnget "MDec"
  192. gkMSus chnget "MSus"
  193. gkMRel chnget "MRel"
  194. gkAAtt chnget "AAtt" ; amplitude envelope
  195. gkALev chnget "ALev"
  196. gkADec chnget "ADec"
  197. gkASus chnget "ASus"
  198. gkARel chnget "ARel"
  199. gkLowCutOnOff chnget "LowCutOnOff"
  200. gkLowCut chnget "LowCut"
  201. gkLowPoles chnget "LowPoles"
  202. gkHighCutOnOff chnget "HighCutOnOff"
  203. gkHighCut chnget "HighCut"
  204. gkHighPoles chnget "HighPoles"
  205. gkmod chnget "mod" ; modulation
  206. gkVDel chnget "VDel"
  207. gkVRis chnget "VRis"
  208. gkVRate chnget "VRate"
  209. gkVRatRnd chnget "VRatRnd"
  210. gkVibDep chnget "VibDep"
  211. gkTremDep chnget "TremDep"
  212. gkToneDep chnget "ToneDep"
  213. gkNoiseAmp chnget "NoiseAmp" ; noise
  214. gkNoiseDamp chnget "NoiseDamp"
  215. gkBendDown chnget "BendDown"
  216. gkBendUp chnget "BendUp"
  217. gkBendRange chnget "BendRange"
  218. gkPchBend portk (gkBendDown+gkBendUp)*gkBendRange, kporttime
  219. endin
  220. instr 2 ;triggered via MIDI
  221. gkNoteTrig init 1 ;at the beginning of a new note set note trigger flag to '1'
  222. inum notnum ;read in midi note number
  223. givel veloc 0,1 ;read in midi note velocity
  224. gknum = inum ;update a global krate variable for note pitch
  225. ;============================================================================================================================================================
  226. if i(gkmonopoly)==0 then ; if we are *not* in legato mode...
  227. ; METHOD 1: calling sub-instruments using event_1, fractional p1s and turnoff2s. (problematic on windows)
  228. ; event_i "i",p1+1+(inum*0.001),0,-1,inum ; call sound producing instr
  229. ;krel release ; release flag (1 when note is released, 0 otherwise)
  230. ;if krel==1 then ; when note is released...
  231. ; turnoff2 p1+1+(inum*0.001),4,1 ; turn off the called instrument
  232. ;endif ; end of conditional
  233. ; METHOD 2: using subinstr (problematic on windows and mac)
  234. ;a1,a2 subinstr 3,inum
  235. ; outs a1,a2
  236. ; METHOD 3: all instr code within the same instrument (the safest option on windows and mac, if rather inelegant)
  237. kporttime linseg 0,0.001,1 ;portamento time function rises quickly from zero to a held value
  238. kglisstime = kporttime*gkLegTim ;scale portamento time function with value from GUI knob widget
  239. /* MODULATION */
  240. krate randomi gkVRate-gkVRatRnd,gkVRate+gkVRatRnd,1,1
  241. kModRise linseg 0,i(gkVDel)+0.0001, 0, i(gkVRis)+0.0001, 1
  242. kmod lfo gkmod*kModRise,krate,0
  243. kporttime linseg 0,0.001,1 ;CREATE A FUNCTION THAT RISES RAPIDLY FROM ZERO TO A FIXED VALUE THAT WILL BE USED FOR PORTAMENTO TIME
  244. ;------------------------------------------------------------------------------------------------------------
  245. ;PITCH JITTER (THIS WILL BE USED TO ADD HUMAN-PLAYER REALISM)
  246. ;------------------------------------------------------------------------------------------------------------
  247. ; AMP | MIN_FREQ. | MAX_FREQ
  248. kPitchJit jitter 0.05*gkjitter*4, 1, 20
  249. ;------------------------------------------------------------------------------------------------------------
  250. ;AMPLITUDE JITTER (THIS WILL BE USED TO ADD HUMAN-PLAYER REALISM)
  251. ;------------------------------------------------------------------------------------------------------------
  252. ; AMP | MIN_FREQ. | MAX_FREQ
  253. kAmpJit jitter 0.1*gkjitter*4, 0.2, 1
  254. kAmpJit = kAmpJit+1 ;OFFSET SO IT MODULATES ABOUT '1' INSTEAD OF ABOUT ZERO
  255. knum = inum+kPitchJit ;DERIVE K-RATE NOTE NUMBER VALUE INCORPORATING PITCH BEND, VIBRATO, AND PITCH JITTER
  256. /* OSCILLATOR */
  257. kmul portk gkmul, kporttime*0.1
  258. ;kMulEnv linsegr 0, i(gkMAtt)+0.0001, i(gkMLev), i(gkMDec)+0.0001, i(gkMSus), i(gkMRel)+0.0001, 0
  259. kMulEnv expsegr 0.001, i(gkMAtt)+0.0001, i(gkMLev)+0.001, i(gkMDec)+0.0001, i(gkMSus)+0.001, i(gkMRel)+0.0001, 0.001
  260. kMulEnv = kMulEnv + 0.001 ; offset
  261. kmul = kmul+kMulEnv+(kmod*gkToneDep)
  262. kmul limit kmul,0,0.9
  263. knum = knum + gkPchBend + (kmod*gkVibDep)
  264. ifn = ( i(gkwaveform) < 3 ? (gicos+i(gkwaveform)-1) : giwave)
  265. knum = knum+(gkoctave*12)
  266. asig gbuzz (kAmpJit*0.1)*(1+(kmod*gkTremDep*0.9)), cpsmidinn(knum), gknh, gklh, kmul, ifn;gicos+i(gkwaveform)-1
  267. /* NOISE */
  268. kNoiseAmp expcurve kmul,40
  269. kNoiseAmp scale kNoiseAmp,2,0.1
  270. anoise gauss kNoiseAmp*gkNoiseAmp
  271. anoise butlp anoise,gkNoiseDamp
  272. asig = asig * (1+anoise)
  273. /* LOW CUT / HIGH CUT FILTERS */
  274. ;FILTER
  275. if gkLowCutOnOff=1 then
  276. kLowCut portk gkLowCut,kporttime*0.1
  277. kLowCut limit cpsmidinn(knum)*kLowCut,20,sr/2
  278. ktrig changed gkLowPoles
  279. if ktrig=1 then
  280. reinit RESTART_LOWCUT
  281. endif
  282. RESTART_LOWCUT:
  283. asig clfilt asig,kLowCut,1,i(gkLowPoles)
  284. rireturn
  285. endif
  286. if gkHighCutOnOff=1 then
  287. kHighCut portk gkHighCut,kporttime*0.1
  288. kHighCut limit cpsmidinn(knum)*kHighCut,20,sr/2
  289. ktrig changed gkHighPoles
  290. if ktrig=1 then
  291. reinit RESTART_HIGHCUT
  292. endif
  293. RESTART_HIGHCUT:
  294. asig clfilt asig,kHighCut,0,i(gkHighPoles)
  295. rireturn
  296. endif
  297. aenv linsegr 0,i(gkAAtt)+0.0001,i(gkALev),i(gkADec),i(gkASus),i(gkARel),0 ;AMPLITUDE ENVELOPE
  298. asig = asig * aenv
  299. klevel portk gklevel,kporttime*0.1
  300. kpan portk gkpan,kporttime*0.1
  301. kRvbMix portk gkRvbMix,kporttime*0.1
  302. aL,aR pan2 asig*klevel,kpan ;scale amplitude level and create stereo panned signal
  303. outs aL*(1-gkRvbSize), aR*(1-gkRvbSize) ;SEND AUDIO TO THE OUTPUTS
  304. gasendL = gasendL+aL*kRvbMix
  305. gasendR = gasendR+aR*kRvbMix
  306. ;============================================================================================================================================================
  307. else ;otherwise... (i.e. legato mode)
  308. ;iactive active p1+1 ;check to see if there is already a note active...
  309. iactive = i(gkactive) ;number of active notes of instr 3 (note in release are disregarded)
  310. if iactive==0 then ;...if no notes are active
  311. event_i "i",p1+1,0,-1 ;...start a new held note
  312. endif
  313. endif
  314. endin
  315. instr 3 ;gbuzz instrument. MIDI notes are directed here.
  316. kporttime linseg 0,0.001,1 ;portamento time function rises quickly from zero to a held value
  317. kglisstime = kporttime*gkLegTim ;scale portamento time function with value from GUI knob widget
  318. /* MODULATION */
  319. krate randomi gkVRate-gkVRatRnd,gkVRate+gkVRatRnd,1,1
  320. if gkNoteTrig==1 then
  321. reinit RESTART_MOD_ENV
  322. endif
  323. RESTART_MOD_ENV:
  324. kModRise linseg 0,i(gkVDel)+0.0001, 0, i(gkVRis)+0.0001, 1
  325. kmod lfo gkmod*kModRise,krate,0
  326. rireturn
  327. gkNoteTrig = 0 ;reset new-note trigger (in case it was '1')
  328. if i(gkmonopoly)==1 then ;if we are in legato mode...
  329. krel release ;sense when note has been released
  330. gkactive = 1-krel ;if note is in release, gkactive=0, otherwise =1
  331. knum SsplinePort gknum,kglisstime,1,i(gkPortMode)-1
  332. kactive active p1-1 ;...check number of active midi notes (previous instrument)
  333. if kactive==0 then ;if no midi notes are active...
  334. turnoff ;... turn this instrument off
  335. endif
  336. else ;otherwise... (polyphonic / non-legato mode)
  337. knum = p4 ;pitch equal to the original note pitch
  338. endif
  339. ivel init givel
  340. ;------------------------------------------------------------------------------------------------------------
  341. ;PITCH JITTER (THIS WILL BE USED TO ADD HUMAN-PLAYER-LIKE INSTABILITY)
  342. ;------------------------------------------------------------------------------------------------------------
  343. ; AMP | MIN_FREQ. | MAX_FREQ
  344. kPitchJit jitter 0.05*gkjitter*4, 1, 20
  345. ;------------------------------------------------------------------------------------------------------------
  346. ;AMPLITUDE JITTER (THIS WILL BE USED TO ADD HUMAN-PLAYER-LIKE INSTABILITY)
  347. ;------------------------------------------------------------------------------------------------------------
  348. ; AMP | MIN_FREQ. | MAX_FREQ
  349. kAmpJit jitter 0.1*gkjitter*4, 0.2, 1
  350. kAmpJit = kAmpJit+1 ;OFFSET SO IT MODULATES ABOUT '1' INSTEAD OF ABOUT ZERO
  351. knum = knum+kPitchJit ;DERIVE K-RATE NOTE NUMBER VALUE INCORPORATING PITCH BEND, VIBRATO, AND PITCH JITTER
  352. /* OSCILLATOR */
  353. kmul portk gkmul, kporttime*0.1
  354. ;kMulEnv linsegr 0, i(gkMAtt)+0.0001, i(gkMLev), i(gkMDec)+0.0001, i(gkMSus), i(gkMRel)+0.0001, 0
  355. kMulEnv expsegr 0.001, i(gkMAtt)+0.0001, i(gkMLev)+0.001, i(gkMDec)+0.0001, i(gkMSus)+0.001, i(gkMRel)+0.0001, 0.001
  356. kMulEnv = kMulEnv + 0.001 ; offset
  357. kmul = kmul+kMulEnv+(kmod*gkToneDep)
  358. kmul limit kmul,0,0.9
  359. knum = knum + gkPchBend + (kmod*gkVibDep)
  360. ifn = ( i(gkwaveform) < 3 ? (gicos+i(gkwaveform)-1) : giwave)
  361. asig gbuzz (kAmpJit*0.1)*(1+(kmod*gkTremDep*0.9)), cpsmidinn(knum+(gkoctave*12)), gknh, gklh, kmul, ifn;gicos+i(gkwaveform)-1
  362. /* NOISE */
  363. kNoiseAmp expcurve kmul,40
  364. kNoiseAmp scale kNoiseAmp,2,0.1
  365. anoise gauss kNoiseAmp*gkNoiseAmp
  366. anoise butlp anoise,gkNoiseDamp
  367. asig = asig * (1+anoise)
  368. /* LOW CUT / HIGH CUT FILTERS */
  369. ;FILTER
  370. if gkLowCutOnOff=1 then
  371. kLowCut portk gkLowCut,kporttime*0.1
  372. kLowCut limit cpsmidinn(knum)*kLowCut,20,sr/2
  373. ktrig changed gkLowPoles
  374. if ktrig=1 then
  375. reinit RESTART_LOWCUT
  376. endif
  377. RESTART_LOWCUT:
  378. asig clfilt asig,kLowCut,1,i(gkLowPoles)
  379. endif
  380. if gkHighCutOnOff=1 then
  381. kHighCut portk gkHighCut,kporttime*0.1
  382. kHighCut limit cpsmidinn(knum)*kHighCut,20,sr/2
  383. ktrig changed gkHighPoles
  384. if ktrig=1 then
  385. reinit RESTART_HIGHCUT
  386. endif
  387. RESTART_HIGHCUT:
  388. asig clfilt asig,kHighCut,0,i(gkHighPoles)
  389. rireturn
  390. endif
  391. aenv linsegr 0,i(gkAAtt)+0.0001,i(gkALev),i(gkADec),i(gkASus),i(gkARel),0 ;AMPLITUDE ENVELOPE
  392. asig = asig * aenv
  393. klevel portk gklevel,kporttime*0.1
  394. kpan portk gkpan,kporttime*0.1
  395. kRvbMix portk gkRvbMix,kporttime*0.1
  396. aL,aR pan2 asig*klevel,kpan ;scale amplitude level and create stereo panned signal
  397. outs aL*(1-gkRvbSize), aR*(1-gkRvbSize) ;SEND AUDIO TO THE OUTPUTS
  398. gasendL = gasendL+aL*kRvbMix
  399. gasendR = gasendR+aR*kRvbMix
  400. endin
  401. instr 5 ;reverb
  402. if gkRvbMix==0 kgoto SKIP_REVERB
  403. aL,aR reverbsc gasendL,gasendR,gkRvbSize,12000
  404. outs aL,aR
  405. clear gasendL,gasendR
  406. SKIP_REVERB:
  407. endin
  408. </CsInstruments>
  409. <CsScore>
  410. i 1 0 3600 ; read widgets
  411. i 5 0 3600 ; reverb
  412. f 0 3600
  413. </CsScore>
  414. </CsoundSynthesizer>