form caption("SoundfilerDemo") size(600, 300), colour(58, 110, 182), pluginID("def1")
;----------------------------------
groupbox bounds(0, 0, 140, 280) identchannel("GB_Menu") text("Menu") colour(178, 186, 230, 255) fontcolour:0(0, 0, 0, 255) outlinecolour(9, 16, 91, 255)
{
filebutton bounds(10, 200, 55, 30) channel("filebutton") value(0) text("Save", "Save") mode("snapshot") $PROPERTY_BUT_OSCA
combobox bounds(10, 235, 120, 30) channel("PresetCombo") populate("*.snaps")
}
;-----------------------------------
;- Region: Main Oscillator GUI
;----------------------------------
groupbox bounds(140, 0, 700, 280) identchannel("GB_MainOSc") text("Main Oscilators") visible(1) colour(178, 186, 230, 255) fontcolour:0(0, 0, 0, 255) outlinecolour(9, 16, 91, 255)
{
filebutton bounds(10, 20, 80, 20) channel("filenameOscA") value(0) text("Open File", "Open File") populate("", "") shape("ellipse")
soundfiler bounds(10, 43, 230, 100) channel("beg", "len") identchannel("filerOscA") colour(50, 214, 214, 255) fontcolour:0(160, 160, 160, 255) fontcolour:1(160, 160, 160, 255) tablenumber(900) zoom(0)
keyboard bounds(8, 180, 381, 95)
}
-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5
; Initialize the global variables.
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
gSfilepathOscA init ""
instr LoadSoundFile ; load sound file
if p4 == 1 then
; Sfile strcpy gSfilepathOscA
if filevalid(gSfilepathOscA) ==1 then
gitableOscA ftgen 901,0,0,1,gSfilepathOscA,0,0,0 ; load sound file into a GEN 01 function table
gichansOscA filenchnls gSfilepathOscA ; derive the number of channels (mono=1,stereo=2) in the sound file
giReadyOscA = 1 ; if no string has yet been loaded giReady will be zero
gkTabLenOscA init ftlen(gitableOscA)/gichansOscA ; table length in sample frames
Smessage sprintfk "file(%s)", gSfilepathOscA ; print sound file to viewer
prints Smessage
prints"\n"
chnset Smessage, "filerOscA"
else
printks "File no valid \n",0
endif
endif
endin
instr InitWav
chnset "AKWF_0212.wav","filenameOscA"
endin
instr 2
;- Region: Load soundfile
if changed:k(chnget:S("filenameOscA"))==1 then
gSfilepathOscA chnget "filenameOscA"
endif
kNewFileTrg1 changed gSfilepathOscA ; if a new file is loaded generate a trigger
if kNewFileTrg1 == 1 then ; if user has requested a preset or new file...
event "i", "LoadSoundFile", 0, 0, 1 ; call instrument to update sample storage function table
endif
if changed:k(chnget:k("PresetCombo"))==1 then
gSfilepathOscA chnget "filenameOscA"
event "i", "LoadSoundFile", 0, 0, 1
endif
endin
;instrument will be triggered by keyboard widget
instr 1
kEnv madsr .1, .2, .6, .4
aOut poscil p5, p4,901
outs aOut*kEnv, aOut*kEnv
endin
;causes Csound to run for about 7000 years...
i "InitWav" 0 0
i 2 0.01 z
i 1 0.01 z