how to read raw IQ files into Octave

530 views
Skip to first unread message

dvi

unread,
Dec 20, 2017, 6:34:10 AM12/20/17
to Gqrx SDR
Hi,

Could you give some hints on how to read a raw IQ file made with gqrx into Octave?

I've tried it with c=read_complex_binary('gqrx_20171220_112305_145044398_1999999_fc.raw'), but the resulting vector contains very similar values like this:

-0.0004883 - 0.0004883i
   0.0000000 - 0.0004883i
  -0.0004883 - 0.0004883i
  -0.0004883 - 0.0004883i
   0.0000000 - 0.0009766i
  -0.0004883 - 0.0004883i
   0.0000000 + 0.0000000i
  -0.0004883 - 0.0004883i
  -0.0004883 - 0.0004883i
   0.0000000 + 0.0000000i
  -0.0004883 + 0.0000000i
   0.0000000 + 0.0000000i
   0.0000000 + 0.0000000i
  -0.0004883 - 0.0004883i
  -0.0004883 - 0.0004883i
   0.0000000 - 0.0004883i
  -0.0004883 - 0.0004883i
  -0.0004883 - 0.0004883i
   0.0000000 - 0.0004883i
   0.0000000 - 0.0004883i
   0.0000000 + 0.0000000i
   0.0000000 - 0.0009766i
  -0.0004883 - 0.0004883i

However, in gqrx I can play back the file correctly.

My final goal would be to do an FFT with the vector in Octave and plot it, try some windowing functions, etc.

Thanks you!
Istvan

Alexander Fasching

unread,
Dec 20, 2017, 6:52:54 AM12/20/17
to gq...@googlegroups.com
Works fine with the read_complex_binary function from here:
https://github.com/gnuradio/gnuradio/blob/master/gr-utils/octave/read_complex_binary.m

I've created a complex sine in GNU Radio and wrote it to disk with a
file sink. Gqrx uses this internally.
read_complex_binary returns the data in the correct format and the FFT
shows a peak at the correct frequency.

Your values also make sense. 0.0004883 is the LSB of a 12 Bit ADC when
the values are scaled to a range of [-1; 1).
> --
> You received this message because you are subscribed to the Google
> Groups "Gqrx SDR" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to gqrx+uns...@googlegroups.com
> <mailto:gqrx+uns...@googlegroups.com>.
> To post to this group, send email to gq...@googlegroups.com
> <mailto:gq...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/gqrx/c2932d2d-13dc-4617-b35b-4f0737e93d10%40googlegroups.com
> <https://groups.google.com/d/msgid/gqrx/c2932d2d-13dc-4617-b35b-4f0737e93d10%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

dvi

unread,
Dec 20, 2017, 8:43:59 AM12/20/17
to Gqrx SDR
True, however, if I do a unique in Octave, only a few values are listed, which is quite strange for me, since the recoding contains a complex waveform:

>> unique(c)
ans =

   0.0000000 + 0.0000000i
   0.0000000 - 0.0004883i
   0.0004883 + 0.0000000i
   0.0000000 + 0.0004883i
  -0.0004883 + 0.0000000i
  -0.0004883 - 0.0004883i
   0.0004883 - 0.0004883i
   0.0004883 + 0.0004883i
  -0.0004883 + 0.0004883i
   0.0000000 - 0.0009766i
   0.0009766 + 0.0000000i
   0.0000000 + 0.0009766i
  -0.0009766 + 0.0000000i
  -0.0009766 - 0.0004883i
  -0.0004883 - 0.0009766i
   0.0004883 - 0.0009766i
   0.0009766 - 0.0004883i
   0.0009766 + 0.0004883i
   0.0004883 + 0.0009766i
  -0.0004883 + 0.0009766i
  -0.0009766 + 0.0004883i
  -0.0009766 - 0.0009766i
   0.0009766 - 0.0009766i
  -0.0009766 + 0.0009766i
   0.0000000 - 0.0014648i
   0.0014648 + 0.0000000i
   0.0000000 + 0.0014648i
  -0.0014648 + 0.0000000i
  -0.0014648 - 0.0004883i
  -0.0004883 - 0.0014648i
   0.0004883 - 0.0014648i
   0.0014648 - 0.0004883i
  -0.0004883 + 0.0014648i
  -0.0014648 + 0.0004883i
  -0.0014648 - 0.0009766i
  -0.0009766 - 0.0014648i

What does this mean practically? That the signal is still there, but it's too "weak" and only uses the least significant digits?

Also, what's the actual spectrum contained in the IQ recording? Only the selected frequency (with filtering as selected in the dropdown on the right) converted to baseband? Or is this the raw data coming from the hardware as IQ stream and contains a wider spectrum? (=the whole frequency window shown in gqrx)

Thanks,
Istvan

Alexander Fasching

unread,
Dec 20, 2017, 11:12:31 AM12/20/17
to gq...@googlegroups.com
The IQ file contains the whole spectrum displayed in Gqrx, not just the
demodulated frequency.

If you can play it in Gqrx, then the signal shouldn't be too weak. When
you play the file, Gqrx just feeds it into the receiver.

Do you get the full file into Octave or is something missing after reading?
> > an email to gqrx+uns...@googlegroups.com <javascript:>
> > <mailto:gqrx+uns...@googlegroups.com <javascript:>>.
> > To post to this group, send email to gq...@googlegroups.com
> <javascript:>
> > <mailto:gq...@googlegroups.com <javascript:>>.
> <https://groups.google.com/d/msgid/gqrx/c2932d2d-13dc-4617-b35b-4f0737e93d10%40googlegroups.com?utm_medium=email&utm_source=footer
> <https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Gqrx SDR" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to gqrx+uns...@googlegroups.com
> <mailto:gqrx+uns...@googlegroups.com>.
> To post to this group, send email to gq...@googlegroups.com
> <mailto:gq...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/gqrx/bc284f46-8bcc-48cf-a55c-30e39353f36c%40googlegroups.com
> <https://groups.google.com/d/msgid/gqrx/bc284f46-8bcc-48cf-a55c-30e39353f36c%40googlegroups.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages