aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWohlstand <admin@wohlnet.ru>2017-11-25 04:16:25 +0300
committerWohlstand <admin@wohlnet.ru>2017-11-25 04:16:25 +0300
commit9a9cc5e5ff305114acfb248b65056403ed2e64e6 (patch)
treee1dbc60bb55858656b281d99e679ce6b5fa5af33 /src
parent9166fd48255c7002ba9fbc7a4679a49da544e8c3 (diff)
downloadlibADLMIDI-9a9cc5e5ff305114acfb248b65056403ed2e64e6.tar.gz
libADLMIDI-9a9cc5e5ff305114acfb248b65056403ed2e64e6.tar.bz2
libADLMIDI-9a9cc5e5ff305114acfb248b65056403ed2e64e6.zip
Don't affect percussion chgannels by CC74 Brightness
(As this controller may damage sound of some drums such as DMXOPL3)
Diffstat (limited to 'src')
-rw-r--r--src/adlmidi_midiplay.cpp10
-rw-r--r--src/adlmidi_private.hpp2
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()