Forums > MaxMSP

multi dimension array in max

January 14, 2014 | 5:15 am

say I want a 2d array in max e.g.X[3][4]=12
what are my options?

(I’m mainly interested where indexes are numeric, so hoping for a pretty fast fixed storage lookup, doesn’t even need to be a sparse array – though could be)

as far as i can tell its:
a) put a list in a coll/table, and then index list.
b) use dict with a nested dictionary?
c) javascript?

(a) would is limited to a 2d, I could not do N dimensions e.g. X[3][2][10]=14
(b) seems nice, but a bit of overkill, and presumably not very good for performance, as it works with symbols.
c) I’ve not looked into, and not sure i want to add the complexity

have i missed any other options? where are preferred ways?
(whats the coll or table?)

can I pull coll/tables into other coll/tables?

thanks for any pointers
Mark


January 14, 2014 | 5:34 am

Maybe jit.matrix.


January 14, 2014 | 6:46 am

If your looking for examples, here’s a coll version of a 2d 4×4 array.

<code>

– Pasted Max Patch, click to expand. –

</code>

You could also do this patch with a preset obj

<code>

– Pasted Max Patch, click to expand. –

</code>


January 14, 2014 | 7:27 am

Get familiar with jitter… It’s quite the powerful little tool. You can use it purely for managing numbers and doing math. No bouncing basketballs or ducks required.

Anyway, here are a few max examples in the spirit as Rick’s input.

– Pasted Max Patch, click to expand. –

January 14, 2014 | 7:54 am

FTM is your friend and very efficient

http://ftm.ircam.fr/index.php/Main_Page

– Miguel


January 14, 2014 | 8:08 am

thanks… lots to learn :)
I realised i could use a single dimension by calculating index (e.g. z*(X*Y)+x*Y+y), but was hoping for something that had appropriate messages (easier to read code)

Yup, I thought jit objects were for bouncing ducks :) so will take a more careful look obviously wrong – jit.matrix looks pretty ideal – any drawbacks? (given the number of options, is it ‘heavy’, i guess not if its used for video etc)

nth on coll, these looks like it could be what I’m after for 2d.

FTM, ah bumped into this the other day… looks interesting, but Im trying to stay vanilla max initially, just so I can grasp a better understanding of whats there – but will definitely add FTM to my list for looking at afterwards.

special thanks for the examples, very helpful seeing how these things work.


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