if time between two presses is less then 1000ms count; else bang

R_Gol's icon

how can I do the above?

I have a toggle then sends either 1 or 0.

if the time between two 1 is more then 1000 ms - then count

else (less then 1000 ms) output bang

I think I have the solution but I wonder if there is a better one?

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

Roman Thilenius's icon

looks good. i am using gate instead of select, but that is not shorter or more effective.

R_Gol's icon

the only issue I notice is that if I am pressing two fast presses - the first press will go to the left(to the counter) and the second press will go to the right (bang). How can this be change so it won't count the counter if the two press are within that time limit ?

Sébastien Gay's icon

Does [change] make any real difference in your patch ?

I always have difficulties understanding something like this (as per the right/left priority rule, shouldn't the "end bang" arrive first ?) :

I came up with this proposal :

Source Audio's icon

you don't state what should happen with very first toggle = 1 ?

if you use timer it will allways be quite long.

it you then have 2 fast toggle hits, then both count and bang will trigger.

maybe you need some interval of inactivity which then ignores first result ?

even fastest possible hits can not produce problem that you describe,

only if period of inactivity is > 1000

R_Gol's icon

you don't state what should happen with very first toggle = 1 ?

if you use timer it will allways be quite long.

it you then have 2 fast toggle hits, then both count and bang will trigger.

True - first I though the solution @Sébastien Gay gave is what I was looking for but now I'm not sure as it is forcing the performance guy to hit twice the toggle in order to make the count (and wait more then 1 sec between the two presses

Andy Maskell's icon

This is another way to do it, although i'm a bit confused whether you want to (BANG) if the interval between two clicks is less than 1000ms (this example) or more than! If you want it the other way around then reverse the connections of the red and green cords:

Max Patch
Copy patch and select New From Clipboard in Max.
R_Gol's icon

@Andy Maskell that is perfect!!

Roman Thilenius's icon

to solve the initial status / reset function problem in such a system, look at it independently from the rest.

Source Audio's icon

I think original question must have been wrong,

because Andy's patch seems to work perfectly

but it does not do what was asked -

progress counter if 2 Toggle = 1 hits are more than 1000 ms apart

and bang if they are shorter.

timing between occured events means looking at the past events.

lets say

1a ~ 250ms ~ 1b ~ 1200ms ~ 1c ~ 100ms ~ 1d ...

what should above sequence produce ?

If we ignore 1a, 1b & 1d should produce bang, and 1c hit counter

Andy Maskell's icon

I struggled to understand the original post myself as the topic heading and the description appear to say opposite things. As the original suggestion used a toggle but only sent the active state messages through to the timer, I just replaced it with a bang button instead for simplicity.

What my routine doesn't address is what happens if there is a stream of 2 or more triggers that all occur at less than 1000ms intervals. This modification addresses that:

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

Anyway, I appear to have satisfied @R Gol.

PS: I've realised that the connection between the right output of [cycle] and the (set 0) message in my original patch didn't need to be there as this is implicit in how [cycle] works in the default mode.