LCOV - code coverage report
Current view: top level - Dynamic - GainLimiterFilter.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 GainLimiterFilter.cpp
       3             :  */
       4             : 
       5             : #include "GainLimiterFilter.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           5 :   GainLimiterFilter<DataType_>::GainLimiterFilter(gsl::index nb_channels, size_t LUTsize, size_t LUTprecision)
      16           5 :   :Parent(nb_channels, LUTsize, LUTprecision)
      17             :   {
      18           5 :   }
      19             : 
      20             :   template<typename DataType_>
      21           3 :   void GainLimiterFilter<DataType_>::set_softness(DataType_ softness)
      22             :   {
      23           3 :     if (softness <= 0)
      24             :     {
      25           1 :       throw ATK::RuntimeError("Softness factor must be strictly positive value");
      26             :     }
      27           2 :     this->softness = softness;
      28           2 :     start_recomputeLUT();
      29           2 :   }
      30             :   
      31             :   template<typename DataType_>
      32           1 :   DataType_ GainLimiterFilter<DataType_>::get_softness() const
      33             :   {
      34           1 :     return softness;
      35             :   }
      36             : 
      37             :   template<typename DataType_>
      38      655548 :   DataType_ GainLimiterFilter<DataType_>::computeGain( DataType_ value ) const
      39             :   {
      40      655548 :     if(value == 0)
      41             :     {
      42          69 :       return 1;
      43             :     }
      44      655479 :     DataType diff = 10 * fmath::log10(value);
      45      655483 :     return static_cast<DataType>(fmath::pow(10, -(std::sqrt(diff*diff + softness) + diff) / 40));
      46             :   }
      47             : 
      48             : #if ATK_ENABLE_INSTANTIATION
      49             :   template class GainLimiterFilter<float>;
      50             :   template class GainFilter<GainLimiterFilter<float>>;
      51             : #endif
      52             :   template class GainLimiterFilter<double>;
      53             :   template class GainFilter<GainLimiterFilter<double>>;
      54             : }

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