User Tools

Site Tools


cs276:oscex

Processing Sketch

// ShiftingTowerTest.pde
// Creator: Greg Pond
// Modified 12/1/09 by spc
 
import oscP5.*;
import netP5.*;
 
OscP5 oscP5;
NetAddress myRemoteLocation;
 
int a;
int i;
int j;
PImage b;
 
//noise
float hu;
float sat;
float br;
color noi;
 
void setup() {
  size(720,480);
  frameRate(25);
  b = loadImage("dg.jpg");
 
  // connect to Pd over network port 12000
  oscP5 = new OscP5(this, 12000);
  myRemoteLocation = new NetAddress("127.0.0.1", 12000);
}
 
// incoming osc message are handled by this method 
void oscEvent(OscMessage theOscMessage) {
  // unpack the message
  int firstValue = theOscMessage.get(1).intValue();  
  int secValue = theOscMessage.get(2).intValue();
 
  // display the image
  image (b, 0, 0);
 
  // draw the shifting "tower"
  stroke (5);
  smooth();
  line (firstValue, 100, firstValue/2, 200);
  stroke (5);
  smooth();
  line (-firstValue + 400, 100, -firstValue/2 + 400, 200);
  stroke (5);
  smooth();
  line (-firstValue + 400, 100, -firstValue/3-10 + 400, 50);
  stroke (5);
  smooth();
  line (firstValue, 100, firstValue/3+10, 50);
  stroke (5);
  smooth();
  line (firstValue/2 , 200, firstValue/1.2-10, 250);
  stroke (5);
  smooth();
  line (150, 200+secValue, 250, 200+secValue);
}
 
void draw() {
}

Pd Patch

Note: click here for the actual .pd file.

cs276/oscex.txt · Last modified: 2009/12/07 12:39 by scarl