summaryrefslogtreecommitdiff
path: root/src/chresampler.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/chresampler.h')
-rw-r--r--src/chresampler.h62
1 files changed, 48 insertions, 14 deletions
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 <memory>
-#include <stdlib.h>
#include <config.h>
+#include <array>
-/**
- * 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> 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<CHResampler, 64> resamplers;
+};