Streaming static buffer into AudioAnalyzeFFT object - is it possible?

ozbox9000

New member
I want to use the output of my static nLMS filter buffer as the input to the AudioAnalyzeFFT1024 fft. I'm calculating
the dBA values, but need to filter out noise from my two i2s microphones before doing so, hence the nLMS filter.

It looks like the patchCord and connection functions only take typedef AudioStream as an input, so I cannot
plug a static buffer in those functions; but would setting the indexed bin values of the fft = the indexed bin values of the nlms buffer work?
An pseudo-code example of what I mean is in the code snippet.

Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

AudioAnalyzeFFT1024 fft;
float nlmsOut[512]; // result of filtering mic data through nLMS
float aWeight[512] = {0.042, ..., 0.033};
float magnitude = 0;

for (int i = 0; i < 512; i++) {
    fft.output[i] = nlmsOut[i];
}

if (fft.available()) {
    for (int i = 0; i < 512; i++) {
        magnitude += sq(fft.read(i) *aWeight[i]);
    }
}

Is what I want to do even possible? The only other alternative is to use the
arm_math.h fft functions (which I prefer not to do but will if necessary). Thanks all.
 
Back
Top