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 › smooth(),minim and complexity
Page Index Toggle Pages: 1
smooth(),minim and complexity (Read 654 times)
smooth(),minim and complexity
Jun 11th, 2009, 12:31am
 
Hello, i'm trying to learn how to  use processing and the minim library.
I've wrote a little program.But it runs very slow.


package musique;
import processing.core.*;
import ddf.minim.*;

public class Ifreq1 extends PApplet {

private static final long serialVersionUID = 1L;
Minim minim;
AudioPlayer player;
float ut=1;

public void setup(){
 size(640, 640);
 smooth();
 minim = new Minim(this);
 player = minim.loadFile("/home/gregoire/Public/bauhaus - in the flat field/cp.mp3");
 player.loop();
}

public void draw(){
 background(255);
 stroke(0);
 float[] left = player.left.toArray();
 float[] right = player.right.toArray();

 for ( int i = 0; i < left.length - 1; i++ )
 {
       //stroke(random(100),random(0),random(0));
       if(left[i]>0.00001){
            fill(random(90),random(190),random(30));
       }
       else{
           fill(random(255),random(200,255),random(255));
             stroke(255);
       }
   float x1 = map(i, 0, player.bufferSize(), 0, width);
   float x2 = map(i+1, 0, player.bufferSize(), 0, height);
ellipse(100+height/3-right[i+1]*120,x2*10,height/3-left[i]*150,x1*10);
}
}
public void stop(){
 player.close();
 minim.stop();
 super.stop();
}

You see, this program is very bad for complexity.
Is there a way to reduce this complexity? I have just one idea, but i don't know how to do it : Is it possible to get :
float[] left = player.left.toArray();
float[] right = player.right.toArray();

before launching the song ? (i don't really understand the way minim works so..)


Thank you for reading this and i wish you a nice and pleasant day.
Re: smooth(),minim and complexity
Reply #1 - Jun 11th, 2009, 7:32pm
 
try P2D mode Wink

size(640, 640,P2D);
Re: smooth(),minim and complexity
Reply #2 - Jun 12th, 2009, 6:24am
 
Hmm thank you but with the P2D mode, it looks the same without smooth() and the speed stills low.
Page Index Toggle Pages: 1