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.

269 lines
15KB

  1. ;BreakBeatCutter.csd
  2. ;Iain McCurdy, 2013.
  3. ; Break Beat Cut Up using the bbcut opcode with additional processing
  4. ;==BBCUT==========================================================================================================================
  5. 'Sub-division' determines the note duration used as the base unit in cut-ups.
  6. For example a value of 8 represents quavers (eighth notes), 16 represents semiquavers (sixteenth notes) and so on.
  7. 'Bar Length' represents the number of beats per bar. For example, a value of 4 represents a 4/4 bar and so on.
  8. 'Phrase' defines the number of bars that will elapse before the cutting up pattern restarts from the beginning.
  9. 'Stutter' is a separate cut-up process which occasionally will take a very short fragment of the input audio and repeat
  10. it many times.
  11. 'Stutter Speed' defines the duration of each stutter in relation to 'Sub-division'.
  12. If subdivision is 8 (quavers / eighth notes) and 'Stutter Speed' is 2 then each stutter will be a semiquaver / sixteenth note.
  13. 'Stutter Chance' defines the frequency of stutter moments.
  14. The range for this parameter is 0 to 1. Zero means stuttering will be very unlikely, 1 means it will be very likely.
  15. 'Repeats' defines the number of repeats that will be employed in normal cut-up events.
  16. When processing non-rhythmical, unmetered material it may be be more interesting to employ non-whole numbers for parameters such as 'Sub-division', 'Phrase' and 'Stutter Speed'.
  17. ;========================================================================================================================
  18. ;==FILTER================================================================================================================
  19. Additionally in this example a randomly moving band-pass filter has been implemented.
  20. 'Filter Mix' crossfades between the unfiltered bbcut signal and the filtered bbcut signal.
  21. 'Cutoff Freq.' consists of two small sliders which determine the range from which random cutoff values are derived.
  22. 'Interpolate<=>S&H' fades continuously between an interpolated random function and a sample and hold type random function.
  23. 'Filter Div.' controls the frequency subdivision with which new random cutoff frequency values are generated - a value of '1' means that new values are generated once every bar.
  24. ;========================================================================================================================
  25. ;==WGUIDE================================================================================================================
  26. A waveguide effect can randomly and rhythmically cut into the audio stream
  27. 'Chance' defines the probability of this happening. 0=never 1=always
  28. The range of frequencies the effect will choose from is defined by the user as note values.
  29. Frequencies are quatised to adhere to equal temperament.
  30. ;========================================================================================================================
  31. ;==SQUARE MOD. (Square wave ring modulation)=============================================================================
  32. This effect can similarly randomly and rhythmically cut into the audio stream using the 'chance' control
  33. The range of frequencies the modulator waveform can move between is defined as 'oct' values.
  34. ;========================================================================================================================
  35. ;==F.SHIFT (Frequency Shifter)===========================================================================================
  36. Similar to the above except using a frequency shifter effect.
  37. ;========================================================================================================================
  38. <Cabbage>
  39. form size(440,485), caption("Break Beat Cutter"), pluginID("bbct")
  40. groupbox bounds( 0, 0,440,145), text("CUTTER"), plant("cutter"), FontColour(silver),colour(40,40,40){
  41. rslider bounds( 10, 25, 70, 70), colour("Tan"), tracker("Tan"), fontcolour("silver"), text("Sub-div."), channel("subdiv"), range(1, 512, 8, 1, 1)
  42. rslider bounds( 80, 25, 70, 70), colour("Tan"), tracker("Tan"), fontcolour("silver"), text("Bar Length"), channel("barlen"), range(1, 16, 2, 1, 1)
  43. rslider bounds(150, 25, 70, 70), colour("Tan"), tracker("Tan"), fontcolour("silver"), text("Phrase"), channel("phrase"), range(1, 512, 8, 1, 1)
  44. rslider bounds(220, 25, 70, 70), colour("Tan"), tracker("Tan"), fontcolour("silver"), text("Repeats"), channel("repeats"), range(1, 32, 2, 1, 1)
  45. rslider bounds(290, 25, 70, 70), colour("Tan"), tracker("Tan"), fontcolour("silver"), text("Stut. Speed"), channel("stutspd"), range(1, 32, 4, 1, 1)
  46. rslider bounds(360, 25, 70, 70), colour("Tan"), tracker("Tan"), fontcolour("silver"), text("Stut. Chance"), channel("stutchnc"), range(0, 1.00, 0.5)
  47. hslider bounds( 5, 95,425, 40), colour("Tan"), tracker("Tan"), fontcolour("silver"), textBox(1) channel("BPM"), range(10, 500, 110,1,1)
  48. label bounds(198,127, 25, 11), text("BPM"), FontColour("silver")
  49. }
  50. groupbox bounds( 0,145,440,100), text("FILTER"), plant("filter"), FontColour(silver),colour(40,40,40){
  51. rslider bounds( 10, 25, 70, 70), colour(200,100,50,255), tracker(200,100,50,255), fontcolour("silver"), text("Mix"), channel("FltMix"), range(0, 1.00, 0.6)
  52. rslider bounds( 80, 25, 70, 70), colour(200,100,50,255), tracker(200,100,50,255), fontcolour("silver"), text("Division"), channel("fltdiv"), range(1, 16, 1,1,1)
  53. rslider bounds(150, 25, 70, 70), colour(200,100,50,255), tracker(200,100,50,255), fontcolour("silver"), text("Bandwidth"), channel("bw"), range(0.1, 10, 1, 0.5, 0.001)
  54. hslider bounds(220, 25,140, 35), colour(200,100,50,255), tracker(200,100,50,255), fontcolour("silver"), channel("cfmin"), range(50, 10000, 50 ,0.5,0.1)
  55. hslider bounds(220, 50,140, 35), colour(200,100,50,255), tracker(200,100,50,255), fontcolour("silver"), channel("cfmax"), range(50, 10000, 10000,0.5,0.1)
  56. label bounds(254, 77, 80, 12), text("Cutoff Freq."), FontColour("white")
  57. rslider bounds(360, 25, 70, 70), colour(200,100,50,255), tracker(200,100,50,255), fontcolour("silver"), text("Int./S&H"), channel("i_h"), range(0, 1, 0)
  58. }
  59. groupbox bounds( 0,245,220,100), text("WAVE GUIDE"), plant("waveguide"), FontColour(silver),colour(40,40,40){
  60. rslider bounds( 10, 25, 70, 70), colour(150,150,50,255), tracker(150,150,50,255), fontcolour("silver"), text("Chance"), channel("WguideChnc"), range(0, 1.00, 0.2)
  61. hslider bounds( 80, 25,140, 35), colour(150,150,50,255), tracker(150,150,50,255), fontcolour("silver"), channel("wguidemin"), range(22, 100, 50,1,1)
  62. hslider bounds( 80, 50,140, 35), colour(150,150,50,255), tracker(150,150,50,255), fontcolour("silver"), channel("wguidemax"), range(22, 100, 70,1,1)
  63. label bounds(108, 77, 85, 12), text("Pitch Range"), FontColour("white")
  64. }
  65. groupbox bounds(220,245,220,100), text("SQUARE MOD."), plant("sqmod"), FontColour(silver),colour(40,40,40){
  66. rslider bounds( 10, 25, 70, 70), colour(200,150,200,255), tracker(200,150,200,255), fontcolour("silver"), text("Chance"), channel("SqModChnc"), range(0, 1.00, 0.2)
  67. hslider bounds( 80, 25,140, 35), colour(200,150,200,255), tracker(200,150,200,255), fontcolour("silver"), channel("sqmodmin"), range(1, 14.0, 6)
  68. hslider bounds( 80, 50,140, 35), colour(200,150,200,255), tracker(200,150,200,255), fontcolour("silver"), channel("sqmodmax"), range(1, 14.0, 12)
  69. label bounds(108, 77, 85, 12), text("Freq.Range"), FontColour("white")
  70. }
  71. groupbox bounds(0,345,220,100), text("FREQUENCY SHIFT"), plant("fshift"), FontColour(silver),colour(40,40,40){
  72. rslider bounds( 10, 25, 70, 70), colour(250,110,250,255), tracker(250,110,250,255), fontcolour("silver"), text("Chance"), channel("FshiftChnc"), range(0, 1.00, 0.2)
  73. hslider bounds( 80, 25,140, 35), colour(250,110,250,255), tracker(250,110,250,255), fontcolour("silver"), channel("fshiftmin"), range(-4000, 4000,-1000)
  74. hslider bounds( 80, 50,140, 35), colour(250,110,250,255), tracker(250,110,250,255), fontcolour("silver"), channel("fshiftmax"), range(-4000, 4000, 1000)
  75. label bounds(108, 77, 85, 12), text("Freq.Range"), FontColour("white")
  76. }
  77. groupbox bounds(220,345,220,100), text("OUTPUT"), plant("output"), FontColour(silver),colour(40,40,40){
  78. rslider bounds( 10, 25, 70, 70), colour("Tan"), tracker("Tan"), fontcolour("silver"), text("Gain"), channel("gain"), range(0, 1, 0.75)
  79. rslider bounds( 80, 25, 70, 70), colour("Tan"), tracker("Tan"), fontcolour("silver"), text("Dry/Wet"), channel("DryWet"), range(0, 1, 0.6)
  80. rslider bounds(150, 25, 70, 70), colour("Tan"), tracker("Tan"), fontcolour("silver"), text("Layers"), channel("layers"), range(1, 20, 1,1,1)
  81. }
  82. label bounds( 5,470, 200, 12), text("Author: Iain McCurdy |2013|"), FontColour("grey")
  83. </Cabbage>
  84. <CsoundSynthesizer>
  85. <CsOptions>
  86. -n -d
  87. </CsOptions>
  88. <CsInstruments>
  89. sr = 44100
  90. ksmps = 64
  91. nchnls = 2
  92. 0dbfs=1
  93. seed 0
  94. gisine ftgen 0,0,131072,10,1
  95. opcode BBCutIteration,aa,aaiiiiiiiii
  96. aL,aR,iBPS, isubdiv, ibarlen, iphrase, irepeats, istutspd, istutchnc, icount, ilayers xin
  97. abbcutL bbcutm aL, iBPS, isubdiv, ibarlen, iphrase, irepeats, istutspd, istutchnc
  98. abbcutR bbcutm aR, iBPS, isubdiv, ibarlen, iphrase, irepeats, istutspd, istutchnc
  99. amixL = 0
  100. amixR = 0
  101. if icount<ilayers then
  102. amixL,amixR BBCutIteration aL,aR, iBPS, isubdiv, ibarlen, iphrase, irepeats, istutspd, istutchnc, icount+1, ilayers
  103. endif
  104. xout abbcutL+amixL,abbcutR+amixL
  105. endop
  106. opcode FreqShifter,a,aki
  107. ain,kfshift,ifn xin ;READ IN INPUT ARGUMENTS
  108. areal, aimag hilbert ain ;HILBERT OPCODE OUTPUTS TWO PHASE SHIFTED SIGNALS, EACH 90 OUT OF PHASE WITH EACH OTHER
  109. asin oscili 1, kfshift, ifn, 0
  110. acos oscili 1, kfshift, ifn, 0.25
  111. ;RING MODULATE EACH SIGNAL USING THE QUADRATURE OSCILLATORS AS MODULATORS
  112. amod1 = areal * acos
  113. amod2 = aimag * asin
  114. ;UPSHIFTING OUTPUT
  115. aFS = (amod1 - amod2)
  116. xout aFS ;SEND AUDIO BACK TO CALLER INSTRUMENT
  117. endop
  118. instr 1 ; read widgets
  119. gksubdiv chnget "subdiv"
  120. gkbarlen chnget "barlen"
  121. gkphrase chnget "phrase"
  122. gkrepeats chnget "repeats"
  123. gkstutspd chnget "stutspd"
  124. gkstutchnc chnget "stutchnc"
  125. gkBPM chnget "BPM"
  126. gkfltdiv chnget "fltdiv"
  127. gkDryWet chnget "DryWet"
  128. gkFltMix chnget "FltMix"
  129. gkbw chnget "bw"
  130. gkcfmin chnget "cfmin"
  131. gkcfmax chnget "cfmax"
  132. gki_h chnget "i_h"
  133. gklayers chnget "layers"
  134. gkgain chnget "gain"
  135. konoff chnget "onoff"
  136. endin
  137. instr 2
  138. aL,aR ins
  139. ;aL diskin "loop.wav",1,0,1
  140. ;aR = aL
  141. kSwitch changed gkBPM, gkrepeats, gkphrase, gkstutspd, gkstutchnc, gkbarlen, gksubdiv, gkfltdiv, gklayers ;GENERATE A MOMENTARY '1' PULSE IN OUTPUT 'kSwitch' IF ANY OF THE SCANNED INPUT VARIABLES CHANGE. (OUTPUT 'kSwitch' IS NORMALLY ZERO)
  142. if kSwitch=1 then ;IF I-RATE VARIABLE CHANGE TRIGGER IS '1'...
  143. reinit UPDATE ;BEGIN A REINITIALISATION PASS FROM LABEL 'UPDATE'
  144. endif
  145. UPDATE:
  146. kmetro metro i(gkBPM)/60
  147. ;OUTPUT OPCODE INPUT | BPM | SUBDIVISION | BAR_LENGTH | PHRASE_LENGTH | NUM.OF_REPEATS | STUTTER_SPEED | STUTTER_CHANCE
  148. abbcutL,abbcutR BBCutIteration aL,aR, i(gkBPM)/60, i(gksubdiv), i(gkbarlen), i(gkphrase), i(gkrepeats), i(gkstutspd), i(gkstutchnc), 1, i(gklayers)
  149. ;FILTER=================================================================================================================================================================
  150. kfreq = (gkfltdiv) ;FREQUENCY WITH WHICH NEW FILTER CUTOFF VALUES ARE GENERATED ;LEFT CHANNE
  151. rireturn ;RETURN FROM REINITIALISATION PASS TO PERFORMANCE TIME PASSES
  152. kcf1h randomh gkcfmin, gkcfmax, kfreq ;SAMPLE AND HOLD RANDOM FREQUENCY VALUES ;LEFT CHANNEL
  153. kcf1i lineto kcf1h, 1/kfreq ;INTERPOLATE VALUES ;LEFT CHANNEL
  154. kcf1 ntrpol kcf1i, kcf1h, gki_h ;CROSSFADE BETWEEN INTERPOLATING AND SAMPLE AND HOLD TYPE RANDOM VALUES ;LEFT CHANNEL
  155. abbFltL resonz abbcutL, kcf1, kcf1*gkbw, 2 ;BAND-PASS FILTER ;LEFT CHANNEL
  156. abbMixL ntrpol abbcutL, abbFltL, gkFltMix ;CROSSFADE BETWEEN UNFILTERED AND FILTER AUDIO SIGNAL ;LEFT CHANNEL
  157. kcf2h randomh gkcfmin, gkcfmax, kfreq ;SAMPLE AND HOLD RANDOM FREQUENCY VALUES ;RIGHT CHANNEL
  158. kcf2i lineto kcf2h, 1/kfreq ;INTERPOLATE VALUES ;RIGHT CHANNEL
  159. kcf2 ntrpol kcf2i, kcf2h, gki_h ;CROSSFADE BETWEEN INTERPOLATING AND SAMPLE AND HOLD TYPE RANDOM VALUES ;RIGHT CHANNEL
  160. abbFltR resonz abbcutR, kcf2, kcf2*gkbw, 2 ;BAND-PASS FILTER ;RIGHT CHANNEL
  161. abbMixR ntrpol abbcutR, abbFltR, gkFltMix ;CROSSFADE BETWEEN UNFILTERED AND FILTER AUDIO SIGNAL ;RIGHT CHANNEL
  162. ;=======================================================================================================================================================================
  163. ;WGUIDE1================================================================================================================================================================
  164. kchance chnget "WguideChnc"
  165. kdice trandom kmetro,0,1
  166. if kdice<kchance then
  167. kwguidemin chnget "wguidemin"
  168. kwguidemax chnget "wguidemax"
  169. knum randomh kwguidemin,kwguidemax,gkBPM/60
  170. afrq interp cpsmidinn(int(knum))
  171. kfb randomi 0.8,0.99,gkBPM/(60*4)
  172. kcf randomi 800,4000,gkBPM/60
  173. abbMixL wguide1 abbMixL*0.7,afrq,kcf,kfb
  174. abbMixR wguide1 abbMixR*0.7,afrq,kcf,kfb
  175. endif
  176. ;=======================================================================================================================================================================
  177. ;SQUARE MOD==============================================================================================================================================================
  178. kchance chnget "SqModChnc"
  179. ksqmodmin chnget "sqmodmin"
  180. ksqmodmax chnget "sqmodmax"
  181. kDiceRoll trandom kmetro,0,1
  182. if kDiceRoll<kchance then
  183. kratei randomi ksqmodmin,ksqmodmax,gkBPM/60
  184. krateh randomh ksqmodmin,ksqmodmax,gkBPM/60
  185. kcross randomi 0,1,gkBPM
  186. kcross = kcross>0.5?1:0
  187. krate ntrpol kratei,krateh,kcross
  188. amod lfo 1,cpsoct(krate),2
  189. abbMixL = abbMixL*amod
  190. abbMixR = abbMixR*amod
  191. endif
  192. ;=======================================================================================================================================================================
  193. ;FSHIFT=================================================================================================================================================================
  194. kchance chnget "FshiftChnc"
  195. kdice trandom kmetro,0,1
  196. if kdice<kchance then
  197. kfshiftmin chnget "fshiftmin"
  198. kfshiftmax chnget "fshiftmax"
  199. ; kfsfrq randomh kfshiftmin,kfshiftmax,gkBPM/60
  200. kfsfrqi randomi kfshiftmin,kfshiftmax,gkBPM/60
  201. kfsfrqh randomh kfshiftmin,kfshiftmax,gkBPM/60
  202. kcross randomi 0,1,gkBPM/2
  203. kcross = kcross>0.5?1:0
  204. kfsfrq ntrpol kfsfrqi,kfsfrqh,kcross
  205. abbMixL FreqShifter abbMixL,kfsfrq,gisine
  206. abbMixR FreqShifter abbMixR,kfsfrq,gisine
  207. endif
  208. ;=======================================================================================================================================================================
  209. amixL sum aL*(1-gkDryWet), abbMixL*gkDryWet ;SUM AND MIX DRY SIGNAL AND BBCUT SIGNAL (LEFT CHANNEL)
  210. amixR sum aR*(1-gkDryWet), abbMixR*gkDryWet ;SUM AND MIX DRY SIGNAL AND BBCUT SIGNAL (RIGHT CHANNEL)
  211. outs amixL*gkgain, amixR*gkgain ;SEND AUDIO TO OUTPUTS
  212. endin
  213. </CsInstruments>
  214. <CsScore>
  215. i1 0 36000
  216. i2 0 36000
  217. </CsScore>
  218. </CsoundSynthesizer>