We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › osc in the new version of processing
Page Index Toggle Pages: 1
osc in the new version of processing (Read 221 times)
osc in the new version of processing
Sep 23rd, 2006, 11:52pm
 
Hi,

I used some "old" osc processing code and opened it in the new version of processing, but when I ran the code,  it gave me an error message pointing at         oscP5 = new OscP5(
               this,
               host,
               sendToPort,
               receiveAtPort,
               oscP5event
               );

The message: Null pointer exception

I wonder if a mac intell makes a difference here, because I can run this processing code fine in earlier versions of processing ...

Here's the entire code:

import oscP5.*;

import processing.opengl.*;

float c1,  c2,  c3,  c4, c5,  c6,  c7,  c8, b1, b2, b3,  b4, b5,  b6;


OscP5 oscP5;
int receiveAtPort;
int sendToPort;
String host;
String oscP5event;

void initOsc() {
       receiveAtPort = 7005;
       sendToPort = 7006;
       host = "127.0.0.1"; // 127.0.0.1 means talk to your own computer - it is a syntax 192.168.0.6
       oscP5event = "oscEvent";
       oscP5 = new OscP5(
               this,
               host,
               sendToPort,
               receiveAtPort,
               oscP5event
               );
}


void oscEvent(OscIn oscIn) {
       //println("received a message ... forwarding to analyseMessage(OscIn)");
       c1 = oscIn.getFloat(0); // an index inside a message
       c2 = oscIn.getFloat(1);
       c3 = oscIn.getFloat(2);
       c4 = oscIn.getFloat(3);
       c5 = oscIn.getFloat(4);
       c6 = oscIn.getFloat(5);
       c7 = oscIn.getFloat(6);
       c8 = oscIn.getFloat(7);
       b1 = oscIn.getFloat(8);
       b2 = oscIn.getFloat(9);
       b3 = oscIn.getFloat(10);
       b4 = oscIn.getFloat(11);
       b5 = oscIn.getFloat(12);
       b6 = oscIn.getFloat(13);
//if (b1 == 1.0) {
//println("got a 1");
//}
 if (b2 == 1.0) {
   //println("got button2 1");
   }
   
////////////////All buttons send back a message when they are clicked: change pitch//////////////////////////    
}
void button1() {

}


void button2() {

}
void button3() {

}


void button4() {

}
void button5() {

}


void button6() {

}


////////////////////////////////////////////////////////////////////////////////
///////////////////////
void setup(){
  size(320, 240, OPENGL);
  background(255);
  fill(200, 200, 200);
  initOsc();
 
 
 

}

void draw() {
 background(0); // clear the screen in everyframe - put this at the beginning always!
 // the parameters of the rect: xpos, ypos, width, height
 stroke(234);  
 line(20, c1, 20, 320);
 line(40, c2, 40, 320);
 line(60, c3, 60, 320);
 line(80, c4, 80, 320);
 line(100, c5, 100, 320);
 line(120, c6, 120, 320);
 line(140, c7, 140, 320);
 
 //smooth();
 noStroke();
 
  // all the circles switch into a new color when the buttons are pushed//////////////////
 int[] circle1 = new int[] { 50, 50, 50 };
 int[] circle2 = new int[] { 50, 50, 50 };
 int[] circle3 = new int[] { 50, 50, 50 };
 int[] circle4 = new int[] { 50, 50, 50 };
 int[] circle5 = new int[] { 50, 50, 50 };
 int[] circle6 = new int[] { 50, 50, 50 };
 
  if(b1 == 1) {
     circle1[0] = 230;
     circle1[1] = 0;
     circle1[2] = 110;
     button1();//OSC message is sent back to max when button is pushed
   } else if (b1 == 1) {
     circle1[0] = 50;
     circle1[1] = 50;
     circle1[2] = 50;
   }    

   if(b2 == 1) {
     circle2[0] = 230;
     circle2[1] = 0;
     circle2[2] = 110;
     button2();//OSC message is sent back to max when button is pushed
   } else if (b2 == 1) {
     circle2[0] = 50;
     circle2[1] = 50;
     circle2[2] = 50;
   }
   
   if(b3 == 1) {
     circle3[0] = 230;
     circle3[1] = 0;
     circle3[2] = 110;
     button3();//OSC message is sent back to max when button is pushed
   } else if (b3 == 1) {
     circle3[0] = 50;
     circle3[1] = 50;
     circle3[2] = 50;
   }
   
   if(b4 == 1) {
     circle4[0] = 230;
     circle4[1] = 0;
     circle4[2] = 110;
     button4();//OSC message is sent back to max when button is pushed
   } else if (b4 == 1) {
     circle4[0] = 50;
     circle4[1] = 50;
     circle4[2] = 50;
   }
   
   if(b5 == 1) {
     circle5[0] = 230;
     circle5[1] = 0;
     circle5[2] = 110;
     button5();
   } else if (b5 == 1) {
     circle5[0] = 50;
     circle5[1] = 50;
     circle5[2] = 50;
   }                            
   
   if(b6 == 1) {
     circle6[0] = 230;
     circle6[1] = 0;
     circle6[2] = 110;
     button6();//OSC message is sent back to max when button is pushed
   } else if (b6 == 1) {
     circle6[0] = 50;
     circle6[1] = 50;
     circle6[2] = 50;
   }
   fill(circle1[0], circle1[1], circle1[2]);
   ellipse(20, 20, 20, 20);    
   fill(circle2[0], circle2[1], circle2[2]);
   ellipse(40, 20, 20, 20);
   fill(circle3[0], circle3[1], circle3[2]);
   ellipse(60, 20, 20, 20);    
   fill(circle4[0], circle4[1], circle4[2]);
   ellipse(80, 20, 20, 20);
   fill(circle5[0], circle5[1], circle5[2]);
   ellipse(80, 20, 20, 20);    
   fill(circle6[0], circle6[1], circle6[2]);
   ellipse(100, 20, 20, 20);


}


Page Index Toggle Pages: 1