craiglindley
Well-known member
First let me say that I've just started to work with the Audio library today so I'm probably doing something stupid.
I am trying to do a basic frequency response plot of the AudioFilterStateVariable low pass filter. My idea was to sweep the frequency of sine wave oscillator connected to the input of the filter and use the AudioAnalyzeRMS object to pull back the filtered values so they can be plotted vs the input frequency. My sketch is as follows:
Unfortunately the detector never has data available for me to plot.
What am I doing wrong and is there a better way to accomplish this ?
Thanks
I am trying to do a basic frequency response plot of the AudioFilterStateVariable low pass filter. My idea was to sweep the frequency of sine wave oscillator connected to the input of the filter and use the AudioAnalyzeRMS object to pull back the filtered values so they can be plotted vs the input frequency. My sketch is as follows:
Code:
// Attempt to plot response of low pass filter
#include <Audio.h>
AudioSynthWaveformSine osc;
AudioFilterStateVariable filter;
AudioAnalyzeRMS detector;
AudioOutputI2S i2s1;
AudioConnection patchCord1(osc, 0, filter, 0);
AudioConnection patchCord2(filter, 0, i2s1, 0);
AudioConnection patchCord3(filter, 0, i2s1, 1);
AudioConnection patchCord4(filter, 0, detector, 0);
AudioControlSGTL5000 audioShield;
void setup(void) {
Serial.begin(115200);
while (!Serial);
delay(3000);
AudioMemory(2);
audioShield.enable();
audioShield.volume(1.0);
osc.amplitude(1.0);
// Set filter cutoff frequency
filter.frequency(1000);
Serial.println("Begin Sweep");
for (int f = 10; f < 20000; f += 10) {
// Set osc frequency
osc.frequency(f);
// Let osc settle
delay(1);
// Wait for detector data to be available
while (! detector.available()) {
delay(1);
}
// Read the detected value
float ampl = detector.read();
Serial.printf("f = %d, ampl = %f\n", f, ampl);
}
Serial.println("End Sweep");
}
void loop() {
}
Unfortunately the detector never has data available for me to plot.
What am I doing wrong and is there a better way to accomplish this ?
Thanks