We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello all!
here my first question in the forum, i´m trying to draw a audio reactive lines on screen using the minim library, and all works fine, but when i use the P2D or P3D in the size function that stop working.
using the 2.2.1 version of processing not work. using the 1.5.1 version of processing it works.
what can i do?
thnxs in advance, sorry for the bad english..
here´s the code:
import ddf.minim.*;//minim
//Reactivo
Minim minim;
AudioInput in;
float eyey = 300;
void setup() {
size (500, 500,P2D);// it does not work
// size (500, 500,P2D);// is working
//Minim entrada de audio
minim = new Minim(this);
in = minim.getLineIn();
background(0);
}
void draw() {
difumina(0, 10);
llora(100);
llora(200);
llora(300);
}
void mousePressed() {
background(0);
}
void llora( float _y){
for (int i = 0; i < in.bufferSize () - 1; i++)
{
//Variables waveform
float x1 = map(i, 0, in.bufferSize(), 0, width);
stroke(255, 255);
line(x1, _y+ in.right.get(i)*500, x1, _y+ in.right.get(i)*500);
}
}
//Función fondo pantalla
void difumina(color c, float al) {
fill(c, al);
rect (-2, -2, width +10, height +10);
}
Answers
Hello,
you are doing something a bit odd here using line to draw points:
line(x1, _y+ in.right.get(i)*500, x1, _y+ in.right.get(i)*500);
I can only guess there is some kind of optimization in P5 2.2.1 when rendering a line that has a distance too small between its beginning and end just replace this line by
point(x1, _y+ in.right.get(i)*500);
and your code gives the same result in Processing 1.5.1 and Processing 2.2.1 (Tested)
cheers
vac
Thanks very much, it works perfect! :D