marf.Storage.Loaders
Class AudioSampleLoader

java.lang.Object
  extended by marf.Storage.SampleLoader
      extended by marf.Storage.Loaders.AudioSampleLoader
All Implemented Interfaces:
ISampleLoader
Direct Known Subclasses:
AIFFCLoader, AIFFLoader, AULoader, MIDILoader, MP3Loader, SNDLoader, ULAWLoader, WAVLoader

public abstract class AudioSampleLoader
extends SampleLoader

Abstract class that provides a generic sound-oriented implementation of the sample loading interface. Must be overridden by a concrete audio sample loader.

$Id: AudioSampleLoader.java,v 1.6 2008/07/27 23:59:13 mokhov Exp $

Since:
0.3.0.6
Version:
$Revision: 1.6 $
Author:
Serguei Mokhov, Jimmy Nicolacopoulos

Field Summary
protected  javax.sound.sampled.AudioFormat oAudioFormat
          Properties of a sound sample.
protected  javax.sound.sampled.AudioInputStream oAudioInputStream
          Stream representing sound sample.
protected  javax.sound.sampled.AudioFormat.Encoding oEncoding
          Default audio encoding.
 
Fields inherited from class marf.Storage.SampleLoader
fRequiredFrequency, iRequiredBitSize, iRequiredChannels, oByteArrayOutputStream, oSample
 
Fields inherited from interface marf.Storage.ISampleLoader
DEFAULT_CHANNELS, DEFAULT_FREQUENCY, DEFAULT_SAMPLE_BIT_SIZE, MARF_INTERFACE_CODE_REVISION
 
Constructor Summary
AudioSampleLoader()
          Default constructor.
 
Method Summary
 javax.sound.sampled.AudioFormat getAudioFormat()
           
 javax.sound.sampled.AudioInputStream getAudioInputStream()
           
 javax.sound.sampled.AudioFormat.Encoding getEncoding()
           
static java.lang.String getMARFSourceCodeRevision()
          Returns source code revision information.
 long getSampleSize()
          Retrieves the length of the sample (# of audio data in the audio stream).
 Sample loadSample(byte[] patFileData)
          Overrides the parent to include the AudioInputStream into the chain in order avoid audio format related errors.
 int readAudioData(double[] padAudioData)
          Reads sample data from the sample's audio stream into padSampleData.
 void reset()
          Resets the marker for the audio stream.
 void setAudioFormat(javax.sound.sampled.AudioFormat poAudioFormat)
           
 void setAudioInputStream(javax.sound.sampled.AudioInputStream poAudioInputStream)
           
 void setEncoding(javax.sound.sampled.AudioFormat.Encoding poEncoding)
           
 int writeAudioData(double[] padSampleData, int piWords)
          Writes sample data into the sample's audio stream.
 
Methods inherited from class marf.Storage.SampleLoader
getRequiredBitSize, getRequiredChannels, getRequiredFrequency, getSample, loadSample, loadSample, loadSample, saveSample, saveSample, saveSample, saveSample, setRequiredBitSize, setRequiredChannels, setRequiredFrequency, setSample, updateSample
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface marf.Storage.ISampleLoader
readSampleData, writeSampleData
 

Field Detail

oAudioFormat

protected javax.sound.sampled.AudioFormat oAudioFormat
Properties of a sound sample.


oAudioInputStream

protected javax.sound.sampled.AudioInputStream oAudioInputStream
Stream representing sound sample.


oEncoding

protected javax.sound.sampled.AudioFormat.Encoding oEncoding
Default audio encoding.

See Also:
AudioFormat.Encoding.PCM_SIGNED
Constructor Detail

AudioSampleLoader

public AudioSampleLoader()
Default constructor. Instantiates ByteArrayOutputStream.

Method Detail

loadSample

public Sample loadSample(byte[] patFileData)
                  throws StorageException
Overrides the parent to include the AudioInputStream into the chain in order avoid audio format related errors.

Specified by:
loadSample in interface ISampleLoader
Overrides:
loadSample in class SampleLoader
Parameters:
patFileData - the byte data of a sample to be read from
Returns:
Sample object reference
Throws:
StorageException - if there was an error loading the sample
See Also:
SampleLoader.loadSample(byte[])

readAudioData

public int readAudioData(double[] padAudioData)
                  throws StorageException
Reads sample data from the sample's audio stream into padSampleData.

Parameters:
padAudioData - an array of doubles to store the data read
Returns:
the number of datums read
Throws:
StorageException - if there was an error reading the data

writeAudioData

public int writeAudioData(double[] padSampleData,
                          int piWords)
                   throws StorageException
Writes sample data into the sample's audio stream.

Parameters:
padSampleData - an array of doubles
piWords - the number of audio data items to write from the padSampleData array
Returns:
the actual number of data written
Throws:
StorageException - if there was an error loading the sample

reset

public void reset()
           throws StorageException
Resets the marker for the audio stream. 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 audio stream

getSampleSize

public long getSampleSize()
                   throws StorageException
Retrieves the length of the sample (# of audio data in the audio stream).

Specified by:
getSampleSize in interface ISampleLoader
Overrides:
getSampleSize in class SampleLoader
Returns:
sample size, long
Throws:
StorageException - if there was an error getting sample size

getAudioFormat

public javax.sound.sampled.AudioFormat getAudioFormat()

setAudioFormat

public void setAudioFormat(javax.sound.sampled.AudioFormat poAudioFormat)

getAudioInputStream

public javax.sound.sampled.AudioInputStream getAudioInputStream()

setAudioInputStream

public void setAudioInputStream(javax.sound.sampled.AudioInputStream poAudioInputStream)

getEncoding

public javax.sound.sampled.AudioFormat.Encoding getEncoding()

setEncoding

public void setEncoding(javax.sound.sampled.AudioFormat.Encoding poEncoding)

getMARFSourceCodeRevision

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

Returns:
revision string


SourceForge Logo