From 3da2e91acf609d8be54a48a199cb5cfdb38fe37b Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 17 Apr 2020 23:29:09 -0400 Subject: [PATCH] Adjusts range of output, makes declaration of `level` full owner of type information. --- Components/OPL2/Implementation/Channel.cpp | 6 ++---- Components/OPL2/Implementation/Channel.hpp | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Components/OPL2/Implementation/Channel.cpp b/Components/OPL2/Implementation/Channel.cpp index fbc5c51bc..a01d7aac8 100644 --- a/Components/OPL2/Implementation/Channel.cpp +++ b/Components/OPL2/Implementation/Channel.cpp @@ -38,10 +38,8 @@ int Channel::update(Operator *modulator, Operator *carrier, OperatorOverrides *m modulator->update(modulator_state_, key_on_, period_ << frequency_shift_, octave_, modulator_overrides); carrier->update(carrier_state_, key_on_, period_ << frequency_shift_, octave_, carrier_overrides); - // TODO: almost everything. This is a quick test. - // Specifically: use lookup tables. - const auto modulator_level = level(modulator_state_, 0); - return level(carrier_state_, modulator_level); + const auto modulator_level = level(modulator_state_); + return level(carrier_state_, modulator_level) << 2; } bool Channel::is_audible(Operator *carrier, OperatorOverrides *carrier_overrides) { diff --git a/Components/OPL2/Implementation/Channel.hpp b/Components/OPL2/Implementation/Channel.hpp index 0393f11be..9ee159d46 100644 --- a/Components/OPL2/Implementation/Channel.hpp +++ b/Components/OPL2/Implementation/Channel.hpp @@ -46,7 +46,8 @@ class Channel { bool is_audible(Operator *carrier, OperatorOverrides *carrier_overrides = nullptr); private: - int level(OperatorState &state, int modulator_level); + /// @returns The linear output level for the operator with state @c state and with an [optional] modulation input of @c modulator_level. + int level(OperatorState &state, int modulator_level = 0); /// 'F-Num' in the spec; this plus the current octave determines channel frequency. int period_ = 0;