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:
1 parent
724b6d606e
commit
058e131b26
29 files changed
+43
-163
No files matched your search
@@ -98,8 +98,11 @@ bool AudioGeneratorWAV::loop() {
|
||||
} else {
|
||||
r = 0;
|
||||
}
|
||||
lastSample[AudioOutput::LEFTCHANNEL] = l;
|
||||
lastSample[AudioOutput::RIGHTCHANNEL] = r;
|
||||
|
||||
// Upsample from unsigned 8 bits to signed 16 bits
|
||||
lastSample[AudioOutput::LEFTCHANNEL] = (((int16_t)(lastSample[AudioOutput::LEFTCHANNEL] & 0xff)) - 128) << 8;
|
||||
lastSample[AudioOutput::RIGHTCHANNEL] = (((int16_t)(lastSample[AudioOutput::RIGHTCHANNEL] & 0xff)) - 128) << 8;
|
||||
|
||||
} else if (bitsPerSample == 16) {
|
||||
if (!GetBufferedData(2, &lastSample[AudioOutput::LEFTCHANNEL])) {
|
||||
stop();
|
||||
@@ -312,10 +315,6 @@ bool AudioGeneratorWAV::begin(AudioFileSource *source, AudioOutput *output) {
|
||||
Serial.printf_P(PSTR("AudioGeneratorWAV::begin: failed to SetRate in output\n"));
|
||||
return false;
|
||||
}
|
||||
if (!output->SetBitsPerSample(bitsPerSample)) {
|
||||
Serial.printf_P(PSTR("AudioGeneratorWAV::begin: failed to SetBitsPerSample in output\n"));
|
||||
return false;
|
||||
}
|
||||
if (!output->SetChannels(channels)) {
|
||||
Serial.printf_P(PSTR("AudioGeneratorWAV::begin: failed to SetChannels in output\n"));
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user