net.sf.jack4j.util.file.wav
Class WavFileReader

java.lang.Object
  extended by net.sf.jack4j.util.file.wav.WavFileReader

public class WavFileReader
extends java.lang.Object

Allows read-only access to WAV file.

The class uses dedicated FileChannel instance that must be passed to the constructor and may not be used by anyone else.

Author:
repa

Constructor Summary
WavFileReader(java.nio.channels.FileChannel fileChannel)
           
 
Method Summary
 int getAvgBytesPerSecond()
           
 int getBitsPerSample()
           
 int getBlockAlign()
           
 int getChannelCount()
           
 int getSamplesPerSecond()
           
 int readSamples(java.nio.ByteBuffer[] channelBuffers, int nframes)
          Reads samples from WAV file, starting at current position, and writes them to specified buffers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WavFileReader

public WavFileReader(java.nio.channels.FileChannel fileChannel)
              throws java.io.IOException
Throws:
java.io.IOException
Method Detail

readSamples

public int readSamples(java.nio.ByteBuffer[] channelBuffers,
                       int nframes)
                throws java.io.IOException
Reads samples from WAV file, starting at current position, and writes them to specified buffers.

Buffers in the given array are used for corresponding channels. If the array element at index i is null, the channel i will not be processed. If the array has less elements than the number of channels, channels with higher numbers will not be processed. If the array has more elements than the number of channels, zero samples (0.0f) will be put into unused buffers.

Returns:
number of samples read
Throws:
java.io.IOException

getBitsPerSample

public int getBitsPerSample()
Returns:
the bitsPerSample

getSamplesPerSecond

public int getSamplesPerSecond()
Returns:
the samplesPerSecond

getChannelCount

public int getChannelCount()
Returns:
the channelCount

getBlockAlign

public int getBlockAlign()
Returns:
the blockAlign

getAvgBytesPerSecond

public int getAvgBytesPerSecond()
Returns:
the avgBytesPerSecond


Copyright © 2008 Ondrej Par. All Rights Reserved.