Forums > Java

apply and expression to jit.noise

Jan 18 2010 | 7:44 am

I am trying to port this simple jitter code into java:

— Pasted Max Patch, click to expand. —

However, i am finding difficulties to apply the expression to the noise. Maybe a simple solution but i haven’t been able to figure it out. I realize that i suck in java!
So far this:

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

public class NoiseExpr2 extends MaxObject
JitterObject noiss;
JitterObject expression;
JitterMatrix dim1;
JitterMatrix dim2;

public NoiseExpr2(Atom[] args){
declareInlets(new int[]{DataTypes.ALL});
declareOutlets(new int[]{DataTypes.ALL});
noiss=new JitterObject( "jit.noise");
expression=new JitterObject("jit.expr");
expression.setAttr("expr","hypot((norm[0]-0.5)+((in[0]*0.1)-0.05) , (norm[1]-0.5))");
dim1=new JitterMatrix("dimen",3,"float32",10,100);
//noiss.expr("hypot((norm[0]-0.5)+((in[0]*0.1)-0.05) , (norm[1]-0.5))");

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

any idea?


Jan 18 2010 | 7:59 am

one way to create a JitterObject:

JitterObject(java.lang.String classname, com.cycling74.max.Atom[] args)
creates a JitterObject

so your noiss should be

// jit.noise 12 float32 10 10
Atom[] args = new Atom[] {
noiss=new JitterObject("jit.noise", args);

also, you could check if your noiss.matrixcalc is succesfull by doing

boolean success = noiss.matrixcalc(null,dim1);
post("noiss succes: "+success);

btw. the outlet can also be called like this:
outlet(0,"jit_matrix", dim1.getName());
(no need to create atoms)

I am doing this off the top of my head, so I can’t guarantee success.
Alos, I haven’t worked with JitterObjects like noise in java yet either…
Will get back to it.


Jan 18 2010 | 8:11 am

Thank you Marcus:
nice tips!. However, the problem is not to generate the noise in java(that is working already) but to apply the expression to the matrix. Somehow i was thinking that by using the expr as a method(noiss.expr) it would work, but it didn’t.

Jan 18 2010 | 5:17 pm

Another option might be to use the java lang directly. But it seems strange that jit.expr cannot be used as a simple JitterObject

Jan 19 2010 | 1:54 am

It’s working:

import com.cycling74.jitter.JitterMatrix;
import com.cycling74.jitter.JitterObject;
import com.cycling74.max.DataTypes;
import com.cycling74.max.MaxObject;

public class NoiseExpr2 extends MaxObject {

	JitterObject noise;
	JitterMatrix noiseOut;

	JitterObject expression;
	JitterMatrix expressionOut;

	public NoiseExpr2() {

		declareOutlets(new int[] {DataTypes.ALL, DataTypes.ALL});

		// jit.noise 12 float32 10 10
		noise = new JitterObject("jit.noise");//, noiseArgs);
		noise.setAttr("planecount", 12);
		noise.setAttr("type", "float32");
		noise.setAttr("dim", new int[] { 10,10});

		noiseOut = new JitterMatrix(12, "float32", 10, 10);

		// jit.expr @expr "hypot((norm[0]-0.5)+((in[0]*0.1)-0.05) , (norm[1]-0.5))"
		expression=new JitterObject("jit.expr");
		expression.setAttr("expr","hypot((norm[0]-0.5)+((in[0]*0.1)-0.05) , (norm[1]-0.5))");

		expressionOut = new JitterMatrix(12, "float32", 10, 10);


	public void bangnoise() {
		noise.matrixcalc(null, noiseOut);
		outlet(1, "jit_matrix", noiseOut.getName());

	public void bang() {
		expression.matrixcalc(noiseOut, expressionOut);
		outlet(0, "jit_matrix", expressionOut.getName());

Jan 19 2010 | 1:56 am

And here’s an example patch using this object:

— Pasted Max Patch, click to expand. —

Jan 19 2010 | 3:35 am

Thank you Marcus!
You are really a java-jitter guru
it is quite interesting the use of two matrices

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

Forums > Java