So this is my main file (named Testing
)
Minim minim;
Audio audio;
void setup()
{
audio = new Audio();
size(800, 800);
}
void draw()
{
audio.drawShape();
background(255);
}
And this is the Audio
class file
import ddf.minim.*;
import ddf.minim.analysis.*;
class Audio
{
final int BUFFERSIZE = 2048;
AudioPlayer audio;
Audio()
{
minim = new Minim(this);
audio = minim.loadFile("audio.mp3", BUFFERSIZE);
audio.play(); // This is where the nullpointer exception thing happens.
}
void drawShape()
{
ellipse(200, 400, audio.left.get(1)*800, audio.left.get(1)*800);
ellipse(600, 400, audio.right.get(1)*800, audio.right.get(1)*800);
}
}
I have the audio.mp3
in the same directory as these two files. But why do I keep getting this error message:
NullPointerException
Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help ? Troubleshooting.
Before I wasn’t getting it when I wasn’t uses classes, now all of a sudden why is this happening?