Manual: Polyphonic

[ javadoc | examples ]

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)

import ddf.minim.*;
import ddf.minim.signals.*;
 
AudioOutput out;
SineWave sine;
WaveformRenderer waveform;
 
void setup()
{
  size(512, 200);
  // always start Minim first
  Minim.start(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);
  waveform.draw();
}
 
void stop()
{
  // always close Minim audio classes when you are done with them
  out.close();
  // always stop Minim before you exit
  Minim.stop();
 
  super.stop();
}