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) --- README.md | 1 + src/adlmidi_midiplay.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index db07572..2f00e5f 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,7 @@ To build that example you will need to have installed SDL2 library. * Reworked rhythm-mode percussions system, WOPL banks with rhythm-mode percussions * Added Public Domain Opal OPL3 emulator made by Reality (a team who originally made the Reality Adlib Tracker) (Thanks to [Jean Pierre Cimalando](https://github.com/jpcima) for a work!) * Added LGPL licensed JavaOPL3 emulator made by Robson Cozendey in Java and later rewritten into C++ for GZDoom (Thanks to [Jean Pierre Cimalando](https://github.com/jpcima) for a work!) + * Fixed an accuracy of the DMX volume model ## 1.4.0 2018-10-01 * Implemented a full support for Portamento! (Thanks to [Jean Pierre Cimalando](https://github.com/jpcima) for a work!) 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