From b2d78c296a5a2f9cf37bf8bd3dafb5c8ba166812 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 3 Apr 2009 20:07:08 +0000 Subject: Show MIDI event types with string identifiers. Subversion-branch: /branches/opl-branch Subversion-revision: 1495 --- src/midifile.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/midifile.c b/src/midifile.c index e4273c12..ef2ceb88 100644 --- a/src/midifile.c +++ b/src/midifile.c @@ -474,6 +474,36 @@ boolean MIDI_ReadEvent(midi_file_t *file, midi_event_t *event) #ifdef TEST +static char *MIDI_EventTypeToString(midi_event_type_t event_type) +{ + switch (event_type) + { + case MIDI_EVENT_NOTE_OFF: + return "MIDI_EVENT_NOTE_OFF"; + case MIDI_EVENT_NOTE_ON: + return "MIDI_EVENT_NOTE_ON"; + case MIDI_EVENT_AFTERTOUCH: + return "MIDI_EVENT_AFTERTOUCH"; + case MIDI_EVENT_CONTROLLER: + return "MIDI_EVENT_CONTROLLER"; + case MIDI_EVENT_PROGRAM_CHANGE: + return "MIDI_EVENT_PROGRAM_CHANGE"; + case MIDI_EVENT_CHAN_AFTERTOUCH: + return "MIDI_EVENT_CHAN_AFTERTOUCH"; + case MIDI_EVENT_PITCH_BEND: + return "MIDI_EVENT_PITCH_BEND"; + case MIDI_EVENT_SYSEX: + return "MIDI_EVENT_SYSEX"; + case MIDI_EVENT_SYSEX_SPLIT: + return "MIDI_EVENT_SYSEX_SPLIT"; + case MIDI_EVENT_META: + return "MIDI_EVENT_META"; + + default: + return "(unknown)"; + } +} + int main(int argc, char *argv[]) { midi_file_t *file; @@ -495,7 +525,9 @@ int main(int argc, char *argv[]) while (MIDI_ReadEvent(file, &event)) { - printf("Event type: %i\n", event.event_type); + printf("Event type: %s (%i)\n", + MIDI_EventTypeToString(event.event_type), + event.event_type); switch(event.event_type) { -- cgit v1.2.3