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.

363 lines
14KB

  1. hsboscil_synth.csd
  2. Synthesizer is divided into seven panels.
  3. Amplitude
  4. ---------
  5. Amp - amplitude control
  6. Att. - amplitude envelope attack time
  7. Dec. - amplitude envelope decay time
  8. Sus. - amplitude envelope sustain level
  9. Rel. - amplitude envelope release time
  10. Mod.Shape- shape used for amplitude modulation (tremolo). Choose from sine shaped, random splines, random sample and hold (randomh) or square wave.
  11. Rate - rate of amplitude LFO (tremolo)
  12. Depth - depth of amplitude LFO
  13. Delay - delay time before amplitude LFO begins
  14. Rise - time over which amplitude LFO depth rises from zero to its prescribed value
  15. Brightness - brightness is really just a description of where the emphasis is in the stack of octave spaced tones that hsboscil produces
  16. ----------
  17. Brite - manual brightness control
  18. Vel. - amount of velocity to brightness control
  19. Att. - brightness envelope attack time
  20. Att.Lev - brightness envelope attack level
  21. Dec. - brightness envelope decay time
  22. Sus. - brightness envelope sustain level
  23. Rel. - brightness envelope release time
  24. Rel.Lev - brightness envelope release level
  25. Oct.Cnt.- Number of octave spaced partials in a tone
  26. Mod.Shape- shape used for brightness modulation. Choose from sine shaped, random splines, random sample and hold (randomh) or square wave.
  27. Rate - rate of brightness LFO
  28. Depth - depth of brightness LFO
  29. Delay - delay time before brightness LFO begins
  30. Rise - time over which brightness LFO depth rises from zero to its prescribed value
  31. Noise - interpolated gaussian modulation is applied to the pitch (tone) parameter which, at high rates/frequencies results in the addition of a noise component in the tone
  32. -----
  33. Rate - rate/frequency of noise modulation
  34. Depth - depth of noise modulation
  35. Reverb - the screverb opcode is used
  36. ------
  37. Mix - amount of reverb that is mixed into the output. When mix is zero the effect is bypassed.
  38. Size - size of the virtual space created by the reverb effect
  39. Pitch Modulation - modulation of the tone (pitch) parameter. This will be at a much slower rate than that applied using the 'noise' function
  40. ----------------
  41. Mod.Shape- shape used for pitch modulation. Choose from sine shaped, random splines, random sample and hold (randomh) or square wave.
  42. Rate - rate of pitch modulation LFO
  43. Depth - depth of pitch modulation LFO
  44. Delay - delay time before pitch modulation LFO begins
  45. Rise - time over which pitch modulation LFO depth rises from zero to its prescribed value
  46. Freq.Shift - a frequency shifting effect
  47. ----------
  48. Freq. - frequency by which the signal will be shifted
  49. Chorus - a stereo chorus effect. Two chorus voices are created which the panning of which is modulated randomly. Delay time/pitch modulations are random rather than cyclical.
  50. ------
  51. Mix - Amount of chorussed signal that is mixed into the output
  52. Depth - Depth of modualtion used in the chorus effect
  53. Rate - Rate of modulation used in the chorus effect
  54. <Cabbage>
  55. form caption("hsboscil Synth") size(590, 480), pluginID("hsbo")
  56. snapshot bounds( 5,455,200, 20), preset("hsboscil"), master(1), items("Preset 1", "Preset 2", "Preset 3", "Preset 4", "Preset 5", "Preset 6", "Preset 7", "Preset 8", "Preset 9", "Preset 10")
  57. ;AMPLITUDE
  58. groupbox bounds(0, 0, 590, 100), colour( 10, 15, 30, 100) text("Amplitude"), fontcolour(255,0,0){
  59. rslider bounds( 5, 30, 60, 60), text("Amp."), channel("amp"), range(0, 1, 0.3)
  60. line bounds( 65, 30, 2, 60), colour("DarkSlateGrey")
  61. rslider bounds( 70, 30, 60, 60), text("Att."), channel("AAtt"), range( 0, 8.00, 0.3,0.5)
  62. rslider bounds(120, 30, 60, 60), text("Dec."), channel("ADec"), range( 0, 8.00, 0.01,0.5)
  63. rslider bounds(170, 30, 60, 60), text("Sus."), channel("ASus"), range( 0, 1.00, 0.5,0.5)
  64. rslider bounds(220, 30, 60, 60), text("Rel."), channel("ARel"), range(0.01, 8, 0.3,0.5)
  65. line bounds(285, 30, 2, 60), colour("DarkSlateGrey")
  66. label bounds(305, 35, 70, 12), text("Mod.Shape")
  67. combobox bounds(300, 50, 70, 20), channel("amplfo"), value(2), text("sine", "splines", "S+H", "square")
  68. rslider bounds(375, 30, 60, 60), text("Rate"), channel("ARte"), range(0, 16.0, 4)
  69. rslider bounds(425, 30, 60, 60), text("Depth"), channel("ADep"), range(0, 1.00, 1)
  70. rslider bounds(475, 30, 60, 60), text("Delay"), channel("ADel"), range(0, 2.00, 0, 0.5)
  71. rslider bounds(525, 30, 60, 60), text("Rise"), channel("ARis"), range(0, 2.00, 0.1, 0.5)
  72. }
  73. ;BRIGHTNESS
  74. groupbox bounds(0, 100,450,170), colour( 6, 18, 22, 100), text("Brightness"), fontcolour(205,10,10){
  75. rslider bounds( 5,135, 60, 60), text("Brite"), channel("brite"), range(-6, 6.00, -2)
  76. rslider bounds( 5,200, 60, 60), text("Vel."), channel("BVelDep"), range(0, 6.00, 3)
  77. rslider bounds( 65,135, 60, 60), text("Oct.Cnt."), channel("octcnt"), range(2, 20, 3, 1, 1)
  78. line bounds(130,127, 2, 60), colour("DarkSlateGrey")
  79. rslider bounds(135,135, 60, 60), text("Att."), channel("BAtt"), range(0, 8.00, 0.1,0.5)
  80. rslider bounds(185,135, 60, 60), text("Att.Lev."), channel("BAttLev"), range(-6.00, 6, 1)
  81. rslider bounds(235,135, 60, 60), text("Dec."), channel("BDec"), range(0, 8.00, 0.1,0.5)
  82. rslider bounds(285,135, 60, 60), text("Sus."), channel("BSus"), range(-6, 6.00, 0)
  83. rslider bounds(335,135, 60, 60), text("Rel."), channel("BRel"), range(0, 8.00, 0.01,0.5)
  84. rslider bounds(385,135, 60, 60), text("Rel.Lev."), channel("BRelLev"), range(-4.00, 4, 0)
  85. line bounds( 90,200, 2, 60), colour("DarkSlateGrey")
  86. label bounds(120,205, 70, 12), text("Mod.Shape")
  87. combobox bounds(115,220, 70, 20), channel("britelfo"), value(2), text("sine", "splines", "S+H", "square")
  88. rslider bounds(185,200, 60, 60), text("Rate"), channel("BRte"), range(0, 30.0, 4)
  89. rslider bounds(235,200, 60, 60), text("Depth"), channel("BDep"), range(0, 6.00, 2)
  90. rslider bounds(285,200, 60, 60), text("Delay"), channel("BDel"), range(0, 2.00, 0.5, 0.5)
  91. rslider bounds(335,200, 60, 60), text("Rise"), channel("BRis"), range(0, 4.00, 1.5, 0.5)
  92. }
  93. ;NOISE
  94. groupbox bounds(450, 100, 70,170), colour( 20, 7, 19, 100), text("Noise"), fontcolour(255,40,60){
  95. rslider bounds(455, 135, 60, 60), text("Rate"), channel("NRte"), range(16,10000, 1000, 0.5)
  96. rslider bounds(455, 200, 60, 60), text("Depth"), channel("NDep"), range(0, 1.00, 0.05, 0.5)
  97. }
  98. ;REVERB
  99. groupbox bounds(520, 100, 70,170), colour( 3, 25, 11, 100), text("Reverb"), fontcolour(255,0,100){
  100. rslider bounds(525,135, 60, 60), text("Mix"), channel("RvbMix"), range(0, 1.00, 0.3)
  101. rslider bounds(525,200, 60, 60), text("Size"), channel("RvbSize"), range(0, 1.00, 0.82)
  102. }
  103. ;PITCH MOD.
  104. groupbox bounds( 0,270,350,100), colour( 20, 25, 40, 100), text("Pitch Modulation"), fontcolour(255,100,0){
  105. label bounds( 15,305, 65, 12), text("Mod.Shape")
  106. combobox bounds( 10,320, 65, 20), channel("pitchlfo"), value(1), text("sine", "splines", "S+H", "square")
  107. rslider bounds( 80,300, 60, 60), text("Rate"), channel("PRte"), range(0, 16.00, 0, 0.5)
  108. rslider bounds(130,300, 60, 60), text("Depth"), channel("PDep"), range(0, 1.00, 0)
  109. rslider bounds(180,300, 60, 60), text("Delay"), channel("PDel"), range(0, 2.00, 0, 0.5)
  110. rslider bounds(230,300, 60, 60), text("Rise"), channel("PRis"), range(0, 2.00, 0.1, 0.5)
  111. rslider bounds(280,300, 60, 60), text("Risset"), channel("TRate"), range(-3.00, 3, 0)
  112. }
  113. ;FREQ. SHIFT
  114. groupbox bounds(350,270, 70,100), colour( 20, 5, 25, 100), text("Freq.Shift"), fontcolour(200,0,0){
  115. rslider bounds(355,300, 60, 60), text("Freq."), channel("FShift"), range(-1000, 1000, -1000)
  116. }
  117. ;CHORUS
  118. groupbox bounds(420,270,170,100), colour( 3, 10, 13, 100), text("Chorus"), fontcolour(255,200,0){
  119. rslider bounds(425,300, 60, 60), text("Mix"), channel("ChoMix"), range(0, 1.00, 1)
  120. rslider bounds(475,300, 60, 60), text("Depth"), channel("ChoDep"), range(0, 0.100, 0.01,0.5,0.0001)
  121. rslider bounds(525,300, 60, 60), text("Rate"), channel("ChoRte"), range(0, 20.0, 4, 0.5)
  122. }
  123. keyboard pos(0, 370), size(590, 80)
  124. }
  125. image bounds(290, 455, 210, 20), colour(75, 85, 90, 100), plant("credit"){
  126. label bounds(0.03, 0.15, .9, .7), text("Author: Iain McCurdy |2012|"), colour("white")
  127. </Cabbage>
  128. <CsoundSynthesizer>
  129. <CsOptions>
  130. -dm0 -n -+rtmidi=null -M0
  131. </CsOptions>
  132. <CsInstruments>
  133. sr = 44100 ;SAMPLE RATE
  134. ksmps = 32 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE. HIGHER ksmps can result in quantisation noise in kbrite modulations.
  135. nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
  136. 0dbfs = 1
  137. seed 0
  138. massign 0,2
  139. ;Author: Iain McCurdy (2012)
  140. gisine ftgen 0,0,4096,10,1
  141. giwfn ftgen 0, 0, 131072, 10, 1 ;A SINE WAVE
  142. gioctfn ftgen 0, 0, 1024, -19, 1, 0.5, 270, 0.5 ;A HANNING-TYPE WINDOW
  143. gasendL,gasendR init 0
  144. opcode FreqShifter,a,aki
  145. ain,kfshift,ifn xin ;READ IN INPUT ARGUMENTS
  146. areal, aimag hilbert ain ;HILBERT OPCODE OUTPUTS TWO PHASE SHIFTED SIGNALS, EACH 90 OUT OF PHASE WITH EACH OTHER
  147. asin oscili 1, kfshift, ifn, 0
  148. acos oscili 1, kfshift, ifn, 0.25
  149. ;RING MODULATE EACH SIGNAL USING THE QUADRATURE OSCILLATORS AS MODULATORS
  150. amod1 = areal * acos
  151. amod2 = aimag * asin
  152. ;UPSHIFTING OUTPUT
  153. aFS = (amod1 - amod2)
  154. xout aFS ;SEND AUDIO BACK TO CALLER INSTRUMENT
  155. endop
  156. instr 1 ;read in widgets
  157. gkamplfo chnget "amplfo"
  158. gkbritelfo chnget "britelfo"
  159. gkChoMix chnget "ChoMix"
  160. gkChoDep chnget "ChoDep"
  161. gkChoRte chnget "ChoRte"
  162. gkRvbMix chnget "RvbMix"
  163. gkRvbSize chnget "RvbSize"
  164. gkFShift chnget "FShift"
  165. gkNRte chnget "NRte"
  166. gkNDep chnget "NDep"
  167. gkpitchlfo chnget "pitchlfo"
  168. gkPDel chnget "PDel"
  169. gkPRis chnget "PRis"
  170. gkPRte chnget "PRte"
  171. gkPDep chnget "PDep"
  172. endin
  173. instr 2 ;hsboscil instrument. MIDI notes are directed here.
  174. kporttime linseg 0,0.001,0.01 ;PORTAMENTO TIME VALUE RISES QUICKLY FROM ZERO TO A HELD VALUE
  175. kamp chnget "amp" ;READ WIDGETS...
  176. iAAtt chnget "AAtt" ;
  177. iADec chnget "ADec" ;
  178. iASus chnget "ASus" ;
  179. iARel chnget "ARel" ;
  180. aenv linsegr 0.001,iAAtt+0.001,1,iADec+0.001,iASus,iARel+0.001,0.001 ;AMPLITUDE ENVELOPE
  181. iADel chnget "ADel" ;
  182. iARis chnget "ARis" ;
  183. kADep chnget "ADep" ;
  184. kARte chnget "ARte" ;
  185. kbrite chnget "brite" ;
  186. kbrite portk kbrite,kporttime
  187. koctcnt chnget "octcnt" ;
  188. iBVelDep chnget "BVelDep" ;
  189. iBAtt chnget "BAtt" ;
  190. iBAttLev chnget "BAttLev" ;
  191. iBDec chnget "BDec" ;
  192. iBSus chnget "BSus" ;
  193. iBRel chnget "BRel" ;
  194. iBRelLev chnget "BRelLev" ;
  195. kBEnv linsegr 0,iBAtt+0.001,iBAttLev,iBDec+0.001,iBSus,iBRel+0.001,iBRelLev ;'BRIGHTNESS' ENVELOPE
  196. iBDel chnget "BDel" ;
  197. iBRis chnget "BRis" ;
  198. kBDep chnget "BDep" ;
  199. kBRte chnget "BRte" ;
  200. kTRate chnget "TRate" ;
  201. ibasfreq cpsmidi ;READ MIDI NOTE PITCH
  202. ktrig changed koctcnt ;IF 'NUMBER OF OCTAVES' AS DEFINED BY WIDGET CHANGES GENERATE A TRIGGER
  203. if ktrig==1 then ;IF 'NUMBER OF OCTAVES' CHANGE TRIGGER HAS BEEN GENERATED...
  204. reinit UPDATE ;BEGIN A REINITIALISATION PASS FROM LABEL 'UPDATE'
  205. endif ;END OF CONDITIONAL
  206. UPDATE: ;LABEL 'UPDATE'. REINITIALISATION PASS BEGINS FROM HERE
  207. ;AMPLITUDE LFO
  208. kdepth linseg 0,iADel+0.001,0,iARis+0.001,1 ;DEPTH OF MODULATION ENVELOPE
  209. if gkamplfo==1 then
  210. kALFO lfo (kdepth*kADep)/2,kARte,0 ;LFO (sine)
  211. elseif gkamplfo==2 then
  212. kALFO jspline (kdepth*kADep)/2,kARte,kARte
  213. elseif gkamplfo==3 then
  214. kALFO randomh -(kdepth*kADep)/2,(kdepth*kADep)/2,kARte
  215. kALFO port kALFO,0.001 ;smooth out the clicks
  216. else
  217. kALFO lfo (kdepth*kADep)/2,kARte,2 ;LFO (bi-square)
  218. kALFO port kALFO,0.001 ;smooth out the clicks
  219. endif
  220. kALFO = (kALFO+0.5) + (1 - kADep) ;OFFSET AND RESCALE LFO FUNCTION
  221. ;VELOCITY TO AMPLITUDE
  222. iVelAmp veloc 0.2,1 ;READ IN MIDI NOTE VELOCITY AS A VALUE WITHIN THE RANGE 0.2 TO 1
  223. ;BRIGHTNESS LFO
  224. kdepth linseg 0,iBDel+0.001,0,iBRis+0.001,1 ;DEPTH OF MODULATION ENVELOPE
  225. if gkbritelfo==1 then
  226. kBLFO lfo kdepth*kBDep,kBRte,0 ;LFO (sine)
  227. elseif gkbritelfo==2 then
  228. kBLFO jspline kdepth*kBDep,kBRte,kBRte
  229. elseif gkbritelfo==3 then
  230. kBLFO randomh -kdepth*kBDep,kdepth*kBDep,kBRte
  231. kBLFO port kBLFO,0.004 ;smooth out the clicks
  232. else
  233. kBLFO lfo kdepth*kBDep,kBRte,2 ;LFO (bi-square)
  234. kBLFO port kBLFO,0.004 ;smooth out the clicks
  235. endif
  236. ;VELOCITY TO BRIGHTNESS
  237. iBVel ampmidi iBVelDep ;MIDI NOTE VELOCITY USED TO DERIVE A VALUE THAT WILL INFLUENCE 'BRIGHTNESS'
  238. ;NOISE
  239. knoise gaussi 1, gkNDep, gkNRte
  240. ;RISSET
  241. kRisset lfo 1,kTRate,4 ;'RISSET GLISSANDO' FUNCTION
  242. ;PITCH MODULATION
  243. kPDepth linseg 0,i(gkPDel)+0.001,0,i(gkPRis)+0.001,1 ;DEPTH OF MODULATION ENVELOPE
  244. if gkpitchlfo==1 then
  245. kPLFO lfo gkPDep*kPDepth,gkPRte,0 ;LFO
  246. elseif gkpitchlfo==2 then
  247. kPLFO jspline gkPDep*kPDepth,gkPRte,gkPRte
  248. elseif gkpitchlfo==3 then
  249. kPLFO randomh -gkPDep*kPDepth,gkPDep*kPDepth,gkPRte
  250. kPLFO port kPLFO,0.002 ;smooth out the clicks
  251. else
  252. kPLFO lfo gkPDep*kPDepth,gkPRte,2 ;LFO (bi-square)
  253. kPLFO port kPLFO,0.002 ;smooth out the clicks
  254. endif
  255. aL hsboscil kamp*kALFO*iVelAmp, kPLFO+kRisset+knoise, kbrite+kBEnv+kBLFO+iBVel, ibasfreq, giwfn, gioctfn, i(koctcnt), rnd(1) ;CREATE AN hsboscil TONE FOR THE LEFT CHANNEL. RANDOM INITIAL PHASE CREATE STEREO EFFECT.
  256. aR hsboscil kamp*kALFO*iVelAmp, kPLFO+kRisset+knoise, kbrite+kBEnv+kBLFO+iBVel, ibasfreq, giwfn, gioctfn, i(koctcnt), rnd(1) ;CREATE AN hsboscil TONE FOR THE RIGHT CHANNEL. RANDOM INITIAL PHASE CREATE STEREO EFFECT.
  257. aL = aL*aenv ;APPLY AMPLITUDE ENVELOPE TO AUDIO OUTPUT OF hsboscil
  258. aR = aR*aenv ;APPLY AMPLITUDE ENVELOPE TO AUDIO OUTPUT OF hsboscil
  259. rireturn
  260. /*FREQUENCY SHIFTER*/
  261. if gkFShift==0 kgoto SKIP_FSHIFT ;IF F.SHIFT VALUE = 0, BYPASS THE EFFECT
  262. kFShift portk gkFShift,kporttime
  263. aL FreqShifter aL,kFShift,gisine
  264. aR FreqShifter aR,kFShift,gisine
  265. SKIP_FSHIFT:
  266. outs aL,aR ;SEND AUDIO TO OUTPUTS
  267. gasendL = gasendL+aL
  268. gasendR = gasendR+aR
  269. endin
  270. instr 3 ;Chorus effect
  271. if gkChoMix==0 goto SKIP_CHORUS
  272. kporttime linseg 0,0.001,1
  273. kporttime = kporttime/gkChoRte
  274. kdlt1 randomi ksmps/sr,gkChoDep,gkChoRte,1
  275. kdlt1 portk kdlt1,kporttime
  276. adlt1 interp kdlt1
  277. acho1 vdelay gasendL,adlt1*1000,1*1000
  278. kdlt2 randomi ksmps/sr,gkChoDep,gkChoRte,1
  279. kdlt2 portk kdlt2,kporttime
  280. adlt2 interp kdlt2
  281. acho2 vdelay gasendR,adlt2*1000,1*1000
  282. kpan1 randomi 0,1,gkChoRte,1
  283. kpan2 randomi 0,1,gkChoRte,1
  284. a1L,a1R pan2 acho1,kpan1
  285. a2L,a2R pan2 acho2,kpan2
  286. achoL = a1L+a2L
  287. achoR = a1R+a2R
  288. outs achoL*gkChoMix,achoR*gkChoMix
  289. gasendL = (gasendL+achoL)*gkRvbMix
  290. gasendR = (gasendR+achoR)*gkRvbMix
  291. SKIP_CHORUS:
  292. gasendL = gasendL*gkRvbMix
  293. gasendR = gasendR*gkRvbMix
  294. endin
  295. instr 4 ;reverb
  296. if gkRvbMix==0 goto SKIP_REVERB
  297. aL,aR reverbsc gasendL,gasendR,gkRvbSize,12000
  298. outs aL,aR
  299. SKIP_REVERB:
  300. clear gasendL,gasendR
  301. endin
  302. </CsInstruments>
  303. <CsScore>
  304. i 1 0 [3600*24*7]
  305. i 3 0 [3600*24*7]
  306. i 4 0 [3600*24*7]
  307. </CsScore>
  308. </CsoundSynthesizer>