aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-07-03 17:20:35 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-07-03 17:20:35 +0200
commit4870d0c148eb49ffeb5482ae55d9cc4c9cc89786 (patch)
tree0009fbe559e7e38b1cb30b7095930cfce267a83c /src/utils.cpp
parent777ef8b852aab3e95859b9042ddffb09818b28d2 (diff)
downloadetisnoop-4870d0c148eb49ffeb5482ae55d9cc4c9cc89786.tar.gz
etisnoop-4870d0c148eb49ffeb5482ae55d9cc4c9cc89786.tar.bz2
etisnoop-4870d0c148eb49ffeb5482ae55d9cc4c9cc89786.zip
Measure audio levels, add ensemble database WIP
Diffstat (limited to 'src/utils.cpp')
-rw-r--r--src/utils.cpp8
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;
+}
+