Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeline and beats callbacks #81

Open
nerdp opened this issue Aug 5, 2021 · 2 comments
Open

Timeline and beats callbacks #81

nerdp opened this issue Aug 5, 2021 · 2 comments

Comments

@nerdp
Copy link

nerdp commented Aug 5, 2021

Hello! There is a little issue I wanna ask about. I'm subscribing on a Beat markers event, but because signals are fired only when _process in the game is called I'm getting a lag between an actual music beat and event. And that really troubles me. So the question - Is there some specific reason why signals are handled this way but not called right in the moment Fmod sends events?
Thanks!

@CedNaru
Copy link
Member

CedNaru commented Aug 6, 2021

Hi.
It was quite a while since that part was done so I'm not sure anymore.
I think the main reason was that we wanted the signals to be emitted by Godot main thread. As non-deferred signals are immediately calling the subscribers functions, if we were to call those signals from another thread, they would risk running at the same time as the main thread which could result in Data Race.

At the same time, we weren't knowledgeable enough about both Godot and the FMOD API so I guess we were too safe about that. But now that I checking that code again, I feel like it was unecessary.
You even have an option so Fmod triggers callback in a deferred way, just like you can defer Godot signals.

I guess I can make the change to emit the signals immediately instead of caching them for the next _process() call but it would be the responsibility of the user to be sure that the functions called by the signals are thread-safe.
Maybe I could add a parameter so you can set whether or not a signal is emitted immediately or not but that would overlap with the FMOD setting.

For reference:
https://fmod.com/resources/documentation-api?version=2.00&page=studio-guide.html#event-callbacks

Why is your opinion on that?

@nerdp
Copy link
Author

nerdp commented Aug 6, 2021

I guess I can make the change to emit the signals immediately instead of caching them
It would be great!

Maybe I could add a parameter so you can set whether or not a signal is emitted immediately or not but that would overlap with the FMOD setting.
I'm not sure it's really necessary and it can lead to a confusion. Probably it would be enough to mention it in readme and provide a link on Fmod docs. Or mb adding a little descriptions to FMOD_STUDIO_INIT_DEFERRED_CALLBACKS and FMOD_STUDIO_INIT_SYNCHRONOUS_UPDATE flags in gd script file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants