ha7ilm / csdr

A simple DSP library and command-line tool for Software Defined Radio.
508 stars 169 forks source link

Poor WFM decoding performance with homepage example #35

Open felixzero opened 6 years ago

felixzero commented 6 years ago

Hello, I am playing around with SDR with my newly bought RTL-SDR and I tried some of the examples given on the homepage (https://github.com/simonyiszk/csdr).

However, I could not manage to make any good quality demodulation of a standard WFM commercial broadcast using csdr. I applied the "Demodulate WFM: Advanced" command line almost as-it: rtl_sdr -s 2400000 -f 97700000 -g 20 - | ./csdr convert_u8_f | ./csdr shift_addition_cc -0.085 | ./csdr fir_decimate_cc 10 0.05 HAMMING | ./csdr fmdemod_quadri_cf | ./csdr fractional_decimator_ff 5 | ./csdr deemphasis_wfm_ff 48000 50e-6 | ./csdr convert_f_s16 > csdr_decode.raw

but all I could get was a very noisy decoded sound. Here is a short audio clip after converting the raw to wav: Link to WAV file

This is surprising since I can get a much better output in GNU Radio using the very same sequence as csdr: untitled2 grc

And then, on the same channel, only a few seconds apart, the output is really good: Link to WAV file

Am I missing something? Are these two doing something different?

-- felixzero

ha7ilm commented 6 years ago

Thanks for the feedback.
Possibly the transition BW for the fir_decimate_cc is low. 0.05*2400000 = 120 kHz
What if you change it to ./csdr fir_decimate_cc 10 0.005 HAMMING (12 kHz)?

(The bandwidth of the signal fed to the FM demodulator is also quite high, 240 kHz in this configuration. This could possibly be decreased to 96 kHz by playing around with the decimation rates, although on the other side that might be too low:

rtl_sdr -s 2400000 -f 97700000 -g 20 - | ./csdr convert_u8_f | ./csdr shift_addition_cc -0.085 | ./csdr fir_decimate_cc 25 0.005 HAMMING | ./csdr fmdemod_quadri_cf | ./csdr fractional_decimator_ff 2 | ./csdr deemphasis_wfm_ff 48000 50e-6 | ./csdr convert_f_s16 > csdr_decode.raw

Possibly you have distorted sound because there are multiple channels next to each other at your receiver. At my place, WFM channels are quite strong and are quite far away from each other, so it's not a problem that this simple receiver does not provide much selectivity with the original command.

felixzero commented 6 years ago

Thanks for your answer,

I just tried the command you propose. I don't upload the audio clip, but it is very similar to the previous one (i.e. as noisy and distorted).

I don't think this is an issue with nearby channels, as I didn't plug a good antenna on my RTL-SDR (just a piece of random wire) and it is picking up only a few stations and noise sources. As seen on GQRX: capture du 2018-05-08 22-09-29

Plus, the GNU Radio script/sketch seems to work so I guess it is probably a filtering/demodulation issue.

ha7ilm commented 6 years ago

Thanks for trying the new command.
Unfortunately, I can't find out anything else without trying myself.
Maybe there's someting with the fractional_decimator_ff which I had to fix about a year ago. You could possibly try the old_fractional_decimator_ff which is actually worse in some scenarios, but I used that algorithm originally when I tried the WFM demod last time.

felixzero commented 6 years ago

Yes! This is it. I simply changed the fractional_decimator_ff to old_fractional_decimator_ff and it works really well: Link to WAV.

I guess I will stick to the old function. Thanks.

ha7ilm commented 6 years ago

Thanks for finding that. Maybe the default parameters for the fractional_decimator_ff are not good enough.

ha7ilm commented 6 years ago

What about csdr fractional_decimator_ff 5 16 --prefilter? Could you test that, too?

felixzero commented 6 years ago

It is also working well: WAV file

ha7ilm commented 6 years ago

OK, thanks!

TunaLobster commented 1 year ago

I can confirm that old_fractional_decimator_ff 5 is better in some cases. I was getting very similar results with fractional_decimator_ff 5 with and without 16 --prefilter. Thanks for keeping that code included!