Miamiamiam
YaBB Newbies
Offline
Posts: 11
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); }