Theremingenieur
Senior Member+
Although it might rather be a CPP problem (or better a "me understanding CPP" problem), I allow to ask here since it's a teensy 3.1 project:
My project is simple: I created a class which generates a 2kB wave table (depending on several parameters) and everything worked fine until I wanted to output the wave table with the help of an IntervalTimer (private object within the class).
Here is the header declaration of the class from the .h file:
Now the excerpt from the .cpp file:
When I take away the brackets from *_sortie as follows, I get a different compile error:
Please help! I feel that the solution is simple, but I'm not familiar with pointers...
Thank you in advance!
My project is simple: I created a class which generates a 2kB wave table (depending on several parameters) and everything worked fine until I wanted to output the wave table with the help of an IntervalTimer (private object within the class).
Here is the header declaration of the class from the .h file:
Code:
class THF_son
{
public:
THF_son(thfInstruments_t monInstrument, thfPresets_t monPreset = thfPresetDefaut); //constructor
void setIncrement(unsigned int monIncrement = 1000); //Method to change the output frequency by setting an increment for the table pointer
void demarre(); //Should start outputting the sound (gives a compiler error, see below)
void muet(); //Should stop outputting the sound
private:
void _genTableau(); //private Method to generate the wave table, called by the constructor (work!)
void _sortie(); //private function to read a value from the wave table and to output it to the DAC, to be called as ISR from the IntervalTimer
IntervalTimer _ticOut; //THE Intervaltimer
volatile int _tableau[thfTailleTableau]; //the wave table itself, volatile to be in reach from the ISR
volatile unsigned long _pointeur = 0; //the wave table pointer, volatile to be in reach from the ISR
volatile unsigned int _increment; //the wave table pointer increment (set by public method setIncrement), volatile to be in reach from the ISR
thfOndes_t _onde; //private internal parameter for the wave table generation
thfFormes_t _forme; //private internal parameter for the wave table generation
int _relamp = 1; //private internal parameter for the wave table generation
double _par1 = 0, _par2 = 1, _par3 = 1; //private internal parameter for the wave table generation
};
Now the excerpt from the .cpp file:
Code:
void THF_son::setIncrement(unsigned int monIncrement) {
_increment = monIncrement; //sets a new increment
}
void THF_son::_sortie(void) {
int y = _tableau[_pointeur]; //reads the wave table value at position _pointer
unsigned int z = y + (1 << (thfResolution - 1)); //adds an offset to pass from signed to unsigned
//Todo send z to the DAC
_pointeur += _increment; //moves the pointer forward by the increment
}
void THF_son::demarre() {
_ticOut.begin(*_sortie(), thfCadence); //<=== gives a compile error:
[COLOR="#FF0000"][B]THF_son.cpp: In member function 'void THF_son::demarre()':
THF_son.cpp:34: error: void value not ignored as it ought to be
[/B][/COLOR]}
void THF_son::muet() {
_ticOut.end(); //should stop sound output
}
When I take away the brackets from *_sortie as follows, I get a different compile error:
Code:
void THF_son::demarre() {
_ticOut.begin(*_sortie, thfCadence); //<=== gives a compile error:
[COLOR="#FF0000"][B]THF_son.cpp: In member function 'void THF_son::demarre()':
THF_son.cpp:34: error: invalid use of member function (did you forget the '()' ?)[/B][/COLOR]
}
Please help! I feel that the solution is simple, but I'm not familiar with pointers...
Thank you in advance!