//set up AudioContext, make an instance of the class -- kind of like an audio object
ac = new AudioContext();
// path to file must be absolute path on your machine, something like this
String audioFile = "/Users/aileen/Documents/Processing/beads_audio/oriental_gong.wav";
//init granular sample player
player = new GranularSamplePlayer(ac, SampleManager.sample(audioFile));
//loop the sample at its end points
player.setLoopType(SamplePlayer.LoopType.LOOP_ALTERNATING);
//set begin of defined envelope to start
player.getLoopStartEnvelope().setValue(0);
//set end of defined envelope to end
player.getLoopEndEnvelope().setValue(SampleManager.sample(audioFile).getLength());
// Example uses keypresses of [ and ] to change rate envelope
void keyPressed() {
if (key == ']') {
varRate += .2;
}
else if (key == '[') {
varRate += -.2;
}
Envelope newRateEnvelope = new Envelope(ac, varRate);
player.setRateEnvelope(newRateEnvelope);
}
ERROR:
processing.app.debug.RunnerException: NullPointerException
at processing.app.Sketch.placeException(Sketch.java:1543)
at processing.app.debug.Runner.findException(Runner.java:583)
at processing.app.debug.Runner.reportException(Runner.java:558)
at processing.app.debug.Runner.exception(Runner.java:498)
at processing.app.debug.EventThread.exceptionEvent(EventThread.java:367)
at processing.app.debug.EventThread.handleEvent(EventThread.java:255)
at processing.app.debug.EventThread.run(EventThread.java:89)
Exception in thread "Animation Thread" java.lang.NullPointerException
at beads.GranularSamplePlayer.<init>(Unknown Source)
at sketch_feb16b.setup(sketch_feb16b.java:44)
at processing.core.PApplet.handleDraw(PApplet.java:1583)
at processing.core.PApplet.run(PApplet.java:1503)
at java.lang.Thread.run(Thread.java:613)