i am using the FMOD extension from @dapetcu21 so far. This works pretty good so far, thanks to all contributors! However, there 2 question I would like to discuss here:
A really cool feature of FMOD is that you can set callbacks on the beats of the timeline of an event. This way, you could spawn game objects with the beat of your music. I tried to get that setup with defold, but with no luck so far. It seems that the setCallback or set_callback function just don’t exist in the fmod extension for Defold. Has anyone got that working already?
I am experiencing a small, but noticable delay when starting events. I would say it is about 100-200ms, on Linux as well as HTML5. Is this normal/expected behaviour?
Unfortunately there’s no way to respond to callbacks since they happen on a separate thread and FMOD expects a response immediately. Unfortunately I cannot call into the main Lua context from a separate thread, so… no callbacks. There might be some solution, but it would involve a lot of gymnastics.
As for the latency, that’s dependent on the platform’s audio drivers. On HTML, it’s a hit tricky because FMOD needs to do all audio processing on the main thread in-between frames. You can try to reduce the size of the audio buffer (I think there are some game.properties settings if I recall correctly), but you might experience under-runs.
What do you mean by “FMOD expects a response immediately”? Isn’t this a callback from FMOD to Lua? Or does Lua have to somehow respond to the callback?
Okay, thanks for the info. I will have to dig deeper into your FMOD extension i guess I also understood this as the fmod is running on a different thread. And yes, then it becomes more complicated to install the callback. But we might send a message/event asynchronously from FMOD to the lua main thread, right?
Yeah. Last I remember working with this, it expects a response synchronously on the callback’s thread. I guess a solution would be to block the callback thread until the main Lua thread has the time to answer, but I’m afraid it might not be fast enough for FMOD. Worth a try though.
I think at least one-way notification would be a step forward, e.g. the game could react to the fmod events.
Sure, we can’t supply a response in time, but that might be ok for now?
Well, I guess this is what surprises me. I expect an event system to emit events that others may or may not listen for. I do not expect an event system to also require a response to an emitted event.
By the way, here’s the documentation for setCallback():
The docs mention “Callbacks are called from the Studio Update Thread in default / async mode and the main (calling) thread in synchronous mode” so there might also be a synchronous mode. Not sure if it is feasible to run everything on the main thread though.
Also, looking at the actual callback function I don’t see anything about FMOD requiring a response: