1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-09-30 22:56:03 +00:00

Attempts better to balance attenuations.

This commit is contained in:
Thomas Harte 2020-05-05 22:14:11 -04:00
parent b943441901
commit 1a4321d7d0
2 changed files with 7 additions and 6 deletions

View File

@ -79,10 +79,10 @@ template <int envelope_precision, int period_precision> class EnvelopeGenerator
}
/*!
@returns The current attenuation from this envelope generator.
@returns The current attenuation from this envelope generator. This is independent of the envelope precision.
*/
int attenuation() const {
return attenuation_ + tremolo_;
return (attenuation_ + tremolo_) << 3;
}
/*!

View File

@ -298,10 +298,11 @@ void OPLL::update_all_channels() {
int OPLL::melodic_output(int channel) {
// TODO: key-rate scaling.
// TODO: proper scales of all attenuations below.
// TODO: verify attenuation scales.
auto modulation = WaveformGenerator<period_precision>::wave(channels_[channel].modulator_waveform, phase_generators_[channel + 9].phase());
modulation += envelope_generators_[channel + 9].attenuation() + channels_[channel].modulator_attenuation;
modulation += envelope_generators_[channel + 9].attenuation() + (channels_[channel].modulator_attenuation << 5) + key_level_scalers_[channel + 9].attenuation();
return WaveformGenerator<period_precision>::wave(channels_[channel].carrier_waveform, phase_generators_[channel].scaled_phase(), modulation).level() + channels_[channel].attenuation;
auto carrier = WaveformGenerator<period_precision>::wave(channels_[channel].carrier_waveform, phase_generators_[channel].scaled_phase(), modulation);
carrier += envelope_generators_[channel].attenuation() + (channels_[channel].attenuation << 7) + key_level_scalers_[channel].attenuation();
return carrier.level();
}