The Polyphonic interface defines methods for adding, removing, and manipulating the state of AudioSignals. It looks a lot like a Collection. The methods are:
// Adds a signal to the signal chain. void addSignal(AudioSignal signal) // Removes all signals from the signal chain. void clearSignals() // Disables signal if it is in the chain. void disableSignal(AudioSignal signal) // Disables the ith signal in the signal chain. void disableSignal(int i) // Enables signal if it is in the chain. void enableSignal(AudioSignal signal) // Enables the ith signal in the signal chain. void enableSignal(int i) // Returns the ith signal in the signal chain. AudioSignal getSignal(int i) // Returns true if the signal is in the signal chain. boolean hasSignal(AudioSignal signal) // Returns true if signal is in the chain and is also enabled. boolean isEnabled(AudioSignal signal) // Enables all signals currently attached to this. void sound() // Disables all signals currently attached to this. void noSound() // Returns true if at least one signal in the chain is enabled. boolean isSounding() // Removes signal from the signals chain. void removeSignal(AudioSignal signal) // Removes and returns the ith signal in the signal chain. AudioSignal removeSignal(int i) // Returns the number of signals in the chain. int signalCount()
Note that there is no way to insert a signal into a particular slot. Signals are always added to the end of the signal list. The number of signals that can be added does not have a limit, other than memory. Processing time will also be a factor if signals are complex.
Code Sample (online example)
/** * This sketch demonstrates how to use the <code>addSignal</code> method of a <code>Polyphonic</code> class. * Currently the only <code>Polyphonic</code> class in Minim is <code>AudioOutput</code>. * This sketch adds a sine wave to the output and you should be hearing (and seeing) the results of that now. */ import ddf.minim.*; import ddf.minim.signals.*; Minim minim; AudioOutput out; SineWave sine; WaveformRenderer waveform; void setup() { size(512, 200, P3D); minim = new Minim(this); // this gets a stereo output out = minim.getLineOut(); waveform = new WaveformRenderer(); // see the example Recordable >> addListener for more about this out.addListener(waveform); // see the example AudioOutput >> SineWaveSignal for more about this sine = new SineWave(300, 0.2, out.sampleRate()); // add the signal to out out.addSignal(sine); } 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 out.close(); // alway stop Minim before exiting minim.stop(); super.stop(); }

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