How to find minimum and maximum values in a buffer

i.m.klif's icon

Hi,

I need to find minimum and maximum values of individual channels of a buffer~.

So far I tried using javascript but am getting inconsistent values. Realtime measurements are out of questios because of the way the patch works. I would appreciate if anyone can help with this because, although I am using max for 30 years, my gen coding skills are zero.

Ivan

lennox's icon

I don’t know about gen. But I have been working on a similarproblem. I use a buffer to “store” transients generated by the aubio extension and want to cycle through them one at a time. I am uzi banging samples to [peek~] and gating the Uzi when I hit a >0. But I’ve been struggling with finding something smooth either aubio is making too many slices (doubling up?) or I still don’t have the right syntax for what I want yet.

my point is, oftentimes for this particular application I question why I don’t just use [coll] instead… a buffer is just an array so it’s almost the same thing… I just like the convenience of visualizing/zooming the buffer for what I’m doing and making my own gui would be pita. Imo vanilla arrays like coll or dict are way more powerful than what buffer~ can do alone, as convient am object as it is.

also it sounds like you should check out [change] or [thresh]?

florian1947's icon

good old mxj buf.Op

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

i.m.klif's icon

Thank you Florian! That is it!

Lennox, thanks for your contribution. In a meanwhile I used minmax~ and play~ to play a sample once and get min and max values. As I use short samples this was a usable solution for me.

Ivan

Sébastien Gay's icon

Not gen. But wouldn't something like this work ?

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

Nodanoma's icon

I really don't understand why Max no longer shows its users the Java implementation, like mxj buf.Op mentioned above. It does things other objects simply cannot and there is no longer a way to find the helpfile from where the Max patch was copied from. It really puzzles me.

One will only find mxj objects if one knows they exist, otherwise they are nowhere to be found anywhere in the program, anymore… the helpfiles don't work, but they do exist in the application package.

Any ideas why ?

florian1947's icon

Perhaps they'd like to phase it out, because of the overhead involved bridging Max to the Java engine. Or the learning involved to add your own code.

I couldn't help myself, did a speed comparison between buf.Op and Sébastiens patch.

With both long or short buffers, buf.Op always lags equally a few milliseconds behind. Suggesting that the bridge might indeed be the cause.

Depending on usage, this is compensated by the ease of adding own code which executes faster than JS.