This was originally posted on the processing forum but it seems to have been pretty useful. This is a very basic class that can be used in processing to make a syphon server. The syphon library for processing can be picked up from here and installed per these instructions.
import codeanticode.syphon.*;
class SFD{
public PGraphics canvas;
public SyphonServer server;
PApplet that;
SFD(PApplet tthat){
that = tthat;
canvas = createGraphics(that.width, that.height, P3D);
// Create syhpon server to send frames out.
server = new SyphonServer(that, "Processing Syphon");
}
void update(){
that.loadPixels();
canvas.loadPixels();
for(int i=0;i<that.pixels.length;i++){
canvas.pixels[i] = that.pixels[i];
}
canvas.updatePixels();
server.sendImage(canvas);
}
}
Now that you have the library installed and this class in your code, you would add SFD send as a global variable. This needs to be global because the next two parts will be in setup() and draw(). In setup you would create the object from the class using send = new SFD(this) where ‘this’ is the current applet. In order to send your frames you would add send.update() in draw, after everything you want to send. if you are going to add any interface to the sketch to control the output I would put it after the send.update() bit so that it doesn’t get rendered to your final output
Leave a Reply