# How to play spectrum recordings made with rtl_sdr in gqrx?

I have an R820T DVB dongle and the rtl_sdr software on a linux computer.

I can listen to various frequencies using the gqrx software which uses the rtl_sdr library as a device driver for the USB-attached dongle. I also (obviously) get the spectrum scope and waterfall display of adjacent channels. Thus, the hardware and software is functional at some level.

Now I notice there is a separate program in the rtl_sdr bundle also called "rtl_sdr" that can record a slice of spectrum onto the hard drive.

Here is an excerpt from the usage reminder generated by running rtl_sdr with no parameters:

rtl_sdr, an I/Q recorder for RTL2832 based DVB-T receivers

Usage:   -f frequency_to_tune_to [Hz]
[-s samplerate (default: 2048000 Hz)]
[-d device_index (default: 0)]
[-g gain (default: 0 for auto)]
[-p ppm_error (default: 0)]
[-b output_block_size (default: 16 * 16384)]
[-n number of samples to read (default: 0, infinite)]
[-S force sync output (default: async)]
filename (a '-' dumps samples to stdout)


For a test, I wanted a loud continuous narrow band FM voice signal, so I attempted to record the local national weather service transmitter on 162.55 Mhz with

rtl_sdr -f 162550000 -g35 -s 1000000 test1.dat


I note that this also records the 1 Mhz sample around 162.55 Mhz. Large files are made quickly. A few minutes netted about 300 MB. I've noticed he R820T is finicky and won't always set low sample rates, and once again this is only to produce a test file. If I wanted to leave it run all night on some other frequency range, I would consider finding a smaller sample rate.

Once recorded, what program plays these files? Although gqrx has an option to play an I/Q sample file, it doesn't seem to play files made with rtl_sdr. I get a blank waterfall and no audio when attempting to play the file in gqrx.

Any ideas?

• – Paul Oct 14 '14 at 3:43

I haven't really tried this, so beware!

I thought the output, as recorded in the file, would actually be the samples in a certain format. So I tried to look it up, and found this page:

http://sdr.osmocom.org/trac/wiki/rtl-sdr#rtl_sdr

At the bottom of the page is a flow diagram for gnu-radio, which takes the contents of the archive, and de-interlaces it (the interlacing is the trick use by the rtl_sdr recorder to record alternatively I and Q).

Apparently the samples are stored as unsigned bytes in the original file, and this flow-chart alternatively sends one byte to the top chain or the bottom chain. They are first converted to float, then -127 is added to convert them into signed values. Finally, after some scaling, they are recombined into a complex signal, which would probably be the signal you'd receive from the dongle in the first place.

In the flow-chart, they save the complex output to a *.cfile format, but I think you could actually input the complex signal into the original receiver to decode it again.

If you original idea was to record the audio, it would probably be more useful to send the receiver audio to a wav_file sink. That way you simply record it as audio.

Edit: The scaling ('8m') is multiplying the samples from -128 to +127, into normalized float values, between -1.0 and +1.0. 8m means 0.008, which is (more or less 1/128)

• Thanks for sending me this. So the deal is that this flow-chart is a program that can be written in gnu radio companion in half an hour or so. The capture.bin is the input file to the flowgraph (made by rtl_sdr) and the capture.cfile that it spits out is the output file. That .cfile can be fed to gqrx and it sort-of-works. And sort-of-not. The audio gqrx spits out is downshifted in frequency and very slow. Recording that gqrx audio into a .wav and getting an audio player to play it at 3x the normal rate sounds about correct. – Paul Oct 14 '14 at 3:24
• Yes... Though you can also use gnuradio as a command line utility (and it might be faster that way), as a casual user it is certainly easier to go the graphic way. – jcoppens Oct 15 '14 at 4:59

The recording in rtl_sdr can be played in gqrx by following the below procedure carefully:

1. Either A or B: (A) Create a gnu radio program with the flowchart posted by @jcoppens above. A copy can be found at the rtl-sdr site, but as mentioned on Stack Overflow, the rtl-sdr .grc file uses obsolete modules and must be rewritten in the new gnu radio companion (30 min to 1 hour work) OR (B) Compile and use the Linux GCC program I wrote for rtlsdr-to-gqrx conversion.
2. Make a SDR recording with rtl_sdr and take note of the actual sample rate
3. Run the conversion mentioned in step #1. Note: the output .cfile will be more than 4x the size of the input .raw file.
4. Start gqrx, go to the "Configure I/O Devices" dialog
5. Set the "Device String" to read the .cfile generated in step 3 and set the rate from step #2
6. IMPORTANT: Set the "Sample Rate" box immediately below the device string to the rate from step #2. This seems redundant (the rate is also in device string) but apparently is not (as of October 2014). If left blank, the sample rate will be set to something you might not want (I suspect 96k) and override the device string setting even though the line appears blank. Leaving this line blank can lead to slow audio.
7. Click the "Power" button in gqrx and playback will begin.