The Effectable interface defines methods that allow adding, removing, and manipulating the state of AudioEffects. It looks a lot like a Collection. The methods are:
// Adds an effect to the effects chain. void addEffect(AudioEffect effect) // Removes all effects from the effect chain. void clearEffects() // Disables effect if it is in the chain. void disableEffect(AudioEffect effect) // Disables the ith effect in the effect chain. void disableEffect(int i) // Returns the number of effects in the chain. int effectCount() // Enables all effects currently attached to this. void effects() // Enables effect if it is in the chain. void enableEffect(AudioEffect effect) // Enables the ith effect in the effect chain. void enableEffect(int i) // Returns the ith effect in the effect chain. AudioEffect getEffect(int i) // Returns true if effect is in the chain. boolean hasEffect(AudioEffect effect) // Returns true if at least one effect in the chain is enabled. boolean isEffected() // Returns true if effect is in the chain and is also enabled. boolean isEnabled(AudioEffect effect) // Disables all effects currently attached to this. void noEffects() // Removes effect from the effects chain. void removeEffect(AudioEffect effect) // Removes and returns the ith effect in the effect chain. AudioEffect removeEffect(int i)
Note that there is no way to insert an effect into a particular slot. Effects are always added to the end of the effect list. The number of effects that can be added does not have a limit, other than memory. Processing time will also be a factor if effects are complex.
Code Sample (online example)
/** * This sketch demonstrates how to use the <code>addEffect</code> method of an <code>Effectable</code> class. * The class used here is <code>AudioPlayer</code>, but you can also add effects to <code>AudioInput</code>, * <code>AudioOutput</code>, and <code>AudioSample</code> objects. This sketch adds a low pass filter to * the player and you should be hearing the results of that now. */ import ddf.minim.*; import ddf.minim.effects.*; Minim minim; AudioPlayer groove; LowPassFS lpfilter; WaveformRenderer waveform; void setup() { size(512, 200, P3D); minim = new Minim(this); groove = minim.loadFile("groove.mp3", 2048); groove.loop(); waveform = new WaveformRenderer(); // see the example Recordable >> addListener for more about this groove.addListener(waveform); // see the example AudioEffect >> LowPassFSFilter for more about this lpfilter = new LowPassFS(300, groove.sampleRate()); // add the effect to the player groove.addEffect(lpfilter); } void draw() { background(0); // see waveform.pde for an explanation of how this works waveform.draw(); } void stop() { // always close Minim audio classes when you are done with them groove.close(); minim.stop(); super.stop(); }

No comments
Comments feed for this article
Trackback link: http://code.compartmental.net/tools/minim/manual-effectable/trackback/