marf.Storage
Interface ISampleLoader

All Known Implementing Classes:
AIFFCLoader, AIFFLoader, AudioSampleLoader, AULoader, MIDILoader, MP3Loader, SampleLoader, SineLoader, SNDLoader, TextLoader, ULAWLoader, WAVLoader

public interface ISampleLoader

Common sample loading interface. Must be overridden by a concrete sample loader. Derivatives should try their best to inherit from the SampleLoader class; otherwise, they must implement this interface.

$Id: ISampleLoader.java,v 1.14 2007/12/23 06:29:46 mokhov Exp $

Since:
0.3.0.2
Version:
$Revision: 1.14 $
Author:
Serguei Mokhov
See Also:
SampleLoader

Field Summary
static int DEFAULT_CHANNELS
          Mono.
static float DEFAULT_FREQUENCY
          Default sampling frequency of 8000 Hz.
static int DEFAULT_SAMPLE_BIT_SIZE
          Default number of bits per amplitude.
static java.lang.String MARF_INTERFACE_CODE_REVISION
          Interface source code revision.
 
Method Summary
 Sample getSample()
          Returns internal reference to a Sample object.
 long getSampleSize()
          Retrieves the length of the sample (# of audio data in the audio stream).
 Sample loadSample(byte[] patFileData)
          Assumes the file data is in the array of bytes for loading.
 Sample loadSample(java.io.File poInFile)
          Prime SampleLoader interface.
 Sample loadSample(java.io.InputStream poDataInputStream)
          Assumes the incoming stream is the sample file data.
 Sample loadSample(java.lang.String pstrFilename)
          Same as loadSample(File) but takes filename as an argument.
 int readSampleData(double[] padSampleData)
          Reads sample data from the sample's stream into the parameter.
 void reset()
          Resets the marker for the audio stream.
 void saveSample(byte[] patFileData)
          Assumes the file data is in the array of bytes for loading.
 void saveSample(java.io.File poOutFile)
          Prime SampleLoader interface.
 void saveSample(java.io.OutputStream poDataOutputStream)
          Assumes the output stream is the sample file data.
 void saveSample(java.lang.String pstrFilename)
          Same as saveSample(File) but takes filename as an argument.
 void setSample(Sample poSample)
          Sets internal sample reference from outside.
 void updateSample()
          updateSample() is just used whenever the AudioInputStream is assigned to a new value (wave file).
 int writeSampleData(double[] padSampleData, int piWords)
          Writes sample data into the sample's stream.
 

Field Detail

DEFAULT_SAMPLE_BIT_SIZE

static final int DEFAULT_SAMPLE_BIT_SIZE
Default number of bits per amplitude. Default 16.

See Also:
Constant Field Values

DEFAULT_CHANNELS

static final int DEFAULT_CHANNELS
Mono. Default 1.

See Also:
Constant Field Values

DEFAULT_FREQUENCY

static final float DEFAULT_FREQUENCY
Default sampling frequency of 8000 Hz.

See Also:
Constant Field Values

MARF_INTERFACE_CODE_REVISION

static final java.lang.String MARF_INTERFACE_CODE_REVISION
Interface source code revision.

See Also:
Constant Field Values
Method Detail

readSampleData

int readSampleData(double[] padSampleData)
                   throws StorageException
Reads sample data from the sample's stream into the parameter. In 0.3.0.6 was renamed from readAudioData() to readSampleData() to accommodate non-audio loaders. readAudioData() was moved down to AudioSampleLoader as a wrapper for this method for some semblance of backwards compatibility.

Parameters:
padSampleData - 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
See Also:
AudioSampleLoader.readAudioData(double[])

writeSampleData

int writeSampleData(double[] padSampleData,
                    int piWords)
                    throws StorageException
Writes sample data into the sample's stream. In 0.3.0.6 this method was renamed from writeAudioData() to writeSampleData() to accommodate non-audio loaders. writeAudioData() was moved down to AudioSampleLoader as a wrapper for this method for some semblance of backwards compatibility.

Parameters:
padSampleData - an array of doubles
piWords - the number of data items (words) to write from the padSampleData
Returns:
the number of data actually written
Throws:
StorageException - if there was an error loading the sample
See Also:
AudioSampleLoader.writeAudioData(double[], int)

loadSample

Sample loadSample(java.io.File poInFile)
                  throws StorageException
Prime SampleLoader interface. Must be overridden by a concrete loader that knows how to load a specific sample format.

Parameters:
poInFile - file object a sample to be read from
Returns:
Sample object reference
Throws:
StorageException

loadSample

Sample loadSample(java.lang.String pstrFilename)
                  throws StorageException
Same as loadSample(File) but takes filename as an argument.

Parameters:
pstrFilename - filename of a sample to be read from
Returns:
Sample object reference
Throws:
StorageException - if there was an error loading the sample

loadSample

Sample loadSample(byte[] patFileData)
                  throws StorageException
Assumes the file data is in the array of bytes for loading.

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
Since:
0.3.0.6

loadSample

Sample loadSample(java.io.InputStream poDataInputStream)
                  throws StorageException
Assumes the incoming stream is the sample file data.

Parameters:
poDataInputStream - the stream of a sample to be read from
Returns:
Sample object reference
Throws:
StorageException - if there was an error loading the sample
Since:
0.3.0.6

saveSample

void saveSample(java.io.File poOutFile)
                throws StorageException
Prime SampleLoader interface. Must be overridden by a concrete loader that knows how to save a specific sample.

Parameters:
poOutFile - File object of a sample to be saved to
Throws:
StorageException - if there was an error saving the sample

saveSample

void saveSample(java.lang.String pstrFilename)
                throws StorageException
Same as saveSample(File) but takes filename as an argument.

Parameters:
pstrFilename - filename of a sample to be saved to
Throws:
StorageException - if there was an error saving the sample

saveSample

void saveSample(byte[] patFileData)
                throws StorageException
Assumes the file data is in the array of bytes for loading.

Parameters:
patFileData - the byte data of a sample to be read from
Throws:
StorageException - if there was an error loading the sample
Since:
0.3.0.6

saveSample

void saveSample(java.io.OutputStream poDataOutputStream)
                throws StorageException
Assumes the output stream is the sample file data.

Parameters:
poDataOutputStream - the stream of a sample to be written to
Throws:
StorageException - if there was an error loading the sample
Since:
0.3.0.6

updateSample

void updateSample()
                  throws StorageException

updateSample() is just used whenever the AudioInputStream is assigned to a new value (wave file). Then you would simply call this method to update the Sample member with the contents of the new AudioInputStream.

Throws:
StorageException - if there was an error updating the sample data array

reset

void reset()
           throws StorageException
Resets the marker for the audio stream. Used after writing audio data into the sample's audio stream.

Throws:
StorageException - if there was an error resetting the audio stream

getSampleSize

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

Returns:
sample size, long
Throws:
StorageException - if there was an error getting sample size

getSample

Sample getSample()
Returns internal reference to a Sample object.

Returns:
Sample reference

setSample

void setSample(Sample poSample)
Sets internal sample reference from outside.

Parameters:
poSample - Sample object


SourceForge Logo