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