From 8ec32c94e0d8161120018170724d64d262bc133d Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 8 May 2016 12:15:10 +0200 Subject: Make Resamplers container class. --- src/chresampler.h | 62 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 14 deletions(-) (limited to 'src/chresampler.h') diff --git a/src/chresampler.h b/src/chresampler.h index bbe2521..4148aee 100644 --- a/src/chresampler.h +++ b/src/chresampler.h @@ -27,16 +27,14 @@ #pragma once #include -#include #include +#include -/** - * Channel resampler class using either zita-resampler or secret rabbit code - * (really!!) depending on the value of the WITH_RESAMPLER macro. - * If WITH_RESAMPLER is unset the resampler is disabled entirely. - * If WITH_RESAMPLER=="zita" zita-resampler will be used. - * If WITH_RESAMPLER=="src" Secret Rabbit Code will be used. - */ +//! Channel resampler class using either zita-resampler or secret rabbit code +//! (really!!) depending on the value of the WITH_RESAMPLER macro. +//! If WITH_RESAMPLER is unset the resampler is disabled entirely. +//! If WITH_RESAMPLER=="zita" zita-resampler will be used. +//! If WITH_RESAMPLER=="src" Secret Rabbit Code will be used. class CHResampler { public: @@ -45,13 +43,13 @@ public: void setup(double input_fs, double output_fs); - void setInputSamples(float* samples, size_t count); - void setOutputSamples(float* samples, size_t count); + void setInputSamples(float* samples, std::size_t count); + void setOutputSamples(float* samples, std::size_t count); void process(); - size_t getInputSampleCount() const; - size_t getOutputSampleCount() const; + std::size_t getInputSampleCount() const; + std::size_t getOutputSampleCount() const; double getRatio() const; @@ -60,7 +58,43 @@ private: class Prv; std::unique_ptr prv; - double input_fs{44100}; - double output_fs{44100}; + double input_fs{44100.0}; + double output_fs{44100.0}; #endif /*WITH_RESAMPLER*/ }; + +//! Container class for the resampler array. +class Resamplers +{ +public: + void setup(double input_fs, double output_fs) + { + for(auto& resampler : resamplers) + { + resampler.setup(input_fs, output_fs); + } + } + + bool isActive() const + { + return getRatio() != 1.0; + } + + double getRatio() const + { + return resamplers[0].getRatio(); + } + + + CHResampler& operator[](std::size_t idx) + { + return resamplers[idx]; + } + + std::size_t getOutputSampleCount() const + { + return resamplers[0].getOutputSampleCount(); + } + + std::array resamplers; +}; -- cgit v1.2.3