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 & HelpOther Libraries › UDP Array transfert
Page Index Toggle Pages: 1
UDP Array transfert (Read 808 times)
UDP Array transfert
Dec 25th, 2009, 12:06pm
 
Hello everyone,

First of all, im quite a (enthousiastic) beginner, so i might have done some stupid stuff. Excuse me in advance... and thanks for showing/explaining me the way.

Im trying to send and array corresponding to some audio spectrum bar values, in order to transfer it to 3D geometry in Grasshopper, a Rhino plug in, using the Udp library from S.Cousot.

Im trying to do that with 4 bars.
This is what i wrote (just focuse on the draw part, the rest is about setting up the spectrum). My problem is that i get a null pointer everytime i let the "udps.send(message, ip, port);" run...
everything else looks just fine to me... obviously its not. Thanks for helping me out.
it goes :



import krister.Ess.*;
import hypermedia.net.*; // import the UDP library
UDP udps;  // define the UDP object

FFT myfft;
AudioInput myinput;
int bufferSize=4; // number of bars

void setup() {
 size(200,300);
 frameRate(30);
 Ess.start(this);
 myinput=new AudioInput(bufferSize);
 myfft=new FFT(bufferSize*2);
 myinput.start();
 myfft.damp(.3);
 myfft.equalizer(true);
 myfft.limits(.005,.05);
}

void draw() {
 background(255);
 String message  = "";
 String ip       = "127.0.0.1";      // the remote IP address
 int port        = 6400;            // the destination port

 for (int i=0; i<bufferSize;i++) {
   rect(((i)*5)+20,250,3,myfft.spectrum[i]*-300);

   int data = ceil(myfft.spectrum[i]*500);

   if (i>0){
     message  = "a" + String.valueOf(i)+"="+String.valueOf(data);
     println (message);
     udps.send(message, ip, port); // here comes trouble
   }
 }
}
// close input
public void audioInputData(AudioInput theInput) {
 myfft.getSpectrum(myinput);
}
Re: UDP Array transfert
Reply #1 - Dec 25th, 2009, 12:13pm
 
UDP udps; - at the very top of your code - is not enough to set up the UDP object. It is declared, but not set yet.

You should have
udps = new UDP(this); or something like that, somewhere in setup().

Please have a look to the UDP library reference / example.
Page Index Toggle Pages: 1