Remove 8-bit handling in output, promote WAV/FLAC to 16 (#782)

Only the WAV and FLAC generators can generate 8-bit values, so it is
more efficient and sane to just have those generators upscale to 16-bit
signed (if necessary) in generation and simplify all the other
Generators and Outputs.
This commit is contained in:
Earle F. Philhower, III authored and GitHub committed 2025-10-13 09:56:39 -07:00
1 parent 724b6d606e
commit 058e131b26
29 files changed
+43 -163

No files matched your search

+7 -13
View File
@@ -35,14 +35,14 @@ bool AudioOutputSerialWAV::begin() {
wavHeader[25] = (hertz >> 8) & 0xff;
wavHeader[26] = (hertz >> 16) & 0xff;
wavHeader[27] = (hertz >> 24) & 0xff;
int byteRate = hertz * bps * channels / 8;
int byteRate = hertz * 16 * channels / 8;
wavHeader[28] = byteRate & 0xff;
wavHeader[29] = (byteRate >> 8) & 0xff;
wavHeader[30] = (byteRate >> 16) & 0xff;
wavHeader[31] = (byteRate >> 24) & 0xff;
wavHeader[32] = channels * bps / 8;
wavHeader[32] = channels * 16 / 8;
wavHeader[33] = 0;
wavHeader[34] = bps;
wavHeader[34] = 16;
wavHeader[35] = 0;
Serial.write(wavHeader, sizeof(wavHeader));
count = 0;
@@ -55,15 +55,10 @@ bool AudioOutputSerialWAV::ConsumeSample(int16_t sample[2]) {
return false;
}
for (int i = 0; i < channels; i++) {
if (bps == 8) {
uint8_t l = sample[i] & 0xff;
Serial.write(l);
} else {
uint8_t l = sample[i] & 0xff;
uint8_t h = (sample[i] >> 8) & 0xff;
Serial.write(l);
Serial.write(h);
}
uint8_t l = sample[i] & 0xff;
uint8_t h = (sample[i] >> 8) & 0xff;
Serial.write(l);
Serial.write(h);
}
return true;
}
@@ -73,4 +68,3 @@ bool AudioOutputSerialWAV::stop() {
audioLogger->printf_P(PSTR("\n\n\nEOF\n\n\n"));
return true;
}