diff options
author | Sander Vocke <sandervocke@gmail.com> | 2024-07-25 09:09:35 +0200 |
---|---|---|
committer | Sander Vocke <sandervocke@gmail.com> | 2024-07-25 11:06:32 +0200 |
commit | 624aafbc9cde2b9e83c7c278e44f19ab9e3bc9fc (patch) | |
tree | f6e2ef7329b32e4601326012221e0b5ce64a0367 /test/dgreftest/midiinputengine.cc | |
parent | 019d478818950f7880d2c0f80d8fc8f963e9736b (diff) |
Support curve maps in midi map file
Diffstat (limited to 'test/dgreftest/midiinputengine.cc')
-rw-r--r-- | test/dgreftest/midiinputengine.cc | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/test/dgreftest/midiinputengine.cc b/test/dgreftest/midiinputengine.cc index dbffec9..4827e5f 100644 --- a/test/dgreftest/midiinputengine.cc +++ b/test/dgreftest/midiinputengine.cc @@ -155,9 +155,14 @@ 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]; - auto instruments = mmap.lookup(key); - for(const auto& instrument_idx : instruments) + auto entries = mmap.lookup(key); + for(const auto& entry : entries) { + auto instrument_idx = mmap.lookup_instrument(entry.instrument_name); + if (instrument_idx < 0) + { + continue; + } events.emplace_back(); auto& event = events.back(); event.type = EventType::OnSet; @@ -165,6 +170,10 @@ void MidifileInputEngine::run(size_t pos, size_t len, std::vector<event_t>& even event.offset = evpos - pos; event.instrument = instrument_idx; event.velocity = velocity / 127.0; + if (entry.maybe_curve_map) + { + event.velocity = entry.maybe_curve_map->map(event.velocity); + } } } } |