From 9007918bce92c5af1305426ead055591e29dd6b9 Mon Sep 17 00:00:00 2001 From: JP Cimalando Date: Thu, 31 May 2018 07:36:51 +0200 Subject: rewrite the check of whether aftertouch is used --- src/adlmidi_midiplay.cpp | 12 ++++++++++-- src/adlmidi_private.hpp | 3 --- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/adlmidi_midiplay.cpp b/src/adlmidi_midiplay.cpp index e453a05..b8ef555 100644 --- a/src/adlmidi_midiplay.cpp +++ b/src/adlmidi_midiplay.cpp @@ -1258,8 +1258,16 @@ void MIDIplay::realTime_NoteAfterTouch(uint8_t channel, uint8_t note, uint8_t at { i->vibrato = atVal; } - chan.noteAftertouch[note % 128] = atVal; - chan.noteAfterTouchInUse = (std::memcmp(chan.noteAftertouch, chan.noteAftertouch_Zero, 128) != 0); + + uint8_t oldAtVal = chan.noteAftertouch[note % 128]; + if(atVal != oldAtVal) + { + chan.noteAftertouch[note % 128] = atVal; + bool inUse = atVal != 0; + for(unsigned n = 0; !inUse && n < 128; ++n) + inUse = chan.noteAftertouch[n] != 0; + chan.noteAfterTouchInUse = inUse; + } } void MIDIplay::realTime_ChannelAfterTouch(uint8_t channel, uint8_t atVal) diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index 0e3affe..ee73c61 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -508,8 +508,6 @@ public: uint8_t panning, vibrato, aftertouch, sustain; //! Per note Aftertouch values uint8_t noteAftertouch[128]; - //! Zero-filled array. Is used to compare with note aftertouch range - uint8_t noteAftertouch_Zero[128]; //! Is note aftertouch has any non-zero value bool noteAfterTouchInUse; char ____padding[6]; @@ -717,7 +715,6 @@ public: vibrato = 0; aftertouch = 0; std::memset(noteAftertouch, 0, 128); - std::memset(noteAftertouch_Zero, 0, 128); noteAfterTouchInUse = false; vibspeed = 2 * 3.141592653 * 5.0; vibdepth = 0.5 / 127; -- cgit v1.2.3