Time issues: milliseconds

I know Codea is limited knowing the accurate time in milliseconds, is there a workaround?

Maybe if Codea knows real time in seconds, a program could “learn” to calculate when the next second is coming in…
The “EslapsedTime” is deprecated?

I am dumb… Weeks figuring why… Is ElapsedTime… Not ESlapsedTime…

[/Thread]

Codea measures in frames (60 frames per second) so that can be used to figure out when the next second is coming

@Doge The speed of draw() varies depending on the amount of objects are on the screen. So frames vary from 60 FPS to below 1 FPS, which make it useless for accurate time.

There’s also the os time functions which can be used for more accurate timings.

os.clock() will give you CPU time in fractions of a second. If you need a quick time difference, that might work. os.time() will give you seconds and should be use over a longer time period.

i managed to sync a flashing image to a music’s beat, the sync would not be lost but the accuracy is medium… I will post an example…

Here an example of music sync:

 -- Syncing Test

function setup()
    music("A Hero's Quest:Battle",1)
    isrestarted=readGlobalData("restarted",false)
    bpm=105
    beattime=60/bpm
    beatcount=1
    starttime=ElapsedTime
    delay=0.05
    parameter.watch("ElapsedTime")
    parameter.watch("beatcount")
    parameter.boolean("SomeOverload")
    parameter.boolean("LotOfCalcs")
    currentcolor=0
end


function draw()
    background(0,currentcolor,0)
    if currentcolor>4 then
        currentcolor = currentcolor - 4
    end
    if ElapsedTime>=starttime+(beattime*beatcount) + delay then
        beatcount = beatcount + 1
        currentcolor=70
    end
    if isrestarted==false then
        saveGlobalData("restarted",true)
        text("Please for correct sync press restart now.",300,10)
    end
    if SomeOverload==true then
        sprite(CAMERA,WIDTH/2,HEIGHT/2,200,200)
    end
    if LotOfCalcs==true then
        for i=1, 30000 do
            a=math.log10(i)*math.tan(i)
        end
    end
end