XML Feeds

.

[java-dev] Re: Jitter in mxj

Andrew Robertson andrew at moceanic.com
Tue May 6 12:12:01 MDT 2008


Hi,

As an update - here's the code. I get the dimensions 307200 (=240*320*4) for the return of copyMatrixToArray, but it doesn't seem to work right. If I try printing out a value of my new array, I always get -1. I've tried both int and float[] arrays.

Any ideas?

Andrew.

//////////////


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

public class jitter_sub extends MaxObject
{
	JitterMatrix output1 = new JitterMatrix();
	JitterMatrix output2 = new JitterMatrix();
	JitterMatrix start_output = new JitterMatrix();
private int planecount = 4;

	public float[] store_array = new float[307200];
private int index = 1;	

	public jitter_sub(float gain)
	{
		declareIO(1,2);
		setInletAssist(0, "input (matrix)");
		setOutletAssist(0, "output (matrix)");
	}
    
	public void jit_matrix(String mname)
	{

if (index == 1){
		output1.frommatrix(mname);
		
		//insert processing here
		


int[] my_dim = output2.getDim();
post("Jitter matrix dim : rows "+my_dim[0]+"  cols "+my_dim[1]);


//int[] copy_array = new int[my_dim[0] * my_dim[1] * planecount];

int copied_elts = output2.copyMatrixToArray(store_array);
post("elements "+copied_elts+"  Array copied "+store_array[100]);

Atom[] my_cell = output2.getcell2d(0,0);

post("My cell "+my_cell[0]+"My cell1 "+my_cell[1]+"My cell2 "+my_cell[2]+"My cell3 "+my_cell[3]);
index = 2;

		outlet(0, "jit_matrix", output2.getName());


	}
else{
	output2.frommatrix(mname);
		
		//insert processing here
		
		outlet(0, "jit_matrix", output1.getName());
index = 1;

}

}

public void bang(){
start_output = output1;
post("Stored matrix");
		outlet(1, "jit_matrix", start_output.getName());
}

}





More information about the java-dev mailing list