diff options
author | JP Cimalando <jpcima@users.noreply.github.com> | 2019-01-24 11:29:29 +0100 |
---|---|---|
committer | JP Cimalando <jpcima@users.noreply.github.com> | 2019-01-25 08:41:33 +0100 |
commit | 60bc095f2f431b4e6421307fc7ab62c6cc9ce0c2 (patch) | |
tree | 71b9d776314ba8bc3fbe013dddcae2dcb3daf5eb /src/adlmidi_midiplay.cpp | |
parent | a6256daf01e9ffe1fcb32557f9f9712432f855fd (diff) | |
download | libADLMIDI-60bc095f2f431b4e6421307fc7ab62c6cc9ce0c2.tar.gz libADLMIDI-60bc095f2f431b4e6421307fc7ab62c6cc9ce0c2.tar.bz2 libADLMIDI-60bc095f2f431b4e6421307fc7ab62c6cc9ce0c2.zip |
cache the extended note count per channel
Diffstat (limited to 'src/adlmidi_midiplay.cpp')
-rw-r--r-- | src/adlmidi_midiplay.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/adlmidi_midiplay.cpp b/src/adlmidi_midiplay.cpp index 6261181..f8bd0a2 100644 --- a/src/adlmidi_midiplay.cpp +++ b/src/adlmidi_midiplay.cpp @@ -269,15 +269,23 @@ void MIDIplay::TickIterators(double s) for(size_t c = 0, n = m_midiChannels.size(); c < n; ++c) { MIDIchannel &ch = m_midiChannels[c]; + if(ch.extended_note_count == 0) + continue; + for(MIDIchannel::notes_iterator inext = ch.activenotes.begin(); !inext.is_end();) { MIDIchannel::notes_iterator i(inext++); MIDIchannel::NoteInfo &ni = i->value; + double ttl = ni.ttl; - if(ttl > 0) + if(ttl <= 0) + continue; + + ni.ttl = ttl = ttl - s; + if(ttl <= 0) { - ni.ttl = ttl = ttl - s; - if(ni.isOnExtendedLifeTime && ttl <= 0) + --ch.extended_note_count; + if(ni.isOnExtendedLifeTime) { noteUpdate(c, i, Upd_Off); ni.isOnExtendedLifeTime = false; @@ -608,7 +616,7 @@ bool MIDIplay::realTime_NoteOn(uint8_t channel, uint8_t note, uint8_t velocity) ni.isPercussion = isPercussion; ni.isBlank = isBlankNote; ni.isOnExtendedLifeTime = false; - ni.ttl = isPercussion ? drum_note_min_time : 0; + ni.ttl = 0; ni.ains = ains; ni.chip_channels_count = 0; @@ -628,6 +636,13 @@ bool MIDIplay::realTime_NoteOn(uint8_t channel, uint8_t note, uint8_t velocity) ++midiChan.gliding_note_count; } + // Enable life time extension on percussion note + if (isPercussion) + { + ni.ttl = drum_note_min_time; + ++midiChan.extended_note_count; + } + for(unsigned ccount = 0; ccount < MIDIchannel::NoteInfo::MaxNumPhysChans; ++ccount) { int32_t c = adlchannel[ccount]; @@ -1369,8 +1384,7 @@ void MIDIplay::noteUpdate(size_t midCh, if(info.chip_channels_count == 0) { - if(info.glideRate != HUGE_VAL) - --m_midiChannels[midCh].gliding_note_count; + m_midiChannels[midCh].cleanupNote(i); m_midiChannels[midCh].activenotes.erase(i); } } |