Aren't we missing a conversion here between float velocity [0.0 1.0] and int velocity [0 127]?
Or perhaps better a MidiMessage::noteOff function that takes a float velocity in analogy with noteOn?
void handleNoteOff (MidiKeyboardState*, int midiChannel, int midiNoteNumber, float velocity) override
{
if (! isAddingFromMidiInput)
{
MidiMessage m (MidiMessage::noteOff (midiChannel, midiNoteNumber, velocity));
m.setTimeStamp (Time::getMillisecondCounterHiRes() * 0.001);
postMessageToList (m);
}
}
Out of curiosity: Why would you have "velocity" in a handleNoteOff function? I mean: what exactly does velocity mean for a note off event? How fast you released the key?
Yes, it's the speed of the release. In the midi spec, all note-offs have a velocity, which is mainly why it's been added here, it's not very commonly used.
Be great for some modelled partial muting ... maybe the sound of a string coming to rest against a metal block slowly ... twang ...buzzzzz ... silence...