I’ve created a mp3-mixer in C++ Builder 6 using FMod. Currently I’m working on a class that records whatever is mixed…I tried to use the standard recording functions, but they don’t provide what I’m looking for…because they record every sound that’s currently being played via directsound and if the volume-settings aren’t properly set, they don’t record anything (correct me if I’m wrong on this…).
Therefore I tried to use a dsp-callback and write all of the data to a TMemoryStream so I can use that stream to create a wavefile…(I already have the part to build the waveheader and stuff). But the problem with this approach is that because the dspcallback is a static function, I cannot call the TMemoryStream-object within my CDsp-class ([C++ Error] CDsp.cpp(10): E2231 Member CDsp::pDataBuf cannot be used without an object).
Obviously it’s not allowed to call another member from a static function (which is perfectly logical, so I’m told…), but now I’m more or less stuck…so if somebody would have a proper solution for this issue, I would really appreciate it…
Thanx in advance,
It’s this function that’s giving me a hard time, btw:
void *CDsp::DspCallBack(void *OriginalBuffer, void *NewBuffer, int Length, int Param)
which is declared in my header file like:
static void *CDsp::DspCallBack(void *OriginalBuffer, void *NewBuffer, int Length, int Param);
mixing static and non-static member functions is a common design problem.
there are some solutions i can think of:
-> Use the ‘int param’ in your DSP callback: when creating the dsp assign it the pointer to your CDSP-class. then you could use it in your CDSP-callback like this: ((CDP*)param)->SomeFunc();
Pretty ugly, but it works.
-> Make your CDSP-class a singleton. Only applicable when just one instance is ever created. it simply makes the whole class instance static and thereby accessible from anywhere
The nicest solution.
-> Some global pointer to your CDSP-class…
That’s again an ugly one.
- night answered 15 years ago
Please login first to submit.