diff options
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); |