setKeyPressCallback() how to?
-
Can somone please enlight me how to use the
setKeyPressCallback()
? :-)
Thanks in advance!EDIT: Or is there a way, to control a set of buttons via keyboard?
-
@toxonic you can simply use
button.setValue()
into the on Note and noteOff CBEdit : or a array of buttons of course
-
@Matt_SF Oh, i missunderstood that, i thought about using the computer keyboard to trigger buttons. But when i overthink it, it'd be quite useless, since you wouldn't be abel to trigger more than one button simultanously.
-
@toxonic Your question interested me because I am looking for a way to trigger button via keypress.
I would like to change button's value via specific "on note on" and "on note off" like this :OnNoteOn :
//this doesn't work const var Button15 = Content.getComponent("Button15"); const var Button16 = Content.getComponent("Button16"); function onNoteOn(48) { Button15.setValue(1); } function onNoteOn(49) { Button16.setValue(1); }
-
You just need to use an if statement.
You can't add more onNoteOn callbacks, there can be only one (per script)! And it doesn't take any parameters.
In your one and only
onNoteOn
callback you can do this.if (Message.getNoteNumber() == 48) { Button15.setValue(1); }
Remember to defer this script, you don't want your UI messing with your real-time stuff.
-
@d-healey ok, thank you david.
It works.So I need to add "Synth.deferCallbacks(true);" at the top of the onNoteOn and onNoteOff script?
thanks
-
at the top of the onNoteOn and onNoteOff script?
Both of those callbacks are in a single script, go have a look in your project's scripts folder and you'll see the file which you can open in a text editor.
You should place the deferCallbacks call in on init. This will defer all of the MIDI callbacks in that script.
-
@d-healey Ok thanks david.
it's much clearer for me