diff options
author | Andreas Eversberg <jolly@eversberg.eu> | 2017-01-27 17:17:39 +0100 |
---|---|---|
committer | Andreas Eversberg <jolly@eversberg.eu> | 2017-02-18 21:01:10 +0100 |
commit | b3fd53b1652b1800a0acd14157a6a93c770cd684 (patch) | |
tree | 1ea6a23c0c4c966c54131147fc7516ee2af43b5c /src/common | |
parent | 7ea3bc188df54a4dbe3026bc30ed39a5cded8fdb (diff) |
Test filter uses a dB graph to show the response graphically
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/debug.c | 21 | ||||
-rw-r--r-- | src/common/debug.h | 1 |
2 files changed, 22 insertions, 0 deletions
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 <stdlib.h> #include <stdint.h> #include <errno.h> +#include <math.h> #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); |