Wednesday, September 28, 2016

Easy Listening meets the Friendly Skies | Adventures in Linux Software Defined Radio

There's something both soothing and exciting about listening to live Air Traffic Control chatter. I was psyched to learn that my little USB Software Defined Radio could pick up the tower over at DCA. All it took was plugging in the relevant radio frequencies. However, manually entering frequencies got old quick. What I needed was to automate this bad boy.

While I initially experimented with software defined radio on Android I was delighted to learn that I could turn my Linux laptop into a listening station with almost zero effort. Turns out, all I needed to do was run:

  sudo dnf install rtl-sdr

and I would gain access to the rtl_sdr command line utility. I was absolutely shocked that the rtl_sdr command auto detected the USB dongle. I was sure I needed to mess with kernel modules or other low level nonsense. Instead it all just worked. After fiddling with various options and grabbing the relevant frequencies I finally kicked off the following command and went to bed.

rtl_fm -M am \
          -f 132.65000M \
          -f 128.25000M \
          -f 121.70000M \
          -f 119.10000M \
          -f 134.35000M \
          -f 257.60000M \
          -f 119.30000M \
          -f 335.50000M \
          -f 124.00000M \
          -f 279.57500M \
          -f 124.20000M \
          -f 269.00000M \
          -f 119.85000M \
          -f 322.30000M \
          -f 126.55000M \
          -f 269.50000M \
          -f 128.35000M \
          -f 270.27500M \
          -f 121.05000M \
          -f 343.70000M \
          -f 118.30000M \
          -f 306.30000M \
          -f 124.70000M \
          -f 338.20000M \
          -f 125.65000M \
          -f 396.10000M \
          -f 118.95000M \
          -f 257.20000M \
          -f 129.45000M \
          -f 129.67500M \
          -f 129.22500M \
          -f 130.95000M \
          -f 129.75000M \
          -f 131.85000M \
          -f 131.35000M \
          -f 131.92500M \
          -f 129.25000M \
          -f 130.97500M \
          -f 129.07500M \
          -f 129.52500M \
          -f 130.10000M \
          -f 130.40000M \
          -f 131.00000M \
          -f 130.42500M \
           -s 12k -g 50 -l 230 > listen.raw

This morning I awoke to find a 3 megabyte file had been created, and even more surprisingly, there was clean chatter in it! I initially listened to generated file by running the command:

play -r 12k -t raw -e s -b 16 -c 1 -V1 listen.raw

Once I verified that there was audio in the file I needed to convert it to a more usable format. Ultimately, I converted the raw audio to WAV, MP3 and finally to MP4 video file for easy publishing on YouTube:

sox -traw -r12k -es -b16 -c1 -V1 listen.raw listen.wav  # More info
lame listen.wav listen.mp3 
ffmpeg -framerate 1/5 -pattern_type glob -i 'scaled/*.jpg' -i dca.wav \
   -c:v libx264 -c:a aac  -vf "fps=25,format=yuv420p" -b:a 192k \
   -shortest out.mp4 # More info

And here's the final product:

Next up: automating listening on Android.

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails