hello
i have this code to visualize the songs according the frequency:
import ddf.minim.*; // minim library
import processing.pdf.*; // pdf export library
import java.util.Calendar; // java timestamp
Minim minim; // initialize minim
AudioPlayer song; // setup up player
AudioMetaData meta;
int spacing = 5; // distance between lines
int border = 20; // top, left, right, bottom border
int amplification = 40; // frequency amplification
int num = 100; // resolution in y direction
int cutBack = 20000; // remove parts from the song end
int cutFront = 10000; // remove parts from the song start
int pos, counter;
float[] x = new float[num]; // array of values in x direction
float[] y = new float[num];
void setup() {
size(2000, 2000);
minim = new Minim(this);
song = minim.loadFile("13- 9 PM (Till I Come).mp3"); // load song
meta = song.getMetaData(); // load song meta information
song.play(); // play song
song.cue(cutFront); // cut parts from song beginning
//beginRecord(PDF, meta.author() + “ - “ + meta.title()+ “ - “ + timestamp() + “.pdf”); //
background(255);
noFill();
strokeWeight(1);
stroke(0);
}
void draw() {
beginShape(); // start custom shape
x[0] = pos + border; // set x and y value of first array item to ‘zero’
y[0] = border;
curveVertex(x[0], y[0]);
for (int i = 0; i < num; i++) { // loop through each element in array
x[i] = pos + border + song.mix.get(i)*amplification; // assign frequency value at position
y[i] = map( i, 0, num, border, height-border ); // map ‘i’ to canvas height
curveVertex(x[i], y[i]); // draw curves
}
x[num-1] = x[0]; // set x and y value of last array item to ‘zero’
y[num-1] = height-border;
curveVertex(x[num-1], y[num-1]);
endShape(); // close custom shape
int skip = (song.length() - cutFront - cutBack) / ((width-2*border) / spacing);
// amount to skip song forward, based on spacing
if (pos + border < width-border) { // skip song, set new x position
song.skip(skip);
pos += spacing;
} else {
minim.stop(); // stop song if canvas is full
}
if (song.isPlaying() == false) endRecord(); // stop pdf recording
}
the music will stop when the lines reach to the end of the screen)
but i would like to create something like it:
Thank you so much to help me!