Line data Source code
1 : /** 2 : * \file AttackReleaseHysteresisFilter.h 3 : */ 4 : 5 : #ifndef ATK_DYNAMIC_ATTACKRELEASEHYSTERESISFILTER_H 6 : #define ATK_DYNAMIC_ATTACKRELEASEHYSTERESISFILTER_H 7 : 8 : #include <ATK/Core/TypedBaseFilter.h> 9 : #include <ATK/Dynamic/config.h> 10 : 11 : namespace ATK 12 : { 13 : /// Creates an output signal with the filter power of the input (computed with an AR1 with hysteresis) 14 : template<typename DataType_> 15 : class ATK_DYNAMIC_EXPORT AttackReleaseHysteresisFilter final : public TypedBaseFilter<DataType_> 16 : { 17 : protected: 18 : /// Simplify parent calls 19 : using Parent = TypedBaseFilter<DataType_>; 20 : using typename Parent::DataType; 21 : using Parent::converted_inputs; 22 : using Parent::outputs; 23 : using Parent::nb_input_ports; 24 : using Parent::nb_output_ports; 25 : using Parent::output_delay; 26 : 27 : public: 28 : /*! 29 : * @brief Constructor 30 : * @param nb_channels is the number of input and output channels 31 : */ 32 : explicit AttackReleaseHysteresisFilter(gsl::index nb_channels = 1); 33 : /// destructor 34 16 : ~AttackReleaseHysteresisFilter() override = default; 35 : 36 : /// Sets the speed of the attack (between 0 and 1) 37 : void set_attack(DataType_ attack); 38 : /// Gets the attack speed 39 : DataType_ get_attack() const; 40 : /// Sets the speed of the release (between 0 and 1) 41 : void set_release(DataType_ release); 42 : /// Gets the release speed 43 : DataType_ get_release() const; 44 : 45 : /// Change the attack hysteresis (must be superior to the release hysteresis) 46 : /*! 47 : * Be aware that attack hysteresis is tricky, as you can never get up to the input power... 48 : */ 49 : void set_attack_hysteresis(DataType_ attack_hysteresis); 50 : /// Change the attack hysteresis in dB 51 : void set_attack_hysteresis_db(DataType_ attack_hysteresis_db); 52 : /// Gets the attack hysteresis factor 53 : DataType_ get_attack_hysteresis() const; 54 : /// Change the release hysteresis (between 0 and 1) 55 : void set_release_hysteresis(DataType_ release_hysteresis); 56 : /// Change the release hysteresis in dB 57 : void set_release_hysteresis_db(DataType_ release_hysteresis_db); 58 : /// Gets the release hysteresis factor 59 : DataType_ get_release_hysteresis() const; 60 : 61 : protected: 62 : void process_impl(gsl::index size) const final; 63 : 64 : private: 65 : DataType_ attack{1}; 66 : DataType_ release{1}; 67 : DataType_ attack_hysteresis{1}; 68 : DataType_ release_hysteresis{1}; 69 : }; 70 : } 71 : 72 : #endif