One list comparision with several lists

IvnOs's icon

Hi.
A little bit stuck with lists.

I want to do something like this:

If [list_0] equal [list_1]
Then (set 1)
Else
If [list_0] equal [list_2]
Then (set 2)
Else If [list_0] equal [list_3]
Then (set 3)
Else (set 4)

Lee's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Here's a simple solution which should give you an idea...

Lee's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Another one, bit more easy to expand and configure

Richard Garrett's icon

Hi,

this is just a variation on Lee's work using uzi.

I think it's nice to use zero as the output if there is no match.

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

Richard

Roman Thilenius's icon

i would use expr (as we know)

[zl compare] [zl compare] [zl compare] [zl compare]
[expr ($i1=1) + ($i2=1)*2 + ($i3=1)*3 + ($i4=1)*4]

this, as well as the solutions by the others, wont work when more than one condition is true.

-110

IvnOs's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Thanks all.
I think the best solution for me is to use 4 [zl.compare] with [expr].
But it's all not so good... None of the algorythms is working with my setup, because of some bug, or i don't know.
[zl.compare] somehow is not comparing complex lists even if they are equal.
But with simple lists everything is ok.
Here is example.

Floating Point's icon
Max Patch
Copy patch and select New From Clipboard in Max.

it looks like it's got something to do with rounding error in floating point representation in max.
here's a version which 'works', if the magnitudes are rounded to the nearest 1/64 (-36db error)

IvnOs's icon

Thanks, for help. I thought about that this problem is with lists in message boxes which are already rounded.

Emmanuel Jourdan's icon
Max Patch
Copy patch and select New From Clipboard in Max.

And if you're just interesting in finding the closest list, you can use zsa.dist:

IvnOs's icon

Sorry, Emmanuel, but my max4live version is not supporting this library even in 32bit compatibility mode.

Floating Point's icon

use this expression to truncate the rounding error to 6 decimal places
vexpr int($f1 * 1000000.)/1000000.

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

this will give you a -140db error

eltopo's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Hi

Emmanuel Jourdan's icon

@ivnos it should work both in 32 or 64 bits. At least that's what I'm seeing here using the latest versions of Max, Live and zsa.descriptors. Feel free to contact me if you're still experiencing some problems.

IvnOs's icon

Floating Point, thanks again, but your previous variant were enough. =)

eltopo, sorry but i don't understand your patch.

Emmanuel, sorry, forgot to install it properly (forgot to copy it into packages).