question, its there any tutorial of how I can add a push button and assign a key from the keyboard? I want to do some pads just because I like to see them bright the plug in and some of my design will look really nice with colorful pads, I can do the trick to make look a like pads when I press de keyboard but if I click on the won’t work because obviously its not coded for that, but I really want to do them, thanx
How can I create pads linked to key notes?
Something like this? Hitting a pad will play a note, and so will the keyboard. The length of the note is determined by how long the button is pressed - latched(0)
keyPad.csd (1.1 KB)
Nice UI! Glad that I could
so I’ve try couple of things, I don’t get the pad blinking when I press the key I selected for the pad, I mean , if the client want to press the keyboard instead of touching the pad it won’t light up like when I click the pad, I did come up with a blinking light and I add image of pads on and off but the pad keeps on until the sound finish , it fade out like a meter, I need to be off of as soon I depress the key., I will keep looking to see if I found a way,i know got to be something in the examples, I will check again
You just need to set the off colour when the note is pressed, and when it’s released set to back again:
<Cabbage>
form caption("Untitled") size(400, 300), guiMode("queue"), pluginId("def1"), colour(255)
keyboard bounds(6, 210, 381, 85)
button bounds(2, 2, 100, 100) channel("pad1") corners(10), latched(0), colour:0("red"), colour:1("blue")
button bounds(2, 104, 100, 100) channel("pad2") corners(10), latched(0), colour:0("red"), colour:1("blue")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables.
ksmps = 32
nchnls = 2
0dbfs = 1
instr 99
kPad1, kTrig1 cabbageGet "pad1"
kPad2, kTrig2 cabbageGet "pad2"
if kTrig1 == 1 then
if kPad1 == 1 then
event "i", 1, 0, -1, 200, 1
else
event "i", -1, 0, 0
endif
elseif kTrig2 == 1 then
if kPad2 == 1 then
event "i", 1, 0, -1, 300, 1
else
event "i", -1, 0, 0
endif
endif
endin
;instrument will be triggered by keyboard widget
instr 1
cabbageSet "pad1", "colour:0(\"blue\")"
kEnv madsr .1, 0, 1, .1
aOut vco2 p5, p4
outs aOut*kEnv, aOut*kEnv
cabbageSet release(), "pad1", "colour:0(\"red\")"
endin
</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
i99 0 z
</CsScore>
</CsoundSynthesizer>
Thanks Rory and Thanks djalex1 for the question.