diff options
author | Wohlstand <admin@wohlnet.ru> | 2025-05-25 01:56:52 +0300 |
---|---|---|
committer | Wohlstand <admin@wohlnet.ru> | 2025-05-25 01:56:52 +0300 |
commit | 31ab9fccd609ac6a0c25819d0b7e685298b4047b (patch) | |
tree | 55904a4b74343ff601e6f1a0e4a3c46fefecabae /src/adlmidi_midiplay.hpp | |
parent | 175adb293ba37c527411a5684fe3994a43d95493 (diff) | |
download | libADLMIDI-31ab9fccd609ac6a0c25819d0b7e685298b4047b.tar.gz libADLMIDI-31ab9fccd609ac6a0c25819d0b7e685298b4047b.tar.bz2 libADLMIDI-31ab9fccd609ac6a0c25819d0b7e685298b4047b.zip |
Stabilise the channels logic
Diffstat (limited to 'src/adlmidi_midiplay.hpp')
-rw-r--r-- | src/adlmidi_midiplay.hpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/adlmidi_midiplay.hpp b/src/adlmidi_midiplay.hpp index e5058b9..bcd76a1 100644 --- a/src/adlmidi_midiplay.hpp +++ b/src/adlmidi_midiplay.hpp @@ -235,11 +235,16 @@ public: Phys *phys_find(unsigned chip_chan) { Phys *ph = NULL; + for(unsigned i = 0; i < chip_channels_count && !ph; ++i) + { if(chip_channels[i].chip_chan == chip_chan) ph = &chip_channels[i]; + } + return ph; } + Phys *phys_find_or_create(uint16_t chip_chan) { Phys *ph = phys_find(chip_chan); @@ -251,20 +256,23 @@ public: } return ph; } + Phys *phys_ensure_find_or_create(uint16_t chip_chan) { Phys *ph = phys_find_or_create(chip_chan); assert(ph); return ph; } + void phys_erase_at(const Phys *ph) { intptr_t pos = ph - chip_channels; - assert(pos < static_cast<intptr_t>(chip_channels_count)); + assert(pos >= 0 && pos < static_cast<intptr_t>(chip_channels_count)); for(intptr_t i = pos + 1; i < static_cast<intptr_t>(chip_channels_count); ++i) chip_channels[i - 1] = chip_channels[i]; --chip_channels_count; } + void phys_erase(unsigned chip_chan) { Phys *ph = phys_find(chip_chan); @@ -285,6 +293,24 @@ public: typedef pl_list<NoteInfo>::iterator notes_iterator; typedef pl_list<NoteInfo>::const_iterator const_notes_iterator; + void clear_all_phys_users(unsigned chip_chan) + { + for(pl_list<NoteInfo>::iterator it = activenotes.begin(); it != activenotes.end(); ) + { + NoteInfo::Phys *p = it->value.phys_find(chip_chan); + if(p) + { + it->value.phys_erase_at(p); + if(it->value.chip_channels_count == 0) + it = activenotes.erase(it); + else + ++it; + } + else + ++it; + } + } + notes_iterator find_activenote(unsigned note) { return activenotes.find_if(NoteInfo::FindPredicate(note)); |