summaryrefslogtreecommitdiff
path: root/src/chresampler.h
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2016-05-08 12:15:10 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2016-05-08 12:17:16 +0200
commit8ec32c94e0d8161120018170724d64d262bc133d (patch)
tree62b4a6d97519fdd936ec0c782407ba09a06d52cd /src/chresampler.h
parent32332a63ac9a80750b89452490830e042518797a (diff)
Make Resamplers container class.
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;
+};