summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2009-04-03 20:07:08 +0000
committerSimon Howard2009-04-03 20:07:08 +0000
commitb2d78c296a5a2f9cf37bf8bd3dafb5c8ba166812 (patch)
tree9bb23eeb236013e43c4dccddf5584a76874cca6a
parent9b192c44f932542ccd835936d593c43ce3e9e9e3 (diff)
downloadchocolate-doom-b2d78c296a5a2f9cf37bf8bd3dafb5c8ba166812.tar.gz
chocolate-doom-b2d78c296a5a2f9cf37bf8bd3dafb5c8ba166812.tar.bz2
chocolate-doom-b2d78c296a5a2f9cf37bf8bd3dafb5c8ba166812.zip
Show MIDI event types with string identifiers.
Subversion-branch: /branches/opl-branch Subversion-revision: 1495
-rw-r--r--src/midifile.c34
1 files changed, 33 insertions, 1 deletions
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)
{