form caption("Untitled") size(215, 250), guiMode("queue") pluginId("def1")
nslider bounds(50, 2, 117, 50), channel("rate"), range(0, 16, 1, 1, 0.001), text("rate"), trackerColour(0, 255, 0, 255), outlineColour(0, 0, 0, 50), textColour(0, 0, 0, 255)
rslider bounds(4, 54, 100, 100), channel("fade"), range(0, 50, 1, 1, 0.001), text("fade"), trackerColour(0, 255, 0, 255), outlineColour(0, 0, 0, 50), textColour(0, 0, 0, 255)
rslider bounds(108, 54, 100, 100), channel("amount"), range(0, 1, 1, 1, 0.001), text("amount"), trackerColour(0, 255, 0, 255), outlineColour(0, 0, 0, 50), textColour(0, 0, 0, 255)
rslider bounds(36, 156, 69, 69), channel("power"), range(0, 10, 1, 0.3, 0.001), text("power"), trackerColour(0, 255, 0, 255), outlineColour(0, 0, 0, 50), textColour(0, 0, 0, 255)
rslider bounds(104, 156, 69, 69), channel("lp"), range(0, 20000, 20000, 0.15, 0.001), text("lp"), trackerColour(0, 255, 0, 255), outlineColour(0, 0, 0, 50), textColour(0, 0, 0, 255)
nslider bounds(76, 218, 60, 30), channel("end"), range(0, 4, 1, 1, 0.001), text("end"), trackerColour(0, 255, 0, 255), outlineColour(0, 0, 0, 50), textColour(0, 0, 0, 255)
-n -d
; Initialize the global variables.
ksmps = 32
nchnls = 2
0dbfs = 1
gkstart = 0
opcode checke, k, kk
ksamplength, kplaying xin
setksmps 1
ktimeshit chnget "HOST_PPQ_POS"
if((int(ktimeshit)*(ksamplength/4))%ksamplength == 0) then
gkstart = 1
endif
if(kplaying = 0) then
gkstart = 0
endif
kout = gkstart
xout kout
endop
instr 1
krate cabbageGetValue "rate"
kbpm chnget "HOST_BPM"
kplaying chnget "IS_PLAYING"
//kplaying = 1
kfade chnget "fade"
kamount chnget "amount"
kpower chnget "power"
klp chnget "lp"
kend chnget "end"
a1 inch 1
a2 inch 2
ksamplength = ( ( ( (60/kbpm) * 2 ) * 60 ) * 735 ) * krate
kstart checke ksamplength, kplaying
ktime = kfade*735
kduck loopseg sr/ksamplength, abs(kstart-1), 0, 0, ktime, 1, ksamplength - (ktime+(kend*735)), 1, 0, 0, kend*735, 0
kduck2 loopseg sr/ksamplength, abs(kstart-1), 0, 0, ktime, 0, ksamplength - (ktime+(kend*735)), 0, 0, 1, kend*735, 0
aduck interp pow(kduck, kpower)
aduck2 interp kduck2
alp butlp aduck+aduck2, portk(klp, 0.1)
outs a1 * (((alp) * kamount) + abs(kamount-1) ), a2 * (((alp) * kamount) + abs(kamount-1))
endin
;causes Csound to run for about 7000 years...
f0 z
;starts instrument 1 and runs it for a week
i1 0 [60*60*24*7]