How do I Measure time between taps

Get help using Construct 2

Post » Thu Mar 09, 2017 12:03 pm

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 @Soundcloud
B
14
S
2
G
1
Posts: 63
Reputation: 928

Post » Thu Mar 09, 2017 2:29 pm

@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
Find all the Construct 2 games that were on Steam Greenlight here
B
35
S
9
G
7
Posts: 467
Reputation: 6,864

Post » Thu Mar 09, 2017 3:17 pm

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

It may be response time on the device.
Banned User
B
27
S
7
G
58
Posts: 1,229
Reputation: 34,800

Post » Thu Mar 09, 2017 3:33 pm

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.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Mar 09, 2017 5:15 pm

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.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Mar 09, 2017 5:58 pm

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 @OddConfection.
I've tested it on my computer and on my iPhone - and I get different times depending on witch one I use :)

PC -TEST
Image


iPhone - TEST
Image

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.
Soulmachine @Soundcloud
B
14
S
2
G
1
Posts: 63
Reputation: 928

Post » Thu Mar 09, 2017 6:05 pm

99Instances2Go wrote: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 @Soundcloud
B
14
S
2
G
1
Posts: 63
Reputation: 928

Post » Fri Mar 10, 2017 8:27 pm

@Soulmachine be so nice 2 test this 4 me ?

https://www.dropbox.com/s/jva90n2bq76qt ... .capx?dl=0
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sat Mar 11, 2017 12:57 pm

99Instances2Go wrote:@Soulmachine be so nice 2 test this 4 me ?

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


Hello!
Interesting capx :)

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?

Image

Image

-
I've been thinking and I think if I round my value to the nearest 10th I can get a pretty good result.
Soulmachine @Soundcloud
B
14
S
2
G
1
Posts: 63
Reputation: 928

Post » Sat Mar 11, 2017 2:36 pm

The average is pretty stable, no ?
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Next

Return to How do I....?

Who is online

Users browsing this forum: Lancifer and 8 guests