Emphasis: Add filter to prevent emphasis above 4000 Hz

Remove obsolete filter from fsk.c.
This commit is contained in:
Andreas Eversberg 2017-08-19 12:33:45 +02:00
parent 743d147d16
commit d2472cfca6
4 changed files with 8 additions and 6 deletions

View File

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

View File

@ -1,5 +1,6 @@
typedef struct emphasis {
struct {
iir_filter_t lp;
double x_last;
double factor;
double amp;

View File

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

View File

@ -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 */