/**
* This sketch is an example of how to use the size method of an AudioBuffer to get the
* size of one of an AudioSource's sample buffers. The classes in Minim that extend AudioSource
* and therefore inherit the left, right, and mix buffers of that class, are
* AudioInput, AudioOutput, AudioSample, and AudioPlayer.
* Not coincidentally, these are also all of the classes in Minim that are Recordable.
*
* The value returned by size is the number of samples stored in the buffer. It will always be
* equal to the bufferSize() of the Recordable you are working with. It is often a value
* that you specify when you create the Recordable such as with loadFile or getLineIn.
*/
import ddf.minim.*;
Minim minim;
AudioOutput out;
void setup()
{
size(350, 100, P3D);
textMode(SCREEN);
minim = new Minim(this);
out = minim.getLineOut();
textFont(loadFont("courier12.vlw"));
}
void draw()
{
background(0);
text("The size of the left buffer is " + out.left.size() + " samples.", 5, 15);
text("The size of the right buffer is " + out.right.size() + " samples.", 5, 30);
text("The size of the mix buffer is " + out.mix.size() + " samples.", 5, 45);
text("The buffer size of the player is " + out.bufferSize() + " samples.", 5, 60);
}
void stop()
{
// always close Minim audio classes when you finish with them
out.close();
// always stop Minim before exiting
minim.stop();
super.stop();
}