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.hpp | |
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.hpp')
-rw-r--r-- | src/adlmidi_midiplay.hpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/adlmidi_midiplay.hpp b/src/adlmidi_midiplay.hpp index d3e5ea4..d7d8022 100644 --- a/src/adlmidi_midiplay.hpp +++ b/src/adlmidi_midiplay.hpp @@ -254,6 +254,8 @@ public: char _padding2[5]; //! Count of gliding notes in this channel unsigned gliding_note_count; + //! Count of notes having a TTL countdown in this channel + unsigned extended_note_count; //! Active notes in the channel pl_list<NoteInfo> activenotes; @@ -275,7 +277,10 @@ public: notes_iterator find_or_create_activenote(unsigned note) { notes_iterator it = find_activenote(note); - if(it.is_end()) { + if(!it.is_end()) + cleanupNote(it); + else + { NoteInfo ni; ni.note = note; it = activenotes.insert(activenotes.end(), ni); @@ -352,10 +357,23 @@ public: bendsense = cent * (1.0 / (128 * 8192)); } + /** + * @brief Clean up the state of the active note before removal + */ + void cleanupNote(notes_iterator i) + { + NoteInfo &info = i->value; + if(info.glideRate != HUGE_VAL) + --gliding_note_count; + if(info.ttl > 0) + --extended_note_count; + } + MIDIchannel() : activenotes(128) { gliding_note_count = 0; + extended_note_count = 0; reset(); } }; |