java.lang.Object | ||
↳ | java.io.InputStream | |
↳ | javax.sound.sampled.AudioInputStream |
![]() |
An audio input stream is an input stream with a specified audio format and length. The length is expressed in sample frames, not bytes. Several methods are provided for reading a certain number of bytes from the stream, or an unspecified number of bytes. The audio input stream keeps track of the last byte that was read. You can skip over an arbitrary number of bytes to get to a later position for reading. An audio input stream may support marks. When you set a mark, the current position is remembered so that you can return to it later.
The AudioSystem
class includes many methods that manipulate
AudioInputStream
objects.
For example, the methods let you:
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
format | The format of the audio data contained in the stream. | ||||||||||
frameLength | This stream's length, in sample frames. | ||||||||||
framePos | The current position in this stream, in sample frames (zero-based). | ||||||||||
frameSize | The size of each frame, in bytes. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs an audio input stream that has the requested format and length in sample frames,
using audio data from the specified input stream.
| |||||||||||
Constructs an audio input stream that reads its data from the target
data line indicated.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns the maximum number of bytes that can be read (or skipped over) from this
audio input stream without blocking.
| |||||||||||
Closes this audio input stream and releases any system resources associated
with the stream.
| |||||||||||
Obtains the audio format of the sound data in this audio input stream.
| |||||||||||
Obtains the length of the stream, expressed in sample frames rather than bytes.
| |||||||||||
Marks the current position in this audio input stream.
| |||||||||||
Tests whether this audio input stream supports the
mark and
reset methods. | |||||||||||
Reads some number of bytes from the audio input stream and stores them into
the buffer array
b . | |||||||||||
Reads the next byte of data from the audio input stream.
| |||||||||||
Reads up to a specified maximum number of bytes of data from the audio
stream, putting them into the given byte array.
| |||||||||||
Repositions this audio input stream to the position it had at the time its
mark method was last invoked. | |||||||||||
Skips over and discards a specified number of bytes from this
audio input stream.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() |
This stream's length, in sample frames.
The current position in this stream, in sample frames (zero-based).
The size of each frame, in bytes.
Constructs an audio input stream that has the requested format and length in sample frames, using audio data from the specified input stream.
stream | the stream on which this AudioInputStream
object is based |
---|---|
format | the format of this stream's audio data |
length | the length in sample frames of the data in this stream |
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 AudioSystem#NOT_SPECIFIED.
line | the target data line from which this stream obtains its data. |
---|
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 read
or skip
method for this audio input stream; the limit
can vary each time these methods are invoked.
Depending on the underlying stream,an IOException may be thrown if this
stream is closed.
IOException | if an input or output error occurs |
---|
Closes this audio input stream and releases any system resources associated with the stream.
IOException | if an input or output error occurs |
---|
Obtains the audio format of the sound data in this audio input stream.
Obtains the length of the stream, expressed in sample frames rather than bytes.
Marks the current position in this audio input stream.
readlimit | the maximum number of bytes that can be read before the mark position becomes invalid. |
---|
Reads some number of bytes from the audio input stream and stores them into
the buffer array b
. The number of bytes actually read is
returned as an integer. This method blocks until input data is
available, the end of the stream is detected, or an exception is thrown.
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 b.length - (b.length % frameSize)
bytes will be read.
b | the buffer into which the data is read |
---|
IOException | if an input or output error occurs |
---|
Reads the next byte of data from the audio input stream. The audio input
stream's frame size must be one byte, or an IOException
will be thrown.
IOException | if an input or output error occurs |
---|
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 len
does not specify an integral number
of frames, a maximum of len - (len % frameSize)
bytes will be read.
b | the buffer into which the data is read |
---|---|
off | the offset, from the beginning of array b , at which
the data will be written |
len | the maximum number of bytes to read |
IOException | if an input or output error occurs |
---|
Repositions this audio input stream to the position it had at the time its
mark
method was last invoked.
IOException | if an input or output error occurs. |
---|
Skips over and discards a specified number of bytes from this audio input stream.
n | the requested number of bytes to be skipped |
---|
IOException | if an input or output error occurs |
---|