[PD] d-median (a running median) + d-for (a for loop)

Damian Stewart damian at frey.co.nz
Thu Oct 16 01:43:57 CEST 2008

hey list,

here's [d-median], a 'running median' abstraction i put together today. 
it's pure-Pd, for your PDa/Palmpilot/iPhoning pleasure. it outlets a 
running median of the last n values sent to its inlet.

internally, it maintains two arrays - one a sorted list of values, the 
other a table of the timetags associated with each value. when you pass it 
a new value it increments the current timetag, finds the 'oldest' value in 
the list (the value with the current timetag) and removes it, and inserts 
the new value in-order, attaching the current timetag. this is implemented 
as a single pass through the array, doing the smallest number of copies 
possible, so it's fairly efficient.

also included is [d-for], a C-like for loop based on [until]. you can say 
[d-for 0 20], bang it, and it will outlet sequentially 0,1,2,...,19. you 
can also say [d-for 0 20 2] to increment by 2 instead of 1, or even [d-for 
0 1 0.1427] (negative increments are not supported unfortunately). and just 
like in C, if you say [d-for 1 0], nothing at all will be output. there's a 
debug mode as well, which allows you to step one iteration at a time - 
great for debugging code that is based around the [d-for]. have a look at 
the help for examples.

working on additional documentation for the dlib - everything in here is 
documented... comments appreciated.

damian stewart | skype: damiansnz | damian at frey.co.nz
frey | live art with machines | http://www.frey.co.nz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: d-median.tgz
Type: application/x-gzip
Size: 5568 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20081016/a2912c48/attachment.bin>

More information about the Pd-list mailing list