public class IzouSoundLineClipAndSDLine extends IzouSoundDataLine implements Clip, SourceDataLine
DataLine.Info
isMutable, isMutedFromSystem, line, soundManager
log, main
LOOP_CONTINUOUSLY
Constructor and Description |
---|
IzouSoundLineClipAndSDLine(Clip clip,
SourceDataLine sourceDataLine,
Main main,
boolean isPermanent,
AddOnModel addOnModel) |
Modifier and Type | Method and Description |
---|---|
int |
getFrameLength()
Obtains the media length in sample frames.
|
long |
getMicrosecondLength()
Obtains the media duration in microseconds
|
void |
loop(int count)
Starts looping playback from the current position.
|
void |
open(AudioFormat format)
Opens the line with the specified format, causing the line to acquire any
required system resources and become operational.
|
void |
open(AudioFormat format,
byte[] data,
int offset,
int bufferSize)
Opens the clip, meaning that it should acquire any required
system resources and become operational.
|
void |
open(AudioFormat format,
int bufferSize)
Opens the line with the specified format and suggested buffer size,
causing the line to acquire any required
system resources and become operational.
|
void |
open(AudioInputStream stream)
Opens the clip with the format and audio data present in the provided audio
input stream.
|
void |
setFramePosition(int frames)
Sets the media position in sample frames.
|
void |
setLoopPoints(int start,
int end)
Sets the first and last sample frames that will be played in
the loop.
|
void |
setMicrosecondPosition(long microseconds)
Sets the media position in microseconds.
|
int |
write(byte[] b,
int off,
int len)
Writes audio data to the mixer via this source data line.
|
available, drain, flush, getBufferSize, getFormat, getFramePosition, getLevel, getLongFramePosition, getMicrosecondPosition, isActive, isRunning, start, stop
addLineListener, close, getAddOnModel, getControl, getControls, getLineInfo, getResponsibleID, isControlSupported, isMutedFromSystem, isMuteIfNonPermanent, isOpen, isPermanent, open, opening, removeLineListener, setMuteIfNonPermanent
debug, debug, error, error, fatal, fatal, getID, getMain
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
available, drain, flush, getBufferSize, getFormat, getFramePosition, getLevel, getLongFramePosition, getMicrosecondPosition, isActive, isRunning, start, stop
addLineListener, close, getControl, getControls, getLineInfo, isControlSupported, isOpen, open, removeLineListener
isOwner
public IzouSoundLineClipAndSDLine(Clip clip, SourceDataLine sourceDataLine, Main main, boolean isPermanent, AddOnModel addOnModel)
public void open(AudioFormat format, int bufferSize) throws LineUnavailableException
The buffer size is specified in bytes, but must represent an integral
number of sample frames. Invoking this method with a requested buffer
size that does not meet this requirement may result in an
IllegalArgumentException. The actual buffer size for the open line may
differ from the requested buffer size. The value actually set may be
queried by subsequently calling
.
DataLine.getBufferSize()
If this operation succeeds, the line is marked as open, and an
event is dispatched to the
line's listeners.
OPEN
Invoking this method on a line which is already open is illegal
and may result in an IllegalStateException
.
Note that some lines, once closed, cannot be reopened. Attempts
to reopen such a line will always result in a
LineUnavailableException
.
open
in interface SourceDataLine
format
- the desired audio formatbufferSize
- the desired buffer sizeLineUnavailableException
- if the line cannot be
opened due to resource restrictionsIllegalArgumentException
- if the buffer size does not represent
an integral number of sample frames,
or if format
is not fully specified or invalidIllegalStateException
- if the line is already openSecurityException
- if the line cannot be
opened due to security restrictionsopen(AudioFormat)
,
Line.open()
,
Line.close()
,
Line.isOpen()
,
LineEvent
public void open(AudioFormat format) throws LineUnavailableException
The implementation chooses a buffer size, which is measured in bytes but
which encompasses an integral number of sample frames. The buffer size
that the system has chosen may be queried by subsequently calling
.
DataLine.getBufferSize()
If this operation succeeds, the line is marked as open, and an
event is dispatched to the
line's listeners.
OPEN
Invoking this method on a line which is already open is illegal
and may result in an IllegalStateException
.
Note that some lines, once closed, cannot be reopened. Attempts
to reopen such a line will always result in a
LineUnavailableException
.
open
in interface SourceDataLine
format
- the desired audio formatLineUnavailableException
- if the line cannot be
opened due to resource restrictionsIllegalArgumentException
- if format
is not fully specified or invalidIllegalStateException
- if the line is already openSecurityException
- if the line cannot be
opened due to security restrictionsopen(AudioFormat, int)
,
Line.open()
,
Line.close()
,
Line.isOpen()
,
LineEvent
public int write(byte[] b, int off, int len)
available
),
this method blocks until the requested amount of data has been written.
This applies even if the requested amount of data to write is greater
than the data line's buffer size. However, if the data line is closed,
stopped, or flushed before the requested amount has been written,
the method no longer blocks, but returns the number of bytes
written thus far.
The number of bytes that can be written without blocking can be ascertained
using the
method of the
available
DataLine
interface. (While it is guaranteed that
this number of bytes can be written without blocking, there is no guarantee
that attempts to write additional data will block.)
The number of bytes to write must represent an integral number of
sample frames, such that:
[ bytes written ] % [frame size in bytes ] == 0
IllegalArgumentException
.write
in interface SourceDataLine
b
- a byte array containing data to be written to the data lineoff
- the offset from the beginning of the array, in byteslen
- the length, in bytes, of the valid data in the array
(in other words, the requested amount of data to write, in bytes)IllegalArgumentException
- if the requested number of bytes does
not represent an integral number of sample frames,
or if len
is negativeArrayIndexOutOfBoundsException
- if off
is negative,
or off+len
is greater than the length of the array
b
.TargetDataLine.read(byte[], int, int)
,
DataLine.available()
public void open(AudioFormat format, byte[] data, int offset, int bufferSize) throws LineUnavailableException
OPEN
event is dispatched
to the line's listeners.
Invoking this method on a line which is already open is illegal and may result in an IllegalStateException.
Note that some lines, once closed, cannot be reopened. Attempts
to reopen such a line will always result in a
.LineUnavailableException
open
in interface Clip
format
- the format of the supplied audio datadata
- a byte array containing audio data to load into the clipoffset
- the point at which to start copying, expressed in
bytes from the beginning of the arraybufferSize
- the number of bytes
of data to load into the clip from the array.LineUnavailableException
- if the line cannot be
opened due to resource restrictionsIllegalArgumentException
- if the buffer size does not represent
an integral number of sample frames,
or if format
is not fully specified or invalidIllegalStateException
- if the line is already openSecurityException
- if the line cannot be
opened due to security restrictionsIzouSoundLineBaseClass.close()
,
IzouSoundLineBaseClass.isOpen()
,
LineListener
public void open(AudioInputStream stream) throws LineUnavailableException, IOException
OPEN
event is dispatched
to the line's listeners.
Invoking this method on a line which is already open is illegal and may result in an IllegalStateException.
Note that some lines, once closed, cannot be reopened. Attempts
to reopen such a line will always result in a
.LineUnavailableException
open
in interface Clip
stream
- an audio input stream from which audio data will be read into
the clipLineUnavailableException
- if the line cannot be
opened due to resource restrictionsIOException
- if an I/O exception occurs during reading of
the streamIllegalArgumentException
- if the stream's audio format
is not fully specified or invalidIllegalStateException
- if the line is already openSecurityException
- if the line cannot be
opened due to security restrictionsIzouSoundLineBaseClass.close()
,
IzouSoundLineBaseClass.isOpen()
,
LineListener
public int getFrameLength()
getFrameLength
in interface Clip
AudioSystem.NOT_SPECIFIED
if the line is not open.AudioSystem.NOT_SPECIFIED
public long getMicrosecondLength()
getMicrosecondLength
in interface Clip
AudioSystem.NOT_SPECIFIED
if the line is not open.AudioSystem.NOT_SPECIFIED
public void setFramePosition(int frames)
To obtain the current position in sample frames, use the
method of getFramePosition
DataLine
.
setFramePosition
in interface Clip
frames
- the desired new media position, expressed in sample framespublic void setMicrosecondPosition(long microseconds)
To obtain the current position in microseconds, use the
method of getMicrosecondPosition
DataLine
.
setMicrosecondPosition
in interface Clip
microseconds
- the desired new media position, expressed in microsecondspublic void setLoopPoints(int start, int end)
setLoopPoints
in interface Clip
start
- the loop's starting position, in sample frames (zero-based)end
- the loop's ending position, in sample frames (zero-based), or
-1 to indicate the final frameIllegalArgumentException
- if the requested
loop points cannot be set, usually because one or both falls outside
the media's duration or because the ending point is
before the starting pointpublic void loop(int count)
count
times, and finally continue playback to the end of
the clip.
If the current position when this method is invoked is greater than the loop end point, playback simply continues to the end of the clip without looping.
A count
value of 0 indicates that any current looping should
cease and playback should continue to the end of the clip. The behavior
is undefined when this method is invoked with any other value during a
loop operation.
If playback is stopped during looping, the current loop status is cleared; the behavior of subsequent loop and start requests is not affected by an interrupted loop operation.
loop
in interface Clip
count
- the number of times playback should loop back from the
loop's end position to the loop's start position, or
Clip.LOOP_CONTINUOUSLY
to indicate that looping should
continue until interruptedCopyright © 2016. All rights reserved.