aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2017-01-27 17:17:39 +0100
committerAndreas Eversberg <jolly@eversberg.eu>2017-02-18 21:01:10 +0100
commitb3fd53b1652b1800a0acd14157a6a93c770cd684 (patch)
tree1ea6a23c0c4c966c54131147fc7516ee2af43b5c /src/test
parent7ea3bc188df54a4dbe3026bc30ed39a5cded8fdb (diff)
Test filter uses a dB graph to show the response graphically
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_filter.c25
1 files changed, 3 insertions, 22 deletions
diff --git a/src/test/test_filter.c b/src/test/test_filter.c
index d78578a..0f7c6b9 100644
--- a/src/test/test_filter.c
+++ b/src/test/test_filter.c
@@ -13,31 +13,12 @@
static double get_level(double *samples)
{
-#if 0
- int i;
- double last = 0, envelope = 0;
- int up = 0;
-
- for (i = SAMPLERATE/2; i < SAMPLERATE; i++) {
- if (last < samples[i]) {
- up = 1;
- } else if (last > samples[i]) {
- if (up) {
- if (last > envelope)
- envelope = last;
- }
- up = 0;
- }
- last = samples[i];
- }
-#else
int i;
double envelope = 0;
for (i = SAMPLERATE/2; i < SAMPLERATE; i++) {
if (samples[i] > envelope)
envelope = samples[i];
}
-#endif
return envelope;
}
@@ -72,7 +53,7 @@ int main(void)
gen_samples(samples, (double)i);
filter_process(&filter_low, samples, SAMPLERATE);
level = get_level(samples);
- printf("%4d Hz: %.1f dB", i, level2db(level));
+ printf("%s%4d Hz: %.1f dB", debug_db(level), i, level2db(level));
if (i == 1000)
printf(" cutoff\n");
else if (i == 2000)
@@ -91,7 +72,7 @@ int main(void)
gen_samples(samples, (double)i);
filter_process(&filter_high, samples, SAMPLERATE);
level = get_level(samples);
- printf("%4d Hz: %.1f dB", i, level2db(level));
+ printf("%s%4d Hz: %.1f dB", debug_db(level), i, level2db(level));
if (i == 2000)
printf(" cutoff\n");
else if (i == 1000)
@@ -112,7 +93,7 @@ int main(void)
filter_process(&filter_low, samples, SAMPLERATE);
filter_process(&filter_high, samples, SAMPLERATE);
level = get_level(samples);
- printf("%4d Hz: %.1f dB", i, level2db(level));
+ printf("%s%4d Hz: %.1f dB", debug_db(level), i, level2db(level));
if (i == 1000)
printf(" cutoff high\n");
else if (i == 2000)