very noobie question
in
Contributed Library Questions
•
3 years ago
I have been inspired by the processing software as have i been inspired by open source ethos for sometime. Sometime ago i became wowed by pure data (audio primarily beingmy background). At first it seemed like an uphill struggle getting to grips with PD. It now seems the hill has steepend with processing......
I would long for and would be extremely greatfull if someone could please help me or indeed direct me towards resolving my issues. Firstly i am managing to now send 3 messages to PD as individual signals, and now realise i need to send the variable "coordinates" of the x and y. I have managed to send the 0 ie "brightestX=0".
I now wonder if I should be sending the message from the videoLoadPixels part of the code so PD can recieve the variating x and y positions.
I realise that this really is child play for some people however everyone has to start somewhere.
Thanks
/**
* oscP5sendreceive by andreas schlegel
* example shows how to send and receive osc messages.
* oscP5 website at
http://www.sojamo.de/oscP5
*/
import oscP5.*;
import netP5.*;
import processing.video.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
Capture video;
void setup() {
size(640, 480);
video = new Capture(this, width, height, 30);
noStroke();
smooth();
oscP5 = new OscP5(this,40000);
myRemoteLocation = new NetAddress("127.0.0.1",12000);
}
void draw() {
if (video.available()) {
video.read();
image(video, 0, 0, width, height);
int brightestX = 0;
OscMessage myMessage = new OscMessage("/voice");
myMessage.add(brightestX);
int brightestY = 0;
myMessage.add(brightestY);
float brightestValue = 0; //
myMessage.add(brightestValue);
oscP5.send(myMessage, myRemoteLocation);
video.loadPixels();
int index = 0;
for (int y = 0; y < video.height; y++) {
for (int x = 0; x < video.width; x++) {
int pixelValue = video.pixels[index];
float pixelBrightness = brightness(pixelValue);
if (pixelBrightness > brightestValue) {
brightestValue = pixelBrightness;
brightestY = y;
brightestX = x;
}
index++;
}
}
fill(255, 204, 0, 128);
ellipse(brightestX, brightestY, 200, 200);
}
}
void stop() {
super.stop();
}
1