diff --git a/Components/OPx/OPLL.cpp b/Components/OPx/OPLL.cpp index b7138cf38..b5abd1460 100644 --- a/Components/OPx/OPLL.cpp +++ b/Components/OPx/OPLL.cpp @@ -380,10 +380,12 @@ void OPLL::update_all_channels() { // TODO: verify attenuation scales pervasively below. +#define ATTENUATION(x) ((x) << 7) + int OPLL::melodic_output(int channel) { // The modulator always updates after the carrier, oddly enough. So calculate actual output first, based on the modulator's last value. auto carrier = WaveformGenerator::wave(channels_[channel].carrier_waveform, phase_generators_[channel].scaled_phase(), channels_[channel].modulator_output); - carrier += envelope_generators_[channel].attenuation() + (channels_[channel].attenuation << 7) + key_level_scalers_[channel].attenuation(); + carrier += envelope_generators_[channel].attenuation() + ATTENUATION(channels_[channel].attenuation) + key_level_scalers_[channel].attenuation(); // Get the modulator's new value. auto modulation = WaveformGenerator::wave(channels_[channel].modulator_waveform, phase_generators_[channel + 9].phase()); @@ -402,7 +404,7 @@ int OPLL::bass_drum() { modulation += rhythm_envelope_generators_[RhythmIndices::BassModulator].attenuation(); auto carrier = WaveformGenerator::wave(Waveform::Sine, phase_generators_[6].scaled_phase(), modulation); - carrier += rhythm_envelope_generators_[RhythmIndices::BassCarrier].attenuation() + (channels_[6].attenuation << 7); + carrier += rhythm_envelope_generators_[RhythmIndices::BassCarrier].attenuation() + ATTENUATION(channels_[6].attenuation); return carrier.level(); } @@ -410,7 +412,7 @@ int OPLL::tom_tom() { // Use modulator 8 and the 'instrument' selection for channel 8 as an attenuation. auto tom_tom = WaveformGenerator::wave(Waveform::Sine, phase_generators_[8 + 9].phase()); tom_tom += rhythm_envelope_generators_[RhythmIndices::TomTom].attenuation(); - tom_tom += channels_[8].instrument << 7; + tom_tom += ATTENUATION(channels_[8].instrument); return tom_tom.level(); } @@ -418,7 +420,7 @@ int OPLL::snare_drum() { // Use modulator 7 and the carrier attenuation level for channel 7. LogSign snare = WaveformGenerator::snare(oscillator_, phase_generators_[7 + 9].phase()); snare += rhythm_envelope_generators_[RhythmIndices::Snare].attenuation(); - snare += channels_[7].attenuation << 7; + snare += ATTENUATION(channels_[7].attenuation); return snare.level(); } @@ -426,7 +428,7 @@ int OPLL::cymbal() { // Use modulator 7, carrier 8 and the attenuation level for channel 8. LogSign cymbal = WaveformGenerator::cymbal(phase_generators_[8].phase(), phase_generators_[7 + 9].phase()); cymbal += rhythm_envelope_generators_[RhythmIndices::Cymbal].attenuation(); - cymbal += channels_[8].attenuation << 7; + cymbal += ATTENUATION(channels_[8].attenuation); return cymbal.level(); } @@ -434,6 +436,8 @@ int OPLL::high_hat() { // Use modulator 7, carrier 8 a and the 'instrument' selection for channel 7 as an attenuation. LogSign high_hat = WaveformGenerator::high_hat(oscillator_, phase_generators_[8].phase(), phase_generators_[7 + 9].phase()); high_hat += rhythm_envelope_generators_[RhythmIndices::HighHat].attenuation(); - high_hat += channels_[7].instrument << 7; + high_hat += ATTENUATION(channels_[7].instrument); return high_hat.level(); } + +#undef ATTENUATION