Sound Mapping problem

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:
8989

Thank you so much to help me!

I’m not sure what “like it” means. Do you mean the sound to loop? Do you mean you want the drawing to jump back to the left edge and keep drawing? Both?

It is hard to test sketches like this when we don’t have your media. I would suggest either posting your file or else linking to a public mp3 for testing – for example, mp3 test file : test : Free Download, Borrow, and Streaming : Internet Archive

Also – when I tested with my own mp3 I had to set cutBack and cutFront to 0. This more complex, file-dependent setup may confuse people who are trying to help.

Thank you so much for your answer, yes i want the drawing to jump back to the left edge and keep drawing till the end of the song, and here for test the code its not important what song you use.
i must do this but stacked!!!

This currently you stop the song at the right edge, here:

  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
  }

… it seems like, if you are > width-border, instead of minim.stop() you instead want to set pos to the beginning position.

This will now run until your endRecord() is triggered – so for long songs it may layer many times.

but if i delete
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
}

it will be like this:

Why would you delete it? I suggested: “instead of minim.stop() you instead want to set pos to the beginning position.” Try just changing the else clause, leave the rest the same.

honestly, i’m newbee here, could you write me the code here plz?