Corrected xAxis function for dBFS out on analyze_fft1024_iq_F32

pull/6/merge
boblark 4 years ago
parent deace67137
commit f403ffa416
  1. 16
      analyze_fft1024_iq_F32.cpp
  2. 2
      analyze_fft1024_iq_F32.h
  3. 4
      examples/TestFFT1024iq/TestFFT1024iq.ino

@ -1,6 +1,7 @@
/*
* analyze_fft1024_iq_F32.cpp Assembled by Bob Larkin 3 Mar 2021
* Rev 6 Mar 2021 - Added setXAxis()
* Rev 10 Mar 2021 Corrected averaging bracket - Bob L
*
* Converted to F32 floating point input and also extended
* for complex I and Q inputs
@ -144,6 +145,7 @@ void AudioAnalyzeFFT1024_IQ_F32::update(void) {
sumsq[i] += ss1;
}
}
if (count >= nAverage) { // Average is finished
count = 0;
float inAf = 1.0f/(float)nAverage;
@ -160,13 +162,17 @@ void AudioAnalyzeFFT1024_IQ_F32::update(void) {
output[i] = sqrtf(inAf*sumsq[ii]);
else if(outputType==FFT_POWER)
output[i] = inAf*sumsq[ii];
else if(outputType==FFT_DBFS)
output[i] = 10.0f*log10f(inAf*sumsq[ii])-54.1854f; // Scaled to FS sine wave
else if(outputType==FFT_DBFS) {
if(sumsq[i]>0.0f)
output[i] = 10.0f*log10f(inAf*sumsq[ii])-54.1854f; // Scaled to FS sine wave
else
output[i] = -193.0f; // lsb for 23 bit mantissa
}
else
output[i] = 0.0f;
}
} // end of Average is Finished
outputflag = true;
} // End, set output[i] over all 512
outputflag = true; // moved; rev10mar2021
} // End of average is finished
release(blocklist_i[0]); release(blocklist_q[0]);
release(blocklist_i[1]); release(blocklist_q[1]);

@ -2,6 +2,8 @@
* Analyze_fft1024_iq_F32.h Assembled by Bob Larkin 3 Mar 2021
*
* Rev 6 Mar 2021 - Added setXAxis()
* Rev 11 Mar 2021 - Fixed xAxis correction for dBFS output
*
* Does Fast Fourier Transform of a 1024 point complex (I-Q) input.
* Output is one of three measures of the power in each of the 1024
* output bins, Power, RMS level or dB relative to a full scale

@ -51,8 +51,10 @@ void setup(void) {
//float* pw = FFT1024iq1.getWindow(); // Print window
//for (int i=0; i<512; i++) Serial.println(pw[i], 4);
FFT1024iq1.setNAverage(4);
// xAxis, bit 0 left/right; bit 1 low to high; default 0X03
FFT1024iq1.setXAxis(0X03);
FFT1024iq1.setXAxis(0X02);
delay(1000);
// Print output, once

Loading…
Cancel
Save