public class SignalSplitter extends java.lang.Object implements Recordable, AudioListener
SignalSplitter acts exactly like a headphone splitter.
When you pass it audio with the samples method, it echoes that
audio out to all of its listeners, giving each their own copy of the audio.
In other words, changes that the listeners make to the float arrays
they receive from a SignalSplitter will not be reflected in
the arrays you pass to samples. SignalSplitter is
fully synchronized so that listeners cannot be added and
removed while it is in the midst transmitting.| Constructor and Description |
|---|
SignalSplitter(javax.sound.sampled.AudioFormat format,
int bufferSize)
Construct a
SignalSplitter that will receive
audio in the given format and in buffers the size of
bufferSize. |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(AudioListener listener)
Adds a listener who will be notified each time this receives
or creates a new buffer of samples.
|
int |
bufferSize()
Returns the buffer size being used by this.
|
javax.sound.sampled.AudioFormat |
getFormat()
Returns the format of this recordable audio.
|
void |
removeListener(AudioListener listener)
Removes the listener from the list of listeners.
|
float |
sampleRate()
Returns the sample rate of this recordable audio.
|
void |
samples(float[] samp)
Called by the
Recordable object this is attached to
when that object has new samples. |
void |
samples(float[] sampL,
float[] sampR)
Called by the
Recordable object this is attached to
when that object has new samples. |
int |
type()
Returns either Minim.MONO or Minim.STEREO
|
public SignalSplitter(javax.sound.sampled.AudioFormat format,
int bufferSize)
SignalSplitter that will receive
audio in the given format and in buffers the size of
bufferSize. Strictly speaking, a SignalSplitter
doesn't care about either of these things because it does nothing with
the samples it receives other than pass them on. But both things are
required to fulfill the Recordable contract.format - the AudioFormat of samples that this will receivebufferSize - the size of the float arrays this will receivepublic int bufferSize()
RecordablebufferSize in interface Recordablepublic javax.sound.sampled.AudioFormat getFormat()
RecordablegetFormat in interface Recordablepublic int type()
Recordabletype in interface Recordablepublic void addListener(AudioListener listener)
RecordableaddListener in interface Recordablelistener - the listener to addpublic void removeListener(AudioListener listener)
RecordableremoveListener in interface Recordablelistener - the listener to removepublic void samples(float[] samp)
AudioListenerRecordable object this is attached to
when that object has new samples.samples in interface AudioListenersamp - a buffer of samples from a MONO sound streampublic void samples(float[] sampL,
float[] sampR)
AudioListenerRecordable object this is attached to
when that object has new samples.samples in interface AudioListenersampL - the left channel of a STEREO sound streamsampR - the right channel of a STEREO sound streampublic float sampleRate()
RecordablesampleRate in interface Recordable