mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +00:00
Factors out shift by 7.
This commit is contained in:
parent
44690b1066
commit
9458963311
@ -380,10 +380,12 @@ void OPLL::update_all_channels() {
|
|||||||
|
|
||||||
// TODO: verify attenuation scales pervasively below.
|
// TODO: verify attenuation scales pervasively below.
|
||||||
|
|
||||||
|
#define ATTENUATION(x) ((x) << 7)
|
||||||
|
|
||||||
int OPLL::melodic_output(int channel) {
|
int OPLL::melodic_output(int channel) {
|
||||||
// The modulator always updates after the carrier, oddly enough. So calculate actual output first, based on the modulator's last value.
|
// The modulator always updates after the carrier, oddly enough. So calculate actual output first, based on the modulator's last value.
|
||||||
auto carrier = WaveformGenerator<period_precision>::wave(channels_[channel].carrier_waveform, phase_generators_[channel].scaled_phase(), channels_[channel].modulator_output);
|
auto carrier = WaveformGenerator<period_precision>::wave(channels_[channel].carrier_waveform, phase_generators_[channel].scaled_phase(), channels_[channel].modulator_output);
|
||||||
carrier += envelope_generators_[channel].attenuation() + (channels_[channel].attenuation << 7) + key_level_scalers_[channel].attenuation();
|
carrier += envelope_generators_[channel].attenuation() + ATTENUATION(channels_[channel].attenuation) + key_level_scalers_[channel].attenuation();
|
||||||
|
|
||||||
// Get the modulator's new value.
|
// Get the modulator's new value.
|
||||||
auto modulation = WaveformGenerator<period_precision>::wave(channels_[channel].modulator_waveform, phase_generators_[channel + 9].phase());
|
auto modulation = WaveformGenerator<period_precision>::wave(channels_[channel].modulator_waveform, phase_generators_[channel + 9].phase());
|
||||||
@ -402,7 +404,7 @@ int OPLL::bass_drum() {
|
|||||||
modulation += rhythm_envelope_generators_[RhythmIndices::BassModulator].attenuation();
|
modulation += rhythm_envelope_generators_[RhythmIndices::BassModulator].attenuation();
|
||||||
|
|
||||||
auto carrier = WaveformGenerator<period_precision>::wave(Waveform::Sine, phase_generators_[6].scaled_phase(), modulation);
|
auto carrier = WaveformGenerator<period_precision>::wave(Waveform::Sine, phase_generators_[6].scaled_phase(), modulation);
|
||||||
carrier += rhythm_envelope_generators_[RhythmIndices::BassCarrier].attenuation() + (channels_[6].attenuation << 7);
|
carrier += rhythm_envelope_generators_[RhythmIndices::BassCarrier].attenuation() + ATTENUATION(channels_[6].attenuation);
|
||||||
return carrier.level();
|
return carrier.level();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,7 +412,7 @@ int OPLL::tom_tom() {
|
|||||||
// Use modulator 8 and the 'instrument' selection for channel 8 as an attenuation.
|
// Use modulator 8 and the 'instrument' selection for channel 8 as an attenuation.
|
||||||
auto tom_tom = WaveformGenerator<period_precision>::wave(Waveform::Sine, phase_generators_[8 + 9].phase());
|
auto tom_tom = WaveformGenerator<period_precision>::wave(Waveform::Sine, phase_generators_[8 + 9].phase());
|
||||||
tom_tom += rhythm_envelope_generators_[RhythmIndices::TomTom].attenuation();
|
tom_tom += rhythm_envelope_generators_[RhythmIndices::TomTom].attenuation();
|
||||||
tom_tom += channels_[8].instrument << 7;
|
tom_tom += ATTENUATION(channels_[8].instrument);
|
||||||
return tom_tom.level();
|
return tom_tom.level();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,7 +420,7 @@ int OPLL::snare_drum() {
|
|||||||
// Use modulator 7 and the carrier attenuation level for channel 7.
|
// Use modulator 7 and the carrier attenuation level for channel 7.
|
||||||
LogSign snare = WaveformGenerator<period_precision>::snare(oscillator_, phase_generators_[7 + 9].phase());
|
LogSign snare = WaveformGenerator<period_precision>::snare(oscillator_, phase_generators_[7 + 9].phase());
|
||||||
snare += rhythm_envelope_generators_[RhythmIndices::Snare].attenuation();
|
snare += rhythm_envelope_generators_[RhythmIndices::Snare].attenuation();
|
||||||
snare += channels_[7].attenuation << 7;
|
snare += ATTENUATION(channels_[7].attenuation);
|
||||||
return snare.level();
|
return snare.level();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,7 +428,7 @@ int OPLL::cymbal() {
|
|||||||
// Use modulator 7, carrier 8 and the attenuation level for channel 8.
|
// Use modulator 7, carrier 8 and the attenuation level for channel 8.
|
||||||
LogSign cymbal = WaveformGenerator<period_precision>::cymbal(phase_generators_[8].phase(), phase_generators_[7 + 9].phase());
|
LogSign cymbal = WaveformGenerator<period_precision>::cymbal(phase_generators_[8].phase(), phase_generators_[7 + 9].phase());
|
||||||
cymbal += rhythm_envelope_generators_[RhythmIndices::Cymbal].attenuation();
|
cymbal += rhythm_envelope_generators_[RhythmIndices::Cymbal].attenuation();
|
||||||
cymbal += channels_[8].attenuation << 7;
|
cymbal += ATTENUATION(channels_[8].attenuation);
|
||||||
return cymbal.level();
|
return cymbal.level();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,6 +436,8 @@ int OPLL::high_hat() {
|
|||||||
// Use modulator 7, carrier 8 a and the 'instrument' selection for channel 7 as an attenuation.
|
// Use modulator 7, carrier 8 a and the 'instrument' selection for channel 7 as an attenuation.
|
||||||
LogSign high_hat = WaveformGenerator<period_precision>::high_hat(oscillator_, phase_generators_[8].phase(), phase_generators_[7 + 9].phase());
|
LogSign high_hat = WaveformGenerator<period_precision>::high_hat(oscillator_, phase_generators_[8].phase(), phase_generators_[7 + 9].phase());
|
||||||
high_hat += rhythm_envelope_generators_[RhythmIndices::HighHat].attenuation();
|
high_hat += rhythm_envelope_generators_[RhythmIndices::HighHat].attenuation();
|
||||||
high_hat += channels_[7].instrument << 7;
|
high_hat += ATTENUATION(channels_[7].instrument);
|
||||||
return high_hat.level();
|
return high_hat.level();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef ATTENUATION
|
||||||
|
Loading…
Reference in New Issue
Block a user