metronome—what's the best option for solid timing?

0 favourites
  • 5 posts
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • Hey guys/girls,

    I've been playing around with Construct 2 over the past few weeks and I'm starting to find my way around.

    I'm making a metronome app and I'm wondering what is the most reliable way to generate a steady, repeating "blip" sound. (I'm saying "blip" to avoid confusion with "tick"!)

    So, we have:

    (system) every x seconds -> audio play blip

    while something is true -> audio play blip, wait x seconds

    on timer -> audio play blip

    And one I have discovered which seems to work quite well

    on layout start -> audio play blip (tag "blip1")

    on timer -> seek "blip1" to 0

    And so on and so forth.

    So, I wonder if any of you experts can tell me which of these will be the most accurate and reliably steady? I'm finding all of them to have occasional glitches and they are not totally rock-steady.



  • Hey douglas,

    I gave a solution to a problem that's similar to yours: a metronome plays a sound on beats. Its rhythm is based on a global BPM value. In this thread, you'll find a general code logic that should give you a solid base to build a metronome upon:

    Without a generic base, you'll have trouble adding functionnality further down the road.

    I hope this helps!

  • Hey,

    Thanks for that info. Yes, I already have a framework and I am able to change BPM, beats in the bar, etc. I'm just stuck trying to work out what is the best method to accurately time those beats.

    For example, I have a global variable "bpm". The simple solution would be to assign your beats per secong (i.e. 60/bpm) to a timer behavior. So, if your bpm is set to 120, you get a timer that runs every .5 sec.

    But, I'm wondering how accurate that timer behavior is? Does it run from the system time, or what? Is it rounded down or up? I suppose I'm wondering what the internal precision is and how reliable it is.

    Does that make sense?

    I see your code is using the "time" in a variable. Is that more accurate than using a "timer" behavior?

  • I'm pretty sure that the timer behavior is a set of calculations results based on the Time variable.

    I don't think you need to worry too much about the internal clock's reliability, it should be really precise. You will always have some +/- 17-30ms of error margin that comes along with the framerate. But that's good enough. I've written an example using the Time variable simply because I wasn't aware of the timer behavior ^^' (just starting programming with C2) !

    Sorry for the previous answer!



  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks again for checking this out.

    I'm having a hard time getting my head around how it works.

    From what I can understand, the actual event sheet processes as fast as the computer will allow, correct? But the trigger accuracy of certain events is limited to 60fps (or whatever your device happens to be able to deal with). Is that basically how it works?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)