Fix MIDI note-on events being converted to note-off events

Update documentation with note about MIDI velocity interpretation

(cherry picked from commit f0f72b3132)
This commit is contained in:
voidshine 2022-09-17 11:29:41 -07:00 committed by Rémi Verschelde
parent 3b35454ac3
commit 7284230ebe
No known key found for this signature in database
GPG key ID: C3336907360768E1
2 changed files with 1 additions and 6 deletions

View file

@ -87,11 +87,6 @@ void MIDIDriver::receive_input_packet(uint64_t timestamp, uint8_t *data, uint32_
if (length >= 2 + param_position) { if (length >= 2 + param_position) {
event->set_pitch(data[param_position]); event->set_pitch(data[param_position]);
event->set_velocity(data[param_position + 1]); event->set_velocity(data[param_position + 1]);
if (event->get_message() == MIDI_MESSAGE_NOTE_ON && event->get_velocity() == 0) {
// https://www.midi.org/forum/228-writing-midi-software-send-note-off,-or-zero-velocity-note-on
event->set_message(MIDI_MESSAGE_NOTE_OFF);
}
} }
break; break;

View file

@ -42,7 +42,7 @@
The pressure of the MIDI signal. This value ranges from 0 to 127. For many devices, this value is always zero. The pressure of the MIDI signal. This value ranges from 0 to 127. For many devices, this value is always zero.
</member> </member>
<member name="velocity" type="int" setter="set_velocity" getter="get_velocity" default="0"> <member name="velocity" type="int" setter="set_velocity" getter="get_velocity" default="0">
The velocity of the MIDI signal. This value ranges from 0 to 127. For a piano, this corresponds to how quickly the key was pressed, and is rarely above about 110 in practice. The velocity of the MIDI signal. This value ranges from 0 to 127. For a piano, this corresponds to how quickly the key was pressed, and is rarely above about 110 in practice. Note that some MIDI devices may send a [constant MIDI_MESSAGE_NOTE_ON] message with zero velocity and expect this to be treated the same as a [constant MIDI_MESSAGE_NOTE_OFF] message, but device implementations vary so Godot reports event data exactly as received.
</member> </member>
</members> </members>
<constants> <constants>