public class LiveSoundCommon extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected double[][] |
_audioInDoubleArray
Array of audio samples in double format.
|
protected int |
_bitsPerSample
The number of bits per sample.
|
protected int |
_bufferSize
The requested buffer size in samples per channel.
|
protected int |
_bytesPerSample
The number of bytes per sample, default 2.
|
protected byte[] |
_captureData
Array of audio samples in byte format.
|
protected boolean |
_captureIsActive
true is audio capture is currently active.
|
protected int |
_channels
The number of channels.
|
protected java.util.List |
_liveSoundListeners
The list of listeners.
|
protected double |
_maxSample
Cached value of the maximum integer value, default for 16
bits.
|
protected double |
_maxSampleReciprocal
Cached value of the maximum value scaling factor, default for
16 bits.
|
protected byte[] |
_playbackData
Byte buffer used for playback data.
|
protected boolean |
_playbackIsActive
true is audio playback is currently active.
|
protected float |
_sampleRate
The sample rate.
|
protected java.util.List |
_soundConsumers
The list of sound consumers.
|
protected int |
_transferSize
The number of audio samples to transfer per channel when
getSamples() is invoked.
|
| Constructor and Description |
|---|
LiveSoundCommon() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
_byteArrayToDoubleArray(double[][] doubleArray,
byte[] byteArray)
Convert a byte array of audio samples in linear signed PCM big endian
format into a double array of audio samples (-1, 1) range.
|
protected byte[] |
_doubleArrayToByteArray(double[][] doubleArray)
Convert a double array of audio samples into a byte array of
audio samples in linear signed PCM big endian format.
|
protected void |
_notifyLiveSoundListeners(int parameter)
Notify the live sound listeners about a change in an audio
parameter.
|
void |
addLiveSoundListener(LiveSoundListener listener)
Add a live sound listener.
|
int |
getBitsPerSample()
Return the number of bits per sample.
|
int |
getBufferSize()
Return the suggested size of the internal capture and playback audio
buffers, in samples per channel.
|
int |
getChannels()
Return the number of audio channels, which is set by
the setChannels() method.
|
int |
getSampleRate()
Return the current sampling rate in Hz, which is set
by the setSampleRate() method.
|
int |
getTransferSize()
Get the array length (in samples per channel) to use
for capturing and playing samples via the putSamples()
and getSamples() methods.
|
boolean |
isCaptureActive()
Return true if audio capture is currently active.
|
boolean |
isPlaybackActive()
Return true if audio playback is currently active.
|
void |
removeLiveSoundListener(LiveSoundListener listener)
Remove a live sound listener.
|
void |
setTransferSize(int transferSize)
Set the array length (in samples per channel) to use
for capturing and playing samples via the putSamples()
and getSamples() methods.
|
protected double[][] _audioInDoubleArray
protected int _bitsPerSample
protected int _bufferSize
protected int _bytesPerSample
protected boolean _captureIsActive
protected int _channels
protected byte[] _captureData
protected byte[] _playbackData
protected java.util.List _liveSoundListeners
protected double _maxSampleReciprocal
protected double _maxSample
protected boolean _playbackIsActive
protected float _sampleRate
protected java.util.List _soundConsumers
protected int _transferSize
public LiveSoundCommon()
public void addLiveSoundListener(LiveSoundListener listener)
listener - The LiveSoundListener to add.removeLiveSoundListener(LiveSoundListener)public int getBitsPerSample()
public int getBufferSize()
public int getChannels()
public int getSampleRate()
public int getTransferSize()
setTransferSize(int)public boolean isCaptureActive()
public boolean isPlaybackActive()
public void removeLiveSoundListener(LiveSoundListener listener)
listener - The LiveSoundListener to remove.addLiveSoundListener(LiveSoundListener)public void setTransferSize(int transferSize) throws java.lang.IllegalStateException
This method should only be called while audio capture and playback are inactive. Otherwise an exception will occur.
transferSize - The size of the 2nd dimension of
the 2-dimensional array used by the putSamples() and
getSamples() methodsjava.lang.IllegalStateException - If this method is called
while audio capture or playback are active.getTransferSize()protected void _byteArrayToDoubleArray(double[][] doubleArray, byte[] byteArray)
doubleArray - The resulting array of doubles.byteArray - The linear signed pcm big endian byte array
formatted array representation of audio data.protected byte[] _doubleArrayToByteArray(double[][] doubleArray)
doubleArray - Two dimensional array holding audio samples.
For each channel, m, doubleArray[m] is a single dimensional
array containing samples for channel m. All channels are
required to have the same number of samples, but this is
not checked.protected void _notifyLiveSoundListeners(int parameter)
parameter - The audio parameter of LiveSound that
has changed. The value of parameter should be one of
LiveSoundEvent.SAMPLE_RATE, LiveSoundEvent.CHANNELS,
LiveSoundEvent.BUFFER_SIZE, or
LiveSoundEvent.BITS_PER_SAMPLE.