Totally Of Topic (TOT): This is about software digital FM demodulation

This is about digital FM demodulation, in this case wideband FM demodulation of IQ (nothing to do with intelligence) signals.

When using the cheap (25$) or so digital receiver USB sticks, and librtlsdr, demodulating various systems is an interesting exercise in digital processing. As I am a bit rusty on that, I wanted to write some code to test things.

Of course looking at the existing open source C code (not much documented) can be a bit of a challenge. Some do it this way, some do it that way, filters everywhere, and most of all different sampling rates everywhere, and frequency offsets (rtl_fm.c) or even more mysteries (linrad).

So, I tried a lot of things, and of course nothing really worked, and then I decided to spend a day just studying the math, had a good night sleep, next day everything all of the sudden worked, but no code changes??? must be faith...

Anyways some C code for Linux:

formatting link

Now what can we do with this?

pipe it to the next program!

play via soundcard: nice -n -19 ./sdr_test --freq 107200000 --gain 20 | play -t raw -r 2000000 -e signed-integer -b 16 -c 1 -

Note how 'play' resamples! 'play' is in fact 'sox'.

Or encode to mp3: nice -n -19 ./sdr_test --freq 107200000 --gain 20 | lame -r -s 2000000 -b 16

-m m --lowpass 17000 -h -v - > test.mp3

This last thing is very interesting, normally sampling at 2M samples /second would create an extremely long audio file. But the 'lame' encoder has some interesting features:

1) it can resample. 2) it has a build in lowpass (here set to 17 kHz, gets rid of any stereo pilot and data). 3) it has a high quality mode (-h flag). So using lame we do not have to: lowpass, resample!

To do live test I tested like this: nice -n -19 ./sdr_test --freq 107200000 --gain 20 | lame -r -s 2000000 -b 16 -m m --lowpass 17000 -h -v - | mpg123 -v 10 -

I use nice -n 19 to make sure we get full system resources (everything else can wait) Then encode to mp3 with 'lame', and then leave out the intermediate mp3 file, but directly pipe to the 'mpg123' mp3 decoder that plays via the sound card. so you hear what you do wrong in real time ;-)

Of course you need to use frequency and gain for your situation (FM station, signal strength).

Those routines will go into the xpsa spectrum analyser, also for other modulation types, so I do not have to use rtl_fm (that comes with librtlsdr), as that one uses a frequency offset. Why the frequency offset? I don't, no problem here doing it this way.

Reply to
Jan Panteltje
Loading thread data ...

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.