Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

2019.3468 - Timer fixes are terrible and unnecessary.
Started by aexol Mar 05 2019 01:37 AM

31 replies to this topic
[TOPIC CONTROLS]
Page 2 of 2 1 2
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#26

davebollinger

[GLOBAL: userInfoPane.html]
davebollinger
  • Corona Geek

  • 1,368 posts
  • Corona SDK

fwiw, sample "diagnostics" if you really want to know what's going on at a "pseudo-subframe" level w new opt-in:

timer.allowIterationsWithinFrame = true
print("BEFORE FIRST TIMER FRAME, current real time     :", system.getTimer())
timer.performWithDelay(1, function(event)
  local now = system.getTimer()
  print("TIMER CALLBACK:")
  print("  event time (aka timer's start-of-frame time)  :", event.time)
  print("  callback execution real time (aka 'right now'):", now)
  print("  real-time vs event-time delta (aka 'overhead'):", now-event.time)
  print("  event.source time (aka scheduled time)        :", event.source._time)
  print("  real-time vs event-source-time (aka 'overdue'):", now-event.source._time)
end, 10)


[TOPIC: post.html]
#27

vlads

[GLOBAL: userInfoPane.html]
vlads
  • Contributor

  • 881 posts
  • Corona Staff

Hey guys. So, latest build contains my fixes. Now there's timer timer.allowIterationsWithinFrame, defaulted to false. If put to true, you'll get all the events as soon as possible. Default behaviour is to separate them by frame enter.

Both modes correct old behaviour of cropping timer to frame time.



[TOPIC: post.html]
#28

Gary Duke

[GLOBAL: userInfoPane.html]
Gary Duke
  • Enthusiast

  • 38 posts
  • Corona SDK

While the display may only update at 60fps, I am hoping that calling audio.play will play sound sooner than the next upcoming frame.

 

This will finally enable accurate rhythmic triggering of sounds.

 

DEVS - So - if I call audio.play during a timer-triggered event, before the next upcoming frame, will audio.play truly play the sound at any desired number of milliseconds before the next enterframe event? If so, I'll be VERY happy!

 

Gary



[TOPIC: post.html]
#29

thomas6

[GLOBAL: userInfoPane.html]
thomas6
  • Contributor

  • 980 posts
  • Corona SDK

Hi Gary,

 

I think the topic of accurate audio timing has been beaten to death on this forum - several times I might add!

 

The documentation is pretty clear on this: audio works through OpenAL and works on a "best effort" basis, meaning you have very little chances of getting supertight timing.

 

Making timers, frames and other parts of code tighter and more accurate would not help out a lot, since all that would do is place the "play this sound"-command in a sort of buffer at an accurate time. The problem is the buffer of audio commands is read out at a "as soon as we have the processor time and resources" pace.

 

More in-depth information here:

https://developer.coronalabs.com/partner/audionotes

 

For what it's worth: I think I have followed ALL the threads on tight audio, without success. I have a history as an audio producer/engineer of sorts, and have tried to no end to create some sort of sequencer in Corona. I've tried every trick in the book, including having 16 variations of each sample, each with 1,2,3 etc... milliseconds of silent spacing in front of the sample. My personal opinion: nothing works (well), and it is absolutely impossible to get timing to sound supertight.



[TOPIC: post.html]
#30

Gary Duke

[GLOBAL: userInfoPane.html]
Gary Duke
  • Enthusiast

  • 38 posts
  • Corona SDK

Thanks thomas6 - tried those strategies too.. had a major thread going on back in 2012...  

 

If there was just a way to create an ongoing audio-stream and pre-mix audio into it at the exact desired sample and/or system timer position it would be a boon.

 

Audio latency always seems to be the last thing anyone considers vigorously tackling with both technology and software!

 

Cheers!

 

Gary



[TOPIC: post.html]
#31

thomas6

[GLOBAL: userInfoPane.html]
thomas6
  • Contributor

  • 980 posts
  • Corona SDK

Yup, too bad as I had a great game idea and prototype depending on tight audio...

 

It was called "Beat Boy", and it was a sort of endless runner where your running speed defined the pace of the drumtrack music. If you got up to speed and got all the jumps right, you would have a nice continuous drumbreak rolling, with all of the bonus sounds in sync.

 

Unfortunately, as you can probably guess, the game mechanics worked, but the audio was so jittery it ruined the whole flow-experience.



[TOPIC: post.html]
#32

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 936 posts
  • Corona SDK

These changes should really be documented at https://docs.coronalabs.com/api/library/timer/performWithDelay.html for future sake.




[topic_controls]
Page 2 of 2 1 2
 
[/topic_controls]