0
0

Hello,

I’m writting application that will receive encoded voice via UDP. So far so good, I receive and decompress it fine but it comes time to play the buffered audio data. I checked out the "usercreatedsound" example and it seems that the place to inject my audio data is

[code:1xyfdql4]
FMOD_RESULT F_CALLBACK pcmreadcallback(FMOD_SOUND *sound, void *data, unsigned int datalen)
{
}
[/code:1xyfdql4]

but since this is C callback function, I will not be able to use more than one instance of the wrapper class for buffered audio playing that I have made. Is there some kind of C++ interface with virtual methods( I though that FModEx is all C++ ), if not I will be very happy if there is C callback in witch I can make it so to give me as one of the arguments an instance of my class.

Looking forward for your reply. :)

  • You must to post comments
0
0

You can store a reference to your C++ class in the UserData of the FMOD::Sound object. (Don’t forget to case the FMOD_SOUND to an FMOD::Sound in that callback if you’re using the C++ interface.)

So:
[code:1kbi6w0h]
// Earlier in the code:
FMOD::Sound* pSound;
// Fill pSound with System::createSound()...
pSound->setUserData(&MyGenerator);

FMOD_RESULT F_CALLBACK pcmreadcallback(FMOD_SOUND sound, void *data, unsigned int datalen)
{
FMOD::Sound
pSound = (FMOD::Sound*)sound;

MyGeneratorClass* pGenerator = NULL;
pSound->getUserData((void*)&pGenerator);

pGenerator->GenerateSamples(data, datalen);

}
[/code:1kbi6w0h]

Hope that helps.

  • You must to post comments
0
0

Thanks a lot man, this fits perfectly. :)

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.