Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
rtlsdr-to-gqrx SDR file format converter
#include <complex.h>
#include <stdio.h>
#include <stdlib.h>
// rtlsdr-to-gqrx Copyright 2014 Paul Brewer KI6CQ
// License: GNU GPL 3.0
// IQ file converter for Software Defined Radio Programs rtl_sdr, gqrx
// from rtl_sdr recording format -- interleaved unsigned char
// to gqrx/gnuradio .cfile playback format -- complex64
// compile on Linux with: gcc ./rtlsdr-to-gqrx.c -o rtlsdr-to-gqrx
// For further usage instructions, see my post at:
void main(int argc, char *argv[])
int byte1, byte2; // int -- not unsigned char -- see fgetc man page
float _Complex fc;
const size_t fc_size = sizeof(fc);
FILE *infile,*outfile;
const float scale = 1.0/128.0;
const char *infilename = argv[1];
const char *outfilename = argv[2];
if (argc<3){
printf("usage: rtlsdr-to-gqrx infile outfile\n");
// printf("in= %s out= %s \n", infilename, outfilename);
if ((infile==NULL) || (outfile==NULL)){
printf("Error opening files\n");
while ((byte1=fgetc(infile)) != EOF){
if ((byte2=fgetc(infile)) == EOF){
fc = scale*(byte1-127) + I*scale*(byte2-127);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment