From 1573a8c4cde1cd9528b422b2dcc598e37ffe94a7 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Thu, 2 May 2024 19:12:26 +1000 Subject: WIP merge cyclically dependent components into one big component --- src/audio/resample.cpp | 55 -------------------------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 src/audio/resample.cpp (limited to 'src/audio/resample.cpp') diff --git a/src/audio/resample.cpp b/src/audio/resample.cpp deleted file mode 100644 index 1e20392b..00000000 --- a/src/audio/resample.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2023 jacqueline - * - * SPDX-License-Identifier: GPL-3.0-only - */ -#include "resample.hpp" - -#include -#include -#include -#include -#include -#include - -#include "esp_log.h" -#include "speex/speex_resampler.h" - -#include "sample.hpp" - -namespace audio { - -static constexpr int kQuality = SPEEX_RESAMPLER_QUALITY_MIN; - -Resampler::Resampler(uint32_t source_sample_rate, - uint32_t target_sample_rate, - uint8_t num_channels) - : err_(0), - resampler_(speex_resampler_init(num_channels, - source_sample_rate, - target_sample_rate, - kQuality, - &err_)), - num_channels_(num_channels) { - assert(err_ == 0); -} - -Resampler::~Resampler() { - speex_resampler_destroy(resampler_); -} - -auto Resampler::Process(std::span input, - std::span output, - bool end_of_data) -> std::pair { - uint32_t samples_used = input.size() / num_channels_; - uint32_t samples_produced = output.size() / num_channels_; - - int err = speex_resampler_process_interleaved_int( - resampler_, input.data(), &samples_used, output.data(), - &samples_produced); - assert(err == 0); - - return {samples_used * num_channels_, samples_produced * num_channels_}; -} - -} // namespace audio -- cgit v1.2.3