==== RTL-SDR.com Receiver on a Raspberry Pi ====
A long time ago, I bought this [[https://a.co/d/0dBWxzDy|RTL-SDR.com]] receiver and played with it for a while, put it in a box and forgot about it while we were moving.
A little while ago, Marla and I were listening to Casey Kasem's American Top 40 re-runs on WGRR((Sunday's on WGRR is Casey Kasem’s American Top 40. American Top 40 The 70’s airs 7am-10am Sunday mornings on WGRR, the 80’s every Sunday from 8pm to midnight on 103.5 WGRR. These are the original shows that aired back in the day, not re-creations.)) and we missed most of the broadcast. I thought about getting some sort of tuner card, then remembered I already had one, and a 'Pi that wasn't doing much.
I Googled whether the SDR could receive and decode stereo, it turns out it can, and AI gave me some good pointers on software to do the job. It took a few steps, but, on the 'Pi;
sudo apt update
sudo apt upgrade -y
sudo apt autoremove -y
sudo apt install -y git cmake build-essential libusb-1.0-0-dev rtl-sdr librtlsdr* libev-dev
git clone https://github.com/AlbrechtL/rtl_fm_streamer.git
cd rtl_fm_streamer/
mkdir build && cd build
cmake ..
make
mkdir ~/bin && cd ~/bin
ln -s ../rtl_fm_streamer/build/src/rtl_fm_streamer
cd /etc/modprobe.d/
echo "blacklist dvb_usb_rtl28xxu" | sudo tee /etc/modprobe.d/blacklist-rtl.conf
sudo tee /etc/systemd/system/rtl_fm_streamer.service > /dev/null << 'EOF'
[Unit]
Description=RTL FM Streamer Service
After=network.target
[Service]
Type=simple
User=pi
ExecStart=/home/pi/bin/rtl_fm_streamer
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable rtl_fm_streamer.service
sudo reboot
Now, on another machine on the same network, start up VLC((The Video LAN Client [[https://www.videolan.org/]])), open a network stream (Ctrl-N) and put in the URL 'http://10.100.10.100:2346/103500000/1'. When you press Enter, VLC should start playing, you now have a local network stream that can tune in anything you can get in the car.
The URL is the IP address of the 'Pi, :2346 is the port, /103500000 is the frequency in hertz, and the /1 on the end is for stereo decoding, /0 would be mono. Other options;
pi@subtlepi:~ $ bin/rtl_fm_streamer -h
RTL SDR FM Streamer Version 0.0.7
rtl_fm_streamer, a streaming FM demodulator for RTL2832 based DVB-T receivers
Use: rtl_fm_streamer [-options]
[-d device_index (default: 0)]
[-f frequency_to_tune_to (Hz)]
[-g tuner_gain (default: automatic)]
[-h print this help]
[-j JSON-RPC server listen port (default: 2345)]
[-l squelch_level (default: 0/off)]
[-o oversample (is very buggy, default: 1)]
[-p ppm_error (default: 0)]
[-s sample_rate (default: 240k)]
[-u volume (1 to 50, default: 40)]
[-v print version]
[-E enable_option (default: none)]
use multiple -E to enable multiple options
edge: enable lower edge tuning
deemp50: enable 50us EU de-emphasis filter
deemp75: enable 75us NA de-emphasis filter
direct: enable direct sampling
offset: enable offset tuning
[-P HTTP server listen port (default: 2346)]
[-X Start with FM stereo 50us EU de-emphasis support]
[-Y Start with FM mono 50us EU de-emphasis support]
Experimental options:
[-r resample_rate (default: 48000)]
[-t squelch_delay (default: 10)]
+values will mute/scan, -values will exit
[-F fir_size (default: off)]
enables low-leakage downsample filter
size can be 0 or 9. 0 has bad roll off
Part two of this is a cron job that runs on another machine (this web server) starts the stream and transcodes the audio to an mp3 file on an NFS share that can be attached to by anything on the network.
When you install VLC on a Linux machine, you also get cvlc, the console version of the software, this script;
#!/usr/bin/env bash
cd /Share/Media/Radio/FM/WGRR/Casey_Kasem\'s_American_Top_40
Stream="http://10.100.10.100:2346/103500000/1"
timeout 10865 /usr/bin/cvlc "${Stream}" --sout="#transcode{vcodec=none,acodec=mp3,ab=128,channels=2}:standard{access=file,mux=raw,dst=$(date +\%Y-\%m-\%d_\%H:\%M)_70s.mp3}" vlc://quit &> /dev/null
Does all the rest of what I needed. It's started by a cron job a minute before the show starts, records for 3 hours, 1 minute, and 5 seconds, then shuts itself off, leaving an audio file in its wake.