aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/emphasis.c
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2017-08-19 12:33:45 +0200
committerAndreas Eversberg <jolly@eversberg.eu>2017-09-01 18:42:47 +0200
commitd2472cfca6580ba4e59ece0acd229ee9c7012c59 (patch)
tree81a2ea2e9a9a652c8444026a96d3a623c1e07907 /src/common/emphasis.c
parent743d147d1672837595ae1d6aa024522f4a011614 (diff)
Emphasis: Add filter to prevent emphasis above 4000 Hz
Remove obsolete filter from fsk.c.
Diffstat (limited to 'src/common/emphasis.c')
-rw-r--r--src/common/emphasis.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/common/emphasis.c b/src/common/emphasis.c
index 241deee..5a1453e 100644
--- a/src/common/emphasis.c
+++ b/src/common/emphasis.c
@@ -29,6 +29,7 @@
#define PI M_PI
#define CUT_OFF_H 100.0 /* cut-off frequency for high-pass filter */
+#define CUT_OFF_L 4000.0 /* cut-off frequency for low-pass filter */
static void gen_sine(sample_t *samples, int num, int samplerate, double freq)
{
@@ -66,8 +67,12 @@ int init_emphasis(emphasis_t *state, int samplerate, double cut_off)
state->d.factor = factor;
state->d.amp = 1.0;
+ /* do not de-emphasis below CUT_OFF_H */
iir_highpass_init(&state->d.hp, CUT_OFF_H, samplerate, 1);
+ /* do not pre-emphasis above CUT_OFF_L */
+ iir_lowpass_init(&state->p.lp, CUT_OFF_L, samplerate, 1);
+
/* calibrate amplification to be neutral at 1000 Hz */
gen_sine(test_samples, sizeof(test_samples) / sizeof(test_samples[0]), samplerate, 1000.0);
pre_emphasis(state, test_samples, sizeof(test_samples) / sizeof(test_samples[0]));
@@ -84,6 +89,8 @@ void pre_emphasis(emphasis_t *state, sample_t *samples, int num)
double x, y, x_last, factor, amp;
int i;
+ iir_process(&state->p.lp, samples, num);
+
x_last = state->p.x_last;
factor = state->p.factor;
amp = state->p.amp;