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.

131 lines
5.5KB

  1. ; pvsFreeze.csd
  2. ; Freeze either amplitude stream or frequency stream (or both) of a streaming FFT analysis
  3. ; Changing FFT size can modify the sound quality of the frozen sound
  4. ; 'Auto' can be used to automatically trigger a new freeze frame (both amplitude and frequency) if the amplitude of the sound crosses a threshold
  5. ; 'Delay' specifies the time delay at which the sound will actually be frozen after the threshold triggering. This can be employed to capture the sustain portion of a sound (and not the attack).
  6. ; 'Threshold' specifies the threshold level at which triggering will occur. In a noisy environment, raise 'Threshold'
  7. <Cabbage>
  8. form caption("pvsfreeze"), size(670, 80) colour( 0,140,40,170), pluginID("frez")
  9. image bounds( 0, 0,270, 80), colour( 0,200,100,100), shape("rounded"), outline("white"), line(4)
  10. checkbox bounds( 15, 10, 180, 25), channel("freezb"), text("Freeze Both"), fontcolour("white"), shape("rounded"), colour("red")
  11. checkbox bounds(120, 10, 180, 25), channel("freeza"), text("Freeze Amplitudes"), fontcolour("white"), shape("rounded"), colour("yellow")
  12. checkbox bounds(120, 45, 180, 25), channel("freezf"), text("Freeze Frequencies"), fontcolour("white"), shape("rounded"), colour("orange")
  13. image bounds(270, 0,200, 80), colour( 0,200,100,100), shape("rounded"), outline("white"), line(4)
  14. rslider bounds(280, 10, 60, 60), text("FFT Size"), channel("att_table"), range(1, 8, 5, 1,1), fontcolour("white"), colour( 0,100, 50,255), trackercolour("white")
  15. rslider bounds(340, 10, 60, 60), text("Mix"), channel("mix"), range(0, 1.00, 1), fontcolour("white"), colour( 0,100, 50,255), trackercolour("white")
  16. rslider bounds(400, 10, 60, 60), text("Level"), channel("lev"), range(0, 1.00, 0.5, 0.5), fontcolour("white"), colour( 0,100, 50,255), trackercolour("white")
  17. image bounds(470, 0,200, 80), colour( 0,200,100,100), shape("rounded"), outline("white"), line(4)
  18. checkbox bounds(480, 10, 180, 25), channel("auto"), text("Auto"), fontcolour("white"), shape("rounded"), colour("red")
  19. rslider bounds(540, 10, 60, 60), text("Delay"), channel("delay"), fontcolour("white"), range(0.0001, 0.5, 0.1, 1,0.001), colour( 0,100, 50,255), trackercolour("white")
  20. rslider bounds(600, 10, 60, 60), text("Threshold"), channel("thresh"), fontcolour("white"), range(0.001, 0.5, 0.1,1,0.001), colour( 0,100, 50,255), trackercolour("white")
  21. </Cabbage>
  22. <CsoundSynthesizer>
  23. <CsOptions>
  24. -d -n
  25. </CsOptions>
  26. <CsInstruments>
  27. sr = 44100
  28. ksmps = 64
  29. nchnls = 2
  30. 0dbfs = 1 ;MAXIMUM AMPLITUDE
  31. ;Author: Iain McCurdy (2013)
  32. ;http://iainmccurdy.org/csound.html
  33. /* FFT attribute tables */
  34. giFFTattributes1 ftgen 0, 0, 4, -2, 64, 32, 64, 1
  35. giFFTattributes2 ftgen 0, 0, 4, -2, 128, 64, 128, 1
  36. giFFTattributes3 ftgen 0, 0, 4, -2, 256, 128, 256, 1
  37. giFFTattributes4 ftgen 0, 0, 4, -2, 512, 128, 512, 1
  38. giFFTattributes5 ftgen 0, 0, 4, -2, 1024, 256, 1024, 1
  39. giFFTattributes6 ftgen 0, 0, 4, -2, 2048, 512, 2048, 1
  40. giFFTattributes7 ftgen 0, 0, 4, -2, 4096,1024, 4096, 1
  41. giFFTattributes8 ftgen 0, 0, 4, -2, 8192,2048, 8192, 1
  42. opcode pvsfreeze_module,a,akkkkiiii
  43. ain,kfreeza,kfreezf,kmix,klev,iFFTsize,ioverlap,iwinsize,iwintype xin
  44. f_anal pvsanal ain, iFFTsize, ioverlap, iwinsize, iwintype ;ANALYSE AUDIO INPUT SIGNAL AND OUTPUT AN FSIG
  45. f_freeze pvsfreeze f_anal, kfreeza, kfreezf
  46. aout pvsynth f_freeze ;RESYNTHESIZE THE f-SIGNAL AS AN AUDIO SIGNAL
  47. amix ntrpol ain, aout, kmix ;CREATE DRY/WET MIX
  48. xout amix*klev
  49. endop
  50. instr 1
  51. kmix chnget "mix" ; read in widgets
  52. klev chnget "lev"
  53. kfreeza chnget "freeza"
  54. kfreezf chnget "freeza"
  55. kfreezb chnget "freezb"
  56. ; triggering of 'Freeze All' mode
  57. kon = 1
  58. koff = 0
  59. ktrigon trigger kfreezb,0.5,0
  60. ktrigoff trigger kfreezb,0.5,1
  61. if(ktrigon==1) then
  62. chnset kon,"freeza"
  63. chnset kon,"freezf"
  64. elseif(ktrigoff==1) then
  65. chnset koff,"freeza"
  66. chnset koff,"freezf"
  67. endif
  68. ; audio input
  69. ainL,ainR ins
  70. ;ainL,ainR diskin "808loop.wav",1,0,1 ;USE FOR TESTING
  71. ; auto freeze triggering
  72. kauto chnget "auto" ; read in widgets
  73. kthresh chnget "thresh"
  74. kdelay chnget "delay"
  75. if kauto==1 then ; if 'Auto' is on
  76. krms rms ainL+ainR ; scan RMS of audio signal
  77. ktrig trigger krms,kthresh,0 ; if signal crosses threshold upwards
  78. ktrigdel vdel_k ktrig,kdelay,0.5 ; delayed version of the trigger
  79. if ktrig==1 then ; if initial threshold crossing occurs...
  80. chnset koff,"freeza" ; turn freezing off
  81. chnset koff,"freezf"
  82. endif
  83. if ktrigdel==1 then ; if delayed trigger is received...
  84. chnset kon,"freeza" ; turn freezing on
  85. chnset kon,"freezf"
  86. endif
  87. endif
  88. kofftrig trigger kauto,0.5,1 ; when 'Auto' is turned off generate a trigger
  89. if kofftrig==1 then ; if 'Auto' is turned off...
  90. chnset koff,"freeza" ; turn freezing off
  91. chnset koff,"freezf"
  92. endif
  93. /* SET FFT ATTRIBUTES */
  94. katt_table chnget "att_table" ; FFT atribute table
  95. katt_table init 5
  96. ktrig changed katt_table
  97. if ktrig==1 then
  98. reinit update
  99. endif
  100. update:
  101. iFFTsize table 0, giFFTattributes1 + i(katt_table) - 1
  102. ioverlap table 1, giFFTattributes1 + i(katt_table) - 1
  103. iwinsize table 2, giFFTattributes1 + i(katt_table) - 1
  104. iwintype table 3, giFFTattributes1 + i(katt_table) - 1
  105. /*-------------------*/
  106. aoutL pvsfreeze_module ainL,kfreeza,kfreezf,kmix,klev,iFFTsize,ioverlap,iwinsize,iwintype
  107. aoutR pvsfreeze_module ainR,kfreeza,kfreezf,kmix,klev,iFFTsize,ioverlap,iwinsize,iwintype
  108. outs aoutR,aoutR
  109. endin
  110. </CsInstruments>
  111. <CsScore>
  112. i 1 0 [60*60*24*7]
  113. </CsScore>
  114. </CsoundSynthesizer>