measure mouse drewing to metronome?

R_Gol's icon

How is possible to do the following?

a subject is hearing a metronome in the speaker and he should moving a mouse on a circle on the screen. How can I measure how much he in sync with the metronome he is hearing?

Source Audio's icon

depends on what you take as measurement

large dial set to 360 degrees and no clip could help you ...

R_Gol's icon

depends on what you take as measurement


Max Patch
Copy patch and select New From Clipboard in Max.

How can I take the x y values of the dial and compare them with the input value of the mouse?

Wil's icon

No need for mousestate

He means just bang the dial every time it makes a rotatoin

every bang should match the metronome

add a sound to button

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon

Will is right, but ...

dial as GUI object can not report matched value when moved fast.

no way.

you need something like this

P.S which would work only if your users move the mouse CW, not CCW.

R_Gol's icon

Thank!

P.S which would work only if your users move the mouse CW, not CCW.

Is there a way to make it work also if moving CCW?


assuming I have metronome going 60 BPM. how can I calculate the sync of the user moving that dial over x time frame (lets say 1 minute)

later I would like to convert this patch to work with screen sensor that the user will move his hand on a screen in circular movement

Max Patch
Copy patch and select New From Clipboard in Max.

Edit: maybe something like this to calculate the difference between the metro time and user time?

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon

no matter if circling with mouse or finger,

it is difficult to follow metro, even at very slow speeds.

What do you mean by detecting both directions ?

what do you want to use to detect full circle movement ?

What measurement do you want to accept as a trigger ?

think first then ask

when you sorted that and have a workable trigger,

you will compare deviation between metro bang and trigger

and write that down into a list, coll, whatever.

later you can make calculations

R_Gol's icon

What do you mean by detecting both directions ?

You said it work only when user moving dial CW. I wonder if it can be also CCW?

what do you want to use to detect full circle movement ?

The way it is working now when moving CW is good. could it be also CCW?

What measurement do you want to accept as a trigger ?

what do you mean? one input is the constant tempo bangs on x intervals. The other is the bangs from the user when finishing full circle

Source Audio's icon

ok, one can detect either direction but not both.

otherwise user could just pass the point back and forth without circling at all.

woud that be acceptable ?

best would be to use signal based detection.

Max Patch
Copy patch and select New From Clipboard in Max.

R_Gol's icon

woud that be acceptable ?

This is great!

what regarding calculate sync to metro in specific time frame?

for example metro running at 50 bpm for 1 minute. How to calculate the sync between user moving the dial and the metro time ?

Source Audio's icon

patch above accepts both directions per switch,

but does not prevent users from crossing 359 <-> 0 turn point repeatedly

and so trigger without making a circle at all.

That would need a bit more complicated mechanism.

Here is a patch that does it and also measures metro - trigger timing.

Max Patch
Copy patch and select New From Clipboard in Max.

R_Gol's icon

Thank you very much! I will experiment with it

R_Gol's icon

What does the jump between samples means?

is it possible to get the difference between metro and user every sample?

what should the calculate be for average number between metro and user?

how this patch can be extended for sensor?(user moves hand on screen) assuming it is not possible for user to drew perfect circules in specific diameter. Also this could also work if user asked to drew 8 sign instead of circles?

TFL's icon

how this patch can be extended for sensor?(user moves hand on screen)

If you want gesture recognition you probably need either something like a Leap Motion controller (hands only, low range, high precision) or a simple camera + one of the google MediaPipe for Max (either full body or hands, high range, low precision) as a sensor, and probably some machine learning stuff like the Wekinator app, or ml.star of FluCoMa Max packages to learn and recognize gestures.

R_Gol's icon

Is this not possible to make from exciting touch sensor that is output x and y coordinates?

Source Audio's icon

jump between samples mean user did not

make a circle for THAT metronome count.

That's why it is left out.

R_Gol's icon

jump between samples mean user did not

make a circle for THAT metronome count.

That's why it is left out.

make sense! Any idea how this could work without garbing the dial shaft with mouse rather "drawing" circles or eights on a touch screen?

Source Audio's icon

No idea.

TFL's icon

Is this not possible to make from exciting touch sensor that is output x and y coordinates?

Yes! If you have the source input figured out then you miss the gesture recognition part (see my previous message for suggestions for this task)

R_Gol's icon

if I'm placing an eight or circle figure on the screen and measure is x and y points. I then can to compare the user movement on that figure without the need of gesture sensor?

is the above could be a way of achieving that task?

TFL's icon

Ah, if the gesture is supposed to be done in a given amount of time and is limited to a given path drawn on the screen, it indeed simplifies a lot the problem, and you can probably handle the math yourself.

R_Gol's icon

How can I output the mean value of those value in the coll object?

I could just use the mean value as in the below example but this will not take into consideration a missed rounds.

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon

as first you could calculate percentage of missed counts.

Say you managed 37 % of metro clicks

then you coud split too early and too late hits

and display average deviation for both

or if you don't want that, then use abs.

in any case you need to dump coll

into whatever your calc is.

my answer is based on you question how to output mean

(which is average) value from coll.

R_Gol's icon

as first you could calculate percentage of missed counts.

How to do so?

Source Audio's icon

divide counter number with coll length,

then multiply by 100

gives you success percentage.

wonder how to get missed percentage ?

R_Gol's icon

divide counter number with coll length,

then multiply by 100

gives you success percentage.

Like this?

Max Patch
Copy patch and select New From Clipboard in Max.

wonder how to get missed percentage ?

Of course!

Source Audio's icon
R_Gol's icon

where those wires are coming from?

Source Audio's icon

counter

split comes from interval

R_Gol's icon

Thanks!

so blue data is average time gap only in success rounds(?)

red data is average time gap in total(?) so also rounds without finishing it count it?

green data means the total time in presentage I was not in sync?

Source Audio's icon

no.

Red is average of too early, blue of late hits.

(in case you kept that yellow inverter)

percentage has nothing with time, but with number of hits.

If there were 100 metro clicks, and only 66 entries in coll,

then it is 66 % success and 34 % of missed clicks.

R_Gol's icon

regarding the yellow inverters - now it blocks some of my hits for some reason. Could it be?

meaning I'm finishing a round with the circle but I hear no click and no new data is writing into coll

maybe something is wrong in my patch:

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon

no, it has no influence on missed hits.

But maybe you did not understand the logic arround

circle direction ?

One has to make 25 points in right direction to open the gate.

that number can be increased for strict rule enforcement.

I don't use your patches simply because you allways route patchcords,

which makes it difficult to follow.

here is my version of initial patch with added inverter and average calculation.

Max Patch
Copy patch and select New From Clipboard in Max.

R_Gol's icon

One has to make 25 points in right direction to open the gate.


why is that? I did not understand the rule of that?

why not to calculate constantly?

Source Audio's icon

because user can do lazy movements left and right

crossing the 0 point without making a single circle.

read again my post from

May 13, 2025, 9:13 AM

why am I posting this stuff at all .... ?

R_Gol's icon

why am I posting this stuff at all .... ?


Your help is so great I can't explained how... Thanks!

because user can do lazy movements left and right

crossing the 0 point without making a single circle.

OK I'm getting it now!

R_Gol's icon

how to add a countdown of x clicks before measure is actually starts? so user can be ready?

Edit: I'll find my way