Skip to content
Oona Räisänen edited this page Oct 6, 2019 · 22 revisions

Live decoding from RTL-SDR

The full command to decode RDS live via rtl_fm, on an FM station at 87.9 MHz, is:

rtl_fm -M fm -l 0 -A std -p 0 -s 171k -g 20 -F 9 -f 87.9M | redsea

For Raspberry Pi 1 it's necessary to change -A std to -A fast. This way more CPU cycles will be left to redsea.

Note that rtl_fm will tune the receiver a bit off-center; this is normal and is done to avoid the DC spike. See the rtl_fm FAQ for more about this behavior.

Live decoding with AirSpy or HackRF

csdr can be used to demodulate streams from other radios on the command line, like AirSpy:

airspy_rx -f 87.9 -a 2500000 -g 9 -r /dev/stdout |\
  csdr convert_i16_f | csdr fir_decimate_cc 10 0.05 HAMMING |\
  csdr fmdemod_quadri_cf | csdr convert_f_i16 |\
  redsea -r 250k

Or HackRF:

hackrf_transfer -f 87900000 -s 10000000 |\
  csdr convert_i16_f | csdr fir_decimate_cc 40 0.0125 HAMMING |\
  csdr fmdemod_quadri_cf | csdr convert_f_i16 |\
  redsea -r 250k

Decoding MPX from a file or via sound card

It's easy to decode audio files containing a demodulated FM carrier. Note that the file must have around 128k samples per second or more. 171k will work fastest, because it doesn't require resampling internally.

redsea -f multiplex.wav

If your sound card supports recording at high sample rates (192 kHz) you can also decode the MPX output of an FM tuner or RDS encoder, for instance with this sox command:

rec -t .s16 -r 171k -c 1 - | redsea

By default, the raw MPX input is assumed to be 16-bit signed-integer single-channel samples at 171 kHz.

Listening while decoding live

The --feed-through option echoes the input signal back to stdout. This lets you use both the original signal and the decoded RDS via different streams. For example, the signal can be listened to using sox, while RDS groups are printed to stderr:

rtl_fm -M fm -l 0 -A std -p 0 -s 171k -g 20 -F 9 -f 87.9M |\
  redsea --feed-through |\
  play -t .s16 -r 171k -c 1 -

However, this only works with raw MPX input for now.

Writing RDS Spy compatible sample files

This command writes a hex-format outputfile with a timestamp in its file name.

rtl_fm -M fm -l 0 -A std -p 0 -s 171k -g 40 -F 9 $@ | \
  redsea -x | tee `head -12l | tail -1l | \
  cut -d" " -f1`_`date +%F`_`date +%k`-`date +%M`-`date +%S`_$2Hz.spy 
Clone this wiki locally