Hey guys,
I written a base class (AudioTrackElement), and derived a class
from there (Looper) and another (VolumePan). The looper class implements functionality,
while the AudioTrackElement is there just so I can hold many Loopers and VolumePan
objects in the same vector.
The problem: I can create a std::vector<AudioTrackElement>
no problem,
but when I add a looper to this vector, it calls the base class (AudioTrackElement),
NOT the Looper instance I actually added.
The function I'm calling on the AudioTrackElement vector is process(float* L, float* R, int)
. What I want it to do, is access the first element of the vector, and call process()
on that instance.
Shown below is AudioTrack.hpp (where the vector is stored)
class AudioTrack
{
private:
std::vector<AudioTrackElement> elementVector;
};
Shown below is AudiotrackElemenet.hpp (modified for brevity)
class AudioTrackElement
{
public:
AudioTrackElement();
~AudioTrackElement();
void process(float *L, float *R, int nframes);
};
Shown below is Looper.hpp (modified for brevity)
class Looper : public AudioTrackElement
{
public:
void process(float *L, float *R, int nframes);
};
Shown below is the code in AudioTrack.cpp (That acually calls process() )
elementVector[0].process( &internalL[0], &internalR[0], nframes);
Again it compiles fine, doesn't segfault, but it calls AudioTrackElement::process()
rather than Looper::process()
.
Cheers for reading, hoping somebody knows whats up!
-Harry
PS: If more source is needed, shout. Its all here :-)