diff options
Diffstat (limited to 'src/midimapper.cc')
-rw-r--r-- | src/midimapper.cc | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/midimapper.cc b/src/midimapper.cc index 9593aae..b9316c5 100644 --- a/src/midimapper.cc +++ b/src/midimapper.cc @@ -26,23 +26,25 @@ */ #include "midimapper.h" -int MidiMapper::lookup(int note) +std::vector<int> MidiMapper::lookup(int note_id) { - std::lock_guard<std::mutex> guard(mutex); + std::vector<int> instruments; - auto midimap_it = midimap.find(note); - if(midimap_it == midimap.end()) - { - return -1; - } + std::lock_guard<std::mutex> guard(mutex); - auto instrmap_it = instrmap.find(midimap_it->second); - if(instrmap_it == instrmap.end()) + for(const auto& map_entry : midimap) { - return -1; + if(map_entry.note_id == note_id) + { + auto instrmap_it = instrmap.find(map_entry.instrument_name); + if(instrmap_it != instrmap.end()) + { + instruments.push_back(instrmap_it->second); + } + } } - return instrmap_it->second; + return instruments; } void MidiMapper::swap(instrmap_t& instrmap, midimap_t& midimap) |