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; diff --git a/src/common/emphasis.h b/src/common/emphasis.h index 235e3ce..0e91509 100644 --- a/src/common/emphasis.h +++ b/src/common/emphasis.h @@ -1,5 +1,6 @@ typedef struct emphasis { struct { + iir_filter_t lp; double x_last; double factor; double amp; diff --git a/src/common/fsk.c b/src/common/fsk.c index fa0eaf8..fecd3bf 100644 --- a/src/common/fsk.c +++ b/src/common/fsk.c @@ -115,9 +115,6 @@ int fsk_init(fsk_t *fsk, void *inst, int (*send_bit)(void *inst), void (*receive fsk->cycles_per_bit65536[1] = waves * 65536.0; } - /* filter prevents emphasis to overshoot on bit change */ - iir_lowpass_init(&fsk->tx_filter, 4000.0, samplerate, 2); - return 0; error: @@ -278,8 +275,6 @@ next_bit: done: fsk->tx_phase65536 = phase; - iir_process(&fsk->tx_filter, sample, count); - return count; } diff --git a/src/common/fsk.h b/src/common/fsk.h index 1a1009a..723fe66 100644 --- a/src/common/fsk.h +++ b/src/common/fsk.h @@ -5,7 +5,6 @@ typedef struct ffsk { int (*send_bit)(void *inst); void (*receive_bit)(void *inst, int bit, double quality, double level); fm_demod_t demod; - iir_filter_t tx_filter; double bits_per_sample; /* fraction of a bit per sample */ double *sin_tab; /* sine table with correct peak level */ double phaseshift65536[2]; /* how much the phase of fsk synbol changes per sample */