public class LiveSoundJavaSE extends LiveSoundCommon implements LiveSoundInterface
_audioInDoubleArray, _bitsPerSample, _bufferSize, _bytesPerSample, _captureData, _captureIsActive, _channels, _liveSoundListeners, _maxSample, _maxSampleReciprocal, _playbackData, _playbackIsActive, _sampleRate, _soundConsumers, _transferSize
Constructor and Description |
---|
LiveSoundJavaSE() |
Modifier and Type | Method and Description |
---|---|
void |
flushCaptureBuffer(java.lang.Object consumer)
Flush queued data from the capture buffer.
|
void |
flushPlaybackBuffer(java.lang.Object producer)
Flush queued data from the playback buffer.
|
int |
getBufferSizeCapture()
Return the size of the internal capture audio buffer, in samples per
channel.
|
int |
getBufferSizePlayback()
Return the size of the internal playback audio buffer, in samples per
channel.
|
double[][] |
getSamples(java.lang.Object consumer)
Return an array of captured audio samples.
|
void |
putSamples(java.lang.Object producer,
double[][] samplesArray)
Play an array of audio samples.
|
void |
resetCapture()
Stop audio capture.
|
void |
resetPlayback()
Stop audio playback.
|
void |
setBitsPerSample(int bitsPerSample)
Set the number of bits per sample to use for audio capture
and playback and notify any registered listeners of the change.
|
void |
setBufferSize(int bufferSize)
Request that the internal capture and playback
audio buffers have bufferSize samples per channel and notify the
registered listeners of the change.
|
void |
setChannels(int channels)
Set the number of audio channels to use for capture and
playback and notify any registered listeners of the change.
|
void |
setSampleRate(int sampleRate)
Set the sample rate to use for audio capture and playback
and notify an registered listeners of the change.
|
void |
startCapture(java.lang.Object consumer)
Start audio capture.
|
void |
startPlayback(java.lang.Object producer)
Start audio playback.
|
void |
stopCapture(java.lang.Object consumer)
Stop audio capture.
|
void |
stopPlayback(java.lang.Object producer)
Stop audio playback.
|
_byteArrayToDoubleArray, _doubleArrayToByteArray, _notifyLiveSoundListeners, addLiveSoundListener, getBitsPerSample, getBufferSize, getChannels, getSampleRate, getTransferSize, isCaptureActive, isPlaybackActive, removeLiveSoundListener, setTransferSize
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addLiveSoundListener, getBitsPerSample, getBufferSize, getChannels, getSampleRate, getTransferSize, isCaptureActive, isPlaybackActive, removeLiveSoundListener, setTransferSize
public void flushCaptureBuffer(java.lang.Object consumer) throws java.io.IOException, java.lang.IllegalStateException
Note that only the object with the exclusive lock on the capture audio resources is allowed to invoke this method. An exception will occur if the specified object does not have the lock on the playback audio resources.
flushCaptureBuffer
in interface LiveSoundInterface
consumer
- The object that has an exclusive lock on
the capture audio resources.java.lang.IllegalStateException
- If audio capture is currently
inactive. That is, if startCapture() has not yet been called
or if stopCapture() has already been called.java.io.IOException
- If the calling program does not have permission
to access the audio capture resources.public void flushPlaybackBuffer(java.lang.Object producer) throws java.io.IOException, java.lang.IllegalStateException
Note that only the object with the exclusive lock on the playback audio resources is allowed to invoke this method. An exception will occur if the specified object does not have the lock on the playback audio resources.
flushPlaybackBuffer
in interface LiveSoundInterface
producer
- The object that has an exclusive lock on
the playback audio resources.java.lang.IllegalStateException
- If audio playback is currently
inactive. That is, if startPlayback() has not yet been called
or if stopPlayback() has already been called.java.io.IOException
- If the calling program does not have permission
to access the audio playback resources.public int getBufferSizeCapture() throws java.lang.IllegalStateException
getBufferSizeCapture
in interface LiveSoundInterface
java.lang.IllegalStateException
- If audio capture is inactive.public int getBufferSizePlayback()
getBufferSizePlayback
in interface LiveSoundInterface
java.lang.IllegalStateException
- If audio playback is inactive.public double[][] getSamples(java.lang.Object consumer) throws java.io.IOException, java.lang.IllegalStateException
The first index of the returned array represents the channel number (0 for first channel, 1 for second channel). The number of channels is set by the setChannels() method. The second index represents the sample index within a channel. For example, returned array[n][m] contains the (m+1)th sample of the (n+1)th channel. For each channel, n, the length of returned array[n] is equal to the value returned by the getTransferSize() method. The size of the 2nd dimension of the returned array is set by the setTransferSize() method.
Note that only the object with the exclusive lock on the captured audio resources is allowed to invoked this method. An exception will occur if the specified object does not have the lock on the captured audio resources.
getSamples
in interface LiveSoundInterface
consumer
- The object that has an exclusive lock on
the capture audio resources.java.lang.IllegalStateException
- If audio capture is currently
inactive. That is, if startCapture() has not yet been called or if
stopCapture() has already been called.java.io.IOException
- If the calling program does not have permission
to access the audio capture resources.public void putSamples(java.lang.Object producer, double[][] samplesArray) throws java.io.IOException, java.lang.IllegalStateException
The samples should be in the range (-1, 1). Samples that are outside this range will be hard-clipped so that they fall within this range.
The first index of the specified array represents the channel number (0 for first channel, 1 for second channel, etc.). The number of channels is set by the setChannels() method. The second index represents the sample index within a channel. For example, putSamplesArray[n][m] contains the (m+1)th sample of the (n+1)th channel.
Note that only the object with the exclusive lock on the playback audio resources is allowed to invoke this method. An exception will occur if the specified object does not have the lock on the playback audio resources.
putSamples
in interface LiveSoundInterface
producer
- The object that has an exclusive lock on
the playback audio resources.samplesArray
- A two dimensional array containing
the samples to play or write to a file.java.io.IOException
- If the calling program does not have permission
to access the audio playback resources.java.lang.IllegalStateException
- If audio playback is currently
inactive. That is, If startPlayback() has not yet been called
or if stopPlayback() has already been called.public void resetCapture()
resetCapture
in interface LiveSoundInterface
public void resetPlayback()
resetPlayback
in interface LiveSoundInterface
public void setBitsPerSample(int bitsPerSample) throws java.io.IOException
setBitsPerSample
in interface LiveSoundInterface
bitsPerSample
- The number of bits per sample.java.io.IOException
- If the specified bits per sample is
not supported by the audio hardware or by Java.LiveSoundCommon.getBitsPerSample()
public void setBufferSize(int bufferSize) throws java.io.IOException
setBufferSize
in interface LiveSoundInterface
bufferSize
- The suggested size of the internal capture and
playback audio buffers, in samples per channel.java.io.IOException
- If the specified number of channels is
not supported by the audio hardware or by Java.LiveSoundCommon.getBufferSize()
public void setChannels(int channels) throws java.io.IOException
setChannels
in interface LiveSoundInterface
channels
- The number audio channels.java.io.IOException
- If the specified number of channels is
not supported by the audio hardware or by Java.LiveSoundCommon.getChannels()
public void setSampleRate(int sampleRate) throws java.io.IOException
setSampleRate
in interface LiveSoundInterface
sampleRate
- Sample rate in Hz.java.io.IOException
- If the specified sample rate is
not supported by the audio hardware or by Java.LiveSoundCommon.getSampleRate()
public void startCapture(java.lang.Object consumer) throws java.io.IOException, java.lang.IllegalStateException
If audio capture is already active, then an exception will occur.
startCapture
in interface LiveSoundInterface
consumer
- The object to be given exclusive access
to the captured audio resources.java.io.IOException
- If another object currently has access
to the audio capture resources or if starting the capture or
playback throws it.java.lang.IllegalStateException
- If this method is called
while audio capture is already active.public void startPlayback(java.lang.Object producer) throws java.io.IOException, java.lang.IllegalStateException
If audio playback is already active, then an exception will occur.
startPlayback
in interface LiveSoundInterface
producer
- The object to be given exclusive access
to the playback resources.java.io.IOException
- If another object currently has access
to the audio capture resources or if starting the playback throws it.java.lang.IllegalStateException
- If this method is called
while audio playback is already active.public void stopCapture(java.lang.Object consumer) throws java.io.IOException, java.lang.IllegalStateException
stopCapture
in interface LiveSoundInterface
consumer
- The object that held on exclusive
lock on the captured audio resources when this
method was invoked.java.io.IOException
- If another object currently has access
to the audio capture resources or if stopping the capture throws it.java.lang.IllegalStateException
- If the specified
object did not hold an exclusive lock on the
captured audio resources when this method was invoked.public void stopPlayback(java.lang.Object producer) throws java.io.IOException, java.lang.IllegalStateException
stopPlayback
in interface LiveSoundInterface
producer
- The object that held on exclusive
lock on the playback audio resources when this
method was invoked.java.io.IOException
- If another object currently has access
to the audio capture resources or if stopping the playback throws it.java.lang.IllegalStateException
- If the specified
object did not hold an exclusive lock on the
playback audio resources when this method was invoked.