summaryrefslogtreecommitdiff
path: root/test/dgreftest/midiinputengine.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2021-08-08 10:34:54 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2021-08-08 10:34:54 +0200
commitf43935b5c873676a632b23cbfcef45a4431b233d (patch)
treead1473fa34f3da5292e3344a99ed447261d99584 /test/dgreftest/midiinputengine.cc
parenta2483a839264369482fff135d33f007ded266d3c (diff)
Add support for a single midi note that plays multiple instruments.
Diffstat (limited to 'test/dgreftest/midiinputengine.cc')
-rw-r--r--test/dgreftest/midiinputengine.cc17
1 files changed, 8 insertions, 9 deletions
diff --git a/test/dgreftest/midiinputengine.cc b/test/dgreftest/midiinputengine.cc
index ca223da..dbffec9 100644
--- a/test/dgreftest/midiinputengine.cc
+++ b/test/dgreftest/midiinputengine.cc
@@ -155,16 +155,15 @@ void MidifileInputEngine::run(size_t pos, size_t len, std::vector<event_t>& even
int key = current_event->midi_buffer[1];
int velocity = current_event->midi_buffer[2];
- events.emplace_back();
- auto& event = events.back();
- event.type = EventType::OnSet;
- size_t evpos = current_event->time_seconds * (samplerate / speed);
- event.offset = evpos - pos;
-
- int i = mmap.lookup(key);
- if(i != -1)
+ auto instruments = mmap.lookup(key);
+ for(const auto& instrument_idx : instruments)
{
- event.instrument = i;
+ events.emplace_back();
+ auto& event = events.back();
+ event.type = EventType::OnSet;
+ size_t evpos = current_event->time_seconds * (samplerate / speed);
+ event.offset = evpos - pos;
+ event.instrument = instrument_idx;
event.velocity = velocity / 127.0;
}
}