Emphasis: Add filter to prevent emphasis above 4000 Hz
Remove obsolete filter from fsk.c.
This commit is contained in:
parent
743d147d16
commit
d2472cfca6
|
@ -29,6 +29,7 @@
|
||||||
#define PI M_PI
|
#define PI M_PI
|
||||||
|
|
||||||
#define CUT_OFF_H 100.0 /* cut-off frequency for high-pass filter */
|
#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)
|
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.factor = factor;
|
||||||
state->d.amp = 1.0;
|
state->d.amp = 1.0;
|
||||||
|
|
||||||
|
/* do not de-emphasis below CUT_OFF_H */
|
||||||
iir_highpass_init(&state->d.hp, CUT_OFF_H, samplerate, 1);
|
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 */
|
/* calibrate amplification to be neutral at 1000 Hz */
|
||||||
gen_sine(test_samples, sizeof(test_samples) / sizeof(test_samples[0]), samplerate, 1000.0);
|
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]));
|
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;
|
double x, y, x_last, factor, amp;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
iir_process(&state->p.lp, samples, num);
|
||||||
|
|
||||||
x_last = state->p.x_last;
|
x_last = state->p.x_last;
|
||||||
factor = state->p.factor;
|
factor = state->p.factor;
|
||||||
amp = state->p.amp;
|
amp = state->p.amp;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
typedef struct emphasis {
|
typedef struct emphasis {
|
||||||
struct {
|
struct {
|
||||||
|
iir_filter_t lp;
|
||||||
double x_last;
|
double x_last;
|
||||||
double factor;
|
double factor;
|
||||||
double amp;
|
double amp;
|
||||||
|
|
|
@ -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;
|
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;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
@ -278,8 +275,6 @@ next_bit:
|
||||||
done:
|
done:
|
||||||
fsk->tx_phase65536 = phase;
|
fsk->tx_phase65536 = phase;
|
||||||
|
|
||||||
iir_process(&fsk->tx_filter, sample, count);
|
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ typedef struct ffsk {
|
||||||
int (*send_bit)(void *inst);
|
int (*send_bit)(void *inst);
|
||||||
void (*receive_bit)(void *inst, int bit, double quality, double level);
|
void (*receive_bit)(void *inst, int bit, double quality, double level);
|
||||||
fm_demod_t demod;
|
fm_demod_t demod;
|
||||||
iir_filter_t tx_filter;
|
|
||||||
double bits_per_sample; /* fraction of a bit per sample */
|
double bits_per_sample; /* fraction of a bit per sample */
|
||||||
double *sin_tab; /* sine table with correct peak level */
|
double *sin_tab; /* sine table with correct peak level */
|
||||||
double phaseshift65536[2]; /* how much the phase of fsk synbol changes per sample */
|
double phaseshift65536[2]; /* how much the phase of fsk synbol changes per sample */
|
||||||
|
|
Loading…
Reference in New Issue