Error in compilation: no matching function for call to...

Hi guys, is the following:

I'm trying to make a library, but OO is not my talent. Here is my problem:

I created the .h and .cpp files, but happens an error on compilation, on line 17 of file.cpp. In fact, if I comment this line, the build is successful.


The .h and .cpp files and error message are shown below.

Acoustic.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef Acoustic_h
#define Acoustic_h

#include "WProgram.h"

const float pi = 3.141593;  // valor de pi

class Acoustic
{
		int signal_in;              // pino de entrada do sinal analógico
		float coeff;                //coeficiente para a função goertzel
		float f_normalized;         //frequencia normalizada
		float s;                    //variavel temporaria
		float sPrev1;       	  	//variavel temporaria
		float sPrev2; 		        //variavel temporaria
		int n_sample;           	//contador de amostras
		int size;                   //tamanho do bloco
		void goertzel(void);        //filtro de goertzel, propriamente dito
	public:
		Acoustic(void);				//construtor
		float magnitude;
		void set_goertzel(float f_target, float f_sample, int size_block, int pin_in);  //configura os parametros usados no algoritmo de goertzel
		void start_goertzel(void);      //inicia coleta de amostras e calculo da magnitude
		void stop_goertzel(void);       //para coleta de amostras e calculo da magnitude
};

#endif 



Acoustic.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "WProgram.h"
#include <FlexiTimer2.h>
#include <Acoustic.h>



Acoustic::Acoustic(void)
{
	sPrev1 = 0.0;
	sPrev2 = 0.0;
	n_sample = 0;
}
void Acoustic::set_goertzel(float f_target, float f_sample, int size_block, int pin_in)
{
  f_normalized = f_target/f_sample; //calcula a frequencia normalizada de interesse
  coeff = 2.0 * cos(2.0 * pi * f_normalized); // calcula o coeficiente do algoritmo de Goertzel
  FlexiTimer2::set(1, 1.0/f_sample, goertzel);
  size = size_block;
  signal_in = pin_in;
}

void  Acoustic::start_goertzel(void)
{
  FlexiTimer2::start();
}

void Acoustic::stop_goertzel(void)
{
  FlexiTimer2::stop();
}

void Acoustic::goertzel(void)
{
  s = analogRead(signal_in) + (coeff * sPrev1) - sPrev2;
  sPrev2 = sPrev1;
  sPrev1 = s;
  n_sample++;
  if(n_sample == size)
  {
    FlexiTimer2::stop();
    magnitude = (sPrev1 * sPrev1) + (sPrev2 * sPrev2) - (sPrev1 * sPrev2 * coeff);
    sPrev1 = 0.0;
    sPrev2 = 0.0;
    n_sample = 0;
    FlexiTimer2::start();
  }
}



error message

Acoustic.cpp: In member function 'void Acoustic::set_goertzel(float, float, int, int)':
Acoustic.cpp:17: error: no matching function for call to 'set(int, double, <unresolved overloaded function type>)'
 FlexiTimer2/FlexiTimer2.h:13: note: candidates are: void FlexiTimer2::set(long unsigned int, void (*)())
FlexiTimer2/FlexiTimer2.h:14: note:                        void FlexiTimer2::set(long unsigned int, double, void (*)())



Can anyone help me?
The function pointer for Acoustic::goertzel is not of type void (*)().
And how do I fix it?
Make it a global function or a static member function.
Sorry guy, but I'm new to C + + programming. I made some changes here in the code but didn't work. Can you tell how it would look in the code?
Last edited on
Topic archived. No new replies allowed.