com.icdif.audio.io
Class WaveDecoder
java.lang.Object
com.icdif.audio.io.WaveDecoder
- All Implemented Interfaces:
- AudioDecoder
public class WaveDecoder
- extends java.lang.Object
- implements AudioDecoder
This class implements the AudioDecoder Interface and is responsible for
decoding the audio data from a wave file, i.e. transforming the bytes in pcm
format to arrays of float that we can easily analyse and plot.
- Author:
- wanderer
Constructor Summary |
WaveDecoder(java.io.InputStream stream)
Constructor that initializes the stream from where we read the pcm data. |
Method Summary |
int |
readSamples(float[] samples)
Reads in samples from the decoder and fills the array passed as parameter
with the values read (It tries to read as many samples from the stream as
there are elements in the array passed in). |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WaveDecoder
public WaveDecoder(java.io.InputStream stream)
throws java.lang.Exception
- Constructor that initializes the stream from where we read the pcm data.
It also reads the header of this stream and checks if it really is valid.
- Parameters:
stream
- The Wave file as a stream
- Throws:
java.lang.Exception
- When it's not possible to read from the file
readSamples
public int readSamples(float[] samples)
- Description copied from interface:
AudioDecoder
- Reads in samples from the decoder and fills the array passed as parameter
with the values read (It tries to read as many samples from the stream as
there are elements in the array passed in). Returns the actual number
read in. If this number is smaller than samples.length then the end of
stream has been reached. Note: In the present version, it averages from
all the channels into a single channel.
- Specified by:
readSamples
in interface AudioDecoder
- Parameters:
samples
- The array to which it will write the samples read.
- Returns:
- The number of read samples.