Cabbage Logo
Back to Cabbage Site

Key trigger

without using the text editor :upside_down_face:

Well, yes, look at the first example with the texteditor. Just swap ā€˜1ā€™ for ā€˜aā€™ and an oscillator for a sample.

But, no you canā€™t assign keys to buttons, or at least in a simple way.

ok hanks so much, I only see one example on the site and it doesnā€™t show an oscillator in the codeā€¦are there more examples somewhere?

its just this example here

ignore my tabs lol

I was referring to the example I posted to you at the start of this thread. Thatā€™s the only way to assign and trigger things from the keyboard.

ok i get you now rory, will I have to press enter every time I enter a key for it to work?

Ok I assume you have to press enter everytime to get the key to workā€¦Iā€™m now resorting back to the keyboard to trigger the samples lolā€¦I got the text editor to work pressing and entering ā€œaā€ earlierā€¦now I want this to work with the keyboard insteadā€¦Iā€™ve changed around the code a little but just trying to get it to work.asasasasasa.csd (885 Bytes)

Well, thatā€™s really the simplest thing to do, check what note was pressed, and play a sample accordingly:

<Cabbage>
form caption("Untitled") size(900, 1100), guiMode("queue") pluginId("def1")
button bounds(0, 350, 174, 400)
keyboard bounds(0, 0, 400, 200), value(40) channel("play1")
</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


instr 1
    if p4 == 60 then
        event_i "i", 2, 0, 4, 60
    endif
endin

instr 2

    a1 diskin "marim22.l.wav" 
    
    outs a1, a1
endin
</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
;starts instrument 1 and runs it for a week
i1 0 [60*60*24*7] 
</CsScore>
</CsoundSynthesizer>

cool, im now trying to. combine some of the key trigger stuff to trigger that note with the letter ā€œaā€

new c.csd (830 Bytes)

sorry actually this is more correct
new c.csd (961 Bytes)

Did you read this? you seem to be going round in circles :man_shrugging: Iā€™ve no idea what youā€™re now talking about :rofl:

Probably :joy:
itā€™s all good rory, thanks fro your help

1 Like