From f52b40396a1aa050784269002c2dadd59d818404 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 25 Apr 2020 23:07:06 -0400 Subject: [PATCH] Re-ups output level. Though it's still quiet compared to the SN. --- Components/OPL2/Implementation/Channel.cpp | 2 +- Components/OPL2/OPL2.cpp | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Components/OPL2/Implementation/Channel.cpp b/Components/OPL2/Implementation/Channel.cpp index e85823852..6ec3c6a80 100644 --- a/Components/OPL2/Implementation/Channel.cpp +++ b/Components/OPL2/Implementation/Channel.cpp @@ -43,7 +43,7 @@ int Channel::update_melodic(const LowFrequencyOscillator &oscillator, Operator * // Get modulator and carrier levels separately, return their sum. modulator->update(modulator_state_, nullptr, oscillator, key_on_ || force_key_on, period_ << frequency_shift_, octave_, modulator_overrides); carrier->update(carrier_state_, nullptr, oscillator, key_on_ || force_key_on, period_ << frequency_shift_, octave_, carrier_overrides); - return (modulator_state_.level() + carrier_state_.level()); + return (modulator_state_.level() + carrier_state_.level()) >> 1; } } diff --git a/Components/OPL2/OPL2.cpp b/Components/OPL2/OPL2.cpp index e4be97f71..7d13b3df6 100644 --- a/Components/OPL2/OPL2.cpp +++ b/Components/OPL2/OPL2.cpp @@ -197,11 +197,13 @@ void OPLL::update_all_chanels() { int channel_levels[9]; +#define VOLUME(x) ((x) * total_volume_) >> 11 + // Channels that are updated for melodic output regardless; // in rhythm mode the final three channels — 6, 7, and 8 — // are lost as their operators are used for drum noises. for(int c = 0; c < 6; ++ c) { - channel_levels[c] = (channels_[c].update_melodic(oscillator_) * total_volume_) >> 12; + channel_levels[c] = VOLUME(channels_[c].update_melodic(oscillator_)); } output_levels_[3] = channel_levels[0]; @@ -217,11 +219,11 @@ void OPLL::update_all_chanels() { // Update channel 6 as if melodic, but with the bass instrument. output_levels_[2] = output_levels_[15] = - (channels_[6].update_bass(oscillator_, &operators_[32], depth_rhythm_control_ & 0x10) * total_volume_) >> 12; + VOLUME(channels_[6].update_bass(oscillator_, &operators_[32], depth_rhythm_control_ & 0x10)); // Use the modulator from channel 7 for the tom tom. output_levels_[1] = output_levels_[14] = - (channels_[7].update_tom_tom(oscillator_, &operators_[34], depth_rhythm_control_ & 0x04) * total_volume_) >> 12; + VOLUME(channels_[7].update_tom_tom(oscillator_, &operators_[34], depth_rhythm_control_ & 0x04)); // TODO: snare. output_levels_[6] = output_levels_[16] = 0; @@ -233,9 +235,9 @@ void OPLL::update_all_chanels() { output_levels_[0] = output_levels_[13] = 0; } else { // Not in rhythm mode; channels 7, 8 and 9 are melodic. -// for(int c = 7; c < 9; ++ c) { -// channel_levels[c] = (channels_[c].update_melodic(oscillator_) * total_volume_) >> 12; -// } + for(int c = 7; c < 9; ++ c) { + channel_levels[c] = VOLUME(channels_[c].update_melodic(oscillator_)); + } output_levels_[0] = output_levels_[1] = output_levels_[2] = output_levels_[6] = output_levels_[7] = output_levels_[8] = @@ -255,6 +257,8 @@ void OPLL::update_all_chanels() { // } // channels_[2].level = (channels_[2].update() * total_volume_) >> 14; + +#undef VOLUME } /*