diff options
-rw-r--r-- | src/adlmidi_midiplay.cpp | 10 | ||||
-rw-r--r-- | src/adlmidi_private.hpp | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/adlmidi_midiplay.cpp b/src/adlmidi_midiplay.cpp index c1f40d0..2c10331 100644 --- a/src/adlmidi_midiplay.cpp +++ b/src/adlmidi_midiplay.cpp @@ -110,6 +110,11 @@ static const uint8_t PercussionMap[256] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; +inline bool isXgPercChannel(uint8_t msb, uint8_t lsb) +{ + return (msb == 0x7E || msb == 0x7F) && (lsb == 0); +} + void MIDIplay::AdlChannel::AddAge(int64_t ms) { if(users.empty()) @@ -1196,10 +1201,12 @@ void MIDIplay::realTime_Controller(uint8_t channel, uint8_t type, uint8_t value) case 0: // Set bank msb (GM bank) Ch[channel].bank_msb = value; + Ch[channel].is_xg_percussion = isXgPercChannel(Ch[channel].bank_msb, Ch[channel].bank_lsb); break; case 32: // Set bank lsb (XG bank) Ch[channel].bank_lsb = value; + Ch[channel].is_xg_percussion = isXgPercChannel(Ch[channel].bank_msb, Ch[channel].bank_lsb); break; case 5: // Set portamento msb @@ -1455,7 +1462,8 @@ void MIDIplay::NoteUpdate(uint16_t MidCh, if(props_mask & Upd_Volume) { uint32_t volume; - uint8_t brightness = Ch[MidCh].brightness; + bool is_percussion = (MidCh == 9) || Ch[MidCh].is_xg_percussion; + uint8_t brightness = is_percussion ? 127 : Ch[MidCh].brightness; switch(opl.m_volumeScale) { diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index 947181b..8058824 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -466,6 +466,7 @@ public: uint8_t lastlrpn, lastmrpn; bool nrpn; uint8_t brightness; + bool is_xg_percussion; struct NoteInfo { // Current pressure @@ -523,6 +524,7 @@ public: lastmrpn = 0; nrpn = false; brightness = 127; + is_xg_percussion = false; } MIDIchannel() : activenotes() |