diff options
Diffstat (limited to 'src/utils.cpp')
-rw-r--r-- | src/utils.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/utils.cpp b/src/utils.cpp index 3e741c9..d0c1273 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -29,6 +29,8 @@ #include "utils.hpp" #include <cstring> +#include <cmath> +#include <limits> #include <stdarg.h> using namespace std; @@ -229,3 +231,9 @@ std::string pnum_to_str(uint16_t Programme_Number) } } +int absolute_to_dB(int16_t value) +{ + const int16_t int16_max = std::numeric_limits<int16_t>::max(); + return value ? round(20*log10((double)value / int16_max)) : -90; +} + |