Hi Geo_Pi!
My sound start and stop when two different graphic part start and stop in different time.
I need that Osc Messages is in the draw not in mouse Pressed, and when I add “OscMessage myMessage2 = new OscMessage(”/synth/resonance");" the program gives me error.
In the end I need to have two different sound for two different graphic part in two different time that I just give.
I don’t know if it’s understandable …
This is my code:
import netP5.*;
import oscP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
PImage bg;
int a=1192; //sketch size
float s=20; //lunghezza linea
float x, y; //inizio linea
boolean Impulse= false;
float Time;
int restart = 0;
void settings() {
size(1192,746);}
void setup() {
frameRate(20);
oscP5 = new OscP5(this,57120);
myRemoteLocation = new NetAddress("127.0.0.1",57120);}
void draw() {
bg = loadImage("Amazzonia.jpg");
image(bg, 0, 0, width, height);
//background(0);
float sec = map(frameCount, 0, 60*60, 0, TWO_PI);
println(sec);
pushMatrix();
if (sec >= random(0.1,0.3)){
Impulse = true;
for (int i=0;i<=0.5*a;i++) {
stroke(random(255,0));
x = random(0,a);
y = random(0,a);
line(x,y,x+random(0,s),y);
}
if (sec >= random(0.14,0.18)){
int numberOfColumns = (int) random(1, 20);
int numberOfRectsPerColumn = (int) random(1,(random(100,190)));
for(int i = 1; i<=numberOfColumns; i++){
int x1 = width/numberOfColumns * (i-1);
int x2 = width/numberOfColumns;
new Column(x1, x2, (int)random(height/10), numberOfRectsPerColumn).display();
}
}
if (sec >= random(0.3,0.35)){
Impulse=false;
clear();
image(bg, 0, 0, width, height);
}
if (sec >= random(0.4,0.45))
frameCount=0;
OscMessage myMessage = new OscMessage("/test");
myMessage.add(Impulse);
/* invio messaggio */
oscP5.send(myMessage,myRemoteLocation);
popMatrix();
}
class Column {
int x;
int rectWidth;
int rectHeight;
int numberOfrects;
Column(int x, int rectWidth, int rectHeight, int numberOfrects) {
this.x = x;
this.rectWidth = rectWidth;
this.rectHeight = rectHeight;
this.numberOfrects = numberOfrects;
}
void display(){
for (int i=0; i<numberOfrects; i++) {
fill(random(0, 0), 0, random(0, 0));
rect(x, random(height), rectWidth, rectHeight);
}
for (int i=0; i<numberOfrects; i++) {
fill(random(255, 0), 255, random(255, 0));
rect(x, random(height), rectWidth, rectHeight);
}
}
}