tesselode / kira

Library for expressive game audio.
https://crates.io/crates/kira
Apache License 2.0
865 stars 45 forks source link

Allow frame accurate events #75

Closed trobanga closed 9 months ago

trobanga commented 10 months ago

I noticed that Clock::shared is only updated in on_process_start, which causes a delay up to a few milliseconds e.g. in ClockInfoProvider::when_to_start.

I moved the update of Clock::shared into Clock::update and I didn't notice a performance impact. On my machine, running cargo bench has a performance decrease of 3% for simple and (interestingly) almost no impact for with on_start_processing callback.

Do you think it's possible to move it there or maybe enable it with a feature? If you agree I'd be happy to make a PR.

tesselode commented 10 months ago

Hi! I noticed that too recently. That's a regression from 0.7! 🥶 I fixed it in 338112e, so it'll be in Kira v0.9 (I may even release a v0.8.7 with the fix if enough people care).

The way I fixed it is a little different - I just had the ClockInfoProvider grab the info directly from the clock instead of ClockShared. ClockShared is just for monitoring information from the gameplay thread, there's no reason the audio thread has to rely on it.

trobanga commented 10 months ago

Ok, great! I wrote a test to cover that issue.

For me it would be great to have a v0.87 release, then I don't have to remember to update the kira dependency in the future.

tesselode commented 9 months ago

Fixed in v0.8.7.