Hi. I want to create dead simple sampler which will asssign one sample per one note in octave.
I want to be able to load *.wav
samples in runtime, but this failed for me and I am unable to dig out what am I doing wrong.
<Cabbage>
form caption("WaggonBAU") size(400, 300), colour(58, 110, 182), pluginid("wagb")
keyboard bounds(6, 64, 381, 95)
filebutton bounds(6, 4, 40, 40) text("C", "C") channel("c") populate("*.wav")
filebutton bounds(52, 4, 40, 40) text("D", "D") channel("d")
filebutton bounds(98, 4, 40, 40) text("E", "E") channel("e")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables.
ksmps = 32
nchnls = 2
0dbfs = 1
giSampleC init 0
giSampleD init 0
giSampleE init 0
giSampleF init 0
giSampleG init 0
giSampleA init 0
giSampleH init 0
gSfilepath init ""
;instrument will be triggered by keyboard widget
instr 1
SampleCPath chnget "c"
kLoadC changed SampleCPath
if kLoadC==1 && strcmpk(SampleCPath,"")==1 then
printks "open = %s\n", 0, SampleCPath
gSfilepath = SampleCPath
event "i", 99, 1, 0
endif
kstatus, kchan, kdata1, kdata2 midiin
if changed(kstatus, kchan, kdata1, kdata2)==1 then
if kstatus==144 then
printks "this will trigger note %d\n", 0, kdata1%12
endif
endif
endin
instr 99
printks "99! %s\n", 0, gSfilepath
kSampleNo = p4
giSampleC ftgen 1,0,0,1,gSfilepath,0,0,0
printks "no=%d, lo=%d, fi=%s\n", 0, kSampleNo, giSampleC, gSfilepath
endin
</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
;f0 z
;starts instrument 1 and runs it for a week
i1 0 z
</CsScore>
</CsoundSynthesizer>
If you click on “C” it should load what sample will be played when note “C” is played. However, it seems that I didn’t get something important about loading samples.
(I am basically copying LoscilFilePlayer.csd
example)