1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-11-23 05:19:20 +00:00

Simplify, update noise tap.

This commit is contained in:
Thomas Harte
2025-11-13 11:59:56 -05:00
parent 86bf019aac
commit 1ce013bcf7

View File

@@ -52,7 +52,7 @@ struct Voice {
uint16_t noise_output() const { uint16_t noise_output() const {
// Uses bits: 20, 18, 14, 11, 9, 5, 2 and 0, plus four more zero bits. // Uses bits: 20, 18, 14, 11, 9, 5, 2 and 0, plus four more zero bits.
return return
((noise >> 8) & 0b1000'0000'0000) | // b20 -> b11 ((noise >> 9) & 0b1000'0000'0000) | // b20 -> b11
((noise >> 8) & 0b0100'0000'0000) | // b18 -> b10 ((noise >> 8) & 0b0100'0000'0000) | // b18 -> b10
((noise >> 5) & 0b0010'0000'0000) | // b14 -> b9 ((noise >> 5) & 0b0010'0000'0000) | // b14 -> b9
((noise >> 3) & 0b0001'0000'0000) | // b11 -> b8 ((noise >> 3) & 0b0001'0000'0000) | // b11 -> b8
@@ -194,19 +194,8 @@ struct Voice {
if(adsr.exponential_counter == exponential_prescaler[adsr.envelope]) { if(adsr.exponential_counter == exponential_prescaler[adsr.envelope]) {
adsr.exponential_counter = 0; adsr.exponential_counter = 0;
switch(adsr.phase) { if(adsr.envelope && (adsr.envelope != adsr.sustain || adsr.phase != ADSR::Phase::DecayAndHold)) {
default: __builtin_unreachable(); --adsr.envelope;
case ADSR::Phase::DecayAndHold:
if(adsr.envelope == adsr.sustain) {
break;
}
--adsr.envelope;
break;
case ADSR::Phase::Release:
if(adsr.envelope) {
--adsr.envelope;
}
break;
} }
} }
} }