The example code they have given won't compile and just wondering why. Does anybody else have the same issues?
/*
fft_adc.pde
guest openmusiclabs.com 8.18.12
example sketch for testing the fft library.
it takes in data on ADC0 (Analog0) and processes them
with the fft. the data is sent out over the serial
port at 115.2kb. there is a pure data patch for
visualizing the data.
*/
#define LOG_OUT 1 // use the log output function
#define FFT_N 256 // set to 256 point fft
#include <FFT.h> // include the library
void setup() {
Serial.begin(115200); // use the serial port
TIMSK0 = 0; // turn off timer0 for lower jitter
ADCSRA = 0xe5; // set the adc to free running mode
ADMUX = 0x40; // use adc0
DIDR0 = 0x01; // turn off the digital input for adc0
}
void loop() {
while(1) { // reduces jitter
cli(); // UDRE interrupt slows this way down on arduino1.0
for (int i = 0 ; i < 512 ; i += 2) { // save 256 samples
while(!(ADCSRA & 0x10)); // wait for adc to be ready
ADCSRA = 0xf5; // restart adc
byte m = ADCL; // fetch adc data
byte j = ADCH;
int k = (j << 8) | m; // form into an int
k -= 0x0200; // form into a signed int
k <<= 6; // form into a 16b signed int
fft_input[i] = k; // put real data into even bins
fft_input[i+1] = 0; // set odd bins to 0
}
fft_window(); // window the data for better frequency response
fft_reorder(); // reorder the data before doing the fft
fft_run(); // process the data in the fft
fft_mag_log(); // take the output of the fft
sei();
Serial.write(255); // send a start byte
Serial.write(fft_log_out, 128); // send out the data
}
}
fft_adc.pde: In function 'void loop()':
fft_adc:35: error: 'fft_input' was not declared in this scope
fft_adc:38: error: 'fft_window' was not declared in this scope
fft_adc:39: error: 'fft_reorder' was not declared in this scope
fft_adc:40: error: 'fft_run' was not declared in this scope
fft_adc:41: error: 'fft_mag_log' was not declared in this scope
fft_adc:44: error: 'fft_log_out' was not declared in this scope
I can get rid of the first error by defining the variable fft_input in the sketch however, the other errors are functions/methods and should be in the header file.
The folder structure is incorrect in the downloaded library. Put the folder named "FFT" in the Arduino libraries folder and the example will compile (you don't need to add a variable).
What do you mean that the structure is incorrect in the downloaded library? I unzipped the FFT library in the arduino library folder like it was suggested above. I did not add anything to the code, I just attempted to compile it.
Sorry, I was not clear. If you download the library you get a folder named "ArduinoFFT2-1". Inside that folder is a folder named "FFT". The latter needs to be in the top level of the Arduino libraries folder.
I copied "ArduinoFFT2-1" to the libraries folder, renaming it to "ArduinoFFT2" because of an error message and got the same results as you. After moving the "FET" folder up one level, so that it is directly under the"libraries" folder I could open the example sketch through file=>examples=>FFT and it compiles.
Ah, still the same issue. My computer organizes it alphabetically so I changed the name of the folders a bit to get them where you suggested. It goes libraries folder --> AArduinoFFT2 folder --> FFT folder but same results.
I guess the name of that folder does not really matter too much more than being able to identify it. I just labeled it with a double A to put it at the top like you suggested. I can see the library and examples in the arduino IDE and reset the IDE after each change. Did you get the same error as me or was it something different? Im on another forum post that I created (Audio input analyzed w/ Arduino FFT - Audio - Arduino Forum). I am thinking the #define is not working. the .h file is in my library. The FFT library has been installed correctly in two different ways --> only one FFT folder is in the library, I just tried two different ways. It seems it just is not including the .h file.
I think you misunderstood because I was not suggesting that you rename anything.
From the top: you download the file ArduinoFFT2.zip. Unzip and inside ArduinoFFT2 you see two folders: FFT and reorder_table_creator plus a file named arduinofft_display.pd.
Drag JUST THE FFT folder into the Arduino libraries folder.
So on my computer FFT.h is at Documents/Arduino/libraries/FFT/FFT.h.
BLUE EYES! YES! solution found. I separated the FFT folder from the main folder and no compiling errors. Thank you very much for your help. ;D I would give you Karma but I have to wait an hour.. not a big fan of waiting 10min (which I had to do to post this after trying to help another out) nor am I a fan of waiting to give karma points. Probably people misused their freedom and clogged up the system or something. I wish I could buy you a beer or glass of wine buddy.