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

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