diff options
Diffstat (limited to 'drumgizmo/input')
-rw-r--r-- | drumgizmo/input/midifile/Makefile.am | 10 | ||||
-rw-r--r-- | drumgizmo/input/midifile/midifile.cc | 28 |
2 files changed, 26 insertions, 12 deletions
diff --git a/drumgizmo/input/midifile/Makefile.am b/drumgizmo/input/midifile/Makefile.am index 30a2db4..b5af68e 100644 --- a/drumgizmo/input/midifile/Makefile.am +++ b/drumgizmo/input/midifile/Makefile.am @@ -1,7 +1,10 @@ midifilesources = \ midifile.cc \ - midimap.cc + $(top_srcdir)/src/midimapper.cc \ + $(top_srcdir)/src/midimapparser.cc \ + $(top_srcdir)/src/saxparser.cc + if HAVE_INPUT_MIDIFILE @@ -21,7 +24,8 @@ lib_LTLIBRARIES = $(midifileltlibs) libdir = $(INPUT_PLUGIN_DIR) -INCLUDES = -I$(top_srcdir)/include $(SMF_CFLAGS) -libmidifile_la_LDFLAGS = $(SMF_LIBS) +INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/include $(SMF_CFLAGS) \ + $(EXPAT_CFLAGS) +libmidifile_la_LDFLAGS = $(SMF_LIBS) $(EXPAT_LIBS) libmidifile_la_LIBADD = libmidifile_la_SOURCES = $(midifilebuildsources) diff --git a/drumgizmo/input/midifile/midifile.cc b/drumgizmo/input/midifile/midifile.cc index 7b17028..b2c9ba5 100644 --- a/drumgizmo/input/midifile/midifile.cc +++ b/drumgizmo/input/midifile/midifile.cc @@ -31,7 +31,8 @@ #include <smf.h> -#include "midimap.h" +#include <midimapper.h> +#include <midimapparser.h> #define NOTE_ON 0x90 @@ -55,7 +56,7 @@ private: smf_t *smf; smf_event_t *cur_event; - MidiMap mmap; + MidiMapper mmap; // Parameters std::string filename; @@ -78,7 +79,13 @@ bool MidiFile::init(int instruments, char *inames[]) { smf = smf_load(filename.c_str()); - mmap.load(midimapfile); + MidiMapParser p(midimapfile); + if(p.parse()) return false; + mmap.midimap = p.midimap; + + for(int i = 0; i < instruments; i++) { + mmap.instrmap[inames[i]] = i; + } return true; } @@ -132,13 +139,16 @@ event_t *MidiFile::run(size_t pos, size_t len, size_t *nevents) printf("evpos: %d, sec: %f, pos: %d, len: %d, max_time: %f\n", evpos, cur_event->time_seconds, pos, len, cur_max_time); */ - evs[nevs].instrument = mmap.lookup(key); - evs[nevs].velocity = velocity / 127.0; + int i = mmap.lookup(key); + if(i != -1) { + evs[nevs].instrument = i; + evs[nevs].velocity = velocity / 127.0; - nevs++; - if(nevs > 999) { - printf("PANIC!\n"); - break; + nevs++; + if(nevs > 999) { + printf("PANIC!\n"); + break; + } } } } |