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

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