From 63d9ec8e94d17faddb9a29288ea68f73aac0c0d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Mon, 7 Feb 2022 22:56:48 +0100 Subject: LibAudio: Allow resampling from any array-like type --- Userland/Libraries/LibAudio/Resampler.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'Userland/Libraries/LibAudio') diff --git a/Userland/Libraries/LibAudio/Resampler.h b/Userland/Libraries/LibAudio/Resampler.h index 718c9b3ac9..6ff633fb92 100644 --- a/Userland/Libraries/LibAudio/Resampler.h +++ b/Userland/Libraries/LibAudio/Resampler.h @@ -6,6 +6,7 @@ #pragma once +#include #include #include @@ -50,6 +51,21 @@ public: return false; } + template Samples> + Vector resample(Samples&& to_resample) + { + Vector resampled; + resampled.ensure_capacity(to_resample.size() * ceil_div(m_source, m_target)); + for (auto sample : to_resample) { + process_sample(sample, sample); + + while (read_sample(sample, sample)) + resampled.unchecked_append(sample); + } + + return resampled; + } + void reset() { m_current_ratio = 0; -- cgit v1.2.3