form caption("Presets") size(370, 280), colour(58, 110, 182), pluginId("MPre")
rslider bounds(14, 64, 85, 79), channel("att"), range(0, 1, 0.01, 1, 0.001), text("Att.")
rslider bounds(100, 64, 85, 79), channel("dec"), range(0, 1, 0.4, 1, 0.001), text("Dec.")
rslider bounds(186, 64, 85, 79), channel("sus"), range(0, 1, 0.7, 1, 0.001), text("Sus.")
rslider bounds(272, 64, 85, 79), channel("rel"), range(0, 1, 0.8, 1, 0.001), text("Rel.")
filebutton bounds(46, 186, 60, 28), channel("saveFile"), text("Save"), populate("*.pres"), mode("save")
filebutton bounds(108, 186, 60, 28), channel("openFile") text("Open"), populate("*.pres"), mode("file")
-n -d -+rtmidi=NULL -M0 --midi-key-cps=4 --midi-velocity-amp=5
; Initialize the global variables.
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
;always on and listening for preset updates..
instr 1000
if changed:k(chnget:S("openFile")) == 1 then
event "i", 1002, 0, .1
endif
if changed:k(chnget:S("saveFile")) == 1 then
event "i", 1003, 0, .1
endif
endin
;================================================
instr 1002 ;restore presets
SFileName chnget "openFile"
prints SFileName
if strrindex(SFileName, ".pres") == -1 then
SFileName strcat SFileName, ".pres"
endif
i1, i2, i3, i4 init 0
fini SFileName, 0, 0, i1, i2, i3, i4
chnset i1, "att"
chnset i2, "dec"
chnset i3, "sus"
chnset i4, "rel"
endin
;================================================
instr 1003 ;save presets
SFileName chnget "saveFile"
if strrindex(SFileName, ".pres") == -1 then
SFileName strcat SFileName, ".pres"
endif
fprints SFileName, "%f %f %f %f", chnget:i("att"), chnget:i("dec"), chnget:i("sus"), chnget:i("rel")
ficlose SFileName
endin
;causes Csound to run for about 7000 years...
i1000 0 z