Calculating minimum and maximum values from a single input

Bernard Dolecki's icon

Hello all,

I am trying to solve a dilemma that seems to require some sort of math based operation.

Here is what I am doing:
I have a heart-rate sensor from an Arduino printing to serial a beat. This beat I have incoming into Max no problem. One element of my patch will be to use this number to make a visualization beat to the users heart-rate. I hope to create a more standardized visual that updates with changes in user or changes in heart-rate.

My question:
How do I take ONE number, that refreshes like 100+ times per second, and get a 'recent' average of this number for say over 5 seconds. More precisely, I hope to get a minimum and maximum values. These values I will then port into a scaler to effect elements of a jitter visualization.

Floating Point's icon

use zl stream to make a continuously-updated list, then just use the min, max, and mean objects

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

Bernard Dolecki's icon

Thank you!

I read up on the elements you posted and I really don't understand why inserting "stream" is needed. I understand by inserting it it acts as a limitation, but somehow oddly enough the act of adding it also seems to change the class of the zl object itself? For now I will just use it blindly I suppose, haha!

Floating Point's icon

that's right, zl has many modes of operation-- you have to explicitly state what mode you want, so the word "stream" is an argument of the zl object. Here's a simpler example of how it works:

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

Roman Thilenius's icon

zl is somehow special here, it wont operate unless it is given an argument for its modes.

that is why since max 6 you are also allowed to type [zl.stream] and call the different modes by a single object name.

for max4 and pd you still have to use messageboxes or coll to do the same ;)