marf.Storage.Loaders
Class WAVLoader

java.lang.Object
  extended bymarf.Storage.SampleLoader
      extended bymarf.Storage.Loaders.WAVLoader
All Implemented Interfaces:
ISampleLoader

public class WAVLoader
extends SampleLoader

Loads/stores samples if WAVE format.

$Id: WAVLoader.java,v 1.23 2006/01/14 22:30:13 mokhov Exp $

Since:
0.0.1
Version:
$Revision: 1.23 $
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, MARF_INTERFACE_CODE_REVISION
 
Constructor Summary
WAVLoader()
          WAVLoader Constructor.
 
Method Summary
static java.lang.String getMARFSourceCodeRevision()
          Returns source code revision information.
 Sample loadSample(java.io.File poInFile)
          Loads WAV sample data from a file.
 int readAudioData(double[] padAudioData)
          Buffers out the contents of an audio buffer into the parameter.
 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.
 void validateAudioFormat(javax.sound.sampled.AudioFormat poFormat)
          Validates audio file stream format for WAVE files.
 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 InvalidSampleFormatException
WAVLoader Constructor.

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

loadSample

public 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 an audio buffer into the parameter.

Parameters:
padAudioData - data array to fill in
Returns:
the number of words of data read (a word is two bytes)
Throws:
StorageException - if there was a problem reading 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

validateAudioFormat

public void validateAudioFormat(javax.sound.sampled.AudioFormat poFormat)
                         throws javax.sound.sampled.UnsupportedAudioFileException
Validates audio file stream format for WAVE files. Checks the format has the required bit size, number of channels, and required sampling frequency.

Parameters:
poFormat - the audio format to validate
Throws:
javax.sound.sampled.UnsupportedAudioFileException - if any of the three criteria are not met
Since:
0.3.0.5

getMARFSourceCodeRevision

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

Returns:
revision string
Since:
0.3.0.2


SourceForge Logo