Hmm, I put the fft in new sketch and now I'm having these errors:
C:\Documents and Settings\Administrator\Desktop\arduino-0018\libraries\fft/ffft.h:10: error: 'int16_t' does not name a type
C:\Documents and Settings\Administrator\Desktop\arduino-0018\libraries\fft/ffft.h:11: error: 'int16_t' does not name a type
C:\Documents and Settings\Administrator\Desktop\arduino-0018\libraries\fft/ffft.h:18: error: expected ',' or '...' before '*' token
C:\Documents and Settings\Administrator\Desktop\arduino-0018\libraries\fft/ffft.h:18: error: ISO C++ forbids declaration of 'int16_t' with no type
C:\Documents and Settings\Administrator\Desktop\arduino-0018\libraries\fft/ffft.h:23: error: 'uint16_t' has not been declared
C:\Documents and Settings\Administrator\Desktop\arduino-0018\libraries\fft/ffft.h:24: error: 'int16_t' does not name a type
C:\Documents and Settings\Administrator\Desktop\arduino-0018\libraries\fft/ffft.h:27: error: 'prog_int16_t' does not name a type
In function 'void loop()':
error: invalid conversion from 'int16_t*' to 'int'C:\Documents and Settings\Administrator\Desktop\arduino-0018\libraries\fft/ffft.h:18: error: too many arguments to function 'void fft_input(int)'
ffft.h is like this:
#ifndef FFT_N
#define FFT_N 64 /* Number of samples (64,128,256,512). Don't forget to clean! */
//#define INPUT_NOUSE
//#define INPUT_IQ
#ifndef FFFT_ASM /* for c modules */
typedef struct _tag_complex_t {
int16_t r;
int16_t i;
} complex_t;
#ifndef INPUT_NOUSE
#ifdef INPUT_IQ
void fft_input (const complex_t *, complex_t *);
#else
extern "C" { void fft_input (const int16_t *, complex_t *); }
#endif
#endif
extern "C" {
void fft_execute (complex_t *);
void fft_output (complex_t *, uint16_t *);
int16_t fmuls_f (int16_t, int16_t);
}
for folowing sketch:
#include <ffft.h>
int16_t capture[FFT_N]; /* Wave captureing buffer */
complex_t bfly_buff[FFT_N]; /* FFT buffer */
uint16_t spektrum[FFT_N/2]; /* Spectrum output buffer */
#define NUM_SAMPLES FFT_N
#define FFT_SIZE FFT_N / 2
byte val = 0;
void setup() {
}
void loop() {
val = analogRead(0);
byte i=0;
while (i < NUM_SAMPLES) {
val = analogRead (0);
int16_t adc_val = (int16_t) val;
capture [i] = (int16_t) adc_val;
i++;
}
if(i==NUM_SAMPLES){
fft_input(capture, bfly_buff);
i = 0;
};
}