How to detect when a flow of messages stop?

Joseph Nagy's icon

I want to be able to set a value back to an initial state of zero whenever a flow of numbers stops being sent. What would I use to check for this?

Bill 2's icon

[delay]. Every new bang cuts off the one being delayed, so nothing is output till the delay time is reached.

Joseph Nagy's icon

I think a metro is needed to check if the delay time is reached? How could I do this with just a delay? Delay will send all the bangs at a delayed time regardless of how many are coming in, to my understanding none of these bangs are cut off, so it's always being sent.

Joseph Nagy's icon

I know having a delay will end up setting the value back to zero, but want to know if there is a function that will only bang once after it detects a flow of data has stopped.

Bill 2's icon

I'm not sure exactly what you're after. Unless I'm missing something [delay] does what you've described. Can you post your patch?

EDIT: Oops, I missed your 2nd post. From the documentation: Only one bang at a time can be delayed by delay. If a bang is already in delay when a new bang is received in the left inlet, the first bang is forgotten. HTH.

Roman Thilenius's icon

if there is a function that will only bang once after it detects a flow of data has stopped.

one might think that it is required to have something steadily sending out the other state, but this is not case.

if you just mix the data stream (saying "hi, i am present") with the state the delay object reports ("data stream stopped now"), these two will not interfere:

#P button 249 304 15 0;
#P button 49 305 15 0;
#P window setfont "Sans Serif" 9.;
#P number 151 357 49 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 221 263 77 9109513 t 0;
#P newex 75 262 77 9109513 t 1;
#P newex 221 173 77 9109513 t b;
#P button 120 79 38 0;
#P newex 221 221 77 9109513 delay 500;
#P connect 4 0 5 0;
#P connect 4 0 7 0;
#P connect 3 0 6 0;
#P connect 3 0 5 0;
#P connect 1 0 3 0;
#P connect 1 0 2 0;
#P connect 0 0 4 0;
#P connect 2 0 0 0;
#P window clipboard copycount 8;

Joseph Nagy's icon

I put some comments in it to try to explain what I want

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

Bill 2's icon

As Roman showed, [delay] needs a bang. Floats don't get delayed. Maybe that was the missing ingredient?

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

Joseph Nagy's icon

Ah yes this was it, everything seems to be working as I want now, thank you very much!

Pedro Santos's icon

For me, the easiest method would be to use:

bang
clocker 1000
sel 1000
message "0"

(assuming 1000 ms of no input)

Joseph Nagy's icon

Thank you Pedro, I will look into using this as well!