Hi,

I am trying to produce a power spectrum with meaningful levels on the dsp. This is similar to MATLAB's reference: http://www.mathworks.com/support/tech-notes/1700/1702.html

My problem is that I want to utilize the fract16 datatype or use a 16-bit fixed point representation and avoid using floating point for efficiency. After I do

rfft_fr16(input, output, twiddle_table, 1, FFT_SIZE, &block_exponent, 1); //get fft

for(i=0;i<FFT_SIZE/2;i++){

power_fp[i] = output[i].re*output[i].re + output[i].im*output[i].im; //this may overflow even when no scaling is done..

//beware, results of overflow becomes negative number

}

What happens is that even before I scale anything, my output has overflowed.

I believe I may be missing a crucial step though.. converting from fr16 fractional values from -1 to 1 to fixed point values -32768 to 32767. I can't just insert the values given to me into the -1 to 1 of my fixed point representation or else I'll be losing a lot of information. The easy (cop out) way would be to do this:

outputf[i].re=fr16_to_float(output[i].re)*ldexpf(1.0F,block_exponent);

outputf[i].im=fr16_to_float(output[i].im)*ldexpf(1.0F,block_exponent);

and the divide by the 2^(fractional bits) to obtain my fixed point value. That would involve changing back to float. Would this be my only option? Am I on track or way off? Any suggestions are most welcome.

Thank you

Also, might it be possible to utilize cabs_fr16(output)^2 to find the power spectrum? How would you relate the levels back to "real values" in order to for example, take the log and find dB levels?

Thanks!