[PD] mapping variable-length lists to a fixed length one

tim vets timvets at gmail.com
Thu May 24 10:02:47 CEST 2012


thanks for the suggestions, here's the solution I came up with.
gr,
Tim


2012/5/22 Claude Heiland-Allen <claude at goto10.org>

> On 22/05/12 02:13, tim vets wrote:
>
>> I have lists of floats from measurements which vary in length
>> (they grow with the duration of the measurements)
>> What would be a good way to map those to a list of, say, 150 items?
>> In concreto:
>> -When variable list A has 15 elements and fixed list B is 150 long,
>> I can simply repeat each value of A 10 times to get a 150 elements list.
>> -When list A has 1500 elements, and B 150, I could take list A 10 elements
>> at a time,
>> and write the averages thereof to list B.
>> but how do I generalize this for _any_ length of list A?
>>
>
> look into resampling, eg libsamplerate[1]
>
> when #A > #B you want to low pass filter to antialias when downsampling
> when #A < #B you want to interpolate     to antialias when   upsampling
>
>
>  and how do I patch this up in pd? :)
>>
>
> very temperamental/buggy version attached, especially the filtering is a
> bit rubbish in this one - it just uses a couple of simple causal lop[2]
> instead of doing it properly
>
> for upsampling, tabread4 does one kind of interpolation (but you might
> want to use a different interpolation function, refer to the list archives
> about tabread4c etc)
>
> for downsampling, you might want an acausal filter (like an image blur
> that works in all directions without shifting the image sideways) - most
> audio filters are causal (one direction only - the direction in this case
> is time, and the future can't influence the past, so there's some delay)
>
> you might want to store statistics too, depending on the type of data (eg:
> in an audio scope like audacity you can see long-scale peaks/troughs even
> though the average antialiased visible signal would be a line at 0 assuming
> no DC offset) - you might pick up some ideas from the description of
> zoom-cache[3]
>
> [1] http://www.mega-nerd.com/SRC/
> [2] http://en.wikipedia.org/wiki/**Low_pass_filter#Discrete-time_**
> realization<http://en.wikipedia.org/wiki/Low_pass_filter#Discrete-time_realization>
> [3] http://hackage.haskell.org/**package/zoom-cache<http://hackage.haskell.org/package/zoom-cache>
>
>
> Claude
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20120524/5b09d5d5/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: list-resample.pd
Type: application/octet-stream
Size: 1805 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20120524/5b09d5d5/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: list-resample-help.pd
Type: application/octet-stream
Size: 3645 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20120524/5b09d5d5/attachment-0001.obj>


More information about the Pd-list mailing list