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
FMOD_RESULT F_CALLBACK pcmreadcallback(FMOD_SOUND *sound, void *data, unsigned int datalen)
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.
- The Storm asked 8 years ago
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.)
// Earlier in the code:
// Fill pSound with System::createSound()...
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);
Hope that helps.
- Adiss answered 8 years ago
Please login first to submit.