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.

370 lines
19KB

  1. Choir.csd
  2. Note velocity is interpretted as attack time (along with a slight interpretation as amplitude)
  3. If N.Voices (number of voices) is set to '1' chorussing effect is bypassed, instead a fundemental modulation mechanism is enabled
  4. Vibrato/tremolo depth also controllable using midi controller 1 (mod. wheel), midi channel 1
  5. Vowel is controllable using midi controller 2, midi channel 1
  6. N.Voices value is not strictly speaking accurate: 1 = 1 voice
  7. 2 = 2 voices
  8. 3 = 4 voices
  9. 4 = 6 voices
  10. 5 = 8 voices, this is on account of how the mechanism implements a stereo effect
  11. <Cabbage>
  12. form caption("Choir") size(770, 335), pluginID("choi")
  13. ; main container
  14. image bounds( 0, 0,770, 360), colour(255,100, 0, 40), shape("rounded"), outline("white"), line(3)
  15. ; horizontal stripes
  16. image bounds( 0, 40,770, 75), colour(100,100, 0, 60), shape("sharp")
  17. image bounds( 0,130,770, 35), colour( 0, 0,255, 60), shape("sharp")
  18. ; vertical stripes
  19. image bounds(310, 0, 30, 360), colour( 5,255, 0, 60), shape("sharp")
  20. image bounds(370, 0, 80, 360), colour(255, 0,200, 60), shape("sharp")
  21. image bounds(490, 0, 60, 360), colour( 0,255,200, 60), shape("sharp")
  22. image bounds(560, 0, 40, 360), colour(100, 55,200, 60), shape("sharp")
  23. image bounds(620, 0, 20, 360), colour(255, 55, 0, 60), shape("sharp")
  24. image bounds(660, 0, 90, 360), colour( 5,255,100, 60), shape("sharp")
  25. xypad bounds(10, 10, 250, 210), channel("vowel", "oct"), text("X = Vowel 'AEIOU' : Y = Octave Division"), rangex(0, 1, 0), rangey(0, 4, 0)
  26. combobox bounds(265, 10, 110, 25), channel("voice"), value(5), text("Bass", "Tenor", "Countertenor", "Alto", "Soprano")
  27. button bounds(265, 40, 110, 25), text("monophonic", "polyphonic"), channel("monopoly"), value(1), fontcolour("lime")
  28. rslider bounds(385, 10, 60, 60), text("Leg.Time"), channel("LegTim"), range(0.005, 0.3, 0.025, 0.5, 0.005) ,colour("green"), tracker("white")
  29. rslider bounds(445, 10, 60, 60), text("Vowel"), channel("vowel"), range(0, 1.00, 0) ,colour("green"),midCtrl(1, 2), tracker("white")
  30. rslider bounds(505, 10, 60, 60), text("Level"), channel("lev"), range(0, 1.00, 0.6) ,colour("green"), tracker("white")
  31. rslider bounds(265, 80, 60, 60), text("Vib.Dep."), channel("vibdep"), range(0, 2.00, 0.35) ,colour("tomato"),midCtrl(1, 1), tracker("white")
  32. rslider bounds(325, 80, 60, 60), text("Trem.Dep."), channel("trmdep"), range(0, 1.00, 0.2) ,colour("tomato"),midCtrl(1, 1), tracker("white")
  33. rslider bounds(385, 80, 60, 60), text("Mod.Rate"), channel("modrte"), range(0.10,20, 5, 0.5) ,colour("tomato"), tracker("white")
  34. rslider bounds(445, 80, 60, 60), text("Mod.Delay"), channel("moddel"), range(0, 2.00, 0.3, 0.5) ,colour("tomato"), tracker("white")
  35. rslider bounds(505, 80, 60, 60), text("Mod.Rise"), channel("modris"), range(0, 4.00, 2, 0.5) ,colour("tomato"), tracker("white")
  36. rslider bounds(265,150, 60, 60), text("N.Voices"), channel("nvoices"), range(1, 50, 6, 1, 1) ,colour("yellow"), tracker("white")
  37. rslider bounds(325,150, 60, 60), text("Dtn.Dep."), channel("DtnDep"), range(0, 4.00, 1, 0.5) ,colour("yellow"), tracker("white")
  38. rslider bounds(385,150, 60, 60), text("Dtn.Rate"), channel("DtnRte"), range(0.01,40, 0.2, 0.25) ,colour("yellow"), tracker("white")
  39. rslider bounds(445,150, 60, 60), text("Rvb.Mix"), channel("RvbMix"), range(0, 1.00, 0.15) ,colour("steelblue"), tracker("white")
  40. rslider bounds(505,150, 60, 60), text("Rvb.Size"), channel("RvbSize"), range(0.5, 1.00, 0.82, 2) ,colour("steelblue"), tracker("white")
  41. checkbox bounds(570, 10,190, 20), text("Filter On/Off") channel("FiltOnOff"), colour("lime") value(0)
  42. xypad bounds(570, 35, 190, 185), channel("cf", "bw"), text("x:c.off/y:b.width"), rangex(5, 13, 8), rangey(0.1, 5, 0.3)
  43. keyboard pos(10, 225), size(760, 80)
  44. image bounds(10, 309, 250, 22), colour(75, 85, 90, 100), plant("credit"){
  45. label bounds(0.03, 0.15, .99, .7), text("Author: Iain McCurdy |2012|"), colour("white")
  46. }
  47. </Cabbage>
  48. <CsoundSynthesizer>
  49. <CsOptions>
  50. -dm0 -n -+rtmidi=null -M0
  51. </CsOptions>
  52. <CsInstruments>
  53. sr = 44100
  54. ksmps = 64
  55. nchnls = 2
  56. 0dbfs = 1
  57. massign 0,2
  58. seed 0
  59. ;Author: Iain McCurdy (2012)
  60. gisine ftgen 0, 0, 4096, 10, 1 ;SINE WAVE
  61. giexp ftgen 0, 0, 1024, 19, 0.5, 0.5, 270, 0.5 ;EXPONENTIAL CURVE USED TO DEFINE THE ENVELOPE SHAPE OF FOF PULSES
  62. gasendL,gasendR init 0
  63. ;FUNCTION TABLES STORING DATA FOR VARIOUS VOICE FORMANTS
  64. ;THE FIRST VALUE OF EACH TABLE DEFINES THE NUMBER OF DATA ELEMENTS IN THE TABLE
  65. ;THIS IS NEEDED BECAUSE TABLES SIZES MUST BE POWERS OF 2 TO FACILITATE INTERPOLATED TABLE READING (tablei)
  66. ;BASS
  67. giBF1 ftgen 0, 0, 8, -2, 4, 600, 400, 250, 350 ;FREQ
  68. giBF2 ftgen 0, 0, 8, -2, 4, 1040, 1620, 1750, 600 ;FREQ
  69. giBF3 ftgen 0, 0, 8, -2, 4, 2250, 2400, 2600, 2400 ;FREQ
  70. giBF4 ftgen 0, 0, 8, -2, 4, 2450, 2800, 3050, 2675 ;FREQ
  71. giBF5 ftgen 0, 0, 8, -2, 4, 2750, 3100, 3340, 2950 ;FREQ
  72. giBDb1 ftgen 0, 0, 8, -2, 4, 0, 0, 0, 0 ;dB
  73. giBDb2 ftgen 0, 0, 8, -2, 4, -7, -12, -30, -20 ;dB
  74. giBDb3 ftgen 0, 0, 8, -2, 4, -9, -9, -16, -32 ;dB
  75. giBDb4 ftgen 0, 0, 8, -2, 4, -9, -12, -22, -28 ;dB
  76. giBDb5 ftgen 0, 0, 8, -2, 4, -20, -18, -28, -36 ;dB
  77. giBBW1 ftgen 0, 0, 8, -2, 4, 60, 40, 60, 40 ;BAND WIDTH
  78. giBBW2 ftgen 0, 0, 8, -2, 4, 70, 80, 90, 80 ;BAND WIDTH
  79. giBBW3 ftgen 0, 0, 8, -2, 4, 110, 100, 100, 100 ;BAND WIDTH
  80. giBBW4 ftgen 0, 0, 8, -2, 4, 120, 120, 120, 120 ;BAND WIDTH
  81. giBBW5 ftgen 0, 0, 8, -2, 4, 130, 120, 120, 120 ;BAND WIDTH
  82. ;TENOR
  83. giTF1 ftgen 0, 0, 8, -2, 5, 650, 400, 290, 400, 350 ;FREQ
  84. giTF2 ftgen 0, 0, 8, -2, 5, 1080, 1700, 1870, 800, 600 ;FREQ
  85. giTF3 ftgen 0, 0, 8, -2, 5, 2650, 2600, 2800, 2600, 2700 ;FREQ
  86. giTF4 ftgen 0, 0, 8, -2, 5, 2900, 3200, 3250, 2800, 2900 ;FREQ
  87. giTF5 ftgen 0, 0, 8, -2, 5, 3250, 3580, 3540, 3000, 3300 ;FREQ
  88. giTDb1 ftgen 0, 0, 8, -2, 5, 0, 0, 0, 0, 0 ;dB
  89. giTDb2 ftgen 0, 0, 8, -2, 5, -6, -14, -15, -10, -20 ;dB
  90. giTDb3 ftgen 0, 0, 8, -2, 5, -7, -12, -18, -12, -17 ;dB
  91. giTDb4 ftgen 0, 0, 8, -2, 5, -8, -14, -20, -12, -14 ;dB
  92. giTDb5 ftgen 0, 0, 8, -2, 5, -22, -20, -30, -26, -26 ;dB
  93. giTBW1 ftgen 0, 0, 8, -2, 5, 80, 70, 40, 40, 40 ;BAND WIDTH
  94. giTBW2 ftgen 0, 0, 8, -2, 5, 90, 80, 90, 80, 60 ;BAND WIDTH
  95. giTBW3 ftgen 0, 0, 8, -2, 5, 120, 100, 100, 100, 100 ;BAND WIDTH
  96. giTBW4 ftgen 0, 0, 8, -2, 5, 130, 120, 120, 120, 120 ;BAND WIDTH
  97. giTBW5 ftgen 0, 0, 8, -2, 5, 140, 120, 120, 120, 120 ;BAND WIDTH
  98. ;COUNTER TENOR
  99. giCTF1 ftgen 0, 0, 8, -2, 5, 660, 440, 270, 430, 370 ;FREQ
  100. giCTF2 ftgen 0, 0, 8, -2, 5, 1120, 1800, 1850, 820, 630 ;FREQ
  101. giCTF3 ftgen 0, 0, 8, -2, 5, 2750, 2700, 2900, 2700, 2750 ;FREQ
  102. giCTF4 ftgen 0, 0, 8, -2, 5, 3000, 3000, 3350, 3000, 3000 ;FREQ
  103. giCTF5 ftgen 0, 0, 8, -2, 5, 3350, 3300, 3590, 3300, 3400 ;FREQ
  104. giTBDb1 ftgen 0, 0, 8, -2, 5, 0, 0, 0, 0, 0 ;dB
  105. giTBDb2 ftgen 0, 0, 8, -2, 5, -6, -14, -24, -10, -20 ;dB
  106. giTBDb3 ftgen 0, 0, 8, -2, 5, -23, -18, -24, -26, -23 ;dB
  107. giTBDb4 ftgen 0, 0, 8, -2, 5, -24, -20, -36, -22, -30 ;dB
  108. giTBDb5 ftgen 0, 0, 8, -2, 5, -38, -20, -36, -34, -30 ;dB
  109. giTBW1 ftgen 0, 0, 8, -2, 5, 80, 70, 40, 40, 40 ;BAND WIDTH
  110. giTBW2 ftgen 0, 0, 8, -2, 5, 90, 80, 90, 80, 60 ;BAND WIDTH
  111. giTBW3 ftgen 0, 0, 8, -2, 5, 120, 100, 100, 100, 100 ;BAND WIDTH
  112. giTBW4 ftgen 0, 0, 8, -2, 5, 130, 120, 120, 120, 120 ;BAND WIDTH
  113. giTBW5 ftgen 0, 0, 8, -2, 5, 140, 120, 120, 120, 120 ;BAND WIDTH
  114. ;ALTO
  115. giAF1 ftgen 0, 0, 8, -2, 5, 800, 400, 350, 450, 325 ;FREQ
  116. giAF2 ftgen 0, 0, 8, -2, 5, 1150, 1600, 1700, 800, 700 ;FREQ
  117. giAF3 ftgen 0, 0, 8, -2, 5, 2800, 2700, 2700, 2830, 2530 ;FREQ
  118. giAF4 ftgen 0, 0, 8, -2, 5, 3500, 3300, 3700, 3500, 2500 ;FREQ
  119. giAF5 ftgen 0, 0, 8, -2, 5, 4950, 4950, 4950, 4950, 4950 ;FREQ
  120. giADb1 ftgen 0, 0, 8, -2, 5, 0, 0, 0, 0, 0 ;dB
  121. giADb2 ftgen 0, 0, 8, -2, 5, -4, -24, -20, -9, -12 ;dB
  122. giADb3 ftgen 0, 0, 8, -2, 5, -20, -30, -30, -16, -30 ;dB
  123. giADb4 ftgen 0, 0, 8, -2, 5, -36, -35, -36, -28, -40 ;dB
  124. giADb5 ftgen 0, 0, 8, -2, 5, -60, -60, -60, -55, -64 ;dB
  125. giABW1 ftgen 0, 0, 8, -2, 5, 50, 60, 50, 70, 50 ;BAND WIDTH
  126. giABW2 ftgen 0, 0, 8, -2, 5, 60, 80, 100, 80, 60 ;BAND WIDTH
  127. giABW3 ftgen 0, 0, 8, -2, 5, 170, 120, 120, 100, 170 ;BAND WIDTH
  128. giABW4 ftgen 0, 0, 8, -2, 5, 180, 150, 150, 130, 180 ;BAND WIDTH
  129. giABW5 ftgen 0, 0, 8, -2, 5, 200, 200, 200, 135, 200 ;BAND WIDTH
  130. ;SOPRANO
  131. giSF1 ftgen 0, 0, 8, -2, 5, 800, 350, 270, 450, 325 ;FREQ
  132. giSF2 ftgen 0, 0, 8, -2, 5, 1150, 2000, 2140, 800, 700 ;FREQ
  133. giSF3 ftgen 0, 0, 8, -2, 5, 2900, 2800, 2950, 2830, 2700 ;FREQ
  134. giSF4 ftgen 0, 0, 8, -2, 5, 3900, 3600, 3900, 3800, 3800 ;FREQ
  135. giSF5 ftgen 0, 0, 8, -2, 5, 4950, 4950, 4950, 4950, 4950 ;FREQ
  136. giSDb1 ftgen 0, 0, 8, -2, 5, 0, 0, 0, 0, 0 ;dB
  137. giSDb2 ftgen 0, 0, 8, -2, 5, -6, -20, -12, -11, -16 ;dB
  138. giSDb3 ftgen 0, 0, 8, -2, 5, -32, -15, -26, -22, -35 ;dB
  139. giSDb4 ftgen 0, 0, 8, -2, 5, -20, -40, -26, -22, -40 ;dB
  140. giSDb5 ftgen 0, 0, 8, -2, 5, -50, -56, -44, -50, -60 ;dB
  141. giSBW1 ftgen 0, 0, 8, -2, 5, 80, 60, 60, 70, 50 ;BAND WIDTH
  142. giSBW2 ftgen 0, 0, 8, -2, 5, 90, 90, 90, 80, 60 ;BAND WIDTH
  143. giSBW3 ftgen 0, 0, 8, -2, 5, 120, 100, 100, 100, 170 ;BAND WIDTH
  144. giSBW4 ftgen 0, 0, 8, -2, 5, 130, 150, 120, 130, 180 ;BAND WIDTH
  145. giSBW5 ftgen 0, 0, 8, -2, 5, 140, 200, 120, 135, 200 ;BAND WIDTH
  146. opcode fofx5, a, kkki
  147. kfund,kvowel,koct,ivoice xin
  148. ivoice limit ivoice,0,4 ;protect against out of range values for ivoice
  149. ;create a macro for each formant to reduce code repetition
  150. #define FORMANT(N)
  151. #
  152. invals table 0, giBF1+(ivoice*15)+$N-1 ;number of data elements in each table
  153. invals = invals-1 ;
  154. k$Nform tablei 1+(kvowel*invals), giBF1+(ivoice*15)+$N-1 ;read formant frequency from table
  155. kRandForm$N randomi -0.025,0.025,8,1
  156. k$Nform = k$Nform*octave(kRandForm$N)
  157. k$Ndb tablei 1+(kvowel*invals), giBDb1+(ivoice*15)+$N-1 ;read decibel value from table
  158. k$Namp = ampdb(k$Ndb) ;convert to an amplitude value
  159. k$Nband tablei 1+(kvowel*invals), giBBW1+(ivoice*15)+$N-1 ;read bandwidth from table
  160. #
  161. ;EXECUTE MACRO MULTIPLE TIMES
  162. $FORMANT(1)
  163. $FORMANT(2)
  164. $FORMANT(3)
  165. $FORMANT(4)
  166. $FORMANT(5)
  167. ;======================================================================================================================================================================
  168. iris = 0.003 ;grain pulse rise time
  169. idur = 0.02 ;grain pulse duration
  170. idec = 0.007 ;grain pulse decay
  171. iolaps = 14850 ;maximum number of overlaps (overestimate)
  172. ifna = gisine ;function table for audio contained within fof grains
  173. ifnb = giexp ;function table that defines the attack and decay shapes of each fof grain
  174. itotdur = 3600 ;total maximum duration of a note (overestimate)
  175. ;FOF===================================================================================================================================================================
  176. iRandRange = .1
  177. #define RandFact
  178. #
  179. kRndFact rspline -iRandRange,iRandRange,1,10
  180. kRndFact = semitone(kRndFact)
  181. #
  182. $RandFact
  183. a1 fof k1amp, kfund*kRndFact, k1form, koct, k1band, iris, idur, idec, iolaps, ifna, ifnb, itotdur
  184. a2 fof k2amp, kfund*kRndFact, k2form, koct, k2band, iris, idur, idec, iolaps, ifna, ifnb, itotdur
  185. a3 fof k3amp, kfund*kRndFact, k3form, koct, k3band, iris, idur, idec, iolaps, ifna, ifnb, itotdur
  186. a4 fof k4amp, kfund*kRndFact, k4form, koct, k4band, iris, idur, idec, iolaps, ifna, ifnb, itotdur
  187. a5 fof k5amp, kfund*kRndFact, k5form, koct, k5band, iris, idur, idec, iolaps, ifna, ifnb, itotdur
  188. ;======================================================================================================================================================================
  189. ;OUT===================================================================================================================================================================
  190. asig = (a1+a2+a3+a4+a5)/5 ;mix the five fof streams and reduce amplitude five-fold
  191. xout asig ;send audio back to caller instrument
  192. endop
  193. opcode ChoVoice,a,kkiii
  194. kDtnDep,kDtnRte,ifn,icount,invoices xin ;read in input args.
  195. ktime randomi 0.01,0.1*kDtnDep,kDtnRte,1 ;create delay time value (linearly interpolating random function will implement pitch/time modulations)
  196. kptime linseg 0,0.001,1 ;portamento time (ramps up quickly from zero to a held value)
  197. ktime portk ktime,kptime ;apply portamento smoothing to delay time changes (prevents angular pitch changes)
  198. atime interp ktime ;create an interpolated a-rate version of delay time function (this will prevent qualtisation artifacts)
  199. atap deltapi atime+0.0015 ;tap the delay buffer (nb. buffer opened and closed in caller instrument, UDO exists within the buffer)
  200. iDel random ksmps/sr,0.2 ;random fixed delay time. By also apply a fixed delay time we prevent excessive amplitude at ote onsets when many chorus voices (N.Voices) are used
  201. atap delay atap,iDel ;apply fixed delay
  202. amix init 0 ;initialise amix variable (needed incase N.Voices is 1 in which case recirsion would not be used)
  203. if icount<invoices then ;if stack of chorus voices is not yet completed...
  204. amix ChoVoice kDtnDep,kDtnRte,ifn,icount+1,invoices ;.. call the UDO again. Increment count number.
  205. endif
  206. xout atap+amix ;send chorus voice created in this interation (and all subsequent voices) back to caller instrument
  207. endop
  208. instr 1 ;instrument that continuously scans widgets
  209. gkmonopoly chnget "monopoly" ;read widgets...
  210. gkDtnDep chnget "DtnDep"
  211. gkDtnRte chnget "DtnRte"
  212. gkvibdep chnget "vibdep"
  213. gkmodrte chnget "modrte"
  214. gktrmdep chnget "trmdep"
  215. gklevel chnget "lev"
  216. gkvowel chnget "vowel"
  217. gkoct chnget "oct"
  218. gkLegTim chnget "LegTim"
  219. gkRvbMix chnget "RvbMix"
  220. gkRvbSize chnget "RvbSize"
  221. kporttime linseg 0,0.001,0.1 ;portamento time (ramps up quickly from zero to a held value)
  222. gkvowel portk gkvowel,kporttime ;apply portamento smoothing
  223. gkoct portk gkoct,kporttime
  224. gkFiltOnOff chnget "FiltOnOff"
  225. gkcf chnget "cf"
  226. gkbw chnget "bw"
  227. gkcf portk cpsoct(gkcf),kporttime ;apply portamento smoothing
  228. gkbw portk gkbw*gkcf,kporttime ;apply portamento smoothing
  229. endin
  230. instr 2 ;triggered via MIDI
  231. gkNoteTrig init 1 ;at the beginning of a new note set note trigger flag to '1'
  232. icps cpsmidi ;read in midi note pitch in cycles per second
  233. givel veloc 0,1 ;read in midi note velocity
  234. gkcps = icps ;update a global krate variable for note pitch
  235. if i(gkmonopoly)==0 then ;if we are *not* in legato mode...
  236. inum notnum ; read midi note number (0 - 127)
  237. event_i "i",p1+1+(inum*0.001),0,-1,icps ; call soud producing instr
  238. krel release ; release flag (1 when note is released, 0 otherwise)
  239. if krel==1 then ; when note is released...
  240. turnoff2 p1+1+(inum*0.001),4,1 ; turn off the called instrument
  241. endif ; end of conditional
  242. else ;otherwise... (i.e. legato mode)
  243. iactive active p1+1 ;check to see if these is already a note active...
  244. if iactive==0 then ;...if not...
  245. event_i "i",p1+1,0,-1 ;...start a new held note
  246. endif
  247. endif
  248. endin
  249. instr 3
  250. ivoice chnget "voice" ;read widgets...
  251. imoddel chnget "moddel" ;
  252. imodris chnget "modris" ;
  253. invoices chnget "nvoices" ;
  254. kporttime linseg 0,0.001,1 ;portamento time function rises quickly from zero to a held value
  255. kporttime = kporttime*gkLegTim ;scale portamento time function with value from GUI knob widget
  256. if i(gkmonopoly)==1 then ;if we are in legato mode...
  257. kcps portk gkcps,kporttime ;apply portamento smooth to changes in note pitch (this will only have an effect in 'legato' mode)
  258. kactive active p1-1 ;...check number of active midi notes (previous instrument)
  259. if kactive==0 then ;if no midi notes are active...
  260. turnoff ;... turn this instrument off
  261. endif
  262. else ;otherwise... (polyphonic / non-legato mode)
  263. kcps = p4 ;pitch equal to the original note pitch
  264. endif
  265. if gkNoteTrig==1&&gkmonopoly==1 then ;if a new note is beginning and if we are in monophonic mode...
  266. reinit RESTART_ENVELOPE ;reinitialise the modulations build up
  267. endif
  268. RESTART_ENVELOPE:
  269. ;VIBRATO (PITCH MODULATION)
  270. kmodenv linseg 0,0.001+imoddel,0,0.001+imodris,1 ;modulation depth envelope - modulation can be delayed by the first envelope segement and the rise time is defined by the duration of the second segment
  271. kDepVar randomi 0.5,1,4 ;random variance of the depth of modulation
  272. kmodenv portk kmodenv*kDepVar,kporttime ;smooth changes in modulation envelope to prevent discontinuities whnever the envelope is restarted
  273. rireturn
  274. kRteVar randi 0.1,4 ;random variation of the rate of modulation
  275. kvib lfo gkvibdep*kmodenv,gkmodrte*octave(kRteVar),0 ;vibrato function
  276. ;TREMOLO (AMPLITUDE MODULATION)
  277. ktrem lfo kmodenv*(gktrmdep/2),gkmodrte*octave(kRteVar),0 ;TREMOLO LFO FUNCTION
  278. ktrem = (ktrem+0.5) + (gktrmdep * 0.5) ;OFFSET AND RESCALE TREMOLO FUNCTION ACCORDING TO TREMOLO DEPTH WIDGET SETTING
  279. iRelTim = 0.05
  280. kCpsAtt expsegr 0.6,rnd(0.004)+0.001,1,iRelTim,1-rnd(0.05) ;a little jump in pitch at the beginning of a note will give the note a realistic attack sound. This will be most apparent when note velocity is high. And a little gliss at the end of notes.
  281. kcpsRnd gaussi 1,0.01,10 ;create a function that will be used to apply naturalistic pitch instability
  282. kcps = kcps*(1+kcpsRnd) ;apply pitch instability
  283. asig fofx5 kcps*semitone(kvib)*kCpsAtt, gkvowel, gkoct, ivoice-1 ;CALL fofx5 UDO
  284. if gkFiltOnOff==1 then
  285. asig reson asig,gkcf,gkbw,1 ;parametric EQ
  286. endif
  287. aatt linseg 0,(0.3*(1-givel)*(invoices^0.8))+0.01,1 ;AMPLITUDE ENVELOPE - ATTACK TIME IS INFLUENCED BY KEY VELOCITY
  288. asig = asig*aatt*ktrem*(0.3+givel*0.7)*gklevel ;APPLY AMPLITUDE CONTROLS: ENVELOPE, TREMOLO, KEY VELOCITY AND LEVEL
  289. /*CHORUS*/
  290. if invoices>1 then
  291. abuf delayr 2 ;--left channel--
  292. amixL ChoVoice gkDtnDep,gkDtnRte,gisine,1,invoices ;call UDO
  293. delayw asig
  294. abuf delayr 2 ;--right channel--
  295. amixR ChoVoice gkDtnDep,gkDtnRte,gisine,1,invoices ;call UDO
  296. delayw asig
  297. asigL = amixL/(invoices^0.5) ;scale mix of chorus voices according to the number of voices...
  298. asigR = amixR/(invoices^0.5) ;...and the right channel
  299. else ;otherwise... (N.Voices = 1)
  300. asigL = asig ;send mono signal to both channels
  301. asigR = asig
  302. endif
  303. arel linsegr 1,iRelTim,0 ;release envelope
  304. asigL = asigL*arel ;apply release envelope
  305. asigR = asigR*arel
  306. kwet limit 2*gkRvbMix,0,1 ;wet (reverb) level control (reaches maximum a knob halfway point and hold that value for the remainder of its travel)
  307. gasendL = gasendL+asigL*kwet ;send some audio to the reverb instrument
  308. gasendR = gasendR+asigR*kwet
  309. kdry limit 2*(1-gkRvbMix),0,1 ;dry level (stays at maximum for the first half of the knob's travel then ramps down to zero for the remainder of its travel)
  310. outs asigL*kdry,asigR*kdry ;SEND AUDIO TO OUTPUT
  311. gkNoteTrig = 0 ;reset new-note trigger (in case it was '1')
  312. endin
  313. instr Effects
  314. if gkRvbMix>0 then
  315. aL,aR reverbsc gasendL,gasendR,gkRvbSize,12000 ;create stereo reverb signal
  316. outs aL,aR ;send reverb signal to speakers
  317. clear gasendL,gasendR ;clear reverb send variables
  318. endif
  319. endin
  320. </CsInstruments>
  321. <CsScore>
  322. f 0 [3600*24*7]
  323. i 1 0 [3600*24*7] ;read widgets
  324. i "Effects" 0 [3600*24*7] ;reverb
  325. </CsScore>
  326. </CsoundSynthesizer>