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 & HelpPrograms › visual music
Page Index Toggle Pages: 1
visual music (Read 565 times)
visual music
Nov 3rd, 2008, 8:18pm
 
Hello,
First, sorry for my very bad english...
I'm a french art student and I try to make programs to visualize music in graphics.
I have a probleme with my last program: it memorize in a variable the FFT during 150 frames and display that to make a kind of  field. That works for a while, but when I turn around the scene, after some time, processing write:
Quote:
Exception in thread "Animation Thread" java.lang.ArrayIndexOutOfBoundsException: 360267

at processing.core.PLine.drawLine_plain_alpha_spatial(PLine.java:801)

at processing.core.PLine.draw(PLine.java:407)

at processing.core.PGraphics3D.render_lines(PGraphics3D.java:1569)

at processing.core.PGraphics3D.endShape(PGraphics3D.java:1025)

at processing.core.PGraphics.endShape(PGraphics.java:1350)

at processing.core.PGraphics.line(PGraphics.java:1423)

at processing.core.PApplet.line(PApplet.java:6824)

at son_lignes_3D_temps.draw(son_lignes_3D_temps.java:95)

at processing.core.PApplet.handleDraw(PApplet.java:1400)

at processing.core.PApplet.run(PApplet.java:1305)

at java.lang.Thread.run(Thread.java:595)


this is the code:
Code:
import krister.Ess.*;

AudioInput entree_son;
FFT analyse_fft;
int tampon=128, first, ligne=1, p=0, temps=150;
float[] hauteur=new float[tampon*temps+temps];
float normalisation, valeur, mvmt,asc,x,y, v1, v2, ecart,rX, rY, rotX, rotY,vX_first,vY_first,rX_first,rY_first, vit_X, vit_Y, mX, mY, opacite=temps/4;
void setup(){
 size(600,600,P3D);
 noStroke();
 fill(0);
 colorMode(HSB);
 Ess.start(this);
 entree_son=new AudioInput(tampon);
 analyse_fft= new FFT(tampon*2);
 analyse_fft.equalizer(true);
 float min_limit=.001;
 float max_limit=.1;
 analyse_fft.limits(min_limit,max_limit);
 analyse_fft.damp(.1f);
 analyse_fft.averages(32);
 normalisation=max_limit-min_limit;
 entree_son.start();
 mvmt=0;
 x=y=200;
 ecart=10;
}
void draw(){
 translate(300,300,-temps-400);
 background(120,130,5);
 if (mousePressed){
   if (first==1){
     vX_first=mouseX;
     rX_first=rX;
     vY_first=mouseY;
     rY_first=rY;
     first=0;
   }
 rX=rX_first+(mouseX - vX_first);
 rY=rY_first+(mouseY - vY_first);
 }
 if (mousePressed==false){
   if (first==0){
     vit_X=mouseX-pmouseX ;
     vit_Y=mouseY-pmouseY ;
   }
   first=1;
 }
 mX += vit_X*0.002;
 mY += vit_Y*0.002;
 rotateY(mX + rX*0.01);
 rotateX(mY + rY*0.01);
 translate (-tampon*ecart*0.5,-255*0.5,-temps*ecart*0.5);
 x=0;
 opacite=255;
 float niveau=analyse_fft.getLevel(entree_son)*50;
for (int i=tampon*temps; i>0; i--){
   if (i>=tampon){
     hauteur[i]=hauteur[i-tampon];
   }
   if (i<tampon){
     valeur=analyse_fft.spectrum[i]*150;
     hauteur[i]=valeur;
   }
 }
 for (int j=0; j<tampon*temps;j++){
   if (p==tampon){
     translate (0,0,2*ecart);
     ligne++;
     p=0;
     x=0;
     if (ligne>temps/2){
       opacite=((temps-ligne)*255)/(temps/2);
     }
   }
   p++;
   if(p==tampon || p==1){
     noStroke();
   } else if (ligne==0){
     stroke(10,250,255,200);
     line(x,255-2*hauteur[j], x+ecart,255-2*hauteur[j+1]);
     strokeWeight(2);
     stroke(10,250,255,100);
     line(x,255-2*hauteur[j]-1, x+ecart,255-2*hauteur[j+1]-1);
     line(x,255-2*hauteur[j]+1, x+ecart,255-2*hauteur[j+1]+1);
     stroke(8,250,255,50);
     line(x,255-2*hauteur[j]-2, x+ecart,255-2*hauteur[j+1]-2);
     line(x,255-2*hauteur[j]+2, x+ecart,255-2*hauteur[j+1]+2);
   }else{
     stroke(150+hauteur[j]*2,hauteur[j]*2,255,opacite-230+niveau);
     strokeWeight(1);
   }
   line(x,255-hauteur[j], x+ecart,255-hauteur[j+1]);
   alpha(100);

   x=x+ecart;
 }
 ligne = 0;
 x = 0;
 p = 0;
}
public void audioInputData(AudioInput theInput) {
analyse_fft.getSpectrum(entree_son);
}
public void stop() {
Ess.stop();
super.stop();


sorry, the code is long, but I don't know where is the problem .
Re: visual music
Reply #1 - Nov 4th, 2008, 11:04am
 
nobody understand?
Re: visual music
Reply #2 - Nov 4th, 2008, 12:08pm
 
I remember such an error with to big coordinates in P3D. Maybe you could limit the values or try it in OPENGL.
Re: visual music
Reply #3 - Nov 4th, 2008, 12:23pm
 
Ok, I have try in OPENGL, it run perfectly, thanks!
Re: visual music
Reply #4 - Nov 4th, 2008, 2:26pm
 
You shouldn't be getting that error if you're using release 0154. Are you using the latest release?
Re: visual music
Reply #5 - Nov 4th, 2008, 7:50pm
 
I have downloaded the latest release, and now it run in P3D also!! Thanks a lot Fry.
Page Index Toggle Pages: 1