form caption("SVG FFT") size(600, 300), colour(20, 50, 50), guiMode("queue") pluginId("def1")
image bounds(0, 0, 600, 300), channel("fftGrid"), colour(0,0,0,0)
image bounds(0, 0, 600, 300), channel("fftImage1"), colour(0,0,0,0)
image bounds(0, 0, 600, 300), channel("fftImage2"), colour(0, 0, 0, 0)
button bounds(500, 10, 80, 30), text("Pause", "Unpause"), channel("pause"), corners(5)
label bounds(-100, -100, 50, 15), text(""), channel("hoverFreq")
-n -d -+rtmidi=NULL -M0
; Initialize the global variables.
ksmps = 32
nchnls = 2
0dbfs = 1
opcode rgbString, S,iii
iR, iG, iB xin
SColourString sprintf {{rgb(%d, %d, %d)}}, iR, iG, iB
xout SColourString
endop
opcode svgFFT, 0,Sk[]iiii
SChannel, kData[], iUpdateRate, iR, iG, iB xin
iBounds[] cabbageGet SChannel, "bounds"
kIndex = 0
kLen lenarray kData
if metro(iUpdateRate) == 1 then
SPath strcpyk sprintfk("", iBounds[2], iBounds[3], iBounds[3], rgbString(iR, iG, iB))
cabbageSet 1, SChannel, "svgElement", SPath
endif
endop
instr 1
kData1[] init 1026
if chnget:k("pause") == 0 then
kFreq = 100 + abs(oscili:k(1000, .05))
endif
aSig vco2 1, kFreq
fSig1 pvsanal aSig, 1024,256,1024, 1
kFrame1 pvs2array kData1, fSig1
svgFFT "fftImage1", kData1, 10, 147, 200, 60
cabbageSet metro(20), "freqLabel", sprintfk("text(\"%d Hz.\")", kFreq)
kMouseX chnget "MOUSE_X"
kMouseY chnget "MOUSE_Y"
cabbageSet metro(20), "hoverFreq", "bounds", kMouseX, kMouseY-20, 50, 15
if kMouseY > 50 then
cabbageSet metro(20), "hoverFreq", sprintfk("text(\"%d Hz.\")", pow(kMouseX/600, 2)*sr/4)
else
cabbageSet metro(20), "hoverFreq", "text(\"\")"
endif
endin
i1 0 [60*60*24*7]