need help importing sound!!!
in
Core Library Questions
•
2 years ago
this is what i have so far...
Bubble[] bubbles;
import ddf.minim.*;
Minim minim;
AudioPlayer player;
void setup(){
minim = new Minim(this);
player = minim.loadFile("Bubbles.mp3");
player.loop();
println(player.getControls());
background(108,16,229);
frameRate(20);
size(500, 500);
colorMode(RGB, 300, 100, 50);
smooth();
bubbles = new Bubble[1000];
for(int i = 0; i < 500; i++){
bubbles[i] = new Bubble(random(10, 500),random(50, 500),random(5,50));
}
}
void draw(){
background(108,16,229);
for(int i=0; i<500;i++){
bubbles[i].display();
bubbles[i].move();
}
}
class Bubble {
float mad, ison, diameter, bai, ley, jump, swim;
Bubble(float m, float b, float a){
mad= m;
ison= b;
diameter = a;
jump= .6;
swim= -.99;
bai= random(0,3);
ley= random(0,3);
}
void display(){
fill(119, 64, 89, random(50,100));
ellipse(mad, ison, diameter, diameter);
}
void move(){
ley +=jump;
mad += bai;
ison += ley;
if(mad> width){
mad= width;
bai= -bai;
}
if(mad< 0){
mad= 0;
bai= -bai;
}
if(ison> height){
ison= height;
ley *= swim;
bai *=swim;
}
if(ison< 0){
ison= 0;
ley *= swim;
}
}
}
The error is showing up at the "loadFile" line and the name of the error is NullPointer Exception. I do not know what is wrong with my code or if the problem has to do with where I saved the file. please help!!!
Bubble[] bubbles;
import ddf.minim.*;
Minim minim;
AudioPlayer player;
void setup(){
minim = new Minim(this);
player = minim.loadFile("Bubbles.mp3");
player.loop();
println(player.getControls());
background(108,16,229);
frameRate(20);
size(500, 500);
colorMode(RGB, 300, 100, 50);
smooth();
bubbles = new Bubble[1000];
for(int i = 0; i < 500; i++){
bubbles[i] = new Bubble(random(10, 500),random(50, 500),random(5,50));
}
}
void draw(){
background(108,16,229);
for(int i=0; i<500;i++){
bubbles[i].display();
bubbles[i].move();
}
}
class Bubble {
float mad, ison, diameter, bai, ley, jump, swim;
Bubble(float m, float b, float a){
mad= m;
ison= b;
diameter = a;
jump= .6;
swim= -.99;
bai= random(0,3);
ley= random(0,3);
}
void display(){
fill(119, 64, 89, random(50,100));
ellipse(mad, ison, diameter, diameter);
}
void move(){
ley +=jump;
mad += bai;
ison += ley;
if(mad> width){
mad= width;
bai= -bai;
}
if(mad< 0){
mad= 0;
bai= -bai;
}
if(ison> height){
ison= height;
ley *= swim;
bai *=swim;
}
if(ison< 0){
ison= 0;
ley *= swim;
}
}
}
The error is showing up at the "loadFile" line and the name of the error is NullPointer Exception. I do not know what is wrong with my code or if the problem has to do with where I saved the file. please help!!!
1