marf.Storage.Loaders
Class WAVLoader

java.lang.Object
  |
  +--marf.Storage.SampleLoader
        |
        +--marf.Storage.Loaders.WAVLoader
All Implemented Interfaces:
ISampleLoader

public class WAVLoader
extends SampleLoader

Loads/stores samples of WAV format.

$Id: WAVLoader.java,v 1.19 2005/06/03 17:09:58 mokhov Exp $

Since:
0.0.1
Version:
$Revision: 1.19 $
Author:
Jimmy Nicolacopoulos, Serguei Mokhov

Field Summary
 
Fields inherited from class marf.Storage.SampleLoader
iRequiredBitSize, iRequiredChannels, iRequiredFrequency, oAudioFormat, oAudioInputStream, oByteArrayOutputStream, oSample
 
Fields inherited from interface marf.Storage.ISampleLoader
DEFAULT_CHANNELS, DEFAULT_FREQUENCY, DEFAULT_SAMPLE_BIT_SIZE, INTERFACE_CODE_REVISION
 
Constructor Summary
WAVLoader()
          WAVLoader Constructor.
 
Method Summary
static java.lang.String getRevision()
          Returns source code revision information.
 marf.Storage.Sample loadSample(java.io.File poInFile)
          Loads WAV sample data from a file.
 int readAudioData(double[] padAudioData)
          Buffers out the contents of atAudioBuffer into padAudioData.
 void reset()
          Resets the marker for the audio and byte-array streams.
 void saveSample(java.io.File poOutFile)
          Saves the wave into a file for playback.
 int writeAudioData(double[] padAudioData, int piNbrWords)
          Buffers the contents of padAudioData into atAudioBuffer.
 
Methods inherited from class marf.Storage.SampleLoader
getSample, getSampleSize, loadSample, saveSample, setSample, updateSample
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WAVLoader

public WAVLoader()
          throws StorageException
WAVLoader Constructor.

Throws:
StorageException - if the WAV file isn't really in WAV format or any other error took place.
Method Detail

loadSample

public marf.Storage.Sample loadSample(java.io.File poInFile)
                               throws StorageException
Loads WAV sample data from a file.

Parameters:
poInFile - incoming sample File object
Returns:
Sample object
Throws:
StorageException - if there was a problem loading the sample

readAudioData

public final int readAudioData(double[] padAudioData)
                        throws StorageException
Buffers out the contents of atAudioBuffer into padAudioData.

Parameters:
padAudioData - data array to fill in
Returns:
the number of data read.
Throws:
StorageException - if there was problem readin the audio data

writeAudioData

public final int writeAudioData(double[] padAudioData,
                                int piNbrWords)
                         throws StorageException
Buffers the contents of padAudioData into atAudioBuffer.

Parameters:
padAudioData - array of data to be written
piNbrWords - number of words to be written
Returns:
the number of data written
Throws:
StorageException - if there was an error writing audio data

saveSample

public final void saveSample(java.io.File poOutFile)
                      throws StorageException
Saves the wave into a file for playback.

Parameters:
poOutFile - File object for output
Throws:
StorageException - if there was an error saving sample

reset

public void reset()
           throws StorageException
Resets the marker for the audio and byte-array streams. Used after writing audio data into the sample's audio stream.

Specified by:
reset in interface ISampleLoader
Overrides:
reset in class SampleLoader
Throws:
StorageException - if there was an error resetting the streams
Since:
0.3.0

getRevision

public static java.lang.String getRevision()
Returns source code revision information.

Returns:
revision string
Since:
0.3.0