From 5ab3afa77e91ea4f7a64769ac8a1ac016e29bfeb Mon Sep 17 00:00:00 2001 From: Wohlstand Date: Fri, 21 Aug 2020 00:01:17 +0300 Subject: Make DMX volume model be more accurate (thanks to NukeYKT for a hint) --- src/adlmidi_midiplay.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/adlmidi_midiplay.cpp') diff --git a/src/adlmidi_midiplay.cpp b/src/adlmidi_midiplay.cpp index 5b81d83..61bdf95 100644 --- a/src/adlmidi_midiplay.cpp +++ b/src/adlmidi_midiplay.cpp @@ -704,8 +704,13 @@ void MIDIplay::realTime_ChannelAfterTouch(uint8_t channel, uint8_t atVal) void MIDIplay::realTime_Controller(uint8_t channel, uint8_t type, uint8_t value) { Synth &synth = *m_synth; + + if(value > 127) // Allowed values 0~127 only + value = 127; + if(static_cast(channel) > m_midiChannels.size()) channel = channel % 16; + switch(type) { case 1: // Adjust vibrato @@ -1311,8 +1316,8 @@ void MIDIplay::noteUpdate(size_t midCh, case Synth::VOLUME_DMX: { - volume = 2 * (m_midiChannels[midCh].volume * m_midiChannels[midCh].expression * m_masterVolume / 16129) + 1; - //volume = 2 * (Ch[MidCh].volume) + 1; + volume = (m_midiChannels[midCh].volume * m_midiChannels[midCh].expression * m_masterVolume) / 16129; + volume = (DMX_volume_mapping_table[volume] + 1) << 1; volume = (DMX_volume_mapping_table[(vol < 128) ? vol : 127] * volume) >> 9; } break; -- cgit v1.2.3