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.

97 lines
2.4KB

  1. <Cabbage>
  2. form caption("clip") size(315, 90), pluginID("clip")
  3. image bounds(0, 0, 315, 90), colour( 0, 10, 20), shape("rounded"), outline("white"), line(4)
  4. rslider bounds( 10, 11, 70, 70), text("Limit"), channel("limit"), range(0.001, 1, 1, 0.5,0.001) , colour(0,10,20), fontcolour(silver), tracker(lightblue)
  5. rslider bounds( 75, 11, 70, 70), text("Argument"), channel("arg"), range(0, 1.00, 0.5) , colour(0,10,20), fontcolour(silver), tracker(lightblue)
  6. combobox bounds(150, 15, 80,20), channel("method"), size(80,50), value(1), text("B.D.J.", "Sine", "Tanh")
  7. checkbox bounds(150, 45, 100, 20), channel("clip_light"), text("clip") fontcolour("white"), shape("rounded"), colour("red")
  8. rslider bounds(235, 11, 70, 70), text("Level"), channel("level"), range(0, 10.00, 0.7) , colour(0,10,20), fontcolour(silver), tracker(lightblue)
  9. }
  10. </Cabbage>
  11. <CsoundSynthesizer>
  12. <CsOptions>
  13. -d -n
  14. </CsOptions>
  15. <CsInstruments>
  16. sr = 44100 ;SAMPLE RATE
  17. ksmps = 32 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
  18. nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
  19. 0dbfs = 1
  20. ;Author: Iain McCurdy (2012)
  21. instr 1
  22. gklimit chnget "limit" ;READ WIDGETS...
  23. gkmethod chnget "method" ;
  24. gkmethod init 1
  25. gkmethod init i(gkmethod)-1
  26. gkarg chnget "arg"
  27. gklevel chnget "level" ;
  28. ;asigL, asigR diskin2 "Seashore.wav",1,0,1 ;OPTIONALLY USE A BUILT-IN WAVEFORM FOR TESTING
  29. asigL, asigR ins
  30. kSwitch changed gklimit, gkmethod, gkarg ;GENERATE A MOMENTARY '1' PULSE IN OUTPUT 'kSwitch' IF ANY OF THE SCANNED INPUT VARIABLES CHANGE. (OUTPUT 'kSwitch' IS NORMALLY ZERO)
  31. if kSwitch=1 then ;IF A VARIABLE CHANGE INDICATOR IS RECEIVED...
  32. reinit START ;...BEGIN A REINITIALISATION PASS FROM LABEL 'START'
  33. endif ;END OF CONDITIONAL BRANCHING
  34. START: ;LABEL
  35. /* clip meter */
  36. krmsL rms asigL
  37. krmsR rms asigR
  38. kon = 1
  39. koff = 0
  40. if(krmsL>gklimit||krmsR>gklimit) then
  41. chnset kon,"clip_light"
  42. else
  43. chnset koff,"clip_light"
  44. endif
  45. /*------------*/
  46. aL clip asigL, i(gkmethod), i(gklimit), i(gkarg)
  47. aR clip asigR, i(gkmethod), i(gklimit), i(gkarg)
  48. rireturn ;RETURN TO PERFORMANCE PASSES FROM INITIALISATION PASS
  49. ; outs aL*gklevel*(1/(gklimit^0.5)), aR*gklevel*(1/(gklimit^0.5)) ;pdclip OUTPUTS ARE SENT TO THE SPEAKERS
  50. outs aL*gklevel, aR*gklevel ;pdclip OUTPUTS ARE SENT TO THE SPEAKERS
  51. endin
  52. </CsInstruments>
  53. <CsScore>
  54. i 1 0 [3600*24*7]
  55. </CsScore>
  56. </CsoundSynthesizer>