Skip to content

Commit

Permalink
Context aware MIDI event printing
Browse files Browse the repository at this point in the history
  • Loading branch information
alcomposer authored and akien-mga committed Aug 28, 2023
1 parent 713bfaf commit deaf6c3
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion core/input/input_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit deaf6c3

Please sign in to comment.