|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream javax.sound.sampled.AudioInputStream comirva.audio.util.ReducedAudioInputStream
public class ReducedAudioInputStream
Reduced Audio Input Stream
Description:
This wrapper tries to downsample a PCM audio stream to 11025 Hz and 1 channel. Downsampling can only be performed for interger valued ratios. Channel reduction is only supported form two channel to one. The number of bits per sample is reduced to 16.tritonus_remaining.jar
. Thanks to its specialized functionality
this class is about 10% faster and more stable than the Tritonus
package.
Field Summary | |
---|---|
protected int |
frameSize
|
protected AudioInputStream |
in
|
protected int |
INITIAL_BUFFER_SIZE
|
protected int |
sampleSize
|
protected AudioFormat |
sourceFormat
|
protected AudioFormat |
targetFormat
|
Fields inherited from class javax.sound.sampled.AudioInputStream |
---|
format, frameLength, framePos |
Constructor Summary | |
---|---|
ReducedAudioInputStream(AudioInputStream ais,
float targetSampleRate)
Creates a new ReducedAudioInputStream for a given
AudioInputStream and for a given target sample rate. |
Method Summary | |
---|---|
int |
available()
Returns the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream. |
void |
close()
Closes this input stream and releases any system resources associated with the stream. |
AudioFormat |
getFormat()
Obtains the audio format of the sound data in this audio input stream. |
long |
getFrameLength()
Obtains the length of the stream, expressed in sample frames rather than bytes. |
boolean |
markSupported()
Tests if this input stream supports the mark and
reset methods. |
int |
read()
Reads the next byte of data from the input stream. |
int |
read(byte[] b)
Reads some number of bytes from the input stream and stores them into the buffer array b . |
int |
read(byte[] b,
int off,
int len)
Reads up to len bytes of data from the input stream into an
array of bytes. |
long |
skip(long n)
Skips over and discards n bytes of data from this input
stream. |
Methods inherited from class javax.sound.sampled.AudioInputStream |
---|
mark, reset |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected AudioInputStream in
protected AudioFormat sourceFormat
protected AudioFormat targetFormat
protected int frameSize
protected int sampleSize
protected final int INITIAL_BUFFER_SIZE
Constructor Detail |
---|
public ReducedAudioInputStream(AudioInputStream ais, float targetSampleRate)
ReducedAudioInputStream
for a given
AudioInputStream
and for a given target sample rate.
ais
- AudioInputStream the original audio input streamtargetSampleRate
- float the target sample rateMethod Detail |
---|
public int available() throws IOException
available
in class AudioInputStream
IOException
- if an I/O error occurs.public void close() throws IOException
close
in interface Closeable
close
in class AudioInputStream
IOException
- if an I/O error occurs.public boolean markSupported()
mark
and
reset
methods.
markSupported
in class AudioInputStream
true
if this stream instance supports the mark and
reset methods; false
otherwise.public int read() throws IOException
read
in class AudioInputStream
-1
if the end of the
stream is reached.
IOException
- if an I/O error occurs.public int read(byte[] b) throws IOException
b
.
read
in class AudioInputStream
b
- the buffer into which the data is read.
-1
is there is no more data because the end of the stream
has been reached.
IOException
- if an I/O error occurs.public int read(byte[] b, int off, int len) throws IOException
len
bytes of data from the input stream into an
array of bytes.
read
in class AudioInputStream
b
- the buffer into which the data is read.off
- the start offset in array b
at which the data is
written.len
- the maximum number of bytes to read.
-1
if there is no more data because the end of the stream
has been reached.
IOException
- if an I/O error occurs.public long skip(long n) throws IOException
n
bytes of data from this input
stream.
This method only skips on frame basis, if the original stream is encoded.
Therefore you cannot skip a precise number of bytes. You should at least
skip one frame, or no bytes will be skipped at all. The real number of
skipped bytes will be returned.
skip
in class AudioInputStream
n
- the number of bytes to be skipped.
IOException
- if an I/O error occurs.public AudioFormat getFormat()
getFormat
in class AudioInputStream
public long getFrameLength()
getFrameLength
in class AudioInputStream
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |