Problem with a library

Good morning,

I would like to create a specific frequencies identification. So I downloaded the FFT library and put it in the arduino libraries. But when I compile, I have an error with just one of the FFT fionctions ( fft_mag_log() ) :

sketch_jun26a.cpp.o: In function fft_mag_log': C:\Program Files (x86)\Arduino\libraries\FFT/FFT.h:950: undefined reference tofft_log_out' C:\Program Files (x86)\Arduino\libraries\FFT/FFT.h:950: undefined reference to fft_log_out' C:\Program Files (x86)\Arduino\libraries\FFT/FFT.h:950: undefined reference to_log_table' C:\Program Files (x86)\Arduino\libraries\FFT/FFT.h:950: undefined reference to `_log_table' collect2.exe: error: ld returned 1 exit status

How can I solve this problem please?

Thanks in advance!

Link of the FFT library : http://wiki.openmusiclabs.com/wiki/FFTFunctions

Hi Heliops

Which version of the Arduino IDE are you using? If it is version 1.0.5 or newer, did you download the latest version of library file ArduinoFFT2.zip?

Also, please post your program using code tags (the </> button on the toolbar).

Regards

Ray

Hi Hackscribble,

I have the 1.6.5 version and yes I did it. But I unzipped the file and put in the library only the FFT file.

Here is my code:

#include<stdio.h>
#include<SPI.h>
#include<FFT.h>
#define LOG_OUT 1 // use the log output function
#define FFT_N 256 // set to 256 point fft



void setup() {
  Serial.begin(115200);
  TIMSK0 = 0; // turn off timer0 for lower jitter - delay() and millis() killed
  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();
      fft_reorder();
      fft_run();
      fft_mag_log(); // take the output of the fft
      sei(); // turn interrupts back on
      Serial.write(255); // send a start byte
      

      }
    }

All fft functions are running except the fft_mag_log();

Thanks for your help.

Put the #define statements before the #include :slight_smile:

#define LOG_OUT 1 // use the log output function
#define FFT_N 256 // set to 256 point fft
#include<FFT.h>

Ah... Thank you ! :)