how to stretch or contract a list ?

FP's icon

hi,

i would like to know a method to stretch or contract a list.

a simple example : 1 5 10 -> 1 3 5 7.5 10

i would like to use it to convert 512 to 128 elements.
and also 128 to 512 or 1024 elements.

thx.
f./

Luke Hall's icon

Max can only work with lists containing up to 255 elements. If you want to select every other (or every third/fourth/fifth/...) value from a list try using [zl] objects, you might find

How do you want to calculate the missing values when you go in the opposite direction? The average of the surrounding values like in the example you gave? If you want it to remember other values you might want to try storing the maximum number of values in a [coll] and asking for every other/third/fourth value and then [thresh]-ing them into a list.

lh

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


mzed's icon

Quote: thereishopeforus@hotmail.com wrote on Tue, 05 August 2008 12:53
----------------------------------------------------
> Max can only work with lists containing up to 255 elements. If you want to select every other (or every third/fourth/fifth/...) value from a list try using [zl] objects, you might find

Actually, Max 5 can handle bigger lists. I might do this like so:

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

FP's icon
Luke Hall's icon

As long as your list is ordered numerically then this will work for the "repeat the numbers" version. This example trebles the list. For double or quadruple simply insert/remove "l"s to the [trigger] and [zl join]s underneath. I've got a method for interpolating as well but its not particularly pretty. Would you like me to post it so you can see the method, I'll have another look at it later to see if I can tidy it up a bit.

lh

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

FP's icon

i really need the interpolated version.
does somebody has a solution, please ?

here's a solution for repeated item (using Lobject)

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

--
elt@altern.org
http://pan-etc.net
--

Luke Hall's icon

Ah yes that makes much more sense, I had a look through some of Peter Elsea's other great Lobjects and you might want to look at [Lmerge] as used in the example below. It's still a rather tedious way to achieve the result but it works. In this case it only doubles the list, interpolating one value between each in the original list. If you want to modify it for two values thus trebling the list have a look at [Lmerge]'s interleaf message. You'll have to do some reorganising and I'm sure there's a better way to figure this out.

I hope it helps anyway.

lh

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


volker böhm's icon

On 06 Aug 2008, at 15:29, elt wrote:
> i really need the interpolated version.
> does somebody has a solution, please ?

here is a version that uses linear interpolation to expand the list.
maybe this is what you want.
for shrinking you would have to modify a little.
vb

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


FP's icon
FP's icon

heu sorry. i got it... :-)
thx.
--
elt@altern.org
http://pan-etc.net
--

FP's icon

here's this to resume the three ways to stretch a list.

repeat - padding - interpolate
by the way LPad (from Lobject) doesn't work with float. maybe a bug.
max 463/osX10.4.11

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