shithub: choc

Download patch

ref: b2d78c296a5a2f9cf37bf8bd3dafb5c8ba166812
parent: 9b192c44f932542ccd835936d593c43ce3e9e9e3
author: Simon Howard <[email protected]>
date: Fri Apr 3 16:07:08 EDT 2009

Show MIDI event types with string identifiers.

Subversion-branch: /branches/opl-branch
Subversion-revision: 1495

--- a/src/midifile.c
+++ b/src/midifile.c
@@ -474,6 +474,36 @@
 
 #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 @@
 
     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)
         {