Line data Source code
1 : /** 2 : * \file SinusGeneratorFilter.h 3 : */ 4 : 5 : #ifndef ATK_TOOLS_SINUSGENERATORFILTER_H 6 : #define ATK_TOOLS_SINUSGENERATORFILTER_H 7 : 8 : #include <ATK/Core/TypedBaseFilter.h> 9 : #include <ATK/Tools/config.h> 10 : 11 : #include <vector> 12 : 13 : namespace ATK 14 : { 15 : /// A sin/cos generator 16 : template<typename DataType_> 17 : class ATK_TOOLS_EXPORT SinusGeneratorFilter final : public TypedBaseFilter<DataType_> 18 : { 19 : protected: 20 : /// Simplify parent calls 21 : using Parent = TypedBaseFilter<DataType_>; 22 : using typename Parent::DataType; 23 : using Parent::outputs; 24 : using Parent::output_sampling_rate; 25 : 26 : public: 27 : /// Constructor 28 : SinusGeneratorFilter(); 29 : /// Destructor 30 5 : ~SinusGeneratorFilter() override = default; 31 : 32 : /// Sets the frequency of the oscillator, without resetting it 33 : void set_frequency(DataType_ frequency); 34 : /// Gets the frequency of the oscillator 35 : DataType_ get_frequency() const; 36 : 37 : /// Sets the output volume, doesn't update the cache 38 : void set_volume(DataType_ volume); 39 : /// Gets the output volume 40 : DataType_ get_volume() const; 41 : 42 : /// Sets the offset of the generated signal, doesn't update the cache 43 : void set_offset(DataType_ offset); 44 : /// Gets the offset 45 : DataType_ get_offset() const; 46 : 47 : void full_setup() final; 48 : 49 : protected: 50 : void process_impl(gsl::index size) const final; 51 : 52 : private: 53 : DataType_ volume{1}; 54 : DataType_ offset{0}; 55 : DataType_ frequency{0}; 56 : DataType_ frequ_cos{1}; 57 : DataType_ frequ_sin{0}; 58 : 59 : mutable DataType_ cos{1}; 60 : mutable DataType_ sin{0}; 61 : }; 62 : } 63 : 64 : #endif