MatrixCtrl data to Javascript

Graham Dunne's icon

Hi there,

I'm working on a CA patch for a uni project and I'm trying to figure out how to get the list data from Matrixctrl into Javascript in order to transform each active point into a bang. I'm trying to get to grips with Javascript asap at the moment. I think I need to create Arrays and then a list of if statements perhaps? What I'm not entirely sure how to do is get the data into the js object to input into matrices. Am I on the right track?

Thanks,

G.D.

Graham Dunne's icon

Actually I've found a lot of useful information in the javascript examples section. Working on it!

G.D.

Graham Dunne's icon

Well look, here it is - does anybody actually know if it's at all possible to simultaneously bang the output from a matrixctrl, then store and sort the cell values in javascript in order to send individual bangs/events out of the javascript object?

It's a question, the answer to which I just cannot find, nor do I have the programming capacity to come up with the code if it is possible. I can only get individual cells to do anything, such as a simple print to the Max window function when I click on a cell.

Thanks.

G.

Luke Hall's icon

What do you mean by "transform each active point in to a bang"? I'm not really sure what you're asking for. Could you post a patch that might help me see what you intend. Or even a few examples of what you'd send the javascript object and what you want it to output.

Graham Dunne's icon

Hi Luke,

Thanks for your reply. I've got a CA patch that works (I got it from here somewhere) and I can output the matrixctrl data into a matrix~ object but this seems like a waste to me. I'm trying to figure out how to let each live cell trigger its own event, be it a bang or a frequency or whatever. I'm looking for ways to map really,other than operating a multi gate like the matrix~ object. I thought if I used javascript I could do things like if 0,0 has value 1 then do this, if 0,1 has value 1 etc.. So for each iteration each cell is checked for on/off. Have been checking out bits of code from the forum (probably some of yours too) and all do different things but not that.

I'll upload stuff later, gotta run

Graham Dunne's icon

Here's a sample patch. I've not included a js file because it just wasn't happening.

Graham

2682.c.a.Example.maxpat
Max Patch
Graham Dunne's icon

Here's another with a visual example of the intended javascript function.

2683.c.a.Example2.maxpat
Max Patch
Luke Hall's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Something like this which numbers the cells left to right and top to bottom?

Graham Dunne's icon

Hmm..yes..exactly that. And the same procedure could be applied to the jit.iter object using zl join. Very clever!

As a matter of interest, do you think there's a js solution?

Many thanks, I've been stuck on that problem for a little while now.

G.

Luke Hall's icon

Disclaimer: not tested, but should at least give you some clues.

`outlets = 16;

function list (x, y, state) {
if (state) {
outlet(y*4+x,"bang");
}
}

You could even set the dimensions that the js will work with using arguments.

Graham Dunne's icon

Brilliant!