Forums > Javascript

Should be simple: How to get a matrix into and out of javascript?

June 11, 2014 | 6:23 pm

Hi All,
My question is pretty simple. How do I get data from a jit.matrix into a javascript (where I will do processing on it), and then how do I output a matrix when I’m done processing? For instance…
In my patch I have a 11 plane jit.matrix with @name "test_table". I fill all cells in all planes with 64. I want to get that matrix into a javascript object.

My code looks like this:
function jit_matrix()
var testMatrix = new JitterMatrix("test_table");
outlet(0, testMatrix); // doesnt work
outlet(1, "final_table", testMatrix); // doesnt work
outlet(2, "final_table",; // doesnt work
But I don’t know what I’m doing, and there is no good documentation… The jitter javascript tutorials don’t really ever cover this, except for very briefly, and there are no explanations.
Any help is greatly appreciated!!

codedorf out.

  • This topic was modified 1 year by  codedorf.
June 11, 2014 | 11:02 pm

It is possible to access data in a matrix using the getcell and setcell instructions. There is the jstable-example.maxpat in the jitter-examples/javascript/other folder that shows how to use them. Remember that with matrices, not the actual data, but references are handed. I didn’t try, but outputting the message ‘jit_matrix final_table’ might do it.

June 12, 2014 | 6:54 am

i’ve attached a basic example of two ways to reference a matrix using javascript.

June 12, 2014 | 12:45 pm

Thank you thank you thank you both!
Although I’m still confused on how exactly javascript and jitter work together, the example helped immensely.

One question I had was: what does the frommatrix method do? I don’t see the frommatrix method in the list of methods for the JitterMatrix object here:

where did the method come from if it’s not on the list?

  • This reply was modified 1 year by  codedorf.
  • This reply was modified 1 year by  codedorf.
June 13, 2014 | 10:14 am

it’s a special method of the JS JitterMatrix object.
check out jitter tutorials 45 and 46.

June 25, 2014 | 10:42 am

Go to this link.May be it helps you to an extent.
For more web applications visit at:

June 25, 2014 | 11:14 am

Thanks guys –
I was able to successfully do what I set out to do with javascript. I wish there was more official information on how to use jitter & javascript, but oh well, glad there is at least a forum (& helpful community members) to help out with this kind of thing.

– Codedorf out

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

Forums > Javascript