diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/adlmidi_midiplay.cpp | 10 | ||||
-rw-r--r-- | src/adlmidi_midiplay.hpp | 15 |
2 files changed, 22 insertions, 3 deletions
diff --git a/src/adlmidi_midiplay.cpp b/src/adlmidi_midiplay.cpp index 22019c8..b27ed13 100644 --- a/src/adlmidi_midiplay.cpp +++ b/src/adlmidi_midiplay.cpp @@ -331,14 +331,18 @@ bool MIDIplay::realTime_NoteOn(uint8_t channel, uint8_t note, uint8_t velocity) if(static_cast<size_t>(channel) > m_midiChannels.size()) channel = channel % 16; - noteOff(channel, note, velocity != 0); + + //noteOff(channel, note, velocity != 0); // On Note on, Keyoff the note first, just in case keyoff // was omitted; this fixes Dance of sugar-plum fairy // by Microsoft. Now that we've done a Keyoff, // check if we still need to do a Keyon. // vol=0 and event 8x are both Keyoff-only. if(velocity == 0) + { + noteOff(channel, note, false); return false; + } MIDIchannel &midiChan = m_midiChannels[channel]; @@ -492,7 +496,7 @@ bool MIDIplay::realTime_NoteOn(uint8_t channel, uint8_t note, uint8_t velocity) if(isBlankNote) { // Don't even try to play the blank instrument! But, insert the dummy note. - MIDIchannel::notes_iterator i = midiChan.ensure_find_or_create_activenote(note); + MIDIchannel::notes_iterator i = midiChan.ensure_create_activenote(note); MIDIchannel::NoteInfo &dummy = i->value; dummy.isBlank = true; dummy.isOnExtendedLifeTime = false; @@ -613,7 +617,7 @@ bool MIDIplay::realTime_NoteOn(uint8_t channel, uint8_t note, uint8_t velocity) velocity = static_cast<uint8_t>(std::floor(static_cast<float>(velocity) * 0.8f)); // Allocate active note for MIDI channel - MIDIchannel::notes_iterator ir = midiChan.ensure_find_or_create_activenote(note); + MIDIchannel::notes_iterator ir = midiChan.ensure_create_activenote(note); MIDIchannel::NoteInfo &ni = ir->value; ni.vol = velocity; ni.vibrato = midiChan.noteAftertouch[note]; diff --git a/src/adlmidi_midiplay.hpp b/src/adlmidi_midiplay.hpp index dd5b34e..6ab0915 100644 --- a/src/adlmidi_midiplay.hpp +++ b/src/adlmidi_midiplay.hpp @@ -311,6 +311,14 @@ public: return it; } + notes_iterator create_activenote(unsigned note) + { + NoteInfo ni; + ni.note = note; + notes_iterator it = activenotes.insert(activenotes.end(), ni); + return it; + } + notes_iterator ensure_find_or_create_activenote(unsigned note) { notes_iterator it = find_or_create_activenote(note); @@ -318,6 +326,13 @@ public: return it; } + notes_iterator ensure_create_activenote(unsigned note) + { + notes_iterator it = create_activenote(note); + assert(!it.is_end()); + return it; + } + /** * @brief Reset channel into initial state */ |