|
|
@ -6,11 +6,15 @@ |
|
|
|
// Serial Print out powers of all 4096 bins in
|
|
|
|
// Serial Print out powers of all 4096 bins in
|
|
|
|
// dB relative to Sine Wave Full Scale
|
|
|
|
// dB relative to Sine Wave Full Scale
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Rev- added i to print; added filters on oscillators. 23 Feb 2022
|
|
|
|
|
|
|
|
|
|
|
|
// Public Domain
|
|
|
|
// Public Domain
|
|
|
|
|
|
|
|
|
|
|
|
#include "OpenAudio_ArduinoLibrary.h" |
|
|
|
#include "OpenAudio_ArduinoLibrary.h" |
|
|
|
#include "AudioStream_F32.h" |
|
|
|
#include "AudioStream_F32.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int jj = 0; |
|
|
|
|
|
|
|
|
|
|
|
// GUItool: begin automatically generated code
|
|
|
|
// GUItool: begin automatically generated code
|
|
|
|
AudioSynthSineCosine_F32 sine_cos1; //xy=76,532
|
|
|
|
AudioSynthSineCosine_F32 sine_cos1; //xy=76,532
|
|
|
|
AudioAnalyzeFFT4096_IQ_F32 FFT4096iq1; //xy=243,532
|
|
|
|
AudioAnalyzeFFT4096_IQ_F32 FFT4096iq1; //xy=243,532
|
|
|
@ -37,10 +41,13 @@ void setup(void) { |
|
|
|
// or pick any old frequency
|
|
|
|
// or pick any old frequency
|
|
|
|
sine_cos1.frequency(1000.0f); |
|
|
|
sine_cos1.frequency(1000.0f); |
|
|
|
|
|
|
|
|
|
|
|
// elect the output format
|
|
|
|
// Engage the identical BP Filters on sine/cosine outputs (true).
|
|
|
|
|
|
|
|
sine_cos1.pureSpectrum(true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Select the output format FFT_POWER, FFT_RMS or FFT_DBFS
|
|
|
|
FFT4096iq1.setOutputType(FFT_DBFS); |
|
|
|
FFT4096iq1.setOutputType(FFT_DBFS); |
|
|
|
|
|
|
|
|
|
|
|
// Select the wndow function
|
|
|
|
// Select the wndow function from these four:
|
|
|
|
//FFT4096iq1.windowFunction(AudioWindowNone);
|
|
|
|
//FFT4096iq1.windowFunction(AudioWindowNone);
|
|
|
|
//FFT4096iq1.windowFunction(AudioWindowHanning4096);
|
|
|
|
//FFT4096iq1.windowFunction(AudioWindowHanning4096);
|
|
|
|
//FFT4096iq1.windowFunction(AudioWindowKaiser4096, 55.0f);
|
|
|
|
//FFT4096iq1.windowFunction(AudioWindowKaiser4096, 55.0f);
|
|
|
@ -50,24 +57,37 @@ void setup(void) { |
|
|
|
// float* pw = FFT4096iq1.getWindow(); // Print window
|
|
|
|
// float* pw = FFT4096iq1.getWindow(); // Print window
|
|
|
|
// for (int i=0; i<4096; i++) Serial.println(pw[i], 7);
|
|
|
|
// for (int i=0; i<4096; i++) Serial.println(pw[i], 7);
|
|
|
|
|
|
|
|
|
|
|
|
// xAxis, bit 0 left/right; bit 1 low to high; default 0X03
|
|
|
|
// x-Axis direction and offset for sine to I and cosine to Q.
|
|
|
|
|
|
|
|
// If xAxis=0 f=fs/2 in middle, f=0 on right edge
|
|
|
|
|
|
|
|
// If xAxis=1 f=fs/2 in middle, f=0 on left edge
|
|
|
|
|
|
|
|
// If xAxis=2 f=fs/2 on left edge, f=0 in middle
|
|
|
|
|
|
|
|
// If xAxis=3 f=fs/2 on right edge, f=0 in middle
|
|
|
|
|
|
|
|
// xAxis=3 is mathematically proper -fs/2 start to +fs/2 stop.
|
|
|
|
FFT4096iq1.setXAxis(0X03); |
|
|
|
FFT4096iq1.setXAxis(0X03); |
|
|
|
|
|
|
|
|
|
|
|
FFT4096iq1.setNAverage(1); |
|
|
|
FFT4096iq1.setNAverage(5); |
|
|
|
delay(100); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void loop(void) { |
|
|
|
void loop(void) { |
|
|
|
static bool doPrint=true; |
|
|
|
static bool doPrint=true; |
|
|
|
float *pPwr; |
|
|
|
float *pPwr; |
|
|
|
// Print output, once
|
|
|
|
// Print output, once
|
|
|
|
if( FFT4096iq1.available() && doPrint ) { |
|
|
|
if( FFT4096iq1.available() && jj++>2 && doPrint ) |
|
|
|
|
|
|
|
{ |
|
|
|
pPwr = FFT4096iq1.getData(); |
|
|
|
pPwr = FFT4096iq1.getData(); |
|
|
|
for(int i=0; i<4096; i++) |
|
|
|
for(int i=0; i<4096; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Serial.print((int)((float32_t)i * 44100.0/4096.0)); // Print freq
|
|
|
|
|
|
|
|
Serial.print(i); // FFT Output index (0, 4095)
|
|
|
|
|
|
|
|
Serial.print(" "); |
|
|
|
Serial.println(*(pPwr + i), 8 ); |
|
|
|
Serial.println(*(pPwr + 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); |
|
|
|
} |
|
|
|
} |
|
|
|