LCOV - code coverage report
Current view: top level - Dynamic - GainSwellFilter.cpp (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 16 16 100.0 %
Date: 2021-02-18 20:07:22 Functions: 4 4 100.0 %

          Line data    Source code
       1             : /**
       2             :  * \file GainSwellFilter.cpp
       3             :  */
       4             : 
       5             : #include "GainSwellFilter.h"
       6             : #include <ATK/Core/Utilities.h>
       7             : #include <ATK/Utility/fmath.h>
       8             : 
       9             : #include <cmath>
      10             : #include <cstdint>
      11             : 
      12             : namespace ATK
      13             : {
      14             :   template<typename DataType_>
      15           6 :   GainSwellFilter<DataType_>::GainSwellFilter(gsl::index nb_channels, size_t LUTsize, size_t LUTprecision)
      16           6 :   :Parent(nb_channels, LUTsize, LUTprecision)
      17             :   {
      18           6 :   }
      19             :   
      20             :   template<typename DataType_>
      21           4 :   void GainSwellFilter<DataType_>::set_softness(DataType_ softness)
      22             :   {
      23           4 :     if (softness < 0)
      24             :     {
      25           1 :       throw ATK::RuntimeError("Softness factor must be positive value");
      26             :     }
      27           3 :     this->softness = softness;
      28           3 :     start_recomputeLUT();
      29           3 :   }
      30             :   
      31             :   template<typename DataType_>
      32           1 :   DataType_ GainSwellFilter<DataType_>::get_softness() const
      33             :   {
      34           1 :     return softness;
      35             :   }
      36             : 
      37             :   template<typename DataType_>
      38      786715 :   DataType_ GainSwellFilter<DataType_>::computeGain( DataType_ value ) const
      39             :   {
      40      786715 :     if(value == 0)
      41             :     {
      42          72 :       return 1;
      43             :     }
      44      786643 :     DataType diff = 10 * fmath::log10(value);
      45      786646 :     return static_cast<DataType>(fmath::pow(10, -(std::sqrt(diff*diff + softness) + diff) / 40 * ratio));
      46             :   }
      47             : 
      48             : #if ATK_ENABLE_INSTANTIATION
      49             :   template class GainSwellFilter<float>;
      50             :   template class GainFilter<GainSwellFilter<float>>;
      51             : #endif
      52             :   template class GainSwellFilter<double>;
      53             :   template class GainFilter<GainSwellFilter<double>>;
      54             : }

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