From 7fffafdfd467751f6483959e6e07d8fbab23fa0a Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 29 Apr 2020 22:44:15 -0400 Subject: [PATCH] Wires the high-hat through, possibly incorrectly. --- Components/OPL2/Implementation/Channel.cpp | 4 ++++ Components/OPL2/OPL2.cpp | 28 ++++++++++++++-------- Components/OPL2/OPL2.hpp | 1 + 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/Components/OPL2/Implementation/Channel.cpp b/Components/OPL2/Implementation/Channel.cpp index 5764f29c1..9c92feb77 100644 --- a/Components/OPL2/Implementation/Channel.cpp +++ b/Components/OPL2/Implementation/Channel.cpp @@ -60,6 +60,10 @@ int Channel::cymbal_output(Operator &modulator, Operator &carrier, Channel &chan return carrier.cymbal_output(states_[0], channel8.states_[1]).level(); } +int Channel::high_hat_output(Operator &modulator, Operator &carrier, Channel &channel8, OperatorOverrides *modulator_overrides) { + return carrier.high_hat_output(states_[0], channel8.states_[1]).level(); +} + bool Channel::is_audible(Operator *carrier, OperatorOverrides *carrier_overrides) { return carrier->is_audible(states_[0], carrier_overrides); } diff --git a/Components/OPL2/OPL2.cpp b/Components/OPL2/OPL2.cpp index 125d25d0d..1d39e2d78 100644 --- a/Components/OPL2/OPL2.cpp +++ b/Components/OPL2/OPL2.cpp @@ -152,6 +152,12 @@ void OPLL::write_register(uint8_t address, uint8_t value) { // Select an instrument in the top nibble, set a channel volume in the lower. channels_[index].overrides.attenuation = value & 0xf; channels_[index].modulator = &operators_[(value >> 4) * 2]; + + // Also crib volume levels for rhythm mode, possibly. + if(index >= 6) { + rhythm_overrides_[(index - 6) * 2 + 0].attenuation = value >> 4; + rhythm_overrides_[(index - 6) * 2 + 1].attenuation = value & 0xf; + } break; case 0x10: channels_[index].set_frequency_low(value); break; @@ -163,7 +169,7 @@ void OPLL::write_register(uint8_t address, uint8_t value) { channels_[index].overrides.use_sustain_level = value & 0x20; break; - default: break; + default: printf("Unknown write to %02x?!?\n", address); break; } }); } @@ -216,24 +222,26 @@ void OPLL::update_all_chanels() { if(depth_rhythm_control_ & 0x20) { // TODO: pervasively, volume. And LFSR updates. - // Update channel 6 as if melodic, but with the bass instrument. channels_[6].update(oscillator_, &operators_[32], depth_rhythm_control_ & 0x10); + channels_[7].update(true, oscillator_, operators_[34], bool(depth_rhythm_control_ & 0x01)); + channels_[7].update(false, oscillator_, operators_[35], bool(depth_rhythm_control_ & 0x08)); + channels_[8].update(true, oscillator_, operators_[36], bool(depth_rhythm_control_ & 0x04)); + channels_[8].update(false, oscillator_, operators_[37], bool(depth_rhythm_control_ & 0x02)); + + // Update channel 6 as if melodic, but with the bass instrument. output_levels_[2] = output_levels_[15] = VOLUME(channels_[6].melodic_output()); - // Use the modulator from channel 7 for the tom tom. - channels_[7].update(true, oscillator_, operators_[34], bool(depth_rhythm_control_ & 0x04)); - output_levels_[1] = output_levels_[14] = VOLUME(channels_[7].tom_tom_output(operators_[34])); - // Use the carrier from channel 7 for the snare. - channels_[7].update(false, oscillator_, operators_[35], bool(depth_rhythm_control_ & 0x08)); output_levels_[6] = output_levels_[16] = VOLUME(channels_[7].snare_output(operators_[35])); + // Use the modulator from channel 8 for the tom tom. + output_levels_[1] = output_levels_[14] = VOLUME(channels_[8].tom_tom_output(operators_[37])); + // Use the channel 7 modulator and the channel 8 carrier for a cymbal. - channels_[8].update(false, oscillator_, operators_[36], bool(depth_rhythm_control_ & 0x01)); output_levels_[7] = output_levels_[17] = VOLUME(channels_[7].cymbal_output(operators_[36], operators_[35], channels_[8])); - // TODO: high hat. - output_levels_[0] = output_levels_[13] = 0; + // Use the channel 7 modulator and the channel 8 modulator (?) for a high-hat. + output_levels_[0] = output_levels_[13] = VOLUME(channels_[7].high_hat_output(operators_[36], operators_[35], channels_[8])); } else { // Not in rhythm mode; channels 7, 8 and 9 are melodic. for(int c = 6; c < 9; ++ c) { diff --git a/Components/OPL2/OPL2.hpp b/Components/OPL2/OPL2.hpp index db26c4153..4b22502be 100644 --- a/Components/OPL2/OPL2.hpp +++ b/Components/OPL2/OPL2.hpp @@ -126,6 +126,7 @@ struct OPLL: public OPLBase { void update_all_chanels(); Channel channels_[9]; int output_levels_[18]; + OperatorOverrides rhythm_overrides_[6]; void setup_fixed_instrument(int number, const uint8_t *data); uint8_t custom_instrument_[8];