After setting up the rtl-sdr software as defined here, next step to enable the USB sound card as planned. Unfortunately I don't have any USB sound card as of now, so i emulated one as described here. BBB has the audio output on HDMI port by default, so it is necessary to disable that, to ensure the audio playback on USB sound card. This can be done by changing uEnv.txt after "BEAGLEBONE" drive shows up on your host system. Change the uEnv.txt to
optargs=quiet capemgr.disable_partno=BB-BONELT-HDMI,BB-BONELT-HDMIN
This ensures that HDMI is disable and USB sound card will be the default sound output/input device on BBB.
Add "/usr/local/lib" to LD_LIBRARY_PATH, so that rtl_* commands does not throw any error for LD_LIBRARY_PATH update.
root@beaglebone:~# export LD_LIBRARY_PATH=/usr/local/lib/
Next connect the USB sound card and RTL2838U to BBB using powered USB hub. and enter command "lsusb".
root@beaglebone:~# export LD_LIBRARY_PATH=/usr/local/lib/ root@beaglebone:~# lsusb Bus 001 Device 002: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 003: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB Bus 001 Device 008: ID 1fc9:2046 NXP Semiconductors Bus 001 Device 005: ID 0bda:2838 Realtek Semiconductor Corp. RTL2838 DVB-T
This ensures that both NXP Semiconductors sound card and RTL2838U is now connected to BBB.
You can also use "aplay -L" to list the available sound cards
root@beaglebone:~# aplay -L null Discard all samples (playback) or generate zero samples (capture) default:CARD=Demo NXP Audio Out Demo, USB Audio Default Audio Device sysdefault:CARD=Demo NXP Audio Out Demo, USB Audio Default Audio Device
The output of USB sound card can be tested using.
root@beaglebone:~# cat /dev/urandom | aplay -r 48k Playing raw data 'stdin' : Unsigned 8 bit, Rate 48000 Hz, Mono ^CAborted by signal Interrupt...
All you hear is noise on headphones or external speaker connected to USB sound card
Now we are good to listen to any FM radio station by following command,
root@beaglebone:~# rtl_fm -f 91.9e6 -s 200000 -r 48000 - | aplay -r 48k -f S16_LE Found 1 device(s): 0: Realtek, RTL2838UHIDIR, SN: 00000001 Using device 0: Generic RTL2832U OEM Found Rafael Micro R820T tuner Tuner gain set to automatic. Tuned to 92200000 Hz. Oversampling input by: 6x. Oversampling output by: 1x. Buffer size: 6.83ms Sampling at 1200000 S/s. Output at 200000 Hz. Playing raw data 'stdin' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
"rtl_fm" is the application name for streaming FM radio and it takes following parameters in above mentioned command,
"-f" : frequency, which in our case is 91.9MHz or 91.9e6Hz
"-s" : Sample rate, which is 200k
"-r" : Output rate of 48k
The output from rtl_fm is piped to "aplay" which takes following pararmeter in above command
"-r" : Sample rate of 48k
"-f" : Sample Format, which in our case is 16 bit little endian
Short video: