Line data Source code
1 : /** 2 : * \file GainMaxExpanderFilter.h 3 : */ 4 : 5 : #ifndef ATK_DYNAMIC_GAINMAXEXPANDERFILTER_H 6 : #define ATK_DYNAMIC_GAINMAXEXPANDERFILTER_H 7 : 8 : #include <ATK/Dynamic/GainFilter.h> 9 : #include <ATK/Dynamic/config.h> 10 : 11 : namespace ATK 12 : { 13 : /// 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 GainMaxExpanderFilter : 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 : GainMaxExpanderFilter(gsl::index nb_channels = 1, size_t LUTsize = 128*1024, size_t LUTprecision = 1024); 33 : /// Destructor 34 10 : ~GainMaxExpanderFilter() 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 maximum reduction factor of the filter (limit reduction to this factor instead of infinite) 42 : void set_max_reduction(DataType_ max_reduction); 43 : /// Sets the maximum reduction in dB 44 : void set_max_reduction_db(DataType_ max_reduction); 45 : /// Gets the maximum reduction factor 46 : DataType_ get_max_reduction() const; 47 : 48 : protected: 49 : DataType_ computeGain(DataType_ value) const; 50 : private: 51 : DataType_ softness{0.0001}; 52 : DataType_ max_reduction{0.01}; 53 : }; 54 : } 55 : 56 : #endif