Manual: AudioEffect
The AudioEffect interface is used by the Effectable interface and defines only two methods. These methods are:
void process(float[] samples) void process(float[] samplesLeft, float[] samplesRight)
One of these methods will be called repeatedly by the Effectable object that an AudioEffect has been added to, depending upon whether the audio being effected is mono or stereo. The effect is expected to modify these arrays in such a way that the values remain in the range [-1, 1]. All of the effects included with Minim implement this interface and all you need to do to write your own effects is to create a class that implements this interface and then add an instance of it to an anything that is Effectable, such as an AudioOutput.
Code Sample (online sample)
import ddf.minim.*; import ddf.minim.effects.*; // this is a really straightforward effect that // just reverses the order of the samples it receives // it doesn't sound like how you think ;-) class ReverseEffect implements AudioEffect { void process(float[] samp) { float[] reversed = new float[samp.length]; int i = samp.length - 1; for (int j = 0; j < reversed.length; i--, j++) { reversed[j] = samp[i]; } // we have to copy the values back into samp for this to work arraycopy(reversed, samp); } void process(float[] left, float[] right) { process(left); process(right); } } AudioPlayer groove; ReverseEffect reffect; void setup() { size(512, 200); // always start Minim first Minim.start(this); // try changing the buffer size to see how it changes the effect groove = Minim.loadFile("groove.mp3", 512); groove.loop(); reffect = new ReverseEffect(); groove.addEffect(reffect); } void draw() { background(0); stroke(255); for(int i = 0; i < groove.bufferSize() - 1; i++) { line(i, 50 - groove.left.get(i)*50, i+1, 50 - groove.left.get(i+1)*50); line(i, 150 - groove.right.get(i)*50, i+1, 150 - groove.right.get(i+1)*50); } } void stop() { // always close Minim audio classes when you are done with them groove.close(); // always stop Minim before exiting Minim.stop(); super.stop(); }