MidiKeyboardComponent Remapping Question


#1

Hey guys,

I have 2 questions about the built in keyboard component.
I am trying to reroute the midi output (press C key, output F key) and currently the only command I can find to do so is “setKeyPressForNote(const KeyPress &Key, int midiNoteOffsetFromC)” where you alter each individual note to your desired output. I was wondering if there is a command to remap specific notes, like C, to output a different note in each octave? Currently if you remap a C1, all of the other octaves stay the same, and I would like to know if there is a fix other than writing out each individual octave.

Also is this the correct class to be using to make plugins with midi output such as arps, chords, etc.? I’m not sure if I am on the right track or not.
I’m pretty new to most of this stuff but ill try to reply in an educated manner :slight_smile:


#2

Hi Hawkinsjb1,

I think you’ve misinterpreted the function of the MidiKeyboardComponent::setKeyPressForNote() method - it is used to map a KeyPress (that is, a key or combination of keys on a physical keyboard such as esc or shift+c) to trigger a note on the MidiKeyboardComponent. If you want to modify a MIDI note to trigger a different note then you should do that in your audio processing code - probably in the startNote() method of a SynthesiserVoice object.

The MidiKeyboardComponent class is useful for providing an on-screen keyboard to a user but won’t be much use making a plugin on its own. Take a look at the “Audio, MIDI & Plugins” section of the JUCE tutorials site for help getting started making plugins.

Hope this helps!
Ed


#3

Alright thanks for the help, I assumed changing the keyboard output would automatically change the midi out as well idk why.

So would you recommend using the SynthVoice obj even if the plugin wasn’t supposed to produce audio? Or is there another midi specific-related function?


#4

If your plugin is just creating MIDI output then you can offset the note number of your original MIDI message just before you send it to the output using MidiMessage::setNoteNumber().

Ed