diff options
author | Volker Fischer <corrados@users.noreply.github.com> | 2023-10-03 09:45:35 +0200 |
---|---|---|
committer | Volker Fischer <corrados@users.noreply.github.com> | 2023-10-03 09:45:35 +0200 |
commit | 27cd372b72c8108260eb5198d43d059ecbff2a77 (patch) | |
tree | 4d948bfcbe4cb5f3e6c36bc350400082d67bbaa5 /src/midimapper.cc | |
parent | 19e58b4cc1a722459de3110b246ac637fa6cb0d9 (diff) |
fix issue with hi-hat choking on press of the control pedaledrumulus
Diffstat (limited to 'src/midimapper.cc')
-rw-r--r-- | src/midimapper.cc | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/midimapper.cc b/src/midimapper.cc index 62b9d87..1f75461 100644 --- a/src/midimapper.cc +++ b/src/midimapper.cc @@ -47,13 +47,13 @@ int MidiMapper::lookup(int note, int controller) // find instrument where controller is above threshold with smallest distance to threshold int diff = 10000; std::string instr = controlthreshmap[note].begin()->first; - for(auto& c : controlthreshmap[note]) + for(auto& control_thresh : controlthreshmap[note]) { - int cur_diff = controller - c.second; + int cur_diff = controller - control_thresh.second; if(cur_diff >= 0 && cur_diff < diff) { diff = cur_diff; - instr = c.first; + instr = control_thresh.first; } } instrmap_it = instrmap.find(instr); @@ -69,6 +69,26 @@ void MidiMapper::swap(instrmap_t& instrmap, midimap_t& midimap, controlthreshmap std::swap(this->instrmap, instrmap); std::swap(this->midimap, midimap); std::swap(this->controlthreshmap, controlthreshmap); + + // find instruments which define a control threshold and store it + for(auto& control_thresh : this->controlthreshmap) + { + for(auto& instr : control_thresh.second) + { + auto instrmap_it = this->instrmap.find(instr.first); + if(instrmap_it != this->instrmap.end()) + { + instwithcontrolthresh.push_back(instrmap_it->second); + } + maxcontrolthresh = std::max(maxcontrolthresh, instr.second); + } + } + + // in case no controller threshold is defined, use fix definition + if(maxcontrolthresh == 0) + { + maxcontrolthresh = 100; + } } const midimap_t& MidiMapper::getMap() |