Cabbage Logo
Back to Cabbage Site

Save Samples within VST on export

Hello, thanks for an amazing platform first of all! It is great!
I am able to playback the samples from the folder where the .csd file is at the moment.
But when I export VST and open it in Ableton, there is no sound, Is it possible to embed the samples into VST file?

<Cabbage>
form size(398, 155), caption("NYH DRUM"), pluginID("n123")
keyboard bounds(21, 12, 360, 100)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 --midi-key=4 --midi-velocity-amp=5 -m0d
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 64
nchnls = 2
0dbfs = 1

;triggering samples...
instr 1
event_i "i", 99, 0, .25, p4
endin

;sampler instrument
instr 99
iTable = p4
p3 = ftlen(iTable) 
aOut loscil3 1, 1, iTable, 1, 0;
outs aOut, aOut
endin

</CsInstruments>  
<CsScore>
f1 0 1024 10 1 
f60 0 0 1 "kick.wav" 0 4 1
f61 0 0 1 "snare.wav" 0 4 1
f62 0 0 1 "hat.wav" 0 4 1
f0 3600
</CsScore>
</CsoundSynthesizer>

FIGURED IT OUT, put samples inside .vst/Contents file.
That is great!

Or you can use the bundle() identifier which makes things much easier.

p.s. I formatted your code, if you don’t select and click the </> button, much of your code will not appear when you post…

thanks, i ll have a look into that, now i am trying to trigger the sample with a button but somehow cannot get the button to print in the console

   instr 1

kButtonValue chnget "bu1"
   if changed(kButtonValue) == 1 then
      event "i", 99, 0, .25, 60
      printk2 kButtonValue
   endif

endin

It’s working fine here. Are you sure you didn’t mean to write ‘but1’ instead of ‘bu1’ ?

Was trying different names)) Here is the whole code, no button action for some reason…

<Cabbage> bounds(0, 0, 0, 0)
form size(850, 430), caption("NYH DRUM"), pluginID("n123")
image bounds(64, 154, 182, 183) file("../0005400029_10.jpg")
keyboard bounds(360, 20, 263, 207)
button bounds(86, 54, 80, 40) channel("but1")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 --midi-key=4 --midi-velocity-amp=5 -m0d
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 64
nchnls = 2
0dbfs = 1

;triggering samples...
//instr 1

//event_i "i", 99, 0, .25, p4

//endin



instr 1

kButtonValue chnget "but1"
   if changed(kButtonValue) == 1 then
      event "i", 99, 0, .25, 60
      printk2 kButtonValue
   endif

endin

;sampler instrument
instr 99
iTable = p4
p3 = ftlen(iTable) 
aOut loscil3 1, 1, iTable, 1, 0;
outs aOut, aOut
endin

</CsInstruments>  
<CsScore>
f1 0 1024 10 1 
f60 0 0 1 "kick.wav" 0 4 1
f61 0 0 1 "snare.wav" 0 4 1
f62 0 0 1 "hat.wav" 0 4 1
f0 3600
</CsScore>
</CsoundSynthesizer>

Don’t forget that it won’t print anything unless the instrument is playing. In your case that means a note is pressed. In the sample code below I have instrument set to play automatically in the score. Pressing the button here prints to console fine:

<Cabbage>
form size(500, 130), caption("Untitled"), colour(34, 34, 34)
button bounds(10, 10, 110, 40), channel("bu1"), text("Hit me")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d
</CsOptions>
<CsInstruments>
sr = 44100 
nchnls = 2
ksmps = 32
0dbfs = 1

instr 1

kButtonValue chnget "bu1"
if changed(kButtonValue) == 1 then
  ;event "i", 99, 0, .25, 60
  printk2 kButtonValue
endif
endin

</CsInstruments> 
<CsScore>
i1 0 z
</CsScore> 
</CsoundSynthesizer>

Huge thanks for this “i1 0 z” magic.
I would spent weeks trying to figure out that myself.
Thanks again!
Have a great day!

Not that you will probably one trigger an instrument like this from the score when you are developing effects. I find it’s easier to trigger synths from MIDI notes.