Hello everyone,
after hours of searching, testing and frustrating I ask for your help.
I have a 7 inch TFT driven by an Arduino DUE using UTFT and I want to see a FFT diagramm. I have directly connected the audio signal (smartphone) to an analog in and ground of course.
I have tried the Radix4 library (http://coolarduino.wordpress.com/), the 8-bit one from here http://forum.arduino.cc/index.php/topic,38153.0.html and tried to do this tutorial http://www.instructables.com/id/LoL-Shield-Audio-Spectrum-VU-Meter/?ALLSTEPS.
The 8-bit library only shows noise, the Radix4 with FFT size 2048 (seems to work, but I don't need such a large FFT) is too slow and I can't get it working with 256.
At the moment I'm trying to get this one to work (same 8 bit lib) Fast fourier transformations on an Arduino. - YouTube, until now it shows also only noise using a signal generator.
I'm trying to get something like this Arduino FFT - YouTube to my TFT.
As soon as I get an array with the correct values, visualisation is no problem.
Btw.: Do I have to use an OpAmp for the audio signal in order to get it from say -2.5...2.5V to 0..5V or does a simple diode do the job?
Is there anyone who has done this before? I need your help!
Edit: I can't get the 8 bit library work correctly. Here's my code if anyone wants to try
#include <fix_fft.h>
char im[128], data[128];
byte i;
#include <UTFT.h>
#include <UTouch.h>
extern uint8_t BigFont[];
extern uint8_t SmallFont[];
UTFT myGLCD(SSD1963_800ALT, 25, 26, 27, 28);
UTouch myTouch( 6, 5, 4, 3, 2);
void setup()
{
Serial.begin(9600);
myGLCD.InitLCD();
myGLCD.clrScr();
myTouch.InitTouch();
myTouch.setPrecision(PREC_MEDIUM);
myGLCD.setFont(SmallFont);
myGLCD.setBackColor(255, 255, 255);
myGLCD.setColor(255, 255, 255);
myGLCD.fillRect(1, 1, 800, 480);
}
void loop()
{
for (i = 0; i < 128; i++) {
data[i] = (analogRead(A0) / 4) - 128;
im[i] = 0;
}
fix_fft(data, im, 7, false);
myGLCD.setColor(255, 255, 255);
myGLCD.fillRect(0, 0, 800, 480);
for (i = 1; i < 64; i++) {
data[i] = sqrt(data[i] * data[i] + im[i] * im[i]);
myGLCD.setColor(0, 0, 0);
myGLCD.drawLine(i * 4, 0, i * 4, data[i]);
}
delay(10);
}
Even if the analog input is connected to ground I get such FFT diagram (still mirrored on x axis):
Edit 2: Also this code from here Music Visualization with an Arduino - mcclanahoochie's blog, almost the same, won't work with the DUE. Does not seem to be the script but the DUE...