Hi!
I’m creating a tool that syncs animations to music.
I’m using this function, just to check how defold manages timers and how accurate they are.
local function throb(self,dt)
timer.delay(1, false, throb)
sound.play("#click")
end
I’ve checked the frequency of the clicks using ableton live and I’m getting really big discrepancies (the lines are at exactly one second, the blips are the sound of the click from the game)
Can anyone say why this is? Am I missing something stupid? Thanks!
Is there any reason for this?
I would try this:
local function throb(self, dt)
timer.delay( 1.0, true, function() sound.play("#click") end)
end
Probably it is exactly equivalent, but who knows…
…Rocco, you are right! That solves the problem, because slight delays are being accumulated.
But it doesn’t work for me. I need to be able to dynamically change the repeat value according to the BPM of the music. I think I will need to use message posting to put a repeating time, then cancel it whenever the BPM is updated. Got it!
1 Like
Yes, I guessed that you were interested in it, and I was thinking to the same solution. However expect some delay also from the msg delivering system, but at least it will not accumulate.
Ciao!
1 Like