diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-08-10 19:12:38 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-08-10 19:12:38 +1000 |
| commit | 958160aa545e3d91b2a4f1a367817e73d298e8a9 (patch) | |
| tree | 190e6591a6dda1f0d9651c7e127666ead2a3373b /src/codecs/vorbis.cpp | |
| parent | d8fc77101dcf80a3643a00b3446dca1e390ce997 (diff) | |
| download | tangara-fw-958160aa545e3d91b2a4f1a367817e73d298e8a9.tar.gz | |
Use the libspeexdsp resampler
AFAICT it runs a little slower? but it's fixed point, and has much
better understood audio characteristics.
Diffstat (limited to 'src/codecs/vorbis.cpp')
| -rw-r--r-- | src/codecs/vorbis.cpp | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/src/codecs/vorbis.cpp b/src/codecs/vorbis.cpp index 6fa3256a..aa367e02 100644 --- a/src/codecs/vorbis.cpp +++ b/src/codecs/vorbis.cpp @@ -126,14 +126,9 @@ auto TremorVorbisDecoder::OpenStream(std::shared_ptr<IStream> input) auto TremorVorbisDecoder::DecodeTo(cpp::span<sample::Sample> output) -> cpp::result<OutputInfo, Error> { - cpp::span<int16_t> staging_buffer{ - reinterpret_cast<int16_t*>(output.subspan(output.size() / 2).data()), - output.size_bytes() / 2}; - - int bitstream; - long bytes_written = - ov_read(&vorbis_, reinterpret_cast<char*>(staging_buffer.data()), - staging_buffer.size_bytes(), &bitstream); + int bitstream = 0; + long bytes_written = ov_read(&vorbis_, reinterpret_cast<char*>(output.data()), + output.size_bytes(), &bitstream); if (bytes_written == OV_HOLE) { ESP_LOGE(kTag, "got OV_HOLE"); return cpp::fail(Error::kMalformedData); @@ -142,12 +137,9 @@ auto TremorVorbisDecoder::DecodeTo(cpp::span<sample::Sample> output) return cpp::fail(Error::kMalformedData); } - for (int i = 0; i < bytes_written / 2; i++) { - output[i] = sample::FromSigned(staging_buffer[i], 16); - } - return OutputInfo{ - .samples_written = static_cast<size_t>(bytes_written / 2), + .samples_written = + static_cast<size_t>(bytes_written / sizeof(sample::Sample)), .is_stream_finished = bytes_written == 0, }; } |
