Forums > MaxMSP

matrixctrl and change

August 18, 2009 | 11:39 am

i would like a matrixctrl object only to output if a value changes.

so, if the top left button is lit, sending "0 0 1" will not output anything, but sending "0 0 0" will change the value and output accordingly.

any way to achieve this?


August 18, 2009 | 11:45 am

Have a look at [zl change], it is like [change] but for lists.

lh


August 18, 2009 | 12:03 pm

well, but i would need one [zl change] object for every cell in the [matrixctrl], plus the need to organise the data-flow suitably.

i’m looking for a nicer solution.


August 18, 2009 | 12:11 pm

The patch below blocks sending repeated lists, try clicking on some cells and then hitting the message box above the [matrixctrl] to re-send the last value, notice that it isn’t printed. Is it not what you are trying to achieve?

lh

– Pasted Max Patch, click to expand. –

August 18, 2009 | 12:21 pm

in this case i would like the output to read:

print: 0 0 1
print: 1 2 1

– Pasted Max Patch, click to expand. –

but it doesn’t, [zl change] does not help here.

as i said, to use [zl change] i would need one per cell in the matrix


August 18, 2009 | 12:57 pm

Ah now I see. You want it to be aware of all [matrixctrl] states and not just the previously sent one. Here’s a javascript that should work if you load it into a [js] and give it the number of rows and columns in your [matrixctrl] as arguments. I hope it helps.

lh

// lh.mchange

var rows = jsarguments[1];
var cols = jsarguments[2];
var mem = [];
clear();

function clear() {
    for (i=0; i

----------begin_max5_patcher----------
513.3ocyVssaiBCD8Y3qvBsOlE4KPbx919cTUsxE7RbEXhvNpY2p9uu9BzRx
l1RI.sufkGF64bNimw9wvfn6pOxUQfe.tADD7XXPfyj0PP67fnJ1wrRlx4Vj
j+P8c2Gsx+KM+n1YdeiPp6rJOTIjkbsaEnVi6Y5rcBYwuZ3YZeDonX3J.Zap
cfjX+hgwPvssK420RsjUwcQ3mMBVYuHTeP2EBXO+Uh+57Ggi6LKxcafA1eOk
DYs8TXn8ypqiy2q.k6hqx1wjEbPBXyH4Ok3FfoiV.5hg2j9O649.DEcxV81Z
SxlwnM55hhR9Gk4n0NxtF1Q4yH9.om8L2yqoOUnKGU7IwYiIoKXRAsYVoxnp
8p3JEqf+eEeD.F7MzEoH9cO2swV..Rbcbrj9yofircJEDz3DDeN+KhfPmRAA
BfiPP7kyeQzizoTOxJ4rlOpbfw3WzCB8yUOPiqfgoaDGyzMki79Y+EyHhqi3
50uZGQ7qwwRgx71n1wK0ZD2mWNGL9JO+gYNDZseJYU0GZx5BUqLsB7BHy4Js
PxzhZYOmvm3yNQdNW1+sTUh780lV4sX.SPwoVsveb.97DvsWLkLTrZNhO4X8
Jgj4dp2GRlVUKJlFhLclVN6XhNDLscQwDd.Px7N2kDRD5zeBGgoyS03Lz4.Q
SlErdVZ7xXMkbE4ZyjmB+GPWJ2V+
-----------end_max5_patcher-----------


August 21, 2009 | 2:25 pm

This trick using pattr comes in handy for most UI objects without a dump…
The deferlow is necessary because the order of execution seems different for sending list and clicking into the matrixctrl…

– Pasted Max Patch, click to expand. –

August 21, 2009 | 4:03 pm

very interesting.

the matrixctrl will dump everything on a bang, but with pattr it’s in a different form and happens when any change is made, without needing a bang.

thanks.


August 21, 2009 | 4:06 pm

and i’m not using it for interface so don’t need the deferlow!


August 23, 2009 | 3:57 pm

found a hiccup with this.

sending a "clear" message to the [matrixctrl] outputs weird stuff when going via [pattr], not sure exactly what’s going on yet, but it breaks the solution for me Sad


August 23, 2009 | 4:26 pm

Have you tried the javascript patch I posted above? If it didn’t work let me know what happened, it shouldn’t behave any differently when the "clear" message is sent to [matrixctrl].

lh


August 23, 2009 | 5:37 pm

the problem with running javascript is that i don’t really want to be running a bunch of scripts to fix odd bits where max falls short.

if i’m going to be running some js for a patch then i might as well do the whole thing in js. whenever i start doing stuff in code again i wonder why i’m using max because a lot of the time it feels like such a pain (things like right-to-left).

then if i’m just going to do the whole thing in js then why am i even running max at all?!

the js solution is fine but i’d rather stay in max if possible.


August 24, 2009 | 6:51 am

– Pasted Max Patch, click to expand. –

August 25, 2009 | 3:01 pm

what i want to do is retain the functionality of matrixctrl but simply add something that will filter duplicate output.

i don’t want to break any of the functionality of matrixctrl.

i don’t want to offer alternative methods for something like "clear" as a workaround for breaking it in the first place. if i’m doing this then i may as well not use matrixctrl and build the same functionality from the ground up (in js or whatever).

i think this has got it:

– Pasted Max Patch, click to expand. –


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