summaryrefslogtreecommitdiff
path: root/drumgizmo/input/midifile.cc
diff options
context:
space:
mode:
Diffstat (limited to 'drumgizmo/input/midifile.cc')
-rw-r--r--drumgizmo/input/midifile.cc21
1 files changed, 4 insertions, 17 deletions
diff --git a/drumgizmo/input/midifile.cc b/drumgizmo/input/midifile.cc
index 4e36c9d..7d27998 100644
--- a/drumgizmo/input/midifile.cc
+++ b/drumgizmo/input/midifile.cc
@@ -31,10 +31,10 @@
static int const NOTE_ON = 0x90;
MidifileInputEngine::MidifileInputEngine()
- : smf{nullptr}
+ : AudioInputEngineMidi{}
+ , smf{nullptr}
, current_event{nullptr}
, file{}
- , midimap{}
, speed{1.f}
, track{-1} // all tracks
, loop{false}
@@ -50,11 +50,6 @@ MidifileInputEngine::~MidifileInputEngine()
}
}
-bool MidifileInputEngine::isMidiEngine()
-{
- return true;
-}
-
bool MidifileInputEngine::init(Instruments& instruments)
{
if (file == "")
@@ -74,19 +69,11 @@ bool MidifileInputEngine::init(Instruments& instruments)
<< "'\n";
return false;
}
- MidiMapParser p{midimap};
- if (p.parse())
- {
+ if (!loadMidiMap(midimap, instruments)) {
std::cerr << "[MidifileInputEngine] Failed to parse midimap '" << midimap
<< "'\n";
return false;
}
- midi_mapper.midimap = p.midimap;
- for (auto i = 0u; i < instruments.size(); ++i)
- {
- auto name = instruments[i]->name();
- midi_mapper.instrmap[name] = i;
- }
return true;
}
@@ -176,7 +163,7 @@ event_t *MidifileInputEngine::run(size_t pos, size_t len, size_t *nevents)
size_t evpos = current_event->time_seconds * (44100.0 / speed);
evs[num_events].offset = evpos - pos;
- int i = midi_mapper.lookup(key);
+ int i = mmap.lookup(key);
if (i != -1)
{
evs[num_events].instrument = i;