From 5f1c08bfba0fbb2de90527c47f2a50d222c5403e Mon Sep 17 00:00:00 2001 From: boblark Date: Thu, 24 Feb 2022 09:13:02 -0800 Subject: [PATCH] Correct xAxis values --- analyze_fft4096_iqem_F32.cpp | 14 ++------ analyze_fft4096_iqem_F32.h | 4 +-- examples/TestFFT4096iqEM/TestFFT4096iqEM.ino | 35 +++++++++++--------- 3 files changed, 25 insertions(+), 28 deletions(-) diff --git a/analyze_fft4096_iqem_F32.cpp b/analyze_fft4096_iqem_F32.cpp index 9926381..5d06f36 100644 --- a/analyze_fft4096_iqem_F32.cpp +++ b/analyze_fft4096_iqem_F32.cpp @@ -74,9 +74,7 @@ void AudioAnalyzeFFT4096_IQEM_F32::update(void) { // Here with two new blocks of data. These are retained until the FFT // but with new pointers, blocklist_i[] and blocklist_q[]. - uint32_t tt = micros(); Serial.print(state); - - + // uint32_t tt = micros(); Serial.print(state); switch (state) { case 0: @@ -228,10 +226,7 @@ void AudioAnalyzeFFT4096_IQEM_F32::update(void) { // Second half of post-FFT processing. dBFS (log10f) is the big user of time. if (pSumsq==NULL || count>=nAverage) { // Average is finished - - Serial.println(count); - - count = 0; // CHECK WHERE IS count++ ??? <<<<<<<<<<<<<< + count = 0; float inAf = 1.0f/(float)nAverage; // ii is the index to data source, i is for data output for (int ii=2048; ii < 4096; ii++) { @@ -429,10 +424,7 @@ void AudioAnalyzeFFT4096_IQEM_F32::update(void) { state = 16; break; // From case 31 } // End of switch & case 31 - - - Serial.print(","); Serial.println(micros() - tt); - + // Serial.print(","); Serial.println(micros() - tt); } // End update() // End, if Teensy 4.x #endif diff --git a/analyze_fft4096_iqem_F32.h b/analyze_fft4096_iqem_F32.h index f34d4a9..3f7f2f2 100644 --- a/analyze_fft4096_iqem_F32.h +++ b/analyze_fft4096_iqem_F32.h @@ -138,7 +138,7 @@ * no matter how it is scaled, but this factor needs to be considered * when building the INO. * - * 22 Feb 2022 Fixed xAxis error. + * 22 Feb 2022 Fixed xAxis error, twice! */ /* Info * __MK20DX128__ T_LC; __MKL26Z64__ T3.0; __MK20DX256__T3.1 and T3.2 @@ -278,7 +278,7 @@ public: // xAxis, bit 0 left/right; bit 1 low to high; default 0X03 void setXAxis(uint8_t _xAxis) { - xAxis = _xAxis ^ 0X02; // Change bit 1 to be consistent with other IQ FFT + xAxis = _xAxis; } virtual void update(void); diff --git a/examples/TestFFT4096iqEM/TestFFT4096iqEM.ino b/examples/TestFFT4096iqEM/TestFFT4096iqEM.ino index aafff49..0d91e17 100644 --- a/examples/TestFFT4096iqEM/TestFFT4096iqEM.ino +++ b/examples/TestFFT4096iqEM/TestFFT4096iqEM.ino @@ -1,10 +1,10 @@ // TestFFT2048iqEM.ino for Teensy 4.x +// *** EXTERNAL MEMORY VERSION of 4095 FFT *** // Bob Larkin 9 March 2021 // Generate Sin and Cosine pair and input to IQ FFT. -// Serial Print out powers of all 4096 bins in -// dB relative to Sine Wave Full Scale -// EXTERNAL MEMORY FFT +// Serial Print outputs of all 4096 bins. +// // Public Domain #include "OpenAudio_ArduinoLibrary.h" @@ -41,8 +41,11 @@ void setup(void) { sine_cos1.amplitude(1.0f); // Initialize Waveform Generator + // Engage the identical BP Filters on sine/cosine outputs (true). + sine_cos1.pureSpectrum(true); + // Pick T4.x bin center - //sine_cos1.frequency(689.0625f); + // sine_cos1.frequency(689.0625f); // or pick any old frequency sine_cos1.frequency(1000.0f); @@ -59,36 +62,38 @@ void setup(void) { // Uncomment to Serial print window function // for (int i=0; i<2048; i++) Serial.println(*(window+i), 7); - // xAxis, bit 0 left/right; bit 1 low to high; default 0X03 - FFT4096iqEM1.setXAxis(0X01); + // xAxis, See leadin discussion at analyze_fft4096_iqem_F32.h + FFT4096iqEM1.setXAxis(0X03); // 0X03 default // In order to average powers, a buffer for sumsq[4096] must be // globally declared and that pointer, sumsq, set as the last // parameter in the object creation. Then the following will // cause averaging of 4 powers: - FFT4096iqEM1.setNAverage(20); + FFT4096iqEM1.setNAverage(4); - jj = 0; // This is todelay data gathering to get steady state + jj = 0; // This is to delay data gathering to get steady state } void loop(void) { static bool doPrint=true; float *pPwr; - delay(10); - // Print output, once - if( FFT4096iqEM1.available() && doPrint ) { + if( FFT4096iqEM1.available() && jj++>2 && doPrint ) { if(jj++ < 3)return; for(int i=0; i<4096; i++) { - Serial.print((int)((float32_t)i * 44100.0/4096.0)); +// Serial.print((int)((float32_t)i * 44100.0/4096.0)); // Print freq + Serial.print(i); // FFT Output index (0, 4095) Serial.print(" "); Serial.println(*(fftOutput + i), 8 ); } doPrint = false; } - Serial.print(" Audio MEM Float32 Peak: "); - Serial.println(AudioMemoryUsageMax_F32()); - delay(500); + if(doPrint) + { + Serial.print(" Audio MEM Float32 Peak: "); + Serial.println(AudioMemoryUsageMax_F32()); + } + delay(100); }