First of all, Thank you to all who contributed to this library, it is simply impressive!
I'm not creating any sounds but began investigating when I saw the FFT_1024 running at 86Hz! (versus my FFT_64 @ 69Hz -built upon Tony DiCola's FFT demo). Along the way I ran into a few questions:
1) ADC1( pin ) - This made it easier to "bring my own mic" but through troubleshooting I realized that I needed to make this edit to the library:
I'm using Adafruit's mic - which floats at 1/2 Vcc so I didn't need the lower reference, when using a mic/amp package, do I still need the recommended circuit for mic input?
2) Once I got the example adjusted and running, I noticed that the AudioAnalyzeFFT256 runs at half the speed (43hz) of the default 1024... Why is that? Is the sample rate different?
( I know this is designed to make the audio board very accessible, but some advanced controls would be nice, perhaps: analogRef, and Sample rate )
Here's my code - edited to sample a signal on an analog pin:
I'm not creating any sounds but began investigating when I saw the FFT_1024 running at 86Hz! (versus my FFT_64 @ 69Hz -built upon Tony DiCola's FFT demo). Along the way I ran into a few questions:
1) ADC1( pin ) - This made it easier to "bring my own mic" but through troubleshooting I realized that I needed to make this edit to the library:
Code:
//analogReference(INTERNAL); // range 0 to 1.2 volts
2) Once I got the example adjusted and running, I noticed that the AudioAnalyzeFFT256 runs at half the speed (43hz) of the default 1024... Why is that? Is the sample rate different?
( I know this is designed to make the audio board very accessible, but some advanced controls would be nice, perhaps: analogRef, and Sample rate )
Here's my code - edited to sample a signal on an analog pin:
Code:
// FFT Test
//
// Compute a 1024 point Fast Fourier Transform (spectrum analysis)
// on audio connected to the Left Line-In pin. By changing code,
// a synthetic sine wave can be input instead.
//
// The first 40 (of 512) frequency analysis bins are printed to
// the Arduino Serial Monitor. Viewing the raw data can help you
// understand how the FFT works and what results to expect when
// using the data to control LEDs, motors, or other fun things!
//
// This example code is in the public domain.
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
//const int myInput = AUDIO_INPUT_LINEIN;
//const int myInput = AUDIO_INPUT_MIC;
// Create the Audio components. These should be created in the
// order data flows, inputs/sources -> processing -> outputs
//
AudioInputAnalog adc1(15);
AudioSynthWaveformSine sinewave;
AudioAnalyzeFFT256 myFFT;
//AudioAnalyzeFFT1024 myFFT;
// Connect either the live input or synthesized sine wave
AudioConnection patchCord1(adc1, 0, myFFT, 0);
//AudioConnection patchCord1(sinewave, 0, myFFT, 0);
void setup() {
// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(12);
Serial.begin(115200);
pinMode(15, INPUT);
// Configure the window algorithm to use
//myFFT.windowFunction(AudioWindowFlattop1024);
myFFT.windowFunction(NULL);
// Create a synthetic sine wave, for testing
// To use this, edit the connections above
sinewave.amplitude(0.8);
sinewave.frequency(1034.007);
}
int marktime = 0;
void loop() {
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();
// calculate and print Hz
Serial.print (float( 1000000.00 / (micros() - marktime)) ) ;
Serial.println ("\t Hz");
marktime = micros();
}
}