Line data Source code
1 : /** 2 : * \file OffsetVolumeFilter.h 3 : */ 4 : 5 : #ifndef ATK_TOOLS_OFFSETVOLUMEFILTER_H 6 : #define ATK_TOOLS_OFFSETVOLUMEFILTER_H 7 : 8 : #include <ATK/Core/TypedBaseFilter.h> 9 : #include <ATK/Tools/config.h> 10 : 11 : namespace ATK 12 : { 13 : /// Scales a signal 14 : template<typename DataType_> 15 : class ATK_TOOLS_EXPORT OffsetVolumeFilter 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 : 26 : public: 27 : /*! 28 : * @brief Constructor 29 : * @param nb_channels is the number of input and output channels 30 : */ 31 : explicit OffsetVolumeFilter(gsl::index nb_channels = 1); 32 : /// Destructor 33 8 : ~OffsetVolumeFilter() override = default; 34 : 35 : /// Sets the output volume, doesn't update the cache 36 : void set_volume(DataType_ volume); 37 : /// Gets the output volume 38 : DataType_ get_volume() const; 39 : 40 : /// Sets the offset of the generated signal, doesn't update the cache 41 : void set_offset(DataType_ offset); 42 : /// Gets the offset 43 : DataType_ get_offset() const; 44 : 45 : protected: 46 : void process_impl(gsl::index size) const final; 47 : 48 : private: 49 : DataType_ volume{1}; 50 : DataType_ offset{0}; 51 : }; 52 : } 53 : 54 : #endif