Help in understanding the IQ raw file format used by SDRs/GnuRadio [closed]

I apologise as I feel like I should know this off the top of my head. I will try to explain what I believe I know and then ask a simple question.

The usual file format used in software defined radios should be just numbers in binary format, representing in-phase and quadrature values of the sampled waveform. Those values are usually 32 bits, so every 2*32 bits you have a single sample of the waveform in that moment. When you play back this format, the DAC reproduces the waveform associated with those IQ states at the rate you ask it to. If you are using 10 MHz as your sample rate, the DAC will produce a waveform with the IQ values you ask it to and consume those values 10 million times a second.

The only way to entirely corrupt this file format is to cut 32 bits somewhere, as that would invert I and Q for the rest of the file. If you remove any multiple of 2*32 bits from the middle of the file you would only corrupt that single sample (and maybe the one before/after it), but the integrity of the file as a whole will not be compromised.

I'm asking this because I'm interfacing with the USB driver of a SDR and I'm confused as to what is actually going on.

• You will need to dig deeper into the driver code and maybe ask these questions to the author. There are many reasons why removing samples may break the file/stream: for example, there may be a specific frame format, or a checksum, or a header where the number of samples is specified. – MBaz Mar 30 '18 at 13:58
• For what's worth, it looks like the stream is not breaking. So maybe my assumption is correct. Sorry I can't upvote your comment. – Mara Ara Mar 30 '18 at 16:05

As @Marcus_Müller points out, dropping samples will corrupt whatever digital symbol or analog waveform you were operating on at that instant.

You'll also introduce discontinuities in the time domain, which means you'll get broadband noise in the frequency domain at that time.

Probably the worst effect is, that if you drop a half sample, you end up swapping I & Q and the spectrum gets inverted. Mathematically, if:

$$x(t) e^{j\omega t} = I(t) + jQ(t)$$

then

$$Q(t) + jI(t) = x(t)e^{-j\omega t +j\frac{\pi}{2}}$$

So you get spectral inversion about DC. If your signal of interest was not centered and symmetric about DC, then your downstream DSP will yield junk.

The only way to entirely corrupt this file format is to cut 32 bits somewhere, as that would invert I and Q for the rest of the file. If you remove any multiple of 2*32 bits from the middle of the file you would only corrupt that single sample (and maybe the one before/after it), but the integrity of the file as a whole will not be compromised.

Well, yeah, the "format" would still be intact.

But nobody knows what a sudden loss of a sample might do to your signal. For example, at 20 MS/s, for a 64-carrier OFDM system (WiFi!), that would amount to one corrupted OFDM symbol, and a 1/64 of symbol duration timing error happening somewhere in the middle of an OFDM frame. Your signal as whole would be (probably) irreparably damaged in a much wider sense!

Generally, you can't just remove samples from a sample stream and hope the signal stays intact. You could instead replace them by zeros, or interpolate the from the neighboring samples and do much less harm.

Whatever you're doing sounds like you should be asking another, new question, explaining what it is that you need to achieve and why you think dropping samples is a good idea.