Signal Rate/Gen Equivalent of Peakamp~?

J F's icon

Title basically explains it.

I guess part of it is also trying to understand the functionality of what peakamp is doing internally. In the case of a peakamp~ with 50ms, is it taking the peak amplitude from all the values received in the past 50ms, or just the peak amplitude at every 50ms interval? I tried making something similar with averaging in Gen, but it didn't work at all.

I feel like I'm possibly over thinking this, but I definitely could use some help from the greats in this case.

J F's icon

Here's my attempt at it.

I adapted the gen~.minmax, max amplitude portion and set it to reset with an internal counter, but the values don't move in the same way a normal peakamp~ does. It seems like there's some sort of gating present in peakamp~ that only outputs the peak values, whereas in my attempt it outputs all the values. Hopefully someone can make sense of this for me!

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

J F's icon

Got it working!

I thought about what I said after I typed it and realized latch was the key. Peakamp~ and gen~.peakamp seem to be showing identical values at the exact same intervals.

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

grapple's icon

This is awesome! I was just asking about this yesterday. Your solution seems to be working on my end.

Roman Thilenius's icon


if you want to know if peakamp~ reports the current sample value or the maximum value since last report, use audio input of known values and test it. :)