I changed the sketch using arrays for the clip class and OSC plugs the receive and parse incoming OSC messages.
import oscP5.*;
import netP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
Clip[] clip=new Clip[8];
int vertical=50;
int val=100;
int isplaying;
color shade=color(200);
int id[]= {0, 1, 2, 3, 4, 5, 6, 7};
void setup() {
//size(screenWidth, screenHeight, P2D);
size(500, 700);
PFont font;
font = loadFont("LiGothicMed-48.vlw");
oscP5 = new OscP5(this, 12000);
myRemoteLocation = new NetAddress("127.0.0.1", 11001);
oscP5.plug(this, "name", "/name");
oscP5.plug(this, "colore", "color");
clip[0]=new Clip(vertical, 50, color(shade), id[0]);
clip[1]=new Clip(vertical, 120, color(255, 232, 160), id[1]);
clip[2]=new Clip(vertical, 190, color(232, 160, 160), id[2]);
clip[3]=new Clip(vertical, 260, color(45, 200, 1), id[3]);
clip[4]=new Clip(vertical, 330, color(145, 200, 221), id[4]);
clip[5]=new Clip(vertical, 400, color(3, 20, 121), id[5]);
clip[6]=new Clip(vertical, 470, color(255, 200, 255), id[6]);
clip[7]=new Clip(vertical, 540, color(200, 160, 145), id[7]);
}
public void name(int ide, String nombre) { // plug for the clip names sent from Max
for (int j=0;j<id.length;j++) {
if (id[j]==ide) {
println("id "+ide+" name "+nombre);
}
}
}
public void colore(int idc, int r, int g, int b) { // clip color
for (int k=0;k<id.length;k++) {
if (id[k]==idc) {
println("id "+idc+" RGB "+r+" "+g+" "+b);
shade=color(r, g, b);
}
}
}
void draw() {
for (int i=0;i< clip.length;i++) { // buttons
clip[i].display();
clip[i].change();
}
}
When I send a message like "color 0 23 76 220" to the sketch, it prints out the id and the RGB values from the message. I want to change the color of the buttons (shade) with the incoming messages but it still doesn't work. Any ideas?