diff options
author | Wohlstand <admin@wohlnet.ru> | 2020-09-01 11:01:38 +0300 |
---|---|---|
committer | Wohlstand <admin@wohlnet.ru> | 2020-09-01 11:01:38 +0300 |
commit | 575fa74564c866ed4ed97c80a00d9ee4b90b6415 (patch) | |
tree | f5d17f4ab83504a134df5afc754eab443f78ee2c /src/adlmidi_opl3.cpp | |
parent | cdc7f4af976295d25eeb58073bb2d82d64f20381 (diff) | |
download | libADLMIDI-575fa74564c866ed4ed97c80a00d9ee4b90b6415.tar.gz libADLMIDI-575fa74564c866ed4ed97c80a00d9ee4b90b6415.tar.bz2 libADLMIDI-575fa74564c866ed4ed97c80a00d9ee4b90b6415.zip |
Fixed Apogee volume model for 4-operator voices
Diffstat (limited to 'src/adlmidi_opl3.cpp')
-rw-r--r-- | src/adlmidi_opl3.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/adlmidi_opl3.cpp b/src/adlmidi_opl3.cpp index 3812eab..b6f78b9 100644 --- a/src/adlmidi_opl3.cpp +++ b/src/adlmidi_opl3.cpp @@ -636,31 +636,35 @@ void OPL3::touchNote(size_t c, { tlCar -= volume / 2; } - else if((m_volumeScale == Synth::VOLUME_APOGEE || - m_volumeScale == Synth::VOLUME_APOGEE_FIXED) && - mode <= 1) + else if(m_volumeScale == Synth::VOLUME_APOGEE || + m_volumeScale == Synth::VOLUME_APOGEE_FIXED) { // volume = ((64 * (velocity + 0x80)) * volume) >> 15; do_modulator = do_ops[mode][ 0 ] || m_scaleModulators; + do_carrier = do_ops[mode][1] || m_scaleModulators; - tlCar = 63 - tlCar; - - tlCar *= velocity + 0x80; - tlCar = (midiVolume * tlCar) >> 15; - tlCar = tlCar ^ 63; + if(do_carrier) + { + tlCar = 63 - tlCar; + tlCar *= velocity + 0x80; + tlCar = (midiVolume * tlCar) >> 15; + tlCar = tlCar ^ 63; + } if(do_modulator) { + uint_fast32_t mod = tlCar; + + if(m_volumeScale == Synth::VOLUME_APOGEE_FIXED || mode > 1) + mod = tlMod; // Fix the AM voices bug + tlMod = 63 - tlMod; tlMod *= velocity + 0x80; // NOTE: Here is a bug of Apogee Sound System that makes modulator - // to not work properly on AM instruments - // The fix of this bug is just replacing of tlCar with tmMod - // in this formula - if(m_volumeScale == Synth::VOLUME_APOGEE_FIXED) - tlMod = (midiVolume * tlMod) >> 15; - else - tlMod = (midiVolume * tlCar) >> 15; + // to not work properly on AM instruments. The fix of this bug, you + // need to replace the tlCar with tmMod in this formula. + // Don't do the bug on 4-op voices. + tlMod = (midiVolume * mod) >> 15; tlMod ^= 63; } |