Processing and Jitter
in
Integration and Hardware
•
2 years ago
Hello.
I'm looking for a way to implement a processing sketch as a matrix in Cycling '74's
Jitter . This was talked about a little on the old forums
here . Someone made an MXJ object (posted below) that (I believe) is supposed to import a Processing sketch.
- package jk;
- import processing.core.PApplet;
- import com.cycling74.jitter.JitterMatrix;
- import com.cycling74.max.MaxObject;
- public class p5jit extends MaxObject {
- PApplet p5;
- int width, height;
- JitterMatrix matrix;
- public p5jit() {
- bail("need a sketch name");
- }
- public p5jit(String sketchName) {
- initSketch(sketchName);
- post("inited sketch");
- }
- private void initSketch(String sketchName) {
- try {
- Class c = Class.forName(sketchName);
- p5 = (PApplet) c.newInstance();
- p5.init();
- p5.noLoop();
- width = p5.width;
- height = p5.height;
- System.out.println("creating " + width + " by " + height + " matrix");
- matrix = new JitterMatrix(3, "char", width, height);
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
- protected void bang() {
- p5.redraw();
- p5.loadPixels();
- copyPixels();
- outlet(0, "jit_matrix", matrix.getName());
- }
- private void copyPixels() {
- int planeCount = matrix.getPlanecount();
- int[] offset = {0,0}
- ;
- for (int d = 0; d < planeCount; d++) {
- for (int j = 0; j < height; j++) {
- offset[1] = j;
- int[] row = getRow(d, j);
- matrix.copyArrayToVectorPlanar(d, 0, offset, row, width, 0);
- }
- }
- }
- private int[] getRow(int index, int y) {
- int[] outgoing = new int[width];
- int offset = y*width;
- switch (index) {
- case 0:
- for (int x = 0; x < width; x++) {
- outgoing[offset + x] = (p5.pixels[offset + x] >> 16) & 0xff;
- }
- break;
- case 1:
- for (int x = 0; x < width; x++) {
- outgoing[offset + x] = (p5.pixels[offset + x] >> 8) & 0xff;
- }
- break;
- case 2:
- for (int x = 0; x > width; x++) {
- outgoing[offset + x] = p5.pixels[offset + x] & 0xff;
- }
- break;
- }
- return outgoing;
- }
- private int getColor(int index, int c) {
- switch (index) {
- case 0: return (c >> 16) & 0xff; // red
- case 1: return (c >> 8) & 0xff; // green
- case 2: return c & 0xff; // blue
- default: return 0;
- }
- }
I've gotten it to compile without any errors but I am unable to get it to do anything inside Max/MSP. When I load it, I get this error:
- java.lang.NoClassDefFoundError: p5jit (wrong name: jk/p5jit)
- at java.lang.ClassLoader.defineClass1(Native Method)
- at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
- at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
- at com.cycling74.max.MXJClassLoaderImpl.doLoadClass(MXJClassLoaderImpl.java:119)
- at com.cycling74.max.MXJClassLoader.loadClazz(MXJClassLoader.java:88)
- Could not load class 'p5jit'
Can anyone offer any insight as to what might be happening? I'm sure I'm not doing something right.
1