Null Pointer Exception error with minim
in
Programming Questions
•
3 years ago
Hi,
I am quite new to Processing and I am trying to generate random Audio Sample using a mousePressed. I got a great feedback from a member off
http://code.compartmental.net/tools/minim/manual-audiosample/ , but I must be coding uncorrectly because this error message "NullPointerException"is showing.
This is what I have typed:
import ddf.minim.*;
import ddf.minim.AudioSample.*;
Minim minim;
AudioSample [] oneSounds = new AudioSample [0];
AudioSample [] twoSounds= new AudioSample [1];
AudioSample [] threeSounds = new AudioSample [2];
AudioSample [] fourSounds = new AudioSample [3];
AudioSample [] fiveSounds = new AudioSample [4];
void setup()
{
size(100, 100);
minim = new Minim(this);
oneSounds [0] = minim.loadSample("button-1.mp3");
twoSounds [1] = minim.loadSample("button-2.mp3");
threeSounds [2] = minim.loadSample("button-3.mp3");
fourSounds [3] = minim.loadSample("button-4.mp3");
fiveSounds [4]= minim.loadSample("button-5.mp3");
}
void draw() {
}
void mousePressed() {
{
int index = int( random(0,5 ) );
oneSounds[0].trigger();
twoSounds[1].trigger();
threeSounds[2].trigger();
fourSounds[3].trigger();
fiveSounds [4].trigger();
}
}
void stop()
{
minim.stop();
super.stop();
}
and the line that is highlighted with the error is:
oneSounds [0] = minim.loadSample("button-1.mp3");
Would be lovely to hear some feedback or what I can do to improve.
Thanks.
1