diff options
author | Wohlstand <admin@wohlnet.ru> | 2025-05-26 02:24:26 +0300 |
---|---|---|
committer | Wohlstand <admin@wohlnet.ru> | 2025-05-26 02:24:36 +0300 |
commit | e18263c54f43e8d08cef691507ec4abd0bd04a1b (patch) | |
tree | fcad7af1f97ab96ca0b263150f5afd80786a0cbb /src | |
parent | 21f7817f334ebcd7240eaeee834b0366163f4a5e (diff) | |
download | libADLMIDI-e18263c54f43e8d08cef691507ec4abd0bd04a1b.tar.gz libADLMIDI-e18263c54f43e8d08cef691507ec4abd0bd04a1b.tar.bz2 libADLMIDI-e18263c54f43e8d08cef691507ec4abd0bd04a1b.zip |
adlmidi_midiplay.cpp: Give priority to quietest notes to be stolen
Diffstat (limited to 'src')
-rw-r--r-- | src/adlmidi_midiplay.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/adlmidi_midiplay.cpp b/src/adlmidi_midiplay.cpp index a30fbe8..99b5bf0 100644 --- a/src/adlmidi_midiplay.cpp +++ b/src/adlmidi_midiplay.cpp @@ -1548,6 +1548,7 @@ bool MIDIplay::killSecondVoicesIfOverflow(int32_t &new_chan) bool ret = false; int free2op = 0; + int32_t volume = -1; for(size_t a = 0; a < (size_t)synth.m_numChannels; ++a) { @@ -1557,9 +1558,28 @@ bool MIDIplay::killSecondVoicesIfOverflow(int32_t &new_chan) AdlChannel &chan = m_chipChannels[a]; if(chan.users.empty()) + { ++free2op; + break; // No reason to loop more + } else if(chan.recent_ins.pseudo4op) - new_chan = a; + { + AdlChannel::users_iterator j = &chan.users.front(); + AdlChannel::LocationData &jd = j->value; + MIDIchannel &mc = m_midiChannels[jd.loc.MidCh]; + MIDIchannel::notes_iterator nc = mc.find_activenote(jd.loc.note); + int32_t total = mc.volume + mc.expression; + + if(!nc.is_end()) + total += nc->value.vol; + + // Quitest tones has highest priority to be stolen + if(volume < 0 || total < volume) + { + volume = total; + new_chan = a; + } + } } if(!free2op && new_chan >= 0) |