Comparing frequencies with FFT
hi,
i want use fft library on arduino uno compare incoming sound interval of [1000hz..5000hz] , have no idea how so.
i used code loop found on forum make reading of fft data easier (i had troubles monitor showing me random characters) :
what should do?
i want use fft library on arduino uno compare incoming sound interval of [1000hz..5000hz] , have no idea how so.
i used code loop found on forum make reading of fft data easier (i had troubles monitor showing me random characters) :
code: [select]
/*
fft_adc.pde
guest openmusiclabs.com 8.18.12
example sketch testing fft library.
it takes in data on adc0 (analog0) , processes them
with fft. data sent out on serial
port @ 115.2kb. there pure data patch for
visualizing data.
*/
#define log_out 1 // use log output function
#define fft_n 256 // set 256 point fft
#include <fft.h> // include library
void setup() {
serial.begin(115200); // use serial port
timsk0 = 0; // turn off timer0 lower jitter
adcsra = 0xe5; // set adc free running mode
admux = 0x40; // use adc0
didr0 = 0x01; // turn off digital input adc0
}
void loop() {
while(1) { // reduces jitter
cli(); // udre interrupt slows way down on arduino1.0
(int = 0 ; < 512 ; += 2) { // save 256 samples
while(!(adcsra & 0x10)); // wait adc ready
adcsra = 0xf5; // restart adc
byte m = adcl; // fetch adc data
byte j = adch;
int k = (j << 8) | m; // form int
k -= 0x0200; // form signed int
k <<= 6; // form 16b signed int
fft_input[i] = k; // put real data bins
fft_input[i+1] = 0; // set odd bins 0
}
fft_window(); // window data better frequency response
fft_reorder(); // reorder data before doing fft
fft_run(); // process data in fft
fft_mag_log(); // take output of fft
sei();
serial.println("start");
for(int = 0;i < 128;i++) {
serial.println(fft_log_out[i]);
}
delay(10000);
}
}
what should do?
what should do?
please more specific.
- what trying accomplish?
- you showed code - did work way expected?
- presuming didn't work hoped- since you're posting here - did do?
and, can timer0 interrupt. code disables on, , calls delay(), relies on timer0 interrupt in order function. either refrain disabling interrupt, or don't call delay().
Arduino Forum > Using Arduino > Audio > Comparing frequencies with FFT
arduino
Comments
Post a Comment