FMOD Ex 4.04.47 (Win32)
I must be missing something. I have done call backs many times but I can’t seem to get the compiler to accept this call back. What am I doing wrong?
FMOD_RESULT F_CALLBACK clsAudioManager::event3DAmbientCallback(FMOD::Event *event, FMOD::EVENT_CALLBACKTYPE type, void *param1, void *param2, void *userdata)
// Set this Event callback.
mEvent->setCallback( &clsAudioManager::event3DAmbientCallback, mAmbientEventItem );
The [i:qm3i5y66]setCallback()[/i:qm3i5y66] call is occuring within the same class.
When I compile it yields this error in the compiler:
1>—— Build started: Project: Client, Configuration: Release Win32 ——
1>.\Managers\clsAudioManager\clsAudioManager4.cpp(94) : error C2664: ‘FMOD::Event::setCallback’ : cannot convert parameter 1 from ‘FMOD_RESULT (__stdcall clsAudioManager::* )(FMOD::Event *,FMOD::EVENT_CALLBACKTYPE,void *,void *,void *)’ to ‘FMOD::EVENT_CALLBACK’
1> There is no context in which this conversion is possible
- Van asked 10 years ago
I found it. 😳
static FMOD_RESULT F_CALLBACK event3DAmbientCallback(FMOD::Event *event, FMOD::EVENT_CALLBACKTYPE type, void *param1, void *param2, void *userdata);
note that I needed [i:1jgeop9f]static[/i:1jgeop9f] in the definition statement. This is required for C++ (at least in MS Dev).
[quote="Van":305mz2bv]note that I needed [i:305mz2bv]static[/i:305mz2bv] in the definition statement. This is required for C++ (at least in MS Dev).[/quote:305mz2bv] Only for class member functions: the pointer [i:305mz2bv]this[/i:305mz2bv] is a parameter added automatically to your function, and it’s not added when the function is static 😉
- FireStorm answered 10 years ago
Ok, now we are having a problem with the setCallback not calling the callback or more precisely, the FMOD::Event is not [i:1rgpk4pa]stopping[/i:1rgpk4pa] with the [b:1rgpk4pa]Velocity Loop Behavior[/b:1rgpk4pa] set to [i:1rgpk4pa]’one shot and stop event’ [/i:1rgpk4pa] in the FMOD Designer.
[i:1rgpk4pa]EVENT_STATE_PLAYING[/i:1rgpk4pa] Event has been started. This will still be true even if the’re are no sound active. Event::stop must be called or the event must stop itself using a ‘one shot and stop event’ parameter mode.
I found this post:
http://126.96.36.199/forum/viewtopic.php … stop+event
and followed this statement:
If you want an event to stop using parameters, turn off the ‘one shot’ property, and instead use the parameter loop behaviour ‘one shot and stop event’
However that didn’t seem to work for us. The Event is not stopping and calling the callback.
When the event first starts, it calls the callback twice but never calls it again. The state of the Event is active (though not playing a sound). Am I missing something?
Please login first to submit.