javax.sound.sampled
Interface Clip

All Superinterfaces:
DataLine, Line

public interface Clip
extends DataLine

A Clip represents some pre-loaded audio data.

Since:
1.3

Nested Class Summary
 
Nested classes/interfaces inherited from interface javax.sound.sampled.DataLine
DataLine.Info
 
Field Summary
static int LOOP_CONTINUOUSLY
          This can be passed to loop(int) to indicate that looping should be done continuously.
 
Method Summary
 int getFrameLength()
          Return the frame length of this clip.
 long getMicrosecondLength()
          Return the length of the clip in microseconds.
 void loop(int count)
          Start looping the clip.
 void open(AudioFormat fmt, byte[] data, int offset, int len)
          Open a clip, given an audio format and some data.
 void open(AudioInputStream ais)
          Open a clip, given an audio input stream.
 void setFramePosition(int where)
          Set the position to the indicated frame.
 void setLoopPoints(int begin, int end)
          Set the loop begin and end points.
 void setMicrosecondPosition(long ms)
          Set the position to the indicated microsecond.
 
Methods inherited from interface javax.sound.sampled.DataLine
available, drain, flush, getBufferSize, getFormat, getFramePosition, getLevel, getLongFramePosition, getMicrosecondPosition, isActive, isRunning, start, stop
 
Methods inherited from interface javax.sound.sampled.Line
addLineListener, close, getControl, getControls, getLineInfo, isControlSupported, isOpen, open, removeLineListener
 

Field Detail

LOOP_CONTINUOUSLY

static final int LOOP_CONTINUOUSLY
This can be passed to loop(int) to indicate that looping should be done continuously.

See Also:
Constant Field Values
Method Detail

getFrameLength

int getFrameLength()
Return the frame length of this clip.


getMicrosecondLength

long getMicrosecondLength()
Return the length of the clip in microseconds.


loop

void loop(int count)
Start looping the clip. Looping will occur count times, or, if count is LOOP_CONTINUOUSLY, will be done continuously. A count of 0 indicates that any current looping should stop.

Parameters:
count - the number of times to loop

open

void open(AudioFormat fmt,
          byte[] data,
          int offset,
          int len)
          throws LineUnavailableException
Open a clip, given an audio format and some data.

Parameters:
fmt - the format of the data
data - a byte array containing the audio data
offset - the offset of the first byte of data in the array
len - the length of the audio data in the array, in bytes
Throws:
LineUnavailableException - if the line cannot be opened
SecurityException - if the line cannot be opened for security reasons

open

void open(AudioInputStream ais)
          throws LineUnavailableException,
                 IOException
Open a clip, given an audio input stream.

Parameters:
ais - the input stream
Throws:
LineUnavailableException - if the line cannot be opened
SecurityException - if the line cannot be opened for security reasons
IOException - if there is an I/O error while reading the stream

setFramePosition

void setFramePosition(int where)
Set the position to the indicated frame.

Parameters:
where - new frame position

setLoopPoints

void setLoopPoints(int begin,
                   int end)
Set the loop begin and end points. These are used by loop(int).

Parameters:
begin - the starting point
end - the ending point

setMicrosecondPosition

void setMicrosecondPosition(long ms)
Set the position to the indicated microsecond.

Parameters:
ms - the new position in microseconds