A way to count peaks
I am looking for a way to count peaks from a sensor output during a period of observation. I can do this using excel if I capture all the data and then run a formula but I wonder is there a way to do this directly in Max.
an example - the data outputs through a Float, with sensor readings every 20ms, I need someway of counting a peak, but then also new peaks as they occur, the peaks do not have to be greater than a prior peak.
the difficulty is the peak is not known until subsequent readings have been taken so I guess it would need some way of holding on to values. I would like to filter out fluctuations in readings - in my excel format I use an array to do this with an offset value. so I am happy to take a maximum peak frequency of 500ms to 1000ms or so.
any ideas?
here's one way (there's a million ways to do this, and depends on the nature of the data and what you want to do with it)
basically, get the running average of the data, test to see if it is above the average; then test to see if it's on a down-turn (must have just peaked); send out a bang if it fulfills these two criteria.
this is just a starting point: best to tweak and modify according to your needs
Thanks, that seems to work pretty well and nice and straightforward. Do I need to have all of the sliders etc in - is that just for display or does that aid its function. My current patch is already quite CPU intensive so trying to reduce the amount of activity. as I would be looking at the peaks of about 6 readings.
Thanks
No, the multisliders are just there for illustration, but also useful for when working out how to analyse the actual data or for diagnostics/tweaking of course
Cool, I'll have a play around once I've finished my masters write up.