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.

114 lines
4.8KB

  1. ; pvsBuffer.csd (for Cabbage)
  2. ; Writes audio into a circular FFT buffer.
  3. ; Read speed can be modified as can the frequencies.
  4. ; Take Care! Feedback values above 1 are intended to be used only when transposition if not unison.
  5. <Cabbage>
  6. form caption("pvsBuffer") size(580,90), pluginID("buff")
  7. image bounds(0, 0, 580, 90), colour(100, 80, 80,125), shape("rounded"), outline("white"), line(4)
  8. rslider bounds(10, 11, 70, 70), text("Speed"), channel("speed"), range(0, 4, 1, 0.5, 0.0001), fontcolour("white"), colour(100, 80, 80, 5) trackercolour(silver)
  9. rslider bounds(80, 11, 70, 70), text("Buf. Size"), channel("buflen"), range(0.10, 8.00, 1, 0.5), fontcolour("white"), colour(100, 80, 80, 5) trackercolour(silver)
  10. rslider bounds(150, 11, 70, 70), text("Semitones"), channel("semis"), range(-24, 24, 0, 1, 1), fontcolour("white"), colour(100, 80, 80, 5) trackercolour(silver)
  11. rslider bounds(220, 11, 70, 70), text("Cents"), channel("cents"), range(-100, 100, 0, 1, 1), fontcolour("white"), colour(100, 80, 80, 5) trackercolour(silver)
  12. rslider bounds(290, 11, 70, 70), text("Feedback"), channel("FB"), range(0, 1.50, 0), fontcolour("white"), colour(100, 80, 80, 5) trackercolour(silver)
  13. rslider bounds(360, 11, 70, 70), text("FFT Size"), channel("att_table"), range(1, 8, 5, 1,1), fontcolour("white"), colour(100, 80, 80, 5) trackercolour(silver)
  14. rslider bounds(430, 11, 70, 70), text("Mix"), channel("mix"), range(0, 1.00, 1), fontcolour("white"), colour(100, 80, 80, 5) trackercolour(silver)
  15. rslider bounds(500, 11, 70, 70), text("Level"), channel("lev"), range(0, 1.00, 0.5), fontcolour("white"), colour(100, 80, 80, 5) trackercolour(silver)
  16. </Cabbage>
  17. <CsoundSynthesizer>
  18. <CsOptions>
  19. -d -n
  20. </CsOptions>
  21. <CsInstruments>
  22. sr = 44100
  23. ksmps = 32
  24. nchnls = 2
  25. 0dbfs = 1 ;MAXIMUM AMPLITUDE
  26. ;Author: Iain McCurdy (2012)
  27. ;http://iainmccurdy.org/csound.html
  28. /* FFT attribute tables */
  29. giFFTattributes1 ftgen 0, 0, 4, -2, 64, 32, 64, 1
  30. giFFTattributes2 ftgen 0, 0, 4, -2, 128, 64, 128, 1
  31. giFFTattributes3 ftgen 0, 0, 4, -2, 256, 128, 256, 1
  32. giFFTattributes4 ftgen 0, 0, 4, -2, 512, 128, 512, 1
  33. giFFTattributes5 ftgen 0, 0, 4, -2, 1024, 256, 1024, 1
  34. giFFTattributes6 ftgen 0, 0, 4, -2, 2048, 512, 2048, 1
  35. giFFTattributes7 ftgen 0, 0, 4, -2, 4096,1024, 4096, 1
  36. giFFTattributes8 ftgen 0, 0, 4, -2, 8192,2048, 8192, 1
  37. opcode pvsbuffer_module,a,akkkkkkiiii
  38. ain,kspeed,kbuflen,kscale,kfeedback,kmix,klev,iFFTsize,ioverlap,iwinsize,iwintype xin
  39. kPhOffset = 0
  40. ktrig changed kbuflen
  41. ibuflen init 1
  42. kspeed init 1
  43. kscale init 1
  44. if ktrig==1 then
  45. reinit UPDATE
  46. endif
  47. UPDATE:
  48. ibuflen = i(kbuflen)
  49. iphasor ftgen 0, 0, 65536, 7, 0, 65536, 1 ;WAVE SHAPE FOR A MOVING PHASE POINTER
  50. aread osciliktp kspeed/ibuflen, iphasor, kPhOffset ;CREATE MOVING POINTER TO READ FROM BUFFER
  51. kread downsamp aread
  52. kread = kread * ibuflen ;RESCALE READ POINTER WITH PHASOR RANGE SLIDER
  53. aFB init 0
  54. f_anal pvsanal ain+aFB, iFFTsize, ioverlap, iwinsize, iwintype ;ANALYSE THE AUDIO SIGNAL THAT WAS CREATED IN INSTRUMENT 1. OUTPUT AN F-SIGNAL.
  55. ibuffer,ktime pvsbuffer f_anal, ibuflen ;BUFFER FSIG
  56. rireturn
  57. khandle init ibuffer ;INITIALISE HANDLE TO BUFFER
  58. f_buf pvsbufread kread , khandle ;READ BUFFER
  59. f_scale pvscale f_buf, kscale ;RESCALE FREQUENCIES
  60. aresyn pvsynth f_scale ;RESYNTHESIZE THE f-SIGNAL AS AN AUDIO SIGNAL
  61. aFB dcblock2 aresyn * kfeedback ;CREATE FEEDBACK SIGNAL FOR NEXT PASS AND BLOCK DC OFFSET ACCUMULATION
  62. amix ntrpol ain, aresyn, kmix ;CREATE DRY/WET MIX
  63. xout amix*klev
  64. endop
  65. instr 1
  66. ainL,ainR ins
  67. ;ainL,ainR diskin "SynthPad.wav",1,0,1 ;USE FOR TESTING
  68. kspeed chnget "speed"
  69. kbuflen chnget "buflen"
  70. ksemis chnget "semis"
  71. kcents chnget "cents"
  72. ksemis init 0
  73. kcents init 0
  74. kscale = semitone(ksemis)*cent(kcents)
  75. kscale init 1
  76. kbuflen init 1
  77. kspeed init 1
  78. kmix chnget "mix"
  79. kfeedback chnget "FB"
  80. klev chnget "lev"
  81. kmix init 1
  82. kfeedback init 0
  83. klev init 0.5
  84. /* SET FFT ATTRIBUTES */
  85. katt_table chnget "att_table" ; FFT atribute table
  86. katt_table init 5
  87. ktrig changed katt_table
  88. if ktrig==1 then
  89. reinit update
  90. endif
  91. update:
  92. iFFTsize table 0, giFFTattributes1 + i(katt_table) - 1
  93. ioverlap table 1, giFFTattributes1 + i(katt_table) - 1
  94. iwinsize table 2, giFFTattributes1 + i(katt_table) - 1
  95. iwintype table 3, giFFTattributes1 + i(katt_table) - 1
  96. /*-------------------*/
  97. aoutL pvsbuffer_module ainL,kspeed,kbuflen,kscale,kfeedback,kmix,klev,iFFTsize,ioverlap,iwinsize,iwintype
  98. aoutR pvsbuffer_module ainR,kspeed,kbuflen,kscale,kfeedback,kmix,klev,iFFTsize,ioverlap,iwinsize,iwintype
  99. outs aoutL,aoutR
  100. endin
  101. </CsInstruments>
  102. <CsScore>
  103. i 1 0.1 [60*60*24*7]
  104. </CsScore>
  105. </CsoundSynthesizer>