Cabbage Logo
Back to Cabbage Site

Create VSTi from samples

Hi there! I’m new to Cabbage and it looks really great. Is it possible to create VSTi from recorded samples? (With different velocities). I can’t find an example that contains .WAV files as source to give me an idea. Thanks.

1 Like

Hi @bendur, try the SampleLoadAndPlayback example in the Misc folder. Just open a directory containing some .wav file and away you go. Should be enough to get you started :+1:

Thanks for your answer. But the SampleLoadAndPlayback code is designed for the user to load the samples, right? It would be easier for me to understand if there was something like a vst piano created from samples. Is there something like that?

Yes, you can do it. I even created a python script that will read ableton multisample xml and transform the parameters into something you can use in with flooper2. It’s not exactly something I can hand over as a turnkey system but it can be done!

1 Like

If you have the samples, playing them back is as easy as:

<Cabbage>
form caption("Untitled") size(400, 300), guiMode("queue"), pluginId("def1")
keyboard bounds(8, 158, 381, 95)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
ksmps = 32
nchnls = 2
0dbfs = 1

;instrument will be triggered by keyboard widget
instr 1
    event "i", 10, 0, 1, p4, p5
endin


instr 10
    iAmp = p5
    if p4 == 60 then
        p3 = filelen("C4.wav")
        a1, a2 diskin2 "C4.wav", 1
    elseif p4 == 61 then
        p3 = filelen("D4.wav")
        a1, a2 diskin2 "D4.wav", 1
    elseif p4 == 62 then
        //keep adding samples...
    endif
    
    outs a1*iAmp, a2*iAmp

endin
</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
</CsScore>
</CsoundSynthesizer>

There are more succinct way of doing this, but if you’re only starting out with Csound, this method is probably the simplest to understand. You trigger instr 10 with the note and amplitude currently being played. instr 10 then checks the note and plays the corresponding sample. The amplitude of the sample is then scaled according to the MIDI velocity.

1 Like

Just what I was looking for