com.groovemanager.sampled
Interface AudioPlayerProvider

All Known Implementing Classes:
WaveTab

public interface AudioPlayerProvider

An AudioPlayerProvider represents any kind of audio source that can present audio data to an AudioPlayer to be played and/or can process recorded audio data in any way.

Author:
Manu Robledo

Method Summary
 boolean canLoop()
          Ask this provider, if he can provide audio data in a loop.
 boolean canProvide()
          Ask this provider, if he is ready for providing playback audio data
 boolean canRec()
          Ask this provider, if he can process recorded audio data in any way.
 javax.sound.sampled.AudioInputStream getAudioInputStream()
          Provide an AudioInputStream for playback
 int getLastStart()
          Get the last start position inside the whole audio source.
 int rec(byte[] b, int offset, int length)
          Process a recorded buffer of audio data.
 javax.sound.sampled.AudioFormat startRec()
          Start recording of audio data.
 void stopRec()
          Notification from the AudioPlayer that recording has finished.
 

Method Detail

canLoop

boolean canLoop()
Ask this provider, if he can provide audio data in a loop. If so, he will be asked for a new AudioInputStream after each loop end.

Returns:
true, if this provider can provide its audio data in a loop, false otherwise

canProvide

boolean canProvide()
Ask this provider, if he is ready for providing playback audio data

Returns:
true, if audio data can provided, false otherwise

canRec

boolean canRec()
Ask this provider, if he can process recorded audio data in any way.

Returns:
true, if this provider can currently process recorded audio data, false otherwise

getAudioInputStream

javax.sound.sampled.AudioInputStream getAudioInputStream()
                                                         throws NotReadyException
Provide an AudioInputStream for playback

Returns:
The AudioInputStream to be played back
Throws:
NotReadyException - If no audio data can be presented at the moment

getLastStart

int getLastStart()
Get the last start position inside the whole audio source. Is needed for correct displaying of The play position and will usually be called shortly after getAudioInputStream()

Returns:
The frame position inside the audio source represented by this provider, at which the provided AudioInputStream starts.

rec

int rec(byte[] b,
        int offset,
        int length)
Process a recorded buffer of audio data. This method will be called continuously between startRec() and stopRec(). The delivered audio data will be in the format returned by startRec().

Parameters:
b - The Array containing the audio data to process
offset - Offset position inside the Array where the usable audio data begins
length - The length of the usable audio data in bytes
Returns:
The number of bytes processed. If this value is less then length, the AudioPlayer will re-attempt to write the remaining data in the next call.

startRec

javax.sound.sampled.AudioFormat startRec()
                                         throws NotReadyException
Start recording of audio data. The AudioFormat in which the the data will be processed from this provider is returned to give the AudioPlayer a hint. If the AudioPlayer can not find a way to convert the audio data he gets into this format, recording will not start.

Returns:
The AudioFormat in which this provider processes the recorded data.
Throws:
NotReadyException - If recording is not possible at the moment

stopRec

void stopRec()
Notification from the AudioPlayer that recording has finished.