ShreddinPB
Member
Hey guys, I am trying to start an audio project, im just in the testing phase and have run into something. Im using and FFT and a peak, no matter which one I use, the audio sticks.
Cant really explain, but look at the images, when the sketch starts, all the audio is 0.0, and when the mic pics up audio the lower parts keep values, the louder the audio the more stays. I did try different mics with the same result.
before audio
after audio
The code is very basic.
Any ideas what is going on?
Cant really explain, but look at the images, when the sketch starts, all the audio is 0.0, and when the mic pics up audio the lower parts keep values, the louder the audio the more stays. I did try different mics with the same result.
before audio
after audio
The code is very basic.
Code:
/* Mono Peak Meter
Scrolling peak audio level meter in the Arduino Serial Monitor
Audio input needs to connect to pin 16 (A2). The signal range is 0 to 1.2V.
See the documentation in the Audio System Design Tool for the recommended
circuit to connect an analog signal.
This example code is in the public domain
*/
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioInputAnalog adc1(A0); //xy=413,132
AudioAnalyzePeak peak1; //xy=637,122
AudioAnalyzeFFT256 myFFT; //xy=654,240
AudioConnection patchCord1(adc1, peak1);
AudioConnection patchCord2(adc1, myFFT);
// GUItool: end automatically generated code
void setup() {
AudioMemory(24);
Serial.begin(9600);
myFFT.windowFunction(AudioWindowHanning1024);
}
// for best effect make your terminal/monitor a minimum of 31 chars wide and as high as you can.
elapsedMillis fps;
void loop() {
getFFT();
//getPeak();
}
void getFFT() {
float n;
int i;
if (myFFT.available()) {
// each time new FFT data is available
// print it all to the Arduino Serial Monitor
Serial.print("FFT: ");
for (i=0; i<40; i++) {
n = myFFT.read(i);
if (n >= 0.01) {
Serial.print(n);
Serial.print(" ");
} else {
Serial.print(" - "); // don't print "0.00"
}
}
Serial.println();
}
}
void getPeak()
{
if (fps > 24) {
if (peak1.available()) {
fps = 0;
int monoPeak = peak1.read() * 30.0;
Serial.print("|");
for (int cnt=0; cnt<monoPeak; cnt++) {
Serial.print(">");
}
Serial.println(monoPeak);
}
}
}
Any ideas what is going on?