Line data Source code
1 : /** 2 : * \file GainCompressorFilter.h 3 : */ 4 : 5 : #ifndef ATK_DYNAMIC_GAINCOMPRESSORFILTER_H 6 : #define ATK_DYNAMIC_GAINCOMPRESSORFILTER_H 7 : 8 : #include <ATK/Dynamic/GainFilter.h> 9 : #include <ATK/Dynamic/config.h> 10 : 11 : namespace ATK 12 : { 13 : /// Gain "compressor". Computes a new amplitude/volume gain based on threshold, slope and the power of the input signal 14 : template<typename DataType_> 15 : class ATK_DYNAMIC_EXPORT GainCompressorFilter : public ParentGainFilter<DataType_> 16 : { 17 : public: 18 : using Parent = ParentGainFilter<DataType_>; 19 : using Parent::ratio; 20 : using Parent::start_recomputeLUT; 21 : using typename Parent::DataType; 22 : /*! 23 : * @brief Constructor 24 : * @param nb_channels is the number of input and output channels 25 : * @param LUTsize is the total LUT size used by the filter 26 : * @param LUTprecision is the number of elements used to compute values < 1 27 : */ 28 : GainCompressorFilter(gsl::index nb_channels = 1, size_t LUTsize = 128*1024, size_t LUTprecision = 64); 29 : /// Destructor 30 13 : ~GainCompressorFilter() override = default; 31 : 32 : /// Sets the softness of the knee of the filter (positive value) 33 : void set_softness(DataType_ softness); 34 : /// Retrieves the softness afctor 35 : DataType_ get_softness() const; 36 : 37 : protected: 38 : DataType_ computeGain(DataType_ value) const; 39 : private: 40 : DataType_ softness{0.0001}; 41 : }; 42 : } 43 : 44 : #endif