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); };