form caption("Police Siren") size(500, 150) pluginID("def1")
rslider bounds(376, 8, 100, 100), channel("gain"), range(0, 1, 0.5, 1, .01), text("Gain"), trackercolour("lime"), outlinecolour(0, 0, 0, 50)
;gentable bounds(8, 8, 260, 160), tablenumber(1), identchannel("table")
rslider bounds(8, 8, 65, 65), channel("attackShape"), range(-10, 1, -6), text("Att.")
rslider bounds(136, 8, 65, 65), channel("decayShape"), range(-10, 1, -3), text("Dec.")
rslider bounds(72, 8, 65, 65), channel("attackDur"), range(0, 4096, 2048), text("Att Dur")
rslider bounds(200, 8, 65, 65), channel("overdrive"), text("overdrive"), range(1, 100, 1)
rslider bounds(264, 8, 65, 65), channel("freq"), text("speed"), range(0.1, 3, 0.2)
button bounds(8, 88, 108, 35), channel("playButton"), text("Start", "Stop")
-n -d -+rtmidi=NULL -M0 -m0d
; Initialize the global variables.
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
; Rory Walsh, 2016
;============================================================
instr CONTROLLER ;always on instrument waiting to spawn events
kPlayButton chnget "playButton"
if changed(kPlayButton) == 1 then
if kPlayButton == 1 then
event "i", "SIREN", 0, -1
else
turnoff2 "SIREN", 1, 0
endif
endif
endin
instr SIREN
k1 oscil 800, chnget:k("freq"), 1
a1 vco2 .5*chnget:k("overdrive"), 300+k1
a1 clip a1, 1, 1
outs (a1)*chnget:k("gain"), (a1)*chnget:k("gain")
kAtt chnget "attackShape"
kDec chnget "decayShape"
kDur chnget "attackDur"
kTrig changed kAtt, kDec, kDur
if kTrig ==1 then
event "i", 2, 0, 0, kDur, kAtt, kDec, p
endif
endin
;this instrument is used to display graph in Cabbage..
instr 2
gi1 ftgen 1, 0, 4096, 16, 0, p4, p5, 1, 4096-p4, p6, 0
chnset "tablenumber(1)", "table" ; update table display
endin
f1 0 4096 16 0 2048 -6 1 2048 -3 0
i"CONTROLLER" 0 [60*60*24*7]