Correct xAxis values

pull/13/head
boblark 3 years ago
parent 527363e338
commit 5f1c08bfba
  1. 14
      analyze_fft4096_iqem_F32.cpp
  2. 4
      analyze_fft4096_iqem_F32.h
  3. 31
      examples/TestFFT4096iqEM/TestFFT4096iqEM.ino

@ -74,9 +74,7 @@ void AudioAnalyzeFFT4096_IQEM_F32::update(void) {
// Here with two new blocks of data. These are retained until the FFT // Here with two new blocks of data. These are retained until the FFT
// but with new pointers, blocklist_i[] and blocklist_q[]. // 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) { switch (state) {
case 0: 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. // Second half of post-FFT processing. dBFS (log10f) is the big user of time.
if (pSumsq==NULL || count>=nAverage) { // Average is finished if (pSumsq==NULL || count>=nAverage) { // Average is finished
count = 0;
Serial.println(count);
count = 0; // CHECK WHERE IS count++ ??? <<<<<<<<<<<<<<
float inAf = 1.0f/(float)nAverage; float inAf = 1.0f/(float)nAverage;
// ii is the index to data source, i is for data output // ii is the index to data source, i is for data output
for (int ii=2048; ii < 4096; ii++) { for (int ii=2048; ii < 4096; ii++) {
@ -429,10 +424,7 @@ void AudioAnalyzeFFT4096_IQEM_F32::update(void) {
state = 16; state = 16;
break; // From case 31 break; // From case 31
} // End of switch & case 31 } // End of switch & case 31
// Serial.print(","); Serial.println(micros() - tt);
Serial.print(","); Serial.println(micros() - tt);
} // End update() } // End update()
// End, if Teensy 4.x // End, if Teensy 4.x
#endif #endif

@ -138,7 +138,7 @@
* no matter how it is scaled, but this factor needs to be considered * no matter how it is scaled, but this factor needs to be considered
* when building the INO. * when building the INO.
* *
* 22 Feb 2022 Fixed xAxis error. * 22 Feb 2022 Fixed xAxis error, twice!
*/ */
/* Info /* Info
* __MK20DX128__ T_LC; __MKL26Z64__ T3.0; __MK20DX256__T3.1 and T3.2 * __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 // xAxis, bit 0 left/right; bit 1 low to high; default 0X03
void setXAxis(uint8_t _xAxis) { void setXAxis(uint8_t _xAxis) {
xAxis = _xAxis ^ 0X02; // Change bit 1 to be consistent with other IQ FFT xAxis = _xAxis;
} }
virtual void update(void); virtual void update(void);

@ -1,10 +1,10 @@
// TestFFT2048iqEM.ino for Teensy 4.x // TestFFT2048iqEM.ino for Teensy 4.x
// *** EXTERNAL MEMORY VERSION of 4095 FFT ***
// Bob Larkin 9 March 2021 // Bob Larkin 9 March 2021
// Generate Sin and Cosine pair and input to IQ FFT. // Generate Sin and Cosine pair and input to IQ FFT.
// Serial Print out powers of all 4096 bins in // Serial Print outputs of all 4096 bins.
// dB relative to Sine Wave Full Scale //
// EXTERNAL MEMORY FFT
// Public Domain // Public Domain
#include "OpenAudio_ArduinoLibrary.h" #include "OpenAudio_ArduinoLibrary.h"
@ -41,8 +41,11 @@ void setup(void) {
sine_cos1.amplitude(1.0f); // Initialize Waveform Generator 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 // Pick T4.x bin center
//sine_cos1.frequency(689.0625f); // sine_cos1.frequency(689.0625f);
// or pick any old frequency // or pick any old frequency
sine_cos1.frequency(1000.0f); sine_cos1.frequency(1000.0f);
@ -59,36 +62,38 @@ void setup(void) {
// Uncomment to Serial print window function // Uncomment to Serial print window function
// for (int i=0; i<2048; i++) Serial.println(*(window+i), 7); // for (int i=0; i<2048; i++) Serial.println(*(window+i), 7);
// xAxis, bit 0 left/right; bit 1 low to high; default 0X03 // xAxis, See leadin discussion at analyze_fft4096_iqem_F32.h
FFT4096iqEM1.setXAxis(0X01); FFT4096iqEM1.setXAxis(0X03); // 0X03 default
// In order to average powers, a buffer for sumsq[4096] must be // In order to average powers, a buffer for sumsq[4096] must be
// globally declared and that pointer, sumsq, set as the last // globally declared and that pointer, sumsq, set as the last
// parameter in the object creation. Then the following will // parameter in the object creation. Then the following will
// cause averaging of 4 powers: // 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) { void loop(void) {
static bool doPrint=true; static bool doPrint=true;
float *pPwr; float *pPwr;
delay(10);
// Print output, once // Print output, once
if( FFT4096iqEM1.available() && doPrint ) { if( FFT4096iqEM1.available() && jj++>2 && doPrint ) {
if(jj++ < 3)return; if(jj++ < 3)return;
for(int i=0; i<4096; i++) 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.print(" ");
Serial.println(*(fftOutput + i), 8 ); Serial.println(*(fftOutput + i), 8 );
} }
doPrint = false; doPrint = false;
} }
if(doPrint)
{
Serial.print(" Audio MEM Float32 Peak: "); Serial.print(" Audio MEM Float32 Peak: ");
Serial.println(AudioMemoryUsageMax_F32()); Serial.println(AudioMemoryUsageMax_F32());
delay(500); }
delay(100);
} }

Loading…
Cancel
Save