A Processing sketch to an Isadora stage
-
Interesting comments. Thanks everyone. I think creating a Syphon server in my Processing code and using Izzy's Syphon Server actor is the way I'm going. Here is a simple example of a rotating cube:
import codeanticode.syphon.*;PGraphics canvas;SyphonServer server;void setup(){size(400,400, P3D);canvas = createGraphics(400, 400, P3D);// Create syhpon server to send frames out.server = new SyphonServer(this,"eureka");}void draw(){canvas.beginDraw();canvas.background(0);canvas.lights();canvas.translate(width/2, height/2);canvas.rotateX(frameCount * 0.009);canvas.rotateY(frameCount * 0.009);canvas.box(200);canvas.endDraw();image(canvas,0,0);server.sendImage(canvas);} -
import codeanticode.syphon.*;
import oscP5.*;import netP5.*;PGraphics canvas;SyphonServer server;OscP5 oscP5;NetAddress myBroadcastLocation;float factor;void setup(){
// DISPLAY SETUP
size(640, 480, P3D);
canvas = createGraphics(width, height, P3D);
initTheScene();
// SYPHON SETUP
server = new SyphonServer(this, "Processing Cube");
// OSC SETUP
oscP5 = new OscP5(this, 5001);
myBroadcastLocation = new NetAddress("127.0.0.1", 5000);
factor = 1;
}
// RENDER AND SEND TO SYPHON
void draw()
{
canvas.beginDraw();
renderTheScene();
canvas.endDraw();
image(canvas, 0, 0);
server.sendImage(canvas);
}
// SEND ORDER TO MILLUMIN
void mouseMoved()
{
OscMessage myOscMessage = new OscMessage("/millumin/layer/opacity/0");
myOscMessage.add(100*mouseX/width);
oscP5.send(myOscMessage, myBroadcastLocation);
}
// RECEIVE ORDER FROM MILLUMIN
void oscEvent(OscMessage theOscMessage)
{
if ( theOscMessage.addrPattern().equals("/millumin/layer/scale/0") )
{
factor = theOscMessage.get(0).floatValue()/100;
}
}
-
rest of the code, must be put together, was too much for one message, sorry, can post the txt file as zip.
void initTheScene() {
}
void renderTheScene() {
background(0);
noStroke();
rect(0, 0, width, height);
float sine = sin(phasor * TWO_PI);
float angle = map(sine, -1.0, 1.0, -HALF_PI, HALF_PI);
float divPoint = map(sine, -1.0, 1.0, 1.0, 0.5);
for (int i = 0; i < nBranches; i++) {
float L = startingLength;
float a = TWO_PI / (float) nBranches * (float) i;
PVector v1 = new PVector(width / 2, height / 2);
PVector v2 = getVCoordinates(v1, L, a);
while (L > 2) {
canvas.stroke(random(255), 255, 0, 32);
L *= 0.95;
canvas.line(v1.x, v1.y, v2.x, v2.y);
a += angle;
v1.x = lerp(v1.x, v2.x, divPoint);
v1.y = lerp(v1.y, v2.y, divPoint);
v2 = getVCoordinates(v1, L, a);
}
}
phasor += rate;
if (phasor >= 1.0) {
phasor -= 1.0;
}
}
-
@rainbow: I copy/pasted your code and I get an error at line 87, "cannot find anything named "phasor". I am a Processing beginner with no debugging skills yet. Can you help? Also can you describe what your sketch does? Thanks.
-
@vanderzee: sorry some code is missing, I used Gras.pde and Organic.pde for examples, also a Processing beginner.
thanks for the inspiration.rainbow -
@rainbow: just took a quick look. i'm traveling for next couple days. i will look carefully when i get to my studio. thx.
-
Millumin ia a very nice piece of software. Not really a competitor for Isadora. because less interactivity, no 3D, but it is very simple, well structured, timeline based and does softedge, osc, midi, syphon. It is a great player and does some real time too. I was surprised. The programmer is great, (lives in Lyon, France) responsive and very generous. The soft is quite expensive (double that izzy las time I saw).
By the way, I tried your code and as strange as it seems processing syphons out to mad mapper but doesn't in Isadora... any clue?Thanks -
Well, on my hardware its working, I am beginner, and share some knowledge, I just like Processing syphon oSC tools ;)
-
@Armando: this processing code sends the rotating cube to an izzy syphon to video actor and projector and shows on stage 1. I cannot comment on MadMapper.
import codeanticode.syphon.*;PGraphics canvas;SyphonServer server;void setup(){size(400,400, P3D);canvas = createGraphics(400, 400, P3D);// Create syhpon server to send frames out.server = new SyphonServer(this,"eureka");}void draw(){canvas.beginDraw();canvas.background(0);canvas.lights();canvas.translate(width/2, height/2);canvas.rotateX(frameCount * 0.009);canvas.rotateY(frameCount * 0.009);canvas.box(200);canvas.endDraw();image(canvas,0,0);server.sendImage(canvas);} -
Thanks. Vanderzee the problem might be on my version I'm testing a higher prerelease. Your code works on on syphon recorder, works on mad mapper but doesn't in my version. I'll file a bug report.
Thanks So this is the code for the CI and the Texture. Bur it is not the code for the video actors isn't it? It works (partially only with image and texture actors. -
found this on http://forum.processing.org/two/discussion/comment/3810#Comment_3810
saves my time coding processing syphon out
latest IsadoraCore prerelease OSX 10.9.1 Processing 2.11
Simple cube,syphon and osc scetch. well documented, enjoy …….
rainbow
-
I have a blog page here on OSC and Processing:
http://www.jamiegriffiths.com/isadora-and-processing-via-osc/ -
this is what I used 2 years ago with Processing 1.5.1, it does still works with that version but not with v.2.
Don't know why...
you can then use any Syphon client anywhere:
import javax.media.opengl.;
import processing.opengl.;
import jsyphon.*; // SyphonJSyphonServer mySyphon;
PGraphicsOpenGL pgl;
GL gl;
int[] texID;void setup() {
size(640, 480, OPENGL);
pgl = (PGraphicsOpenGL) g;
gl = pgl.gl;
initSyphon(gl,"processing");strokeWeight(0.5);
stroke(255, 50);
background(0);}
void draw() {
line(width/2, height/2, random(0, width), random(0, height));
renderTexture(pgl.gl);
}void initSyphon(GL gl, String theName) {
if(mySyphon!=null) {
mySyphon.stop();
}
mySyphon = new JSyphonServer();
mySyphon.test();
mySyphon.initWithName(theName);// copy to texture, to send to Syphon.
texID = new int[1];
gl.glGenTextures(1, texID, 0);
gl.glBindTexture(gl.GL_TEXTURE_RECTANGLE_EXT, texID[0]);
gl.glTexImage2D(gl.GL_TEXTURE_RECTANGLE_EXT, 0, gl.GL_RGBA8, width, height, 0, gl.GL_RGBA, gl.GL_UNSIGNED_BYTE, null);
}void renderTexture(GL gl) {
gl.glBindTexture(gl.GL_TEXTURE_RECTANGLE_EXT, texID[0]);
gl.glCopyTexSubImage2D(gl.GL_TEXTURE_RECTANGLE_EXT, 0, 0, 0, 0, 0, width, height);
mySyphon.publishFrameTexture(texID[0], gl.GL_TEXTURE_RECTANGLE_EXT, 0, 0, width, height, width, height, false);
}public void stop() {
dispose();
}void dispose() {
println("\n\nabout to stop sketch ...");
println("deleting textures");
gl.glDeleteTextures(1, texID, 0);
if(mySyphon!=null) {
println("stopping the syphon server");
mySyphon.stop();
}
println("sketch stopped, done.");
}