Need help, Null pointer exception
in
Core Library Questions
•
6 months ago
Hi, I need some help with this code. I had it working a few months ago and foe some reason it dosent seem to work again :/, the idea is to have a free drawing tool over a tone matrix, the code is as follows:
import ddf.minim.*;
Minim minim;
AudioPlayer kick,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12
void setup() {
size(800, 600);
background(255);
minim = new Minim(this);
/*sounds*/
// 1ST ROW
m1 = minim.loadFile("D1.wav");//Background
m2 = minim.loadFile("C#1.wav");//Background
m3 = minim.loadFile("A1.wav");//Background
m4 = minim.loadFile("A#1.wav");//yep
m5 = minim.loadFile("F1.wav");//Yep
m6 = minim.loadFile("D#1.wav");//yep
m7 = minim.loadFile("E1.wav");//yep
m8 = minim.loadFile("C1.wav");
m9 = minim.loadFile("G#1.wav");//yep
m10 = minim.loadFile("G1.wav");//yep
m11 = minim.loadFile("G#1.wav"); //yep
m12 = minim.loadFile("B1.wav");//yep
void draw() {
stroke(0);
strokeWeight(6);
if(mousePressed) {
line(mouseX, mouseY, pmouseX, pmouseY);
}
if(
mouseX >= rx && mouseX <= rx+rwidth &&
mouseY >= ry && mouseY <= ry+rheight
){
m1.play();
}else{
m1.pause();
}
if(
mouseX >= rx2 && mouseX <= rx2+rwidth &&
mouseY >= ry2 && mouseY <= ry2+rheight
){
m2.play();
}else{
m2.pause();
}
if(
mouseX >= rx3 && mouseX <= rx3+rwidth &&
mouseY >= ry3 && mouseY <= ry3+rheight
){
m3.play();
}else{
m3.pause();
}
if(
mouseX >= rx4 && mouseX <= rx4+rwidth &&
mouseY >= ry4 && mouseY <= ry4+rheight
){
m4.play();
}else{
m4.pause();
}
if(
mouseX >= rx5 && mouseX <= rx5+rwidth &&
mouseY >= ry5 && mouseY <= ry5+rheight
){
m5.play();
}else{
m5.pause();
}
if(
mouseX >= rx6 && mouseX <= rx6+rwidth &&
mouseY >= ry6 && mouseY <= ry6+rheight
){
m6.play();
}else{
m6.pause();
}
if(
mouseX >= rx7 && mouseX <= rx7+rwidth &&
mouseY >= ry7 && mouseY <= ry7+rheight
){
m7.play();
}else{
m7.pause();
}
if(
mouseX >= rx8 && mouseX <= rx8+rwidth &&
mouseY >= ry8 && mouseY <= ry8+rheight
){
m8.play();
}else{
m8.pause();
}
if(
mouseX >= rx9 && mouseX <= rx9+rwidth &&
mouseY >= ry9 && mouseY <= ry9+rheight
){
m9.play();
}else{
m9.pause();
}
if(
mouseX >= rx10 && mouseX <= rx10+rwidth &&
mouseY >= ry10 && mouseY <= ry10+rheight
){
m10.play();
}else{
m10.pause();
}
if(
mouseX >= rx11 && mouseX <= rx11+rwidth &&
mouseY >= ry11 && mouseY <= ry11+rheight
){
m11.play();
}else{
m11.pause();
}
if(
mouseX >= rx12 && mouseX <= rx12+rwidth &&
mouseY >= ry12 && mouseY <= ry12+rheight
){
m12.play();
}else{
m12.pause();
}
//the rectangles
noFill();
noStroke();
rect(rx, ry, rwidth, rheight);
rect(rx2, ry2, rwidth, rheight);
rect(rx3, ry3, rwidth, rheight);
rect(rx4, ry4, rwidth, rheight);
rect(rx5, ry5, rwidth, rheight);
rect(rx6, ry6, rwidth, rheight);
rect(rx7, ry7, rwidth, rheight);
rect(rx8, ry8, rwidth, rheight);
rect(rx9, ry9, rwidth, rheight);
rect(rx10, ry10, rwidth, rheight);
rect(rx11, ry11, rwidth, rheight);
rect(rx12, ry12, rwidth, rheight);
//if ( keyCode == ENTER) {
//background(255);
//}
if ( key == ' '){
saveFrame ("screenshot#####.jpg");
}
}
void stop()
{
m1.close();
m2.close();
m3.close();
m4.close();
m5.close();
m6.close();
m7.close();
m8.close();
m9.close();
m10.close();
m11.close();
m12.close();
minim.stop();
super.stop();
}
the error i am getting is :
Exception in thread "Animation Thread" java.lang.NullPointerException
at ddf.minim.javasound.JSMinim.getAudioInputStream(JSMinim.java:604)
at ddf.minim.javasound.JSMinim.getAudioRecordingStream(JSMinim.java:200)
at ddf.minim.Minim.loadFile(Minim.java:357)
at ddf.minim.Minim.loadFile(Minim.java:341)
at sketch_130404a.setup(sketch_130404a.java:346)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:662)
1