Forums > Jitter

How do I copy one matrix to another?

Sep 02 2010 | 10:18 pm


I’m just having a first stab into using Jitter as a way of buffering output to a Launchpad. That is I have two 2D 8×8 matrices.

I ‘render’ the state of the button matrix into one Jitter matrix then compare each cell with a second ‘stored’ matrix outputting updates to the Launchpad for cells that are different in the rendered matrix.

At the end of the process I need to copy the ‘rendered’ matrix into the ‘stored’ matrix for use next time around.

I went looking for an object that would copy a matrix but couldn’t find anything. Is there such a thing? Or do I need to iterate & copy by hand?

In the same vain my method for finding updated buttons is to jit.iter the rendered matrix and compare with the equivalent cell in the stored matrix. Is there an easier path to this that outputs the differences between two matrices? I saw jit.change but that seems just about the degree of change, not the actual differences.

Any help would be much appreciated.



Sep 02 2010 | 10:47 pm

Looks like a combination of jit.spill & jit.fill can do the job more easily than manually iterating.

But maybe there’s an easier way still?


Sep 02 2010 | 10:56 pm

Hi Matt,

Could you post what you have so far? Maybe that will give me a better idea of what you are up to.


Sep 03 2010 | 5:53 pm

you could use [jit.op @op -] —that should tell you the difference on a cell-by-cell basis. maybe you’ll need an absolute value there too, not sure.

For copying, I’m not sure… could you do a workaround with [jit.submatrix] but just use the whole thing? seems weird though.

Maybe a message to a matrix: copymatrix @sourcematrix
would copy the source matrix to the one you’re sending the message to. feature request? probably I’m missing something though.

Sep 03 2010 | 6:49 pm

To set matrix B to have the contents of matrix A, you simply send A to B. (More specifically, you cause matrix A to send a ‘jit_matrix’ message to matrix B.) The trick, though, is to suppress thruput on matrix B by setting its @thru attribute to 0 (it’s 1 by default), so that you can set and recall its contents independently.

So if matrix A is the one that has the most recent Launchpad settings, and matrix B is the one that has the previous Launchpad settings, you can bang matrix B to get it to send out the previous settings, compare those to the settings of matrix A, and then set the contents of matrix B to be those of matrix A. Something like this (note that matrix B has @thru 0):

-- Pasted Max Patch, click to expand. --

Sep 03 2010 | 10:02 pm

what I do for comparing long lists or matrices is simply add them together and then modulo. That gives you a "toggle" function that can be set up for any number of stages. Quite handy.

Sep 04 2010 | 12:03 am

@wetterberg can you elaborate a bit with the modulo? wondering how you’re doing that and what you get from it. always interesting to hear new tactics…

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

Forums > Jitter