Live FM Radio over the network with RTL-SDR!

Lossless Audio Stream with headless configuration.

Luigi Freitas
3 min readJan 13, 2017

There are many ways to listen to an SDR audio output. In this tutorial I will show how to listen any frequency wirelessly using just the command line. Just audio without annoying distractions.

There are two ways to do that. The first one is streaming the audio output straight to the other computer using just command-line software. On the second one, we’ll stream the audio over HTTP using lossless FLAC with OGG. Therefore, it will work with almost every device, including on the iPhone with the VLC App.

The whole process from capture the audio to transmit to another device require quite some processing power from the host computer. The C.H.I.P. 1GHz CPU handled the load like a charm, so probably any Raspberry Pi above the 2nd Gen should handle the load smoothly.

Installation

RTL_FM (Common)

Will capture the signal from the SDR and demodulate it.

// Linux 
sudo apt-get install rtl-sdr
// macOS
brew install rtl-sdr

SoX (Common)

Swiss Army audio converter to make the audio suitable.

// Linux 
sudo apt-get install sox
// macOS
brew install sox

Play (Only Method #1)

Receives the audio and plays it.

// Linux
Bundled `splay`.
// macOS
Bundled `play`.

Netcat (Only Method #1)

Receive the audio via piping and make the streaming.

// Linux 
sudo apt-get install netcat
// macOS
brew install netcat

VLC (Only Method #2)

Handles the entire encoding and streaming over the network seamlessly.

// Linux 
sudo apt-get install vlc browser-plugin-vlc

Capturing the Audio

These two methods have one thing in common, capturing the signal from the SDR and demodulate it. For this task we’ll use the rtl_fm with the command bellow. You’ll just need to set the frequency of the radio station you want to listen. The other options are for bitrate and noise filters used to improve the overall audio quality. Keep the bitrate of the rtl_fm equal to the play.

// Audio Demo (Local Playback)
rtl_fm -g 50 -f 96.9M -M wfm -s 180k -E deemp |
play -r 180k -t raw -e s -b 16 -c 1 -V1 - lowpass 16k

Terminal to Terminal

This is the most simple and fast process of this tutorial, but only computers with command-line can listen. Here we will capture the audio with the rtl_fm and pipe the data straight into the Sox to convert the audio to the Netcat make the network streaming.

// Server Side
rtl_fm -g 50 -f 96.9M -M wfm -s 180k -E deemp |
sox -traw -r24k -es -b16 -c1 -V1 - -tmp3 - |
socat -u -
TCP-LISTEN:8080

On the client side we will need to setup the Netcat to listen the IP Address of the server and pipe to Sox to make the conversion and playback of the audio.

// Client Side
netcat _HOST_IP_HERE_ 8080 | play -t mp3 -

Terminal to HTTP

This HTTP streaming is the same of others services, like on-line radio stream, so almost any device is capable of playing it. As the other method, we’ll capture the audio using the rtl_fm and pipe the data into the SoX to encode it in FLAC and then pipe again to the VLC, which will make HTTP network OGG streaming.

// Server Side
rtl_fm -g50 -f 96.9M -M wfm -s 180k -E deemp |
sox -traw -r180k -es -b16 -c1 -V1 - -t flac - |
cvlc - --sout ‘#standard{access=http,mux=ogg,dst=localhost:8080/audio.ogg}’

On the client, you’ll just need to add your host IP address into a compatible OGG receiver, like VLC (Desktop, iOS, Android).

--

--

Luigi Freitas

Computer Engineering Student. Experienced in Rockets, Satcom, Satellites, Machine Learning, Websites, Apps and Design. https://luigifreitas.me