/**
* This sketch demonstrates how to use the loop method of a Playable class.
* The class used here is AudioPlayer, but you can also loop an AudioSnippet.
* When you call loop() it will make the Playable playback in an infinite loop.
* If you want to make it stop looping you can call play() and it will finish the current loop
* and then stop. Press 'l' to start the player looping.
*
*/
import ddf.minim.*;
import ddf.minim.effects.*;
Minim minim;
AudioPlayer groove;
WaveformRenderer waveform;
void setup()
{
size(512, 200, P3D);
minim = new Minim(this);
groove = minim.loadFile("groove.mp3", 2048);
waveform = new WaveformRenderer();
// see the example Recordable >> addListener for more about this
groove.addListener(waveform);
}
void draw()
{
background(0);
// see waveform.pde for an explanation of how this works
waveform.draw();
}
void keyPressed()
{
if ( key == 'l' ) groove.loop();
}
void stop()
{
// always close Minim audio classes when you are done with them
groove.close();
// always stop Minim before exiting.
minim.stop();
super.stop();
}