Forums > MaxMSP

Coder for median~?

June 7, 2007 | 3:51 pm

I noticed there isn’t an object to do median filtering in MSP.
Median-filtering is more expensive as an envelope follower because it
requires sorting, but it’s really nice in that it’s not affected by
sudden spikes in the way that average~ might. (and is really useful as
an adaptive threshold for envelope detection)

Would anyone be interested in implementing a C++ version of a
signal-rate median filter using quicksort or some other type algorithm?
I definitely don’t have the C/C++ chops to knock this one out, but it
seems like it could be particularly useful.

thanks,
Peter McCulloch

http://www.petermcculloch.com


June 7, 2007 | 5:31 pm

On 07 Jun 2007, at 17:51, Peter McCulloch wrote:

> I noticed there isn’t an object to do median filtering in MSP.
> Median-filtering is more expensive as an envelope follower because
> it requires sorting, but it’s really nice in that it’s not affected
> by sudden spikes in the way that average~ might. (and is really
> useful as an adaptive threshold for envelope detection)
>
> Would anyone be interested in implementing a C++ version of a
> signal-rate median filter using quicksort or some other type
> algorithm? I definitely don’t have the C/C++ chops to knock this
> one out, but it seems like it could be particularly useful.

hi,
if you want something like a "running" median, you don’t need a
sorting algorithm.
once the history array is initialized correctly, you just throw out
the oldest sample value, fit in the new value where it belongs (and
move all values in between) and return the middle value of the array,
the median value.

that’s how it’s done in supercollider’s Median UGen. i have
implemented this code in an msp object (sorry, i couln’t find a
maxmsp only solution ;-) ) for a project, but ended up not using it.
so, it is not heavily tested, seems to work alright, though.
contact me off list, if you are interested.
volker.


Viewing 2 posts - 1 through 2 (of 2 total)