Converting two Jitter matrices into two Java arrays

t's icon

Hi there,

I am struggling with some Max-Java basics...I am an absolute Java beginner

I would like to get two matrices into Java external and convert them into two arrays. Ideally the matrices should have different dimensions.

I know how to do that for one matrix but with two matrices I am stuck.

PS: what I need to do is to compare individual cells of two matrices

Thanks!

t's icon

I am actually already stuck at just getting two matrices inside Java. For instance this is the code from Jitter tutorial 51:

import com.cycling74.max.*;
import com.cycling74.jitter.*;

public class j51matrixinfoexample extends MaxObject {

public void jit_matrix(String s)
{
JitterMatrix jm = new JitterMatrix(s);

outlet(0,"name", jm.getName());
}
}

How to modify this patch so I could input two matrices (one through inlet 1 and another through inlet 2) ?

Floating Point's icon

try this (I haven't tested it but I think this is the way to do it):
[edit--made jm0 and jm1 global]

import com.cycling74.max.*;
import com.cycling74.jitter.*;

JitterMatrix jm0;
JitterMatrix jm1;

public class jtwoMatrixs extends MaxObject
{    
     // just put another "DataTypes.ALL" argument in the declareInlets 
     // method for another inlet
    public jtwoMatrixs(Atom[] args)
    {
        declareInlets(new int[]{DataTypes.ALL, DataTypes.ALL}); 
        declareOutlets(new int[]{DataTypes.ALL});        
    }
    
    public void jit_matrix(String s) 
    {
        //check which inlet the matrix came in
        int inlet_num = getInlet();    
        
        //if it came in the first, call it jm0
        if (inlet_num==0)
        {
            jm0 = new JitterMatrix(s); 
        }
        
        // jm1 for second inlet
        if (inlet_num==1)
        {
             jm1 = new JitterMatrix(s);
        }
    }
    
       public void bang() //bang to see if it works
    {
        outlet(0,"names", jm0.getName( ) +", "+jm1.getName( ));
    }
 }