From b3fd53b1652b1800a0acd14157a6a93c770cd684 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Fri, 27 Jan 2017 17:17:39 +0100 Subject: Test filter uses a dB graph to show the response graphically --- src/common/debug.c | 21 +++++++++++++++++++++ src/common/debug.h | 1 + 2 files changed, 22 insertions(+) (limited to 'src/common') diff --git a/src/common/debug.c b/src/common/debug.c index e4677e7..fe4de48 100644 --- a/src/common/debug.c +++ b/src/common/debug.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "sample.h" #include "debug.h" #include "display.h" @@ -118,6 +119,26 @@ const char *debug_amplitude(double level) return text; } +#define level2db(level) (20 * log10(level)) + +const char *debug_db(double level_db) +{ + static char text[128]; + int l; + + strcpy(text, ": . : . : . : . : . : . : . : . : "); + if (level_db <= 0.0) + return text; + l = (int)round(level2db(level_db)); + if (l > 3) + return text; + if (l < -48) + return text; + text[l + 48] = '*'; + + return text; +} + void debug_list_cat(void) { int i; diff --git a/src/common/debug.h b/src/common/debug.h index 989ee9f..b5b3e2e 100644 --- a/src/common/debug.h +++ b/src/common/debug.h @@ -27,6 +27,7 @@ void _printdebug(const char *file, const char *function, int line, int cat, int level, int chan, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 7, 8))); const char *debug_amplitude(double level); +const char *debug_db(double level_db); void debug_list_cat(void); int parse_debug_opt(const char *opt); -- cgit v1.2.3