cwDsp.h: Initial implementation of ampl_to_db() and db_to_ampl()

This commit is contained in:
kevin 2023-01-08 14:17:15 -05:00
parent 451a7d246e
commit 9a1e306791

View File

@ -16,6 +16,15 @@ namespace cw
typedef std::complex<double> complex_d_t;
typedef std::complex<float> complex_f_t;
template< typename T >
T ampl_to_db( T ampl, T ref=1.0, T minDb=-200.0 )
{ return ampl<1e-10 ? minDb : 20.0 * log10(ampl/ref); }
template< typename T >
T db_to_ampl( T db )
{ return pow(10.0,db/20.0); }
//---------------------------------------------------------------------------------------------------------------------------------
// Window functions
//