From 4920ff67f81b9f0c92ec8330136e6f1e949b040f Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Mon, 8 Aug 2011 22:28:31 +0200 Subject: Missing midimap changes --- drumgizmo/input/midifile/midifile.cc | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'drumgizmo/input/midifile/midifile.cc') 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 -#include "midimap.h" +#include +#include #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; + } } } } -- cgit v1.2.3