The AudioSystem class includes many methods that manipulate
AudioInputStream objects. For example, the methods let you:
URL
AudioSystem, Clip#open(AudioInputStream)
| Modifier and Type | Class and Description |
|---|---|
| private static class | AudioInputStream.
Private inner class that makes a TargetDataLine look like an InputStream. |
| Modifier and Type | Field and Description |
|---|---|
| protected AudioFormat | format
The format of the audio data contained in the stream. |
| protected long | frameLength
This stream's length, in sample frames. |
| protected long | framePos
The current position in this stream, in sample frames (zero-based). |
| protected int | frameSize
The size of each frame, in bytes. |
| private long | markpos
The position where a mark was set. |
| private byte[] | markPushBackBuffer
MarkBuffer at mark position. |
| private int | markPushBackLen
number of valid bytes in the markPushBackBuffer. |
| private byte[] | pushBackBuffer
When the underlying stream could only return a non-integral number of frames, store the remainder in a temporary buffer. |
| private int | pushBackLen
number of valid bytes in the pushBackBuffer. |
| private final InputStream | stream
The |
| Access | Constructor and Description |
|---|---|
| public | AudioInputStream(InputStream
the stream on which this stream, AudioFormat AudioInputStream object
is basedthe format of this stream's audio data format, long the length in sample frames of the data in this stream length)Constructs an audio input stream that has the requested format and length in sample frames, using audio data from the specified input stream. |
| public | AudioInputStream(TargetDataLine
the target data line from which this stream obtains its data line)Constructs an audio input stream that reads its data from the target data line indicated. |
| Modifier and Type | Method and Description |
|---|---|
| public int | Returns: the number of bytes that can be read from this audio input stream without blockingOverrides java. Returns the maximum number of bytes that can be read (or skipped over) from this audio input stream without blocking. |
| public void | close()
Overrides java. Implements java. Closes this audio input stream and releases any system resources associated with the stream. |
| public AudioFormat | Returns: an audio format object describing this stream's formatObtains the audio format of the sound data in this audio input stream. |
| public long | Returns: the length in sample framesObtains the length of the stream, expressed in sample frames rather than bytes. |
| public void | mark(int
the maximum number of bytes that can be read before the
mark position becomes invalid readlimit)Overrides java. Marks the current position in this audio input stream. |
| public boolean | Returns: true if this stream supports the mark and
reset methods; false otherwiseOverrides java. Tests whether this audio input stream supports the |
| public int | read()
Implements abstract java. Reads the next byte of data from the audio input stream. |
| public int | read(byte[] b)
Overrides java. Reads some number of bytes from the audio input stream and stores them
into the buffer array |
| public int | read(byte[] b, int off, int len)
Overrides java. Reads up to a specified maximum number of bytes of data from the audio stream, putting them into the given byte array. |
| public void | reset()
Overrides java. Repositions this audio input stream to the position it had at the time
its |
| public long | Returns: the actual number of bytes skippedthe requested number of bytes to be skipped n)Overrides java. Skips over and discards a specified number of bytes from this audio input stream. |
| format | back to summary |
|---|---|
| protected AudioFormat format The format of the audio data contained in the stream. | |
| frameLength | back to summary |
|---|---|
| protected long frameLength This stream's length, in sample frames. | |
| framePos | back to summary |
|---|---|
| protected long framePos The current position in this stream, in sample frames (zero-based). | |
| frameSize | back to summary |
|---|---|
| protected int frameSize The size of each frame, in bytes. | |
| markpos | back to summary |
|---|---|
| private long markpos The position where a mark was set. | |
| markPushBackBuffer | back to summary |
|---|---|
| private byte[] markPushBackBuffer MarkBuffer at mark position. | |
| markPushBackLen | back to summary |
|---|---|
| private int markPushBackLen number of valid bytes in the markPushBackBuffer. | |
| pushBackBuffer | back to summary |
|---|---|
| private byte[] pushBackBuffer When the underlying stream could only return a non-integral number of frames, store the remainder in a temporary buffer. | |
| pushBackLen | back to summary |
|---|---|
| private int pushBackLen number of valid bytes in the pushBackBuffer. | |
| stream | back to summary |
|---|---|
| private final InputStream stream The | |
| AudioInputStream | back to summary |
|---|---|
| public AudioInputStream(InputStream stream, AudioFormat format, long length) Constructs an audio input stream that has the requested format and length in sample frames, using audio data from the specified input stream.
| |
| AudioInputStream | back to summary |
|---|---|
| public AudioInputStream(TargetDataLine line) Constructs an audio input stream that reads its data from the target data
line indicated. The format of the stream is the same as that of the
target data line, and the length is
| |
| available | back to summary |
|---|---|
| public int available() throws IOException Overrides java. Returns the maximum number of bytes that can be read (or skipped over)
from this audio input stream without blocking. This limit applies only to
the next invocation of a
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Closes this audio input stream and releases any system resources associated with the stream.
| |
| getFormat | back to summary |
|---|---|
| public AudioFormat getFormat() Obtains the audio format of the sound data in this audio input stream.
| |
| getFrameLength | back to summary |
|---|---|
| public long getFrameLength() Obtains the length of the stream, expressed in sample frames rather than bytes.
| |
| mark | back to summary |
|---|---|
| public void mark(int readlimit) Overrides java. Marks the current position in this audio input stream.
| |
| markSupported | back to summary |
|---|---|
| public boolean markSupported() Overrides java. Tests whether this audio input stream supports the | |
| read | back to summary |
|---|---|
| public int read() throws IOException Implements abstract java. Reads the next byte of data from the audio input stream. The audio input
stream's frame size must be one byte, or an
| |
| read | back to summary |
|---|---|
| public int read(byte[] b) throws IOException Overrides java. Reads some number of bytes from the audio input stream and stores them
into the buffer array
This method will always read an integral number of frames. If the length
of the array is not an integral number of frames, a maximum of
| |
| read | back to summary |
|---|---|
| public int read(byte[] b, int off, int len) throws IOException Overrides java. Reads up to a specified maximum number of bytes of data from the audio stream, putting them into the given byte array.
This method will always read an integral number of frames. If
| |
| reset | back to summary |
|---|---|
| public void reset() throws IOException Overrides java. Repositions this audio input stream to the position it had at the time
its
| |
| skip | back to summary |
|---|---|
| public long skip(long n) throws IOException Overrides java. Skips over and discards a specified number of bytes from this audio input stream.
This method will always skip an integral number of frames. If
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv TargetDataLine | line
The TargetDataLine on which this TargetDataLineInputStream is based. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public int | available()
Overrides java. Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. |
| public void | close()
Overrides java. Implements java. Closes this input stream and releases any system resources associated with the stream. |
| public int | read()
Implements abstract java. Reads the next byte of data from the input stream. |
| public int | read(byte[] b, int off, int len)
Overrides java. Reads up to |
| line | back to summary |
|---|---|
| pack-priv TargetDataLine line The TargetDataLine on which this TargetDataLineInputStream is based. | |
| TargetDataLineInputStream | back to summary |
|---|---|
| pack-priv TargetDataLineInputStream(TargetDataLine line) | |
| available | back to summary |
|---|---|
| public int available() throws IOException Overrides java. Doc from java. Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. The read might be on the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes. Note that while some implementations of A subclass's implementation of this method may choose to throw an
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Doc from java. Closes this input stream and releases any system resources associated with the stream.
| |
| read | back to summary |
|---|---|
| public int read() throws IOException Implements abstract java. Doc from java. Reads the next byte of data from the input stream. The value byte is
returned as an
| |
| read | back to summary |
|---|---|
| public int read(byte[] b, int off, int len) throws IOException Overrides java. Doc from java. Reads up to This method blocks until input data is available, end of file is detected, or an exception is thrown. If The first byte read is stored into element In every case, elements
| |