How do I Measure time between taps

0 favourites
  • 11 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • Hello!

    I'm measuring the time between taps ( touches ) when I'm making a Bpm-tap function. Bpm = Beats Per Minute, like you use for tempo in music.

    But I'm getting inconsistent results on touch-devices. However it works very nice on a computer, using a mouse.

    I'm wondering if I missed an important mechanic with the Touch-plugin or something that causes problems?

    The main thing I'm interested in is: What's the best way to measure time between two taps in Construct 2?

    My function works like this:

    When the user touches/tap/click a sprite I measure the time between taps.

    I also count each tap so I can calculate an Average value.

    To calculate the BPM I only need a time... for-example 0.5s or 500ms is a Quarternote at 120 BPM.

    I have tried several of the touch-conditions but the one that seem to work best is "Is touching object" or "Is in touch"

    I use this condition followed by a "Trigger once"

    The result is great if I try the app in my computers web browser.

    I have two BPM-values... First the value calculated with the time between the last two taps. Secondly the BPM calculated from an average from all the taps made.

    On a touch-device... I have tested on an iPhone 4S and also on an android-system: Samsung S3. I also did some testing on a Sony, don't remember the model.

    I seem to get the same results from all of them - where the end result is that they give me a BPM-value 1-2 bpms higher than on the computer.

    It seems like overall the measured time between taps is getting a bit higher than on the computer.

    So both my BPM-values the (real) one and the (average) one... gets misleading values.

    I wont get into more details, for now, unless someone asks for more.

  • Soulmachine

    I'm not sure why you're getting different times on different devices, it could just be the responsiveness of their screens.

    Anyway, here is my attempt at recording time between taps: capx (r233)

    I use Touch: On Tap and add dt to a variable for time between taps

  • Are you setting the reading to Floor, Round or Integer?

    It may be response time on the device.

  • It seems like overall the measured time between taps is getting a bit higher than on the computer.

    So both my BPM-values the (real) one and the (average) one... gets misleading values.

    What FPS on them ? That is an important question because 'time' is dt corrected in c2, but to a point.

    There is a system action to set the 'minimum framerate'. That is default 30 fps. Drop below it, and dt is no longer updated, resulting in longer time measuring s.

    Better off with using the system expression wallclocktime.

  • I see that you talk about milliseconds.

    So ... Also .. C2 works as a sorta kinda sampling machine.

    At a steady 50 FPS the events run 50 times a second.

    Then the 'measuring' happens every 0.02 seconds. Or, you have a random uncertainty between zero and 0.04 seconds.

    At a steady 25 FPS (never happens, dt is always dancing) this is already 0.08 seconds.

    That means nothing in normal circumstances. It does when you want exact measuring, in milliseconds. I think it is impossible to compare devices in that 'quantised' range.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi, thanks for the responses

    Overall it seems to me that the small latency that always is when you use a touch screen is in play somehow.

    Interesting capx you've sent me

    I've tested it on my computer and on my iPhone - and I get different times depending on witch one I use

    PC -TEST

    iPhone - TEST

    I edited your capx a little so I could read the text on my iPhone and I added so you can see the FPS too. http://www.lindsjael.se/soulgames/TapABeat%202.capx

    If anyone would like to also try and see what they get as a result - feel free... I think about 16 taps is good enough for a test. I used a metronome at 120 BPM that I listened to while I tapped - so I could get as consistent readings as possible. Here's a free on-line metronome https://www.starsandcatz.com.au/metronome/

    I tested a couple of times to get into the beat.

    You used the "On tap gesture" that's different from my own tests. I've used "Touching object" or "Is in touch" or "Touch start". I've also tried "On tap object"

    It was interesting with the "On tap gesture"... If I tapped at 120 BPM I only got a tap registered every other tap. So My time between taps are about 1s.

    But if I tapped much slower, like 60 BPM . Every tap got registered? ...thats also 1s between taps.

    If all taps are registered at 120 BPM the time should be around 0.5s.

    I felt it got a little bit more consistent... or should I say less random. Where I got fairly same readings when I used my iPhone ( a touch device ). However the time differs from the Computer readings.

    I looked at the FPS and it stayed between 45-60 all the time.

    I've been thinking of what's the best way to measure the time. I've both tried using delta time and the system expression time.

    Interesting suggestion about the wallclocktime 99Instances2Go I will try it out.

    lamar

    On my own testing I've both used the measurement cleanly as it is ... and used Round. And rounded it up to nearest 0.1 (tenth)

    I get better results rounding I think.

  • I see that you talk about milliseconds.

    So ... Also .. C2 works as a sorta kinda sampling machine.

    At a steady 50 FPS the events run 50 times a second.

    Then the 'measuring' happens every 0.02 seconds. Or, you have a random uncertainty between zero and 0.04 seconds.

    At a steady 25 FPS (never happens, dt is always dancing) this is already 0.08 seconds.

    That means nothing in normal circumstances. It does when you want exact measuring, in milliseconds. I think it is impossible to compare devices in that 'quantised' range.

    It's a bit sensitive with beats and music, cause there's a big difference between lets say 0.5s and 0.51s ( 0.5s = 500ms ) (0.51s = 510ms)

    So 0.5s is 120 beats per minute

    ...and 0.51 is 117.64 beats per minute

    so its a big difference that is very audible (noticeable) when it comes to music

  • Soulmachine be so nice 2 test this 4 me ?

    https://www.dropbox.com/s/jva90n2bq76qt ... .capx?dl=0

    Hello!

    Interesting capx <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    I did some testing, but only on my computer, in the Chrome webbrowser. Forgot my phone at my neighbour. I can test on it also later if you want?

    -

    I've been thinking and I think if I round my value to the nearest 10th I can get a pretty good result.

  • The average is pretty stable, no ?

  • Yes it is pretty good

    I'm working on my real app right now and I think I got a good result both on the Computer and touch-devices.

    ...Using the "wallclocktime" seems to work the best.

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