diff options
| author | Vasile Vilvoiu <vasi@vilvoiu.ro> | 2021-07-16 18:32:27 +0300 |
|---|---|---|
| committer | Vasile Vilvoiu <vasi@vilvoiu.ro> | 2021-07-16 18:32:27 +0300 |
| commit | 47bbfdbf1e2a6193157397938e76b16a1f60e789 (patch) | |
| tree | 5f90ac568bcd0ddfa2e885bacf4e4e996395d249 /src/value-map.hpp | |
| parent | 82c81858c65c80fb667e73ffdcc4ff69007cfa17 (diff) | |
Add support for arbitrary scales, with custom units.
Add support for linear scales.
Logging of scale to stderr.
Closes #9.
Diffstat (limited to 'src/value-map.hpp')
| -rw-r--r-- | src/value-map.hpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/value-map.hpp b/src/value-map.hpp index d162f45..2f32d92 100644 --- a/src/value-map.hpp +++ b/src/value-map.hpp @@ -15,15 +15,18 @@ #include <complex> enum class ValueMapType { - kdBFS + kLinear, + kDecibel }; class ValueMap { protected: const double lower_; const double upper_; + const std::string unit_; + + ValueMap(double lower_, double upper, const std::string& unit); - ValueMap(double lower_, double upper); public: ValueMap() = delete; @@ -31,18 +34,25 @@ public: auto GetUpperBound() const { return upper_; } virtual RealWindow Map(const RealWindow& input) = 0; - virtual std::string GetUnit() const = 0; - virtual std::string GetName() const = 0; + virtual std::string GetUnit() const; + + static std::unique_ptr<ValueMap> Build(ValueMapType type, double lower, double upper, std::string unit); +}; + +class LinearValueMap : public ValueMap { +public: + LinearValueMap(double lower, double upper, const std::string& unit); + + RealWindow Map(const RealWindow& input) override; }; -class dBFSValueMap : public ValueMap { -private: +class DecibelValueMap : public ValueMap { public: - explicit dBFSValueMap(double mindb); + /* unit parameter should NOT contain "dB" prefix */ + DecibelValueMap(double lower, double upper, const std::string& unit); RealWindow Map(const RealWindow& input) override; - std::string GetUnit() const override { return "dBFS"; } - std::string GetName() const override { return "dBFS"; } + std::string GetUnit() const override; }; #endif
\ No newline at end of file |
