I am trying to make a panadapter for a software defined radio and I am a little bit stuck and hope someone can help me.

I have an I Q signal from my radio. (Actually I am using an IQ wav file from the internet recorded at 44800 2 channels 16bit).

If I use HDSDR the spectrum looks like this: enter image description here

The display from my app looks like this: enter image description here

I am doing something wrong and I do not know exactly what (I am new to this and I am not very sure I completly understand the concept behind...) I will try to describe what I am doing and hope you can help me fix it

  1. I open the file and start reading from it in a byte buffer (1024 bytes at a time)
  2. I convert every 2 bytes into shorts (ByteOrder.LITTLE_ENDIAN)
  3. I apply HanningWindow to the buffer
  4. I split the buffer in 2 buffers each for a channel (the %2==0 as left and %2==1 right )
  5. I create and array of Complex numbers considering the left[i] as the real part & right[i] as imag part
  6. I do FFT on the complex array (wavenumber table with size 512)
  7. I do an FFT shift (from [1,2,..,n/2,n/2+1,..,n-1,n] to [n,n-1,..,n/2+1,1,2,..,n/2] )
  8. I plot the result

Do I need to process the IQ signal before somehow (demodulate it ?)

I am reading in a wrong way the file? (I know that the file is starting with header & everything but after that the data part starts)

How can I do a pitch /amplitude correction to remove the unwanted image existing in a not ideal IQ recorded by soundcard?

Thank you, Bogdan


2 Answers 2


There are a number of things that could be going wrong; you haven't provided enough information to definitively diagnose your the problem. (A link to the wav file you obtained would be useful, so we can try it out ourselves.) Here are some observations:

  • You're assuming the file is uncompressed 16-bit little-endian samples, and ignoring the presence of the header. This could be wrong, either because the format is not what you think, or the header is not a multiple of 4 bytes long. Instead, use an audio-editing program such as Audacity to read the file and write it out again as a raw file where you have specified the parameters. That, or use a WAV-reading library in your program.

  • Your lengths don't match up. If you read 1024 bytes, then you have 512 shorts, or 256 complex-shorts — but you say your FFT size is 512, not 256. Either your program is not as you say or it might be reading uninitialized memory.

  • Your output appears to have four almost-copies of the spectrum. Two mirrored copies are explainable if you are misreading the input such that the I and Q components are not aligned properly — a symmetric spectrum is to be expected if one of I or Q is zero, constant, or otherwise not properly aligned with the input.

    The other copy might be due to an error in your FFT shift code or graphics code, or because you are trying to display both components of the complex FFT output separately rather than taking the magnitude.

  • I would suggest adjusting the scaling of your color shading so that it is more similar to the HDSDR output, and increasing the FFT size (bin count). (You may also need to take the log of the magnitude.) This will make the result look more like HDSDR's, which will help you match up parts of the spectrum.

Do I need to process the IQ signal before somehow (demodulate it ?)

No. The sorts of processing that could be done to refine a panadapter display would be done after the FFT. The only things to do before would be things like IQ imbalance correction, which are just as appropriate for a signal being demodulated and played as audio (or whatever sort of information) as one going to the panadapter.

  • $\begingroup$ 10x I have fixed my problem... it seams that my file was 32bits encoded.. I used a wav lib & solved the problem $\endgroup$ Jul 14, 2014 at 6:42

Try using the complement operator on the color bytes. For example, a lot of software used #define's for their colors:

#define MAGENTA           0xF81F

Try adding the complete operator before the numeric value:

 #define MAGENTA           ~0xF81F

Notice the tilde before the number.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.