Go Down

### Topic: fft music labs basic question (Read 1 time)previous topic - next topic

#### nicatam

##### Feb 20, 2014, 11:03 pm
Hi all,
I'm new with the arduino and im trying to do an FFT using the music labs library. (until now nothing makes sense). My final objective is to be able to store a 1500:1 size vector, and then perform an fft in that vector, and then do an inverse fft. First question, does this library allows me to do an inverse fft?
Ive been playing with the basic example provided (fft_adc) but i dont really understand what it is doing. specially what is the output supposed to be and how im i supposed to see it? I put a 4 khz sine in adc0, and checked out the serial monitor but all I saw is random characters, Im not sure whats that also I noticed the serial monitors baud rate is set to 9600, do i need to change that to 115200 to match the code?
I would really appreciate ANY help! thank you so much!

#### jremington

#1
##### Feb 21, 2014, 01:02 am
First of all, you don't have enough RAM on a typical Arduino to perform an FFT on a vector of length 1500, and second, the Open Music Labs code accomodates vectors of length 256 maximum.

It is good to experiment as you are doing, but you do need to know the difference between Serial.write(), which outputs binary to the console, and Serial.print(), which outputs ascii formatted numbers. If you want to look at the output of the transform, you will need to rewrite that section of the code to loop through the 256 elements of the array and print them out using Serial.print()

Of course, the baud rates need to match between the Arduino and the monitor.

#### el_supremo

#2
##### Feb 21, 2014, 03:21 am
Replace this:
Code: [Select]
`    Serial.write(255); // send a start byte    Serial.write(fft_log_out, 128); // send out the data`
with this:
Code: [Select]
`    Serial.println("Start");    for(int i = 0;i < 128;i++) {    Serial.println(fft_log_out[i]);    }    delay(10000);`
This will print the results on the serial monitor and the delay will give you a bit of time to look at the output before the loop starts again.
That library does not appear to have a function to do an inverse FFT.

You need to set the serial monitor to 115200 baud.

Pete
Don't send me technical questions via Private Message.

#### michinyon

#3
##### Feb 21, 2014, 09:36 am
The vector of samples for the FFT has to be a power of 2  (  64, or 128,  or 256,  or 512 samples, etc ).   On the arduino you are limited to 256.

The range of frequencies you can analyze is limited by the sample rate you can perform,  the Nyquist theorum,  and the number of samples.

Go Up