Test filter uses a dB graph to show the response graphically

This commit is contained in:
Andreas Eversberg
2017-01-27 17:17:39 +01:00
parent 7ea3bc188d
commit b3fd53b165
3 changed files with 25 additions and 22 deletions

View File

@@ -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;

View File

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