I am using processing with Minim, but I can't figure out how to play files, if the minim
loading files are in another class. I used both AudioSnippet
and AudioSample
and they both give me NullPointerException
. Here is a the PlayAudio
class.
Minim minim;
AudioSample sample;
AudioSnippet snippet;
class PlayAudio {
PlayAudio() {
minim = new Minim(this);
sample = minim.loadSample("Audio/hover1.mp3", 2048);
snippet = minim.loadSnippet("Audio/hover1.mp3");
}
void playSnippet() {
sample.trigger();
snippet.play();
}
}
The other is a standard processing setup()
and draw()
. Files should be played when mouse is pressed.
import ddf.minim.spi.*;
import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.ugens.*;
import ddf.minim.effects.*;
PlayAudio audio = new PlayAudio();
void setup() {
size(300, 300);
background(0);
}
void draw() {
if(mousePressed) {
audio.playSnippet();
}
}
The errors I get are:
==== JavaSound Minim Error ====
==== Couldn't find a sketchPath method on the file loading object provided!
==== File recording will be disabled.
==== JavaSound Minim Error ====
==== Couldn't find a createInput method in the file loading object provided!
==== File loading will be disabled.
==== JavaSound Minim Error ====
==== Error invoking createInput on the file loader object: null
=== Minim Error ===
=== Couldn't load the file Audio/hover1.mp3