form caption("Fog Horn") size(400, 300), pluginID("def1")
button bounds(8, 256, 80, 40) channel("playButton") text("Play Sample", "Play Sample")
rslider bounds(0, 8, 100, 100) channel("freq") range(50, 300, 132, 1, 1) text("Car. Freq")
rslider bounds(104, 8, 100, 100) channel("index") range(0, 8, 2, 1, 0.001) text("Mod. Index")
rslider bounds(200, 8, 100, 100) channel("filter") range(0, 10000, 200, .5, 0.001) text("Filter Freq")
rslider bounds(304, 8, 100, 100) channel("gain") range(0, 1, .5, 1, 0.001) text("Gain")
rslider bounds(0, 110, 100, 100) channel("duration") range(0, 5, 2, 1, 0.001) text("Duration")
rslider bounds(104, 110, 100, 100) channel("decay") range(0, 5, .5, 1, 0.001) text("Decay")
-n -d
; Initialize the global variables.
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
;Rory Walsh 2017
;============================================================
instr CONTROLLER ;always on instrument waiting to spawn events
kPlayButton chnget "playButton"
if changed(kPlayButton) == 1 then
event "i", "FOGHORN_SYNTH", 0, chnget:k("duration")
endif
endin
instr FOGHORN_SYNTH
kEnv madsr .05, 0, 1, chnget:i("decay")
k1 linsegr 5, .05, 0, chnget:i("decay"), 0.001
kFc chnget "freq"
kIndex chnget "index"
aMod oscil (k1+kIndex)*kFc, kFc*(abs(jitter(.01, 1, 2))+2)
aOut2 oscili kEnv, aMod+(kFc/2)
aOut1 oscili kEnv, aMod+(kFc)
aMix1 = aOut1+aOut2
aClip clip aMix1*10, .5, 1
aFlt1 butterbp aMix1, 2000, 3000
aL, aR reverbsc aClip, aClip, .9, chnget:k("filter")
aL = aL*kEnv
aR = aR*kEnv
outs (aFlt1+aL)*chnget:k("gain"), (aFlt1+aR)*chnget:k("gain")
endin
i"CONTROLLER" 0 1000
;causes Csound to run for about 7000 years...
f0 z