Forums > Java

jit.noise generated from Java


efe
December 17, 2009 | 2:04 pm

Hello!
Maybe a super-simple-to-solve question but I haven’t been able to figure this out!. I am trying to generate a simple java class that triggers a jit.noise every time it gets a bang. I have something like this:

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

public class matrixTest3 extends MaxObject{
JitterObject noiss;
JitterMatrix dim1;

public matrixTest3(Atom[] args){
declareInlets(new int[]{DataTypes.ALL});
declareOutlets(new int[]{DataTypes.ALL});
noiss=new JitterObject( "jit.noise", new Atom[] { Atom.newAtom( 4 ), Atom.newAtom( "char" ), Atom.newAtom( 100 ), Atom.newAtom( 100 ) } );
dim1=new JitterMatrix("dimen",4,"char",100,100);
}

public void bang(){
//generate();< ---here's the method call
outlet(0,"jit_matrix",new Atom[]{Atom.newAtom(dim1.getName())});
}

/*
public void generate(){
I am not sure what to put here!
*/
}

So by calling the method generate() i would like to get the random values of the matrix.
Sorry if the question is too basic!
Emmanuel


December 17, 2009 | 2:35 pm

Jitter generators are just special versions of matrix operators, with no inputs, only outputs. Use the matrixcalc method to generate the output matrix. As mentioned in a previous thread (on jit.noise in Java), in Java, Javascript, or C these objects don’t take matrix arguments like their max wrapper counterparts.

Essentially:

noiss=new JitterObject( "jit.noise");
dim1=new JitterMatrix("dimen",4,"char",100,100);
noiss.matrixcalc(null,dim1);

-Joshua



efe
December 17, 2009 | 3:08 pm

Hello Joshua:
thank you for the fast answer. I modified my code following your advice:

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

public class matrixTest3 extends MaxObject
{
JitterObject noiss;
JitterMatrix dim1;

public matrixTest3(Atom[] args){
declareInlets(new int[]{DataTypes.ALL});
declareOutlets(new int[]{DataTypes.ALL});
noiss=new JitterObject( "jit.noise");
dim1=new JitterMatrix("dimen",4,"char",10,100);
noiss.matrixcalc(null,dim1);
}

public void bang(){
outlet(0,"jit_matrix",new Atom[]{Atom.newAtom(dim1.getName())});
}
}

it works but i cannot update the state of the matrix every time i send a bang. Is there any way to do so?

I tried a different approach but this didn’t work(it compiles properly but doesn’t output anything):
import com.cycling74.max.*;
import com.cycling74.jitter.*;

public class matrixTest4 extends MaxObject
{
JitterObject noiss;
JitterMatrix dim1;

public matrixTest4(Atom[] args){
declareInlets(new int[]{DataTypes.ALL});
declareOutlets(new int[]{DataTypes.ALL});
noiss=new JitterObject( "jit.noise");
dim1=new JitterMatrix("dimen",4,"char",10,100);
noiss.matrixcalc(null,dim1);
}

public void jit_matrix(String inname)
{
dim1.frommatrix(inname);

outlet(0, "jit_matrix", dim1.getName());
}
}

Any suggestions?

Thank you for the help!
Emmanuel



efe
December 17, 2009 | 6:05 pm

This is quite strange. I recompiled the external and now nothing happens.
It is saying:
#N: extra arguments for message "jit_noise"
wow, I am pretty lost here.


December 17, 2009 | 7:24 pm

- #N: extra arguments for message "jit_noise"

That is assuredly from your old example where you passed in matrix arguments to your jit.noise object. the new examples should not exhibit that behavior.

The noise is calculated by matrixcalc. Call it once per frame as in:

public void bang(){
noiss.matrixcalc(null,dim1); // this is what generates noise!
outlet(0,"jit_matrix",new Atom[]{Atom.newAtom(dim1.getName())});
}



efe
December 17, 2009 | 7:52 pm

wow, thank you for the help!
Sorry for all the noise!
Emmanuel


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