Line data Source code
1 : /** 2 : * \file GainMaxColoredExpanderFilter.h 3 : */ 4 : 5 : #ifndef ATK_DYNAMIC_GAINMAXCOLOREDEXPANDERFILTER_H 6 : #define ATK_DYNAMIC_GAINMAXCOLOREDEXPANDERFILTER_H 7 : 8 : #include <ATK/Dynamic/GainFilter.h> 9 : #include <ATK/Dynamic/config.h> 10 : 11 : namespace ATK 12 : { 13 : /// Colored gain "expander". Computes a new amplitude/volume gain based on threshold, slope and the power of the input signal 14 : /*! 15 : * The maximum reduction is given by max_reduction 16 : */ 17 : template<typename DataType_> 18 : class ATK_DYNAMIC_EXPORT GainMaxColoredExpanderFilter : public ParentGainFilter<DataType_> 19 : { 20 : public: 21 : /// Simplify parent calls 22 : using Parent = ParentGainFilter<DataType_>; 23 : using Parent::ratio; 24 : using Parent::start_recomputeLUT; 25 : using typename Parent::DataType; 26 : /*! 27 : * @brief Constructor 28 : * @param nb_channels is the number of input and output channels 29 : * @param LUTsize is the total LUT size used by the filter 30 : * @param LUTprecision is the number of elements used to compute values < 1 31 : */ 32 : GainMaxColoredExpanderFilter(gsl::index nb_channels = 1, size_t LUTsize = 128*1024, size_t LUTprecision = 1024); 33 : /// Destructor 34 14 : ~GainMaxColoredExpanderFilter() override = default; 35 : 36 : /// Sets the softness of the knee of the filter (positive value) 37 : void set_softness(DataType_ softness); 38 : /// Retrieves the softness afctor 39 : DataType_ get_softness() const; 40 : 41 : /// Sets the color of the filter, the behavior around the threshold 42 : /*! 43 : * A positive value increases the gain, a negative value lowers it 44 : */ 45 : void set_color(DataType_ color); 46 : /// Returns the color factor 47 : DataType_ get_color() const; 48 : /// Sets the quality, the extent around the threshold where the color factor has an effect 49 : void set_quality(DataType_ quality); 50 : /// Returns the quality factor 51 : DataType_ get_quality() const; 52 : 53 : /// Sets the maximum reduction factor of the filter (limit reduction to this factor instead of infinite) 54 : void set_max_reduction(DataType_ max_reduction); 55 : /// Sets the maximum reduction in dB 56 : void set_max_reduction_db(DataType_ max_reduction); 57 : /// Gets the maximum reduction factor 58 : DataType_ get_max_reduction() const; 59 : 60 : protected: 61 : DataType_ computeGain(DataType_ value) const; 62 : 63 : private: 64 : DataType_ softness{0.0001}; 65 : DataType_ max_reduction{0.01}; 66 : DataType_ color{0}; 67 : DataType_ quality{0}; 68 : }; 69 : } 70 : 71 : #endif