From f294261285e1f12d9527635cde7aad9ab06be6fc Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Wed, 10 Apr 2024 20:44:47 +0200 Subject: [PATCH] Fix filter of demodulator of received radio signal The filter was way too low. (only half of the total bandwidth) The missing (filtered) high frequency component caused noisy signal. Let's see how this fix changes the quality of received FM sound. --- src/libam/am.c | 2 +- src/libfm/fm.c | 2 +- src/libsdr/sdr.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libam/am.c b/src/libam/am.c index 7194b49..e09f7f2 100644 --- a/src/libam/am.c +++ b/src/libam/am.c @@ -127,7 +127,7 @@ void am_modulate_complex(am_mod_t *mod, sample_t *amplitude, uint8_t *power, int mod->phase = phase; } -/* init AM demodulator */ +/* init AM demodulator, the bandwidth is the demodulated bandwidth (bandwidth of one side band) */ int am_demod_init(am_demod_t *demod, double samplerate, double offset, double bandwidth, double gain) { memset(demod, 0, sizeof(*demod)); diff --git a/src/libfm/fm.c b/src/libfm/fm.c index 079491c..cd13ea1 100644 --- a/src/libfm/fm.c +++ b/src/libfm/fm.c @@ -244,7 +244,7 @@ again: mod->ramp = ramp; } -/* init FM demodulator */ +/* init FM demodulator, bandwidth is the 2 * (deviation + modulation) */ int fm_demod_init(fm_demod_t *demod, double samplerate, double offset, double bandwidth) { if (!has_init) { diff --git a/src/libsdr/sdr.c b/src/libsdr/sdr.c index 537fd9b..e322b5e 100644 --- a/src/libsdr/sdr.c +++ b/src/libsdr/sdr.c @@ -482,9 +482,9 @@ void *sdr_open(int __attribute__((__unused__)) direction, const char __attribute LOGP(DSDR, LOGL_DEBUG, "Frequency #%d: RX offset: %.6f MHz\n", c, rx_offset / 1e6); sdr->chan[c].am = am[c]; if (am[c]) - rc = am_demod_init(&sdr->chan[c].am_demod, samplerate, rx_offset, bandwidth, 1.0 / modulation_index); + rc = am_demod_init(&sdr->chan[c].am_demod, samplerate, rx_offset, bandwidth / 2.0, 1.0 / modulation_index); /* bandwidth is only one side band */ else - rc = fm_demod_init(&sdr->chan[c].fm_demod, samplerate, rx_offset, bandwidth / 2.0); + rc = fm_demod_init(&sdr->chan[c].fm_demod, samplerate, rx_offset, bandwidth); /* bandwidth are deviation and both side bands */ if (rc < 0) goto error; }