From 3536cfb816e4da59347a3cd0191c96bb50ef4f91 Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 17 Aug 2017 17:17:25 +0200 Subject: [PATCH] CalcDB: use direct value for floor in value to dB conversion --- sdrbase/util/db.cpp | 12 +++++++----- sdrbase/util/db.h | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/sdrbase/util/db.cpp b/sdrbase/util/db.cpp index 55c76542d..f76b1b5c7 100644 --- a/sdrbase/util/db.cpp +++ b/sdrbase/util/db.cpp @@ -16,17 +16,19 @@ #include "util/db.h" #include +#include -double CalcDb::dbPower(double magsq, double floordB) +double CalcDb::dbPower(double magsq, double floor) { - if (magsq > 0) + assert(floor > 0.0); + + if (magsq > floor) { - double val = 10.0 * log10(magsq); - return val > floordB ? val : floordB; + return 10.0 * log10(magsq); } else { - return floordB; + return 10.0 * log10(floor); } } diff --git a/sdrbase/util/db.h b/sdrbase/util/db.h index 05fc7a297..de86e81bb 100644 --- a/sdrbase/util/db.h +++ b/sdrbase/util/db.h @@ -22,7 +22,7 @@ class CalcDb { public: - static double dbPower(double magsq, double floordB = -100.0); + static double dbPower(double magsq, double floor = 1e-10); static double powerFromdB(double powerdB); };