public interface LiveSoundInterface
Modifier and Type | Method and Description |
---|---|
void |
addLiveSoundListener(LiveSoundListener listener)
Add a live sound listener.
|
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 |
getBitsPerSample()
Return the number of bits per audio sample, which is
set by the setBitsPerSample() method.
|
int |
getBufferSize()
Return the suggested size of the internal capture and playback audio
buffers, in samples per channel.
|
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.
|
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.
|
double[][] |
getSamples(java.lang.Object consumer)
Return an array of captured audio samples.
|
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 |
putSamples(java.lang.Object producer,
double[][] samplesArray)
Play an array of audio samples.
|
void |
removeLiveSoundListener(LiveSoundListener listener)
Remove a live sound listener.
|
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 |
setTransferSize(int transferSize)
Set the array length (in samples per channel) to use
for capturing and playing samples via the putSamples()
and getSamples() methods.
|
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.
|
void addLiveSoundListener(LiveSoundListener listener)
listener
- The LiveSoundListener to add.removeLiveSoundListener(LiveSoundListener)
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.
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.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.
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.int getBitsPerSample()
setBitsPerSample(int)
int getBufferSize()
setBufferSize(int)
int getBufferSizeCapture() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- If audio capture is inactive.int getBufferSizePlayback()
java.lang.IllegalStateException
- If audio playback is inactive.int getChannels()
setChannels(int)
int getSampleRate()
setSampleRate(int)
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.
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.int getTransferSize()
setTransferSize(int)
boolean isCaptureActive()
boolean isPlaybackActive()
void putSamples(java.lang.Object producer, double[][] samplesArray) throws java.io.IOException, java.lang.IllegalStateException
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.void removeLiveSoundListener(LiveSoundListener listener)
listener
- The LiveSoundListener to remove.addLiveSoundListener(LiveSoundListener)
void resetCapture()
void resetPlayback()
void setBitsPerSample(int bitsPerSample) throws java.io.IOException
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.getBitsPerSample()
void setBufferSize(int bufferSize) throws java.io.IOException
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.getBufferSize()
void setChannels(int channels) throws java.io.IOException
channels
- The number audio channels.java.io.IOException
- If the specified number of channels is
not supported by the audio hardware or by Java.getChannels()
void setSampleRate(int sampleRate) throws java.io.IOException
sampleRate
- Sample rate in Hz.java.io.IOException
- If the specified sample rate is
not supported by the audio hardware or by Java.getSampleRate()
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()
void startCapture(java.lang.Object consumer) throws java.io.IOException, java.lang.IllegalStateException
If audio capture is already active, then an exception will occur.
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.void startPlayback(java.lang.Object producer) throws java.io.IOException, java.lang.IllegalStateException
If audio playback is already active, then an exception will occur.
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.void stopCapture(java.lang.Object consumer) throws java.io.IOException, java.lang.IllegalStateException
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.void stopPlayback(java.lang.Object producer) throws java.io.IOException, java.lang.IllegalStateException
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.