Cabbage Logo
Back to Cabbage Site

Sample player and Kswitch

Yes c5 i made the voices in serum

So you have 88 different samples ready to be played across all keys?

No i dont i could but thats a lot of samples i have to render and considering i have 3 vowels i dont wanna do that

Then you will need to re-pitch each of your samples, which was my original point. If you have a sample that is 440Hz, and want to play it it an octave higher, you will need to play it back at twice the pitch. So you need to work out the transposition ratios for each note, depending on the sample you wish to play. Otherwise nothing will be in tune.

sigh and i thought this was gonna be a quick little idea

Once you have the formula worked out it should be fine, but note that it is also dependant on the sampling rate. :flushed:

how do i make samples that are played in this way velocity sensitve

--midi-velocity-amp=5

This gives you a MIDI mapped amplitude value between 0 and 1. Just scale your output by p5 and you will have velocity sensitive playback :+1:

so i just add p5 to the csound options line?

It’s already there. Just, multiply your outputs by p5 accordingly.

well thats gonna be a lot of outs to multiply

instr 1
    if p4 == 60 then
        a1, a2 diskin2 "kick1.wav", 1, 0, 0
        outs a1, a2
    elseif p4 == 61 then
        a1, a2 diskin2 "kick2.wav", 1, 0, 0
        outs a1, a2
    elseif p4 == 62 then
        a1, a2 diskin2 "kick3.wav", 1, 0, 0
        outs a1, a2
    elseif p4 == 63 then
        a1, a2 diskin2 "kick4.wav", 1, 0, 0
        outs a1, a2
    elseif p4 == 64 then
        a1, a2 diskin2 "kick5.wav", 1, 0, 0
        outs a1, a2
    elseif p4 == 65 then
        a1, a2 diskin2 "snare1.wav", 1, 0, 0
        outs a1, a2
    elseif p4 == 66 then
        a1, a2 diskin2 "snare2.wav", 1, 0, 0
        outs a1, a2
    elseif p4 == 67 then
        a1, a2 diskin2 "snare3.wav", 1, 0, 0
        outs a1, a2
    elseif p4 == 68 then
        a1, a2 diskin2 "snare4.wav", 1, 0, 0
        outs a1, a2
    elseif p4 == 69 then
        a1, a2 diskin2 "snare5.wav", 1, 0, 0
        outs a1, a2
    elseif p4 == 70 then
        a1, a2 diskin2 "hat1.wav", 1, 0, 0
        outs a1, a2
    elseif p4 == 71 then
        a1, a2 diskin2 "hat2.wav", 1, 0, 0
        outs a1, a2
    elseif p4 == 72 then
        a1, a2 diskin2 "hat3.wav", 1, 0, 0
        outs a1, a2
    elseif p4 == 73 then
        a1, a2 diskin2 "hat4.wav", 1, 0, 0
        outs a1, a2
    elseif p4 == 74 then
        a1, a2 diskin2 "hat5.wav", 1, 0, 0
        outs a1, a2
    elseif p4 == 75 then
        a1, a2 diskin2 "ride1.wav", 1, 0, 0
        outs a1, a2
    elseif p4 == 76 then
        a1, a2 diskin2 "ride2.wav", 1, 0, 0
        outs a1, a2
    elseif p4 == 77 then
        a1, a2 diskin2 "ride3.wav", 1, 0, 0
        outs a1, a2
    elseif p4 == 78 then
        a1, a2 diskin2 "ride4.wav", 1, 0, 0
        outs a1, a2
    endif
endin

Take out all of those outs, and just put a single outs at the bottom. And the very top of your instrument do

a1, a2 init 0

so that Csound won’t complain, even if any of those if statement are not hit.

so i just have to put a1, a2 init 0 at the top and bottom of instrument 1 ok

Yeah, and put a single outs at the end…

so something like this

instr 1
a1, a2 init 0
    if p4 == 60 then
        a1, a2 diskin2 "kick1.wav", 1, 0, 0
    elseif p4 == 61 then
        a1, a2 diskin2 "kick2.wav", 1, 0, 0
    elseif p4 == 62 then
        a1, a2 diskin2 "kick3.wav", 1, 0, 0
    elseif p4 == 63 then
        a1, a2 diskin2 "kick4.wav", 1, 0, 0
    elseif p4 == 64 then
        a1, a2 diskin2 "kick5.wav", 1, 0, 0
    elseif p4 == 65 then
        a1, a2 diskin2 "snare1.wav", 1, 0, 0
    elseif p4 == 66 then
        a1, a2 diskin2 "snare2.wav", 1, 0, 0
    elseif p4 == 67 then
        a1, a2 diskin2 "snare3.wav", 1, 0, 0
    elseif p4 == 68 then
        a1, a2 diskin2 "snare4.wav", 1, 0, 0
    elseif p4 == 69 then
        a1, a2 diskin2 "snare5.wav", 1, 0, 0
    elseif p4 == 70 then
        a1, a2 diskin2 "hat1.wav", 1, 0, 0
    elseif p4 == 71 then
        a1, a2 diskin2 "hat2.wav", 1, 0, 0
    elseif p4 == 72 then
        a1, a2 diskin2 "hat3.wav", 1, 0, 0
    elseif p4 == 73 then
        a1, a2 diskin2 "hat4.wav", 1, 0, 0
    elseif p4 == 74 then
        a1, a2 diskin2 "hat5.wav", 1, 0, 0
    elseif p4 == 75 then
        a1, a2 diskin2 "ride1.wav", 1, 0, 0
    elseif p4 == 76 then
        a1, a2 diskin2 "ride2.wav", 1, 0, 0
    elseif p4 == 77 then
        a1, a2 diskin2 "ride3.wav", 1, 0, 0
    elseif p4 == 78 then
        a1, a2 diskin2 "ride4.wav", 1, 0, 0
    endif
a1, a2 init 0
endin

You don’t have outs opcode. And, no you don’t need to call init at the bottom. Just at the top.

ok i replaced the bottom one with outs a1, a2 now all thats left is the velocity sensitive part right?

That’s right. Go for it! All the info is the previous few posts. :muscle:

alright i give up i dont know how to multiply the out

The basic mathematical operators:

+ Addition 2 + 2 = 4
Subtraction 4 – 2 = 2
/ Division 8 / 4 = 2
* Multiplication 4 * 8 = 32