|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object comirva.audio.util.AudioPreProcessor
public class AudioPreProcessor
AudioPreProcessor
Description:
This class simplifies the access to audio streams. It frees you from taking care of the encoding of the input stream. The samples of the audio stream get converted and are stored as double values. The sample rate of the output stream can be specified. The output stream has only one channel. If the input stream has more than one channel, it will get reduced. If the input stream is encoded the Java Sound API will be used for decoding the stream. Also some of the audio conversion operations use the API. So be sure to have correctly configured your Java Audio System.
Field Summary | |
---|---|
static float |
DEFAULT_SAMPLE_RATE
default sample rate of the output stream |
Constructor Summary | |
---|---|
AudioPreProcessor(javax.sound.sampled.AudioInputStream in)
An AudioPreProcessor encapsulates an AudioInputStream object permitting an easy access to the audio data. |
|
AudioPreProcessor(javax.sound.sampled.AudioInputStream in,
float sampleRate)
An AudioPreProcessor encapsulates an AudioInputStream object permitting an easy access to the audio data. |
Method Summary | |
---|---|
int |
append(double[] buffer,
int start,
int len)
Appends a specified number of samples to an array. |
static javax.sound.sampled.AudioInputStream |
convertBitsPerSample(javax.sound.sampled.AudioInputStream in,
int bitsPerSample)
Converts the number bits used to represent one sample within an AudioInputStream by returning a new a new stream using the given number of bits to represent one sample. |
static javax.sound.sampled.AudioInputStream |
convertByteOrder(javax.sound.sampled.AudioInputStream in,
boolean isBigEndian)
Converts the byte order of an AudioInputStream by returning a new a new stream using the given byte order (big/little Endian). |
static javax.sound.sampled.AudioInputStream |
convertChannels(javax.sound.sampled.AudioInputStream in,
int channels)
Converts the number of channels of an AudioInputStream by returning a new stream with the given number of channels. |
static javax.sound.sampled.AudioInputStream |
convertSampleRate(javax.sound.sampled.AudioInputStream in,
float sampleRate)
Converts the sample rate of an AudioInputStream by returning a new stream with the given sample rate. |
static javax.sound.sampled.AudioInputStream |
convertToPCM(javax.sound.sampled.AudioInputStream in)
Converts an AudioInputStream with arbitrary encoding into an AudioInputStream with signed pulse code modulation (PCM_SIGNED). |
int |
fastSkip(int len)
This method only skips on frame basis. |
double[] |
get(int len)
Returns a specified number of samples. |
float |
getSampleRate()
Returns the sample rate of the output stream. |
int |
skip(int len)
Skips a specified number of samples. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final float DEFAULT_SAMPLE_RATE
Constructor Detail |
---|
public AudioPreProcessor(javax.sound.sampled.AudioInputStream in, float sampleRate) throws java.lang.IllegalArgumentException
in
- AudioInputStream the audio input stream to encapsulate, must not
be a null valuesampleRate
- int the sampleRate of the output stream, must be greater
than zero and less or equal the sample rate of the
input stream, such that a conversion is possible;
none integer values are rounded
java.lang.IllegalArgumentException
- raised if method contract is violatedpublic AudioPreProcessor(javax.sound.sampled.AudioInputStream in) throws java.lang.IllegalArgumentException
in
- AudioInputStream the audio input stream to encapsulate, must not
be a null value
java.lang.IllegalArgumentException
- raised if method contract is violatedMethod Detail |
---|
public float getSampleRate()
public int skip(int len) throws java.lang.IllegalArgumentException, java.io.IOException
len
- number of samples to skip, must be a positive value
java.lang.IllegalArgumentException
- raised if method contract is violated
java.io.IOException
- if there are any problems regarding the inputstreamfastSkip(int)
public int fastSkip(int len) throws java.lang.IllegalArgumentException, java.io.IOException
len
- number of samples to skip, must be a positive value
java.lang.IllegalArgumentException
- raised if method contract is violated
java.io.IOException
- if there are any problems regarding the inputstreampublic double[] get(int len) throws java.lang.IllegalArgumentException, java.io.IOException
len
- a number of samples to return, must be a positive value
java.lang.IllegalArgumentException
- raised if method contract is violated
java.io.IOException
- if there are any problems regarding the inputstreampublic int append(double[] buffer, int start, int len) throws java.lang.IllegalArgumentException, java.io.IOException
buffer
- the buffer for the samples to be written in, must not be a
null value and sufficient large to hold the number of samples
specified by lenstart
- start index at which the new samples are filled into the
array, must be greater equal zero; starting form this index
there must be enough space to hold the number of samples
specified by lenlen
- number of samples to be written into the buffer, must be greater
than or equal to zero.
java.lang.IllegalArgumentException
- raised if method contract is violated
java.io.IOException
- if there are any problems regarding the inputstreampublic static javax.sound.sampled.AudioInputStream convertToPCM(javax.sound.sampled.AudioInputStream in) throws java.lang.IllegalArgumentException
in
- AudioInputStream the original audio stream, must not be a null
value
java.lang.IllegalArgumentException
- raised if method contract is violated or
if the conversion is not supported by your
audio systempublic static javax.sound.sampled.AudioInputStream convertSampleRate(javax.sound.sampled.AudioInputStream in, float sampleRate) throws java.lang.IllegalArgumentException
in
- AudioInputStream the original audio stream, must not be a null
valuesampleRate
- float the sample rate to convert, must be greater null
and less or equal the sample rate of the input
stream
java.lang.IllegalArgumentException
- raised if method contract is violated or
if the conversion is not supported by your
audio systempublic static javax.sound.sampled.AudioInputStream convertChannels(javax.sound.sampled.AudioInputStream in, int channels) throws java.lang.IllegalArgumentException
in
- AudioInputStream the original audio stream, must not be a null
valuechannels
- int the number of channels to convert to, must be greater
null
java.lang.IllegalArgumentException
- raised if method contract is violated or
if the conversion is not supported by your
audio systempublic static javax.sound.sampled.AudioInputStream convertBitsPerSample(javax.sound.sampled.AudioInputStream in, int bitsPerSample) throws java.lang.IllegalArgumentException
in
- AudioInputStream the original audio stream, must not be a null
valuebitsPerSample
- int the number of bits per samples to convert to, must
be either 8, 16, 24 or 32
java.lang.IllegalArgumentException
- raised if method contract is violated or
if the conversion is not supported by your
audio systempublic static javax.sound.sampled.AudioInputStream convertByteOrder(javax.sound.sampled.AudioInputStream in, boolean isBigEndian) throws java.lang.IllegalArgumentException
in
- AudioInputStream the original audio stream, must not be a null
valueisBigEndian
- boolean true if the byte order in the resulting stream
should be big-Endian, false otherwise
(little-Endian)
java.lang.IllegalArgumentException
- raised if method contract is violated or
if the conversion is not supported by your
audio system
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |