diff options
Diffstat (limited to 'src/StatsServer.cpp')
-rw-r--r-- | src/StatsServer.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/StatsServer.cpp b/src/StatsServer.cpp index ffe8623..c7cbc9d 100644 --- a/src/StatsServer.cpp +++ b/src/StatsServer.cpp @@ -30,6 +30,7 @@ #include <string.h> #include <math.h> #include <stdint.h> +#include <limits> #include <sstream> #include "StatsServer.h" #include "Log.h" @@ -275,9 +276,11 @@ std::string InputStat::encodeJSON() { std::ostringstream ss; + const int16_t int16_max = std::numeric_limits<int16_t>::max(); + /* convert to dB */ - int dB_l = peak_left ? round(20*log10((double)peak_left / INT16_MAX)) : -90; - int dB_r = peak_right ? round(20*log10((double)peak_right / INT16_MAX)) : -90; + int dB_l = peak_left ? round(20*log10((double)peak_left / int16_max)) : -90; + int dB_r = peak_right ? round(20*log10((double)peak_right / int16_max)) : -90; ss << "{ \"inputstat\" : {" |