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

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

public class WavFileWriter
extends java.lang.Object

Creates WAV file.

This is very simple writer for WAV files. The instance must be closed after last sample was written.


Constructor Summary
WavFileWriter(java.lang.String fileName, int bitsPerSample, int samplesPerSecond, int channelCount)
           
 
Method Summary
 void close()
          Closes the file.
 void writeSamples(java.nio.ByteBuffer[] channelBuffers, int nframes)
          Writes samples from specified buffers to the WAV file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WavFileWriter

public WavFileWriter(java.lang.String fileName,
                     int bitsPerSample,
                     int samplesPerSecond,
                     int channelCount)
              throws java.io.IOException
Throws:
java.io.IOException
Method Detail

writeSamples

public void writeSamples(java.nio.ByteBuffer[] channelBuffers,
                         int nframes)
                  throws java.io.IOException
Writes samples from specified buffers to the WAV file.

Buffers in the given array are used for corresponding channels. If the array element at index i is null, the channel i will be filled with 0db samples. If the array has less elements than the number of channels, channels with higher numbers will be all filled with 0db samples. If the array has more elements than the number of channels, extra buffers will be ignored.

Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Closes the file.

This method must be called after the last sample is written. The instance is unusable afterwards.

Throws:
java.io.IOException


Copyright © 2008 Ondrej Par. All Rights Reserved.