From 8608f9367fc29e498f42f5249aa248dd2044d567 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 26 Sep 2023 17:23:34 +1000 Subject: Tune buffer sizes and locations for I2S --- src/audio/audio_converter.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/audio/audio_converter.cpp') diff --git a/src/audio/audio_converter.cpp b/src/audio/audio_converter.cpp index 88017bf1..a57a1387 100644 --- a/src/audio/audio_converter.cpp +++ b/src/audio/audio_converter.cpp @@ -15,6 +15,7 @@ #include "esp_log.h" #include "freertos/portmacro.h" #include "freertos/projdefs.h" +#include "i2s_dac.hpp" #include "idf_additions.h" #include "resample.hpp" @@ -23,9 +24,9 @@ static constexpr char kTag[] = "mixer"; -static constexpr std::size_t kSampleBufferLength = 240 * 2 * 64; -static constexpr std::size_t kSourceBufferLength = - kSampleBufferLength * 2 * sizeof(sample::Sample); +static constexpr std::size_t kSampleBufferLength = + drivers::kI2SBufferLengthFrames * sizeof(sample::Sample) * 2; +static constexpr std::size_t kSourceBufferLength = kSampleBufferLength * 2; namespace audio { @@ -33,18 +34,18 @@ SampleConverter::SampleConverter() : commands_(xQueueCreate(1, sizeof(Args))), resampler_(nullptr), source_(xStreamBufferCreateWithCaps(kSourceBufferLength, - 1, - MALLOC_CAP_SPIRAM)) { + sizeof(sample::Sample) * 2, + MALLOC_CAP_DMA)) { input_buffer_ = { reinterpret_cast(heap_caps_calloc( - kSampleBufferLength, sizeof(sample::Sample), MALLOC_CAP_SPIRAM)), + kSampleBufferLength, sizeof(sample::Sample), MALLOC_CAP_DMA)), kSampleBufferLength}; input_buffer_as_bytes_ = {reinterpret_cast(input_buffer_.data()), input_buffer_.size_bytes()}; resampled_buffer_ = { reinterpret_cast(heap_caps_calloc( - kSampleBufferLength, sizeof(sample::Sample), MALLOC_CAP_SPIRAM)), + kSampleBufferLength, sizeof(sample::Sample), MALLOC_CAP_DMA)), kSampleBufferLength}; tasks::StartPersistent([&]() { Main(); }); -- cgit v1.2.3