1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-01-12 15:31:09 +00:00

Minor: enables all melodic channels when rhythm mode is disabled; supports non-modulated channels.

This commit is contained in:
Thomas Harte 2020-04-18 17:48:29 -04:00
parent 3da2e91acf
commit cdfd7de221
4 changed files with 23 additions and 8 deletions

View File

@ -39,7 +39,11 @@ int Channel::update(Operator *modulator, Operator *carrier, OperatorOverrides *m
carrier->update(carrier_state_, key_on_, period_ << frequency_shift_, octave_, carrier_overrides);
const auto modulator_level = level(modulator_state_);
return level(carrier_state_, modulator_level) << 2;
if(use_fm_synthesis_) {
return level(carrier_state_, modulator_level) << 2;
} else {
return (modulator_level + level(carrier_state_)) << 1;
}
}
bool Channel::is_audible(Operator *carrier, OperatorOverrides *carrier_overrides) {

View File

@ -66,7 +66,7 @@ void Operator::update(OperatorState &state, bool key_on, int channel_period, int
// Update the raw phase.
// TODO: if this is the real formula (i.e. a downward shift for channel_octave), this is a highly
// suboptimal way to do this. Could just keep one accumulator and shift that downward for the result.
const int octave_divider = 2048 >> channel_octave;
const int octave_divider = 4096 >> channel_octave;
state.divider_ %= octave_divider;
state.divider_ += channel_period;
state.raw_phase_ += multipliers[frequency_multiple_] * (state.divider_ / octave_divider);

View File

@ -181,6 +181,22 @@ void OPLL::setup_fixed_instrument(int number, const uint8_t *data) {
carrier->set_sustain_release(data[7]);
}
void OPLL::update_all_chanels() {
if(depth_rhythm_control_ & 0x20) {
// Rhythm mode. Somehow?
// Melodic channels. Easy!
for(int c = 0; c < 6; ++ c) {
channels_[c].level = (channels_[c].update() * total_volume_) >> 14;
}
} else {
// All melody, all the time.
for(int c = 0; c < 9; ++ c) {
channels_[c].level = (channels_[c].update() * total_volume_) >> 14;
}
}
}
/*
template <Personality personality>
void OPL2<personality>::get_samples(std::size_t number_of_samples, std::int16_t *target) {

View File

@ -105,12 +105,7 @@ struct OPLL: public OPLBase<OPLL> {
OperatorOverrides overrides;
int level = 0;
};
void update_all_chanels() {
for(int c = 0; c < 6; ++ c) { // Don't do anything with channels that might be percussion for now.
channels_[c].level = (channels_[c].update() * total_volume_) >> 14;
}
// channels_[2].level = (channels_[2].update() * total_volume_) >> 14;
}
void update_all_chanels();
Channel channels_[9];
void setup_fixed_instrument(int number, const uint8_t *data);