LCOV - code coverage report
Current view: top level - EQ - Chebyshev2Filter.h (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 2 2 100.0 %
Date: 2021-02-18 20:07:22 Functions: 0 0 -

          Line data    Source code
       1             : /**
       2             :  * \file Chebyshev2Filter.h
       3             :  */
       4             : 
       5             : #ifndef ATK_EQ_CHEbyshev2FILTER_H
       6             : #define ATK_EQ_CHEbyshev2FILTER_H
       7             : 
       8             : #include <ATK/Core/TypedBaseFilter.h>
       9             : #include <ATK/EQ/EQInterface.h>
      10             : 
      11             : namespace ATK
      12             : {
      13             :   /// @brief Chebyshev 2 coeffs for a low pass filter
      14             :   template<typename DataType_>
      15             :   class Chebyshev2LowPassCoefficients: public TypedBaseFilter<DataType_>, public OrderInterface, public SingleCutFrequencyInterface<typename TypeTraits<DataType_>::Scalar>, public RippleInterface<typename TypeTraits<DataType_>::Scalar>
      16             :   {
      17             :   public:
      18             :     /// Simplify parent calls
      19             :     using Parent = TypedBaseFilter<DataType_>;
      20             :     using typename Parent::AlignedScalarVector;
      21             :     using typename Parent::DataType;
      22             :     using CoeffDataType = typename TypeTraits<DataType>::Scalar;
      23             :     using Parent::input_sampling_rate;
      24             :   protected:
      25             :     /// Cut-off of the filter
      26             :     CoeffDataType cut_frequency{0};
      27             :     /// Ripple of the filter
      28             :     CoeffDataType ripple{0};
      29             :     
      30             :     /// Order of the filter
      31             :     unsigned int in_order{1};
      32             :     /// Order of the filter
      33             :     unsigned int out_order{1};
      34             :     
      35             :     void setup() override;
      36             :     
      37             :     /// Coefficients of the MA part of the IIR filter
      38             :     AlignedScalarVector coefficients_in;
      39             :     /// Coefficients of the AR part of the IIR filter
      40             :     AlignedScalarVector coefficients_out;
      41             :     
      42             :   public:
      43             :     /*!
      44             :      * @brief Constructor
      45             :      * @param nb_channels is the number of input and output channels
      46             :      */
      47             :     explicit Chebyshev2LowPassCoefficients(gsl::index nb_channels = 1);
      48             :     
      49             :     /// Sets the cut or central frequency of the filter
      50             :     void set_cut_frequency(CoeffDataType cut_frequency) final;
      51             :     /// Returns the cut or central frequency
      52             :     CoeffDataType get_cut_frequency() const final;
      53             :     /// Sets the ripple
      54             :     void set_ripple(CoeffDataType ripple) final;
      55             :     /// Gets the ripple
      56             :     CoeffDataType get_ripple() const final;
      57             :     /// Sets the order of the IIR filter
      58             :     void set_order(unsigned int order) final;
      59             :     /// Gets the order of the filter
      60             :     unsigned get_order() const final;
      61             :   };
      62             :   
      63             :   /// @brief Chebyshev 2 coeffs for a high pass filter
      64             :   template<typename DataType_>
      65             :   class Chebyshev2HighPassCoefficients: public TypedBaseFilter<DataType_>, public OrderInterface, public SingleCutFrequencyInterface<typename TypeTraits<DataType_>::Scalar>, public RippleInterface<typename TypeTraits<DataType_>::Scalar>
      66             :   {
      67             :   public:
      68             :     /// Simplify parent calls
      69             :     using Parent = TypedBaseFilter<DataType_>;
      70             :     using typename Parent::AlignedScalarVector;
      71             :     using typename Parent::DataType;
      72             :     using CoeffDataType = typename TypeTraits<DataType>::Scalar;
      73             :     using Parent::input_sampling_rate;
      74             :   protected:
      75             :     /// Cut-off of the filter
      76             :     CoeffDataType cut_frequency{0};
      77             :     /// Ripple of the filter
      78             :     CoeffDataType ripple{0};
      79             :     
      80             :     /// Order of the filter
      81             :     unsigned int in_order{1};
      82             :     /// Order of the filter
      83             :     unsigned int out_order{1};
      84             :     
      85             :     void setup() override;
      86             :     
      87             :     /// Coefficients of the MA part of the IIR filter
      88             :     AlignedScalarVector coefficients_in;
      89             :     /// Coefficients of the AR part of the IIR filter
      90             :     AlignedScalarVector coefficients_out;
      91             :     
      92             :   public:
      93             :     /*!
      94             :      * @brief Constructor
      95             :      * @param nb_channels is the number of input and output channels
      96             :      */
      97             :     explicit Chebyshev2HighPassCoefficients(gsl::index nb_channels = 1);
      98             :     
      99             :     /// Sets the cut or central frequency of the filter
     100             :     void set_cut_frequency(CoeffDataType cut_frequency) final;
     101             :     /// Returns the cut or central frequency
     102             :     CoeffDataType get_cut_frequency() const final;
     103             :     /// Sets the ripple
     104             :     void set_ripple(CoeffDataType ripple) final;
     105             :     /// Gets the ripple
     106             :     CoeffDataType get_ripple() const final;
     107             :     /// Sets the order of the IIR filter
     108             :     void set_order(unsigned int order) final;
     109             :     /// Gets the order of the filter
     110             :     unsigned get_order() const final;
     111             :   };
     112             :   
     113             :   /// @brief Chebyshev 2 coeffs for a band pass filter
     114             :   template<typename DataType_>
     115             :   class Chebyshev2BandPassCoefficients: public TypedBaseFilter<DataType_>, public OrderInterface, public RippleInterface<typename TypeTraits<DataType_>::Scalar>, public DualCutFrequencyInterface<typename TypeTraits<DataType_>::Scalar>
     116             :   {
     117             :   public:
     118             :     /// Simplify parent calls
     119             :     using Parent = TypedBaseFilter<DataType_>;
     120             :     using typename Parent::AlignedScalarVector;
     121             :     using typename Parent::DataType;
     122             :     using CoeffDataType = typename TypeTraits<DataType>::Scalar;
     123             :     using Parent::input_sampling_rate;
     124             :   protected:
     125             :     /// Bandwidth of the filter
     126          10 :     std::pair<CoeffDataType, CoeffDataType> cut_frequencies = {0, 0};
     127             :     /// Ripple of the filter
     128             :     CoeffDataType ripple{0};
     129             :     
     130             :     /// Order of the filter
     131             :     unsigned int in_order{1};
     132             :     /// Order of the filter
     133             :     unsigned int out_order{1};
     134             :     
     135             :     void setup() override;
     136             :     
     137             :     /// Coefficients of the MA part of the IIR filter
     138             :     AlignedScalarVector coefficients_in;
     139             :     /// Coefficients of the AR part of the IIR filter
     140             :     AlignedScalarVector coefficients_out;
     141             :     
     142             :   public:
     143             :     /*!
     144             :      * @brief Constructor
     145             :      * @param nb_channels is the number of input and output channels
     146             :      */
     147             :     explicit Chebyshev2BandPassCoefficients(gsl::index nb_channels = 1);
     148             :     
     149             :     /// Sets the bandwidth as a bandwidth
     150             :     void set_cut_frequencies(std::pair<CoeffDataType, CoeffDataType> cut_frequencies) final;
     151             :     /// Sets the bandwidth as two separate values
     152             :     void set_cut_frequencies(CoeffDataType f0, CoeffDataType f1) final;
     153             :     /// Gets the bandwidth
     154             :     std::pair<CoeffDataType, CoeffDataType> get_cut_frequencies() const final;
     155             :     /// Sets the ripple
     156             :     void set_ripple(CoeffDataType ripple) final;
     157             :     /// Gets the ripple
     158             :     CoeffDataType get_ripple() const final;
     159             :     /// Sets the order of the IIR filter
     160             :     void set_order(unsigned int order) final;
     161             :     /// Gets the order of the filter
     162             :     unsigned get_order() const final;
     163             :   };
     164             :   
     165             :   /// @brief Chebyshev 2 coeffs for a band stop filter
     166             :   template<typename DataType_>
     167             :   class Chebyshev2BandStopCoefficients: public TypedBaseFilter<DataType_>, public OrderInterface, public RippleInterface<typename TypeTraits<DataType_>::Scalar>, public DualCutFrequencyInterface<typename TypeTraits<DataType_>::Scalar>
     168             :   {
     169             :   public:
     170             :     /// Simplify parent calls
     171             :     using Parent = TypedBaseFilter<DataType_>;
     172             :     using typename Parent::AlignedScalarVector;
     173             :     using typename Parent::DataType;
     174             :     using CoeffDataType = typename TypeTraits<DataType>::Scalar;
     175             :     using Parent::input_sampling_rate;
     176             :   protected:
     177             :     /// Bandwidth of the filter
     178          10 :     std::pair<CoeffDataType, CoeffDataType> cut_frequencies = {0, 0};
     179             :     /// Ripple of the filter
     180             :     CoeffDataType ripple{0};
     181             :     
     182             :     /// Order of the filter
     183             :     unsigned int in_order{1};
     184             :     /// Order of the filter
     185             :     unsigned int out_order{1};
     186             :     
     187             :     void setup() override;
     188             :     
     189             :     /// Coefficients of the MA part of the IIR filter
     190             :     AlignedScalarVector coefficients_in;
     191             :     /// Coefficients of the AR part of the IIR filter
     192             :     AlignedScalarVector coefficients_out;
     193             :     
     194             :   public:
     195             :     /*!
     196             :      * @brief Constructor
     197             :      * @param nb_channels is the number of input and output channels
     198             :      */
     199             :     explicit Chebyshev2BandStopCoefficients(gsl::index nb_channels = 1);
     200             :     
     201             :     /// Sets the bandwidth as a bandwidth
     202             :     void set_cut_frequencies(std::pair<CoeffDataType, CoeffDataType> cut_frequencies) final;
     203             :     /// Sets the bandwidth as two separate values
     204             :     void set_cut_frequencies(CoeffDataType f0, CoeffDataType f1) final;
     205             :     /// Gets the bandwidth
     206             :     std::pair<CoeffDataType, CoeffDataType> get_cut_frequencies() const final;
     207             :     /// Sets the ripple
     208             :     void set_ripple(CoeffDataType ripple) final;
     209             :     /// Gets the ripple
     210             :     CoeffDataType get_ripple() const final;
     211             :     /// Sets the order of the IIR filter
     212             :     void set_order(unsigned int order) final;
     213             :     /// Gets the order of the filter
     214             :     unsigned get_order() const final;
     215             :   };
     216             : }
     217             : 
     218             : #endif

Generated by: LCOV version TK-3.3.0-4-gdba42eea