public class SignalChain extends java.lang.Object implements AudioSignal
SignalChain is a list of AudioSignals
that gives you the ability to enable (unmute) and disable (mute) signals.
When you add a signal, it is added to the end of the chain and is enabled.
When you remove a signal, signals further down the chain are moved up a slot.
SignalChain is itself an AudioSignal, so you
can easily create groups of signals that can be enabled/disabled together by
putting them in an SignalChain and then adding that chain to a
Polyphonic object as a single signal. When the signal chain is
asked to generate a signal, it asks each of its signals to generate audio and
then mixes all of the signals together. SignalChain is fully
synchronized so that signals cannot be added and removed from
the chain during signal generation.| Constructor and Description |
|---|
SignalChain()
Constructs an empty
SignalChain. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(AudioSignal signal)
Adds
signal to the end of the chain. |
void |
clear()
Removes all signals from the effect chain.
|
boolean |
contains(AudioSignal s)
Returns true if
s is in the chain. |
void |
disable(AudioSignal signal)
Disables
signal if it is in the chain. |
void |
disable(int i)
Disables the
ith effect in the chain. |
void |
disableAll()
Disables all signals in the chain.
|
void |
enable(AudioSignal signal)
Enables
signal if it is in the chain. |
void |
enable(int i)
Enables the
ith effect in the chain. |
void |
enableAll()
Enables all signals in the chain.
|
void |
generate(float[] signal)
Asks all the enabled signals in the chain to generate a new buffer of
samples, adds the buffers together and puts the result in
signal. |
void |
generate(float[] left,
float[] right)
Asks all the enabled signals in the chain to generate a left and right
buffer of samples, adds the signals together and puts the result in
left and right. |
AudioSignal |
get(int i)
Gets the
ith signal in the chain. |
boolean |
hasEnabled()
Returns true if at least one effect in the chain is enabled.
|
boolean |
isEnabled(AudioSignal signal)
Returns true if
e is in the chain and is enabled. |
void |
remove(AudioSignal signal)
Removes
signal from the chain. |
AudioSignal |
remove(int i)
Removes and returns the
ith signal from the
chain. |
int |
size()
Returns the number of signals in the chain.
|
public void add(AudioSignal signal)
signal to the end of the chain.signal - the AudioEffect to addpublic void remove(AudioSignal signal)
signal from the chain.signal - the AudioSignal to removepublic AudioSignal remove(int i)
ith signal from the
chain.i - the index of the AudioSignal to removeAudioSignal that was removedpublic AudioSignal get(int i)
ith signal in the chain.i - the index of the AudioSignal to getpublic boolean contains(AudioSignal s)
s is in the chain.s - the AudioSignal to check fors is in the chainpublic void enable(int i)
ith effect in the chain.i - the index of the effect to enablepublic void enable(AudioSignal signal)
signal if it is in the chain.signal - the AudioSignal to enablepublic void enableAll()
public boolean hasEnabled()
public boolean isEnabled(AudioSignal signal)
e is in the chain and is enabled.signal - the AudioSignal to return the status ofsignal is enabled and in the chainpublic void disable(int i)
ith effect in the chain.i - the index of the effect to disablepublic void disable(AudioSignal signal)
signal if it is in the chain.signal - the AudioSignal to disablepublic void disableAll()
public int size()
public void clear()
public void generate(float[] signal)
signal.generate in interface AudioSignalsignal - the float array to fillpublic void generate(float[] left,
float[] right)
left and right.generate in interface AudioSignalleft - the left channelright - the right channel