diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-09-26 17:23:34 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-09-26 17:23:34 +1000 |
| commit | 8608f9367fc29e498f42f5249aa248dd2044d567 (patch) | |
| tree | c8564bfe6bbc6c5a9413bbd29b4e52f2cf3bd35c /src/audio/audio_converter.cpp | |
| parent | 4d99d22e10a3cb2a421da1618c127128816613c9 (diff) | |
| download | tangara-fw-8608f9367fc29e498f42f5249aa248dd2044d567.tar.gz | |
Tune buffer sizes and locations for I2S
Diffstat (limited to 'src/audio/audio_converter.cpp')
| -rw-r--r-- | src/audio/audio_converter.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
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<sample::Sample*>(heap_caps_calloc( - kSampleBufferLength, sizeof(sample::Sample), MALLOC_CAP_SPIRAM)), + kSampleBufferLength, sizeof(sample::Sample), MALLOC_CAP_DMA)), kSampleBufferLength}; input_buffer_as_bytes_ = {reinterpret_cast<std::byte*>(input_buffer_.data()), input_buffer_.size_bytes()}; resampled_buffer_ = { reinterpret_cast<sample::Sample*>(heap_caps_calloc( - kSampleBufferLength, sizeof(sample::Sample), MALLOC_CAP_SPIRAM)), + kSampleBufferLength, sizeof(sample::Sample), MALLOC_CAP_DMA)), kSampleBufferLength}; tasks::StartPersistent<tasks::Type::kAudioConverter>([&]() { Main(); }); |
