d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Need Help With Processing > Would Donate Fg
Add Reply New Topic New Poll
Member
Posts: 9,730
Joined: Dec 27 2007
Gold: 17,848.00
Jan 11 2017 07:56pm
Hey i want to select a Mp3 file for my Visualizer but i get an error calls
NullPointerException
what should i do for fix?
here is my code

Code

import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;
String path;

Minim minim;
AudioPlayer Player;
int farbe;
PImage playPause;
PImage hintergrund;

void setup() {
size(500,400);
background(0);
selectInput("Suche einen Song aus","selected");
minim = new Minim(this);
Player = minim.loadFile(path); // Spielt die Mp3 datei ab
Player.loop(); // Wiederholt den aktuellen Song
farbe = 0;
smooth();
playPause = loadImage("play3.jpg");
hintergrund = loadImage("hintergrund2.jpg");
}

void selected(File song){
path = song.getAbsolutePath();
}

void interrupt(){
if (path == null){
println("Windows was closed or the user hit cancel.");
} else {
println("User selected " + path);
noLoop();
}
}

void draw() {
background(0);
image(hintergrund,0,0);
image(playPause,25,25);
translate(width/2, height/2);
rotate(radians(frameCount % 360 * 2));
colorMode(HSB);
stroke(farbe, 255, 255);
colorMode(RGB);

for(int j = 0; j < 360; j++){

if(Player.mix.get(j)*200 > 50) {
colorMode(HSB);
stroke(farbe, 255,255);
colorMode(RGB);
}
else {
colorMode(HSB);
stroke(farbe,255,255);
colorMode(RGB);
}
line(cos(j)*100, sin(j)*100, cos(j)*abs(Player.left.get(j))*250 + cos(j)*100, sin(j)*abs(Player.right.get(j))*250 + sin(j)*100);
}

//for(int i = 0; i < fft.avgSize(); i++){
//line((i * w)*3, height/1.1, (i * w)*3, height/1.1 - fft.getAvg(i) * 0.5);

farbe += 2;
if( farbe > 255)
{
farbe = 0;
}
// #########MOUSE############
if (mousePressed && (mouseButton == LEFT)) {
Player.pause();
} else if (mousePressed && (mouseButton == RIGHT)) {
Player.play();
}

}


thx 4 help
Member
Posts: 36,389
Joined: Jul 18 2008
Gold: 3,192.00
Jan 12 2017 04:59am
In all honesty, this is the perfect time get start getting familiar with a debugger.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll