aboutsummaryrefslogtreecommitdiff
path: root/src/adlmidi_midiplay.cpp
diff options
context:
space:
mode:
authorVitaly Novichkov <admin@wohlnet.ru>2018-06-01 00:46:17 +0300
committerVitaly Novichkov <admin@wohlnet.ru>2018-06-01 00:46:17 +0300
commit562f5cb9841109dc2ca213ffe976b11576733b79 (patch)
treedecf3d7c881e68c23e86850488bc347889669d77 /src/adlmidi_midiplay.cpp
parent77cf2d49be3a88ea2b5972b70bb031b1475cb8c0 (diff)
parenta3785e894c562e721a08c1ac7f6c443bcb4c402a (diff)
downloadlibADLMIDI-562f5cb9841109dc2ca213ffe976b11576733b79.tar.gz
libADLMIDI-562f5cb9841109dc2ca213ffe976b11576733b79.tar.bz2
libADLMIDI-562f5cb9841109dc2ca213ffe976b11576733b79.zip
Merge branch 'master' into num-4ops
Diffstat (limited to 'src/adlmidi_midiplay.cpp')
-rw-r--r--src/adlmidi_midiplay.cpp33
1 files changed, 12 insertions, 21 deletions
diff --git a/src/adlmidi_midiplay.cpp b/src/adlmidi_midiplay.cpp
index e453a05..8da4a43 100644
--- a/src/adlmidi_midiplay.cpp
+++ b/src/adlmidi_midiplay.cpp
@@ -25,7 +25,7 @@
// Mapping from MIDI volume level to OPL level value.
-static const uint32_t DMX_volume_mapping_table[] =
+static const uint8_t DMX_volume_mapping_table[128] =
{
0, 1, 3, 5, 6, 8, 10, 11,
13, 14, 16, 17, 19, 20, 22, 23,
@@ -43,23 +43,6 @@ static const uint32_t DMX_volume_mapping_table[] =
116, 117, 117, 118, 118, 119, 119, 120,
120, 121, 121, 122, 122, 123, 123, 123,
124, 124, 125, 125, 126, 126, 127, 127,
- //Protection entries to avoid crash if value more than 127
- 127, 127, 127, 127, 127, 127, 127, 127,
- 127, 127, 127, 127, 127, 127, 127, 127,
- 127, 127, 127, 127, 127, 127, 127, 127,
- 127, 127, 127, 127, 127, 127, 127, 127,
- 127, 127, 127, 127, 127, 127, 127, 127,
- 127, 127, 127, 127, 127, 127, 127, 127,
- 127, 127, 127, 127, 127, 127, 127, 127,
- 127, 127, 127, 127, 127, 127, 127, 127,
- 127, 127, 127, 127, 127, 127, 127, 127,
- 127, 127, 127, 127, 127, 127, 127, 127,
- 127, 127, 127, 127, 127, 127, 127, 127,
- 127, 127, 127, 127, 127, 127, 127, 127,
- 127, 127, 127, 127, 127, 127, 127, 127,
- 127, 127, 127, 127, 127, 127, 127, 127,
- 127, 127, 127, 127, 127, 127, 127, 127,
- 127, 127, 127, 127, 127, 127, 127, 127,
};
static const uint8_t W9X_volume_mapping_table[32] =
@@ -1258,8 +1241,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)
@@ -1588,7 +1579,7 @@ void MIDIplay::NoteUpdate(uint16_t MidCh,
{
volume = 2 * ((Ch[MidCh].volume * Ch[MidCh].expression) * 127 / 16129) + 1;
//volume = 2 * (Ch[MidCh].volume) + 1;
- volume = (DMX_volume_mapping_table[vol] * volume) >> 9;
+ volume = (DMX_volume_mapping_table[(vol < 128) ? vol : 127] * volume) >> 9;
opl.Touch_Real(c, volume, brightness);
}
break;