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.

203 lines
7.3KB

  1. ; Rhythmicon.csd
  2. ; Written by Iain McCurdy, 2013.
  3. ; Recreation of Henry Cowell and Leon Theremin's Rhythmicon instrument (http://en.wikipedia.org/wiki/Rhythmicon)
  4. ; CONTROLS
  5. ; --------
  6. ; BASE -- note number of the fundemental (lowest note)
  7. ; RATE -- base rate (same as rate for fundemental)
  8. ; LEVEL -- output level
  9. ; DESCRIPTION
  10. ; -----------
  11. ; Each note above the fundemental (C3) divides the base rate increasingly according to the arithmetic progression: 2,3,4,5...
  12. ; Therefore if C3 plays crotchets (quarter notes), C#3 plays quavers (eighth notes), D3 triplets and so on.
  13. ; The pitches of each note (in cycles per second) follow a simlar progression.
  14. ; If C3 plays a 200Hz tone, C#3 plays 400Hz, D 600Hz and so on.
  15. ; The 17th note (E4) does not play a note but instead engages a syncopation effect.
  16. ; I have been unable to find a clear technical specification of how this was implemented but have nonetheless made my 'best guess'.
  17. <Cabbage>
  18. form caption("...") size(159, 180), pluginID("basl")
  19. label bounds( 5, 3, 22, 22), text("R"), fontcolour(red)
  20. label bounds( 20, 5, 22, 22), text("H"), fontcolour(yellow)
  21. label bounds( 35, 2, 22, 22), text("Y"), fontcolour(orchid)
  22. label bounds( 50, 4, 22, 22), text("T"), fontcolour(LightGreen)
  23. label bounds( 65, 2, 22, 22), text("H"), fontcolour(OrangeRed)
  24. label bounds( 80, 6, 22, 22), text("M"), fontcolour(orange)
  25. label bounds( 99, 1, 22, 22), text("I"), fontcolour(SkyBlue)
  26. label bounds(110, 4, 22, 22), text("C"), fontcolour(Tomato)
  27. label bounds(125, 1, 22, 22), text("O"), fontcolour(LightGreen)
  28. label bounds(140, 3, 22, 22), text("N"), fontcolour(violet)
  29. label bounds( 81, 24, 100, 8), text("Iain McCurdy [2013]"), FontColour("white")
  30. rslider bounds( 3, 45, 55, 55), channel("base"), textBox(1), range(0, 127,36, 1,1),fontcolour(138, 54, 15),colour(orange), trackercolour(orange)
  31. label bounds( 19, 34, 30, 10), text("BASE"), fontcolour(white)
  32. rslider bounds( 52, 45, 55, 55), channel("rate"), textBox(1), range(0.1, 5.00, 0.5, 0.5, 0.01),fontcolour(138, 54, 15),colour(orange), trackercolour(orange)
  33. label bounds( 68, 34, 30, 10), text("RATE"), fontcolour(white)
  34. rslider bounds(102, 45, 55, 54), channel("level"), textBox(1), range(0, 1.00, 0.5, 0.5, 0.01),fontcolour(138, 54, 15),colour(orange), trackercolour(orange)
  35. label bounds(115, 34, 30, 10), text("LEVEL"), fontcolour(white)
  36. checkbox bounds( 0, 101, 9, 10), channel("k1") value(0) shape(square) colour(yellow)
  37. checkbox bounds( 9, 101, 10, 10), channel("k2") value(0) shape(square) colour(yellow)
  38. checkbox bounds( 19, 101, 9, 10), channel("k3") value(0) shape(square) colour(yellow)
  39. checkbox bounds( 28, 101, 10, 10), channel("k4") value(0) shape(square) colour(yellow)
  40. checkbox bounds( 38, 101, 10, 10), channel("k5") value(0) shape(square) colour(yellow)
  41. checkbox bounds( 48, 101, 8, 10), channel("k6") value(0) shape(square) colour(yellow)
  42. checkbox bounds( 56, 101, 10, 10), channel("k7") value(0) shape(square) colour(yellow)
  43. checkbox bounds( 66, 101, 8, 10), channel("k8") value(0) shape(square) colour(yellow)
  44. checkbox bounds( 74, 101, 10, 10), channel("k9") value(0) shape(square) colour(yellow)
  45. checkbox bounds( 84, 101, 9, 10), channel("k10") value(0) shape(square) colour(yellow)
  46. checkbox bounds( 93, 101, 10, 10), channel("k11") value(0) shape(square) colour(yellow)
  47. checkbox bounds(103, 101, 9, 10), channel("k12") value(0) shape(square) colour(yellow)
  48. checkbox bounds(112, 101, 9, 10), channel("k13") value(0) shape(square) colour(yellow)
  49. checkbox bounds(121, 101, 10, 10), channel("k14") value(0) shape(square) colour(yellow)
  50. checkbox bounds(131, 101, 9, 10), channel("k15") value(0) shape(square) colour(yellow)
  51. checkbox bounds(140, 101, 10, 10), channel("k16") value(0) shape(square) colour(yellow)
  52. checkbox bounds(150, 101, 10, 10), channel("k17") value(0) shape(square) colour(red)
  53. keyboard bounds(-13, 110, 450, 70)
  54. </Cabbage>
  55. <CsoundSynthesizer>
  56. <CsOptions>
  57. -dm0 -n -+rtmidi=null -M0
  58. </CsOptions>
  59. <CsInstruments>
  60. sr = 44100
  61. ksmps = 64
  62. nchnls = 2
  63. 0dbfs = 1
  64. massign 0,1
  65. ; Author: Iain McCurdy (2013)
  66. giAmpScl ftgen 0,0,-20000,-16, 1,100,0,1, 20000-100,-100,0.2
  67. opcode SwitchPort, k, kkk
  68. kin,kUpPort,kDnPort xin
  69. kold init 0
  70. kporttime = (kin<kold?kDnPort:kUpPort)
  71. kout portk kin, kporttime
  72. kold = kout
  73. xout kout
  74. endop
  75. instr 1 ; Listen for midi note changes. Turn lights on or off. Start the rhymicon of at least 1 note is held.
  76. inum notnum ; read in midi note number
  77. #define LightToggle(N) # ; define a macro to reduce code repetition
  78. if inum=(59+$N) then ; if note number played on the keyboard corresponds to 'this' toggle light... (note that first note will be C3 (59 + 1)
  79. ik$N chnget "k$N" ; read current value for 'this' toggle light (at i-time)
  80. chnset 1-ik$N,"k$N" ; write the inverse to it (i.e. toggle it)
  81. endif#
  82. $LightToggle(1) ; expand macro for all 16 layers
  83. $LightToggle(2)
  84. $LightToggle(3)
  85. $LightToggle(4)
  86. $LightToggle(5)
  87. $LightToggle(6)
  88. $LightToggle(7)
  89. $LightToggle(8)
  90. $LightToggle(9)
  91. $LightToggle(10)
  92. $LightToggle(11)
  93. $LightToggle(12)
  94. $LightToggle(13)
  95. $LightToggle(14)
  96. $LightToggle(15)
  97. $LightToggle(16)
  98. $LightToggle(17)
  99. kk1 chnget "k1"
  100. kk2 chnget "k2"
  101. kk3 chnget "k3"
  102. kk4 chnget "k4"
  103. kk5 chnget "k5"
  104. kk6 chnget "k6"
  105. kk7 chnget "k7"
  106. kk8 chnget "k8"
  107. kk9 chnget "k9"
  108. kk10 chnget "k10"
  109. kk11 chnget "k11"
  110. kk12 chnget "k12"
  111. kk13 chnget "k13"
  112. kk14 chnget "k14"
  113. kk15 chnget "k15"
  114. kk16 chnget "k16"
  115. ksum = kk1 + kk2 + kk3 + kk4 + kk5 + kk6 + kk7 + kk8 + kk9 + kk10 + kk11 + kk12 + kk13 + kk14 + kk15 + kk16
  116. if ksum>0 then
  117. schedkwhen 1,0,1,2,0,-1
  118. else
  119. turnoff2 2,0,1
  120. endif
  121. endin
  122. instr 2
  123. kporttime linseg 0,0.001,0.05
  124. kbase chnget "base" ; base pitch as a note number
  125. krate chnget "rate" ; rate of pulsation of fundemental
  126. krate portk krate, kporttime
  127. klevel chnget "level" ; output amplitude level
  128. ksync chnget "k17" ; syncopation mode
  129. kBaseFrq = cpsmidinn(kbase)
  130. kBaseFrq portk kBaseFrq,kporttime
  131. iamp = 0.6
  132. amix = 0
  133. #define LAYER(N)# ; use a macro to reduce code repetition
  134. kk$N chnget "k$N"
  135. kk$N SwitchPort kk$N,kporttime*0.01,kporttime*0.5
  136. ktrig metro krate * $N
  137. kn = $N ; layer number as a variable
  138. if ksync=1&&kn>1 then ; if syncopation is on and this isn't the first layer (syncopation irrelevant for first layer)
  139. ktrig vdelayk ktrig, (1/(krate*$N))/$N , 1/0.1 ; add a syncopation delay for the metronome trigger for this layer
  140. endif
  141. kenv loopseg $N/60, ktrig, 0, 0,0.025, 1,0.84/krate, 0,60, 0 ; retriggering envelope
  142. aenv interp kenv*kk$N ; interpolate to a-rate (for better smoothness)
  143. kcps = kBaseFrq*$N ; pitch for this layer (in cycles per second)
  144. kscl table kcps,giAmpScl ; amp scaling value (to quieten higher sounds)
  145. kamp = iamp*kscl ; apply on/off switch for this layer to its amplitude
  146. asig vco2 kamp,kcps,2,0.1 ; generate a tone (pulse wave)
  147. kcf limit cpsoct(octcps(kcps*3)*kenv),1,10000 ; filter envelope
  148. asig clfilt asig,kcf,0,2 ; butterworth lowpass filter the sound
  149. asig = asig*aenv ; apply amplitude envelope
  150. amix = amix + asig# ; add to 'mix' signal with the other layers
  151. $LAYER(1) ; expand macro multiple times. Once for each layer
  152. $LAYER(2)
  153. $LAYER(3)
  154. $LAYER(4)
  155. $LAYER(5)
  156. $LAYER(6)
  157. $LAYER(7)
  158. $LAYER(8)
  159. $LAYER(9)
  160. $LAYER(10)
  161. $LAYER(11)
  162. $LAYER(12)
  163. $LAYER(13)
  164. $LAYER(14)
  165. $LAYER(15)
  166. $LAYER(16)
  167. xtratim 0.5
  168. outs amix*klevel, amix*klevel
  169. endin
  170. </CsInstruments>
  171. <CsScore>
  172. i 1 0 [3600*24*7] ;read widgets
  173. ;i 2 0 [3600*24*7] ;read widgets
  174. </CsScore>
  175. </CsoundSynthesizer>