Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Context aware MIDI event printing #68820

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading