Context aware MIDI event printing

This commit is contained in:
alcomposer 2022-11-18 18:34:26 +10:30 committed by Rémi Verschelde
parent 713bfaf5ea
commit deaf6c3bb1
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 21 additions and 1 deletions

View File

@ -1722,7 +1722,27 @@ String InputEventMIDI::as_text() const {
}
String InputEventMIDI::to_string() {
return vformat("InputEventMIDI: channel=%d, message=%d, pitch=%d, velocity=%d, pressure=%d, controller_number=%d, controller_value=%d", channel, message, pitch, velocity, pressure, controller_number, controller_value);
String ret;
switch (message) {
case MIDIMessage::NOTE_ON:
ret = vformat("Note On: channel=%d, pitch=%d, velocity=%d", channel, pitch, velocity);
break;
case MIDIMessage::NOTE_OFF:
ret = vformat("Note Off: channel=%d, pitch=%d, velocity=%d", channel, pitch, velocity);
break;
case MIDIMessage::PITCH_BEND:
ret = vformat("Pitch Bend: channel=%d, pitch=%d", channel, pitch);
break;
case MIDIMessage::CHANNEL_PRESSURE:
ret = vformat("Channel Pressure: channel=%d, pressure=%d", channel, pressure);
break;
case MIDIMessage::CONTROL_CHANGE:
ret = vformat("Control Change: channel=%d, controller_number=%d, controller_value=%d", channel, controller_number, controller_value);
break;
default:
ret = vformat("channel=%d, message=%d, pitch=%d, velocity=%d, pressure=%d, controller_number=%d, controller_value=%d, instrument=%d", channel, message, pitch, velocity, pressure, controller_number, controller_value, instrument);
}
return "InputEventMIDI: " + ret;
}
void InputEventMIDI::_bind_methods() {