Regarding offset tuning in rtl_fm.c - the math

Aaron Rossetto aaron at
Sat May 25 01:49:26 UTC 2013

Hi all,

I recently got a Raspberry Pi and an RTL2832 USB card and have been
successful in compiling rtl-sdr and running the associated examples, piping
the data up into LabVIEW for analysis with their Demodulation Toolkit. I'm
a little weak on the signal processing math knowledge here, so I was
wondering if someone could explain the math behind the offset tuning code
in rtl_fm's optimal_settings() function.

It looks like the function takes the desired center tuning frequency and
calculates an integer decimation ratio based on a "capture rate" near 1 MHz
and the desired final sampling rate. Then the center frequency is offset by
a quarter of the capture rate, and this and the capture rate are used to
program the radio. Then in the receive callback, the I/Q data is shifted 90
degrees in rotate_90(). At this point, the I/Q data represents (I presume!)
the spectrum around the original desired center frequency and at the
original sample rate.

How do I get, mathematically speaking, from the oversampled I/Q data
centered at the offset frequency to *my* desired center frequency and
sample rate? I'm especially curious as to the effect of the frequency
offset using that particular value (capture rate/4) and what role the
rotation plays in the transformation.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the osmocom-sdr mailing list