Button to trigger MIDI note
-
Has anyone figured out how to make a button trigger a midi note?
of course this button can play a note
const var test = Content.getComponent("test"); var EventId = 0; inline function ontestControl(component, value) { if (value) { Synth.playNote(1, 100); } else { Synth.noteOffByEventId(EventId); } }; Content.getComponent("test").setControlCallback(ontestControl);
but how can I also play the actual midi note? I'd like to be able to record the button presses in an empty midi file in a midi player, but that currently only records notes pressed by the keyboard, not the buttons
Thanks!
-
@rglides Try
playNoteFromUI
. -
@clevername27 oh, so Synth.playNoteFromUI(1, 100); ?
-
@rglides
The methodsSynth.addNoteOn(int channel, int noteNumber, int velocity, int timeStampSamples)
and
Synth.addNoteOff(int channel, int noteNumber, int timeStampSamples)will make MIDI messages that you can see in the Event Logger: MIDI Processor.
I am not sure, but you may need to put the MIDI player in a separate container in the Module Tree for it to "see" the incoming MIDI messages created this way.
-
@VirtualVirgin said in Button to trigger MIDI note:
timeStampSamples
Thanks! I'm confused by timeStampSamples but I guess I can just try some numbers out
-
@rglides
Engine.getSamplesForMilliSeconds
-
@clevername27 Thank you!