java.lang.reflect.InvocationTargetException error on the following code(any help is much appreciated):
I am working in processing and after adding the most recent chunk of code I ran into a java.lang error. Any help on trying to figure out what's up is very appreciated. The chunk is trying to create a button that will allow the user to select an mp3 file from their computer and use that as music in a waveform.
void draw(){
rectMode(CORNER);
rect(buttonX, buttonY, buttonW, buttonH);
fill(255);
textAlign(LEFT);
text("Import File", buttonX+35, buttonY+30);
if (isChosen) {
s.get(k).waveform();
}
}
void mouseClicked() {
if (mouseX>buttonX && mouseX < buttonX+buttonW && mouseY > buttonY
&& mouseY < buttonY+buttonH) {
selectInput("Import music file", "fileSelected");
}
}
void fileSelected(File selection) {
if (selection == null) {
println("Window was closed or user hit cancel");
}
else {
file = selection.getAbsolutePath();
s.add(new Songs(song, file, "Filename"));
isChosen = true;
}
}
// stop minim and the player.
void stop() {
song.close();
minim.stop();
super.stop();
}
class Songs {
AudioPlayer song;
String directory;
String songName;
Songs(AudioPlayer song, String directory, String songName) {
song=minim.loadFile(directory);
this.song=song;
this.songName=songName;
song.play();
}
void waveform() {
for (int j = 1; j < song.bufferSize() - 1; j++)
{
if (j>0) {
line(j, 214 + song.left.get(j)*50, j+1, 214 +
song.left.get(j+1)*50);
//waves from the left.
stroke( 35, 30, 30 ); //this is the colour of the first line (red)
line(j, 214 + song.right.get(j)*50, j+1, 214 + song.right.get(j+1)*50);
//waves from the right.
stroke(255, 255, 70);
}
}
}
}
Comments
Post a Comment