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.

59 lines
2.2KB

  1. <Cabbage>
  2. form caption("Pink Noise"), size(230, 80), pluginID("pnse")
  3. image bounds( 0, 0,230, 80), colour("pink"), shape("rounded"), outline("red"), line(4)
  4. checkbox bounds( 20, 10, 80, 15), text("On/Off"), channel("onoff"), value(1), fontcolour("black")
  5. combobox bounds( 20, 40, 70, 20), channel("method"), value(1), text("Gardner", "Kellet", "Kellet 2")
  6. rslider bounds(100, 10, 60, 60), text("Amplitude"), channel("amp"), range(0, 1, 0.5, 0.5, 0.001), fontcolour("black")
  7. rslider bounds(160, 10, 60, 60), text("N.Bands"), channel("numbands"), range(4, 32, 20, 1, 1), fontcolour("black")
  8. </Cabbage>
  9. <CsoundSynthesizer>
  10. <CsOptions>
  11. -dm0 -n -+rtmidi=null -M0
  12. </CsOptions>
  13. <CsInstruments>
  14. sr = 44100
  15. ksmps = 64
  16. nchnls = 2
  17. 0dbfs = 1 ;MAXIMUM AMPLITUDE
  18. massign 0,0
  19. instr 1
  20. konoff chnget "onoff" ;read in on/off switch widget value
  21. if konoff==0 goto SKIP ;if on/off switch is off jump to skip label
  22. kmethod chnget "method"
  23. kmethod = kmethod - 1
  24. knumbands chnget "numbands"
  25. kamp chnget "amp"
  26. ktrig changed kmethod, knumbands ;GENERATE BANG (A MOMENTARY '1') IF ANY OF THE INPUT VARIABLES CHANGE
  27. if ktrig==1 then ;IF AN I-RATE VARIABLE HAS CHANGED
  28. reinit UPDATE ;BEGIN A REINITIALISATION PASS FROM LABEL 'UPDATE'
  29. endif ;END OF CONDITIONAL BRANCH
  30. UPDATE: ;LABEL CALLED 'UPDATE'
  31. if kmethod=0 then ;IF GARDNER METHOD HAS BEEN CHOSEN...
  32. asigL pinkish kamp, i(kmethod), i(knumbands) ;GENERATE PINK NOISE
  33. asigR pinkish kamp, i(kmethod), i(knumbands) ;GENERATE PINK NOISE
  34. else ;OTHERWISE (I.E. 2ND OR 3RD METHOD HAS BEEN CHOSEN)
  35. anoise unirand 2 ;WHITE NOISE BETWEEN ZERO AND 2
  36. anoise = (anoise-1) ;OFFSET TO RANGE BETWEEN -1 AND 1
  37. asigL pinkish anoise, i(kmethod) ;GENERATE PINK NOISE
  38. asigR pinkish anoise, i(kmethod) ;GENERATE PINK NOISE
  39. asigL = asigL * kamp ;RESCALE AMPLITUDE WITH gkpinkamp
  40. asigR = asigR * kamp ;RESCALE AMPLITUDE WITH gkpinkamp
  41. endif ;END OF CONDITIONAL
  42. rireturn ;RETURN FROM REINITIALISATION PASS
  43. outs asigL,asigR ;SEND AUDIO SIGNAL TO OUTPUT
  44. SKIP: ;A label. Skip to here is on/off switch is off
  45. endin
  46. </CsInstruments>
  47. <CsScore>
  48. i 1 0 [60*60*24*7] ;instrument that reads in widget data
  49. </CsScore>
  50. </CsoundSynthesizer>