Hi all,
For the past couple of days I’ve been getting into FFT and music visualization. Wanting to make a smooth, circular display of frequencies, I managed to do that, using Minim/FFT, a linear grouping of frequencies, and by using curveVertex to make the vertices around the circle. There is one problem, however, which is that the closing of the circle becomes a straight line instead of a curve, which looks quite off. Here’s what I have so far:
import ddf.minim.analysis.*;
import ddf.minim.*;
Minim minim;
AudioPlayer jingle;
FFT fftLin;
void setup()
{
size(600, 600);
minim = new Minim(this);
jingle = minim.loadFile("jingle.mp3", 1024);
jingle.loop();
fftLin = new FFT( jingle.bufferSize(), jingle.sampleRate() );
fftLin.linAverages( 32 );
}
void draw()
{
background(0);
noFill();
stroke(255);
strokeWeight(3);
translate(width / 2, height / 2);
fftLin.forward(jingle.mix);
beginShape();
for (int i = 0; i < fftLin.avgSize(); i++)
{
float angle = map(i, 0, fftLin.avgSize(), 0, 7);
float amp = fftLin.getAvg(i);
float r = map(amp, 0.2, 2, 150, 200);
float x = r * cos(angle);
float y = r * sin(angle);
curveVertex(x, y);
if (i < 26) {
} else {
}
}
endShape(CLOSE);
}
I am aware that properly closing curveVertex shapes is a quite common issue and I’ve read every single thread I could find about it, trying to get a grasp of how to fix it - but so far, to no avail. The only proper, complete way I came across, was in this thread by @jeremydouglass : https://github.com/processing/processing/issues/5962
I managed to adapt that piece of code into my own project, and it actually closes the circle in a smooth way, but all the vertices only keep increasing in size intead of “resetting” as with my solution above, to the point where the whole circle exceeds the frame.
I would be very grateful for any help! Thanks.