Aibo Posted December 6, 2010 Share Posted December 6, 2010 currently im making something liek a «tracker» (aha, i know it IS stupid ), and using timer to play sounds and stuff. so milliseconds for the timer are calcutated from BPM (beats per minute) like this: ms = math.floor(60000/bpm/4) thing is, for example: INFO: BPM: 89 - timer ms: 168 INFO: BPM: 111 - timer ms: 135 looks like 135 and 168 ms have absolutely no difference for the timer (89 and 111 BPM plays the same), so i am wondering what is the exact timer ms "precision", or "steps" maybe, cause right now i cant directly convert any BPM value to timer ms. PS: resource is here: https://community.multitheftauto.com/index.php?p= ... ls&id=1355 Link to comment
eAi Posted December 6, 2010 Share Posted December 6, 2010 You'd be much better off doing it using onClientRender, which is called every frame. Timers aren't really designed (or able) to be terribly accurate. Of course, bear in mind that with onClientRender frames can be a long time apart. Usually they're going to be 1/20s to 1/30s apart, but if the player pauses the game it could be minutes 168ms and 135ms are exactly 33ms apart, so for the 135ms timer is only going to be guaranteed to occur on a different frame to the 168ms timer if the game is running at over 30 FPS. So the precision is basically the frame time. All the timers are triggered at the same point each frame. Generally, in games, the audio runs on a separate thread with a high priority to avoid such timing issues (though they're generally having to do more than just trigger sounds). I've added some more explanation on the wiki. Link to comment
Aibo Posted December 6, 2010 Author Share Posted December 6, 2010 yep, i had some speculations about frame time, thanks for the clarification. honestly, i dont see a point in using onClientRender either, since FPS are not that constant also. guess it was a bad idea from the start. Link to comment
eAi Posted December 7, 2010 Share Posted December 7, 2010 One alternative would be to write a module that had it's own thread for dealing with this and scheduling audio. I'm sure there's some way we could support this better, but it's a fairly niche use! Good work though - with this and all your other resources. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now