marf.Storage
Class Sample

java.lang.Object
  extended bymarf.Storage.Sample

public class Sample
extends java.lang.Object

Class Sample

Audio sample data container

$Header: /cvsroot/marf/marf/src/marf/Storage/Sample.java,v 1.25 2004/04/20 16:38:48 mokhov Exp $

Author:
Jim

Field Summary
protected  double[] adSample
          Sample data array (amplitudes)
protected  int iArrayIndex
          Chunk pointer in the sample array
protected  int iFormat
          Sample's format
static int MP3
          MP3 sample format
static int ULAW
          ULAW sample format
static int UNK
          Unknown sample format
static int WAV
          WAVE sample format
 
Constructor Summary
Sample()
          Default constructor
Sample(double[] padData)
          Accepts pre-set sample for testing
Sample(int piFormat)
          Constructor with format indication
 
Method Summary
 int getAudioFormat()
           
 int getNextChunk(double[] chunkArray)
          Gets the next chunk of audio data and places it into chunkArray.
 double[] getSampleArray()
          Retrieves array containing audio data of the entire sample.
 long getSampleSize()
          Returns the length of the sample.
 void resetArrayMark()
          Resets the marker used for reading audio data from sample array
 void setAudioFormat(int piFormat)
          Sets current format of a sample
 void setSampleArray(double[] paSampleArray)
          Sets the internal sample array (adSample) with the specified argument.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNK

public static final int UNK
Unknown sample format

See Also:
Constant Field Values

WAV

public static final int WAV
WAVE sample format

See Also:
Constant Field Values

ULAW

public static final int ULAW
ULAW sample format

See Also:
Constant Field Values

MP3

public static final int MP3
MP3 sample format

See Also:
Constant Field Values

iFormat

protected int iFormat
Sample's format


adSample

protected double[] adSample
Sample data array (amplitudes)


iArrayIndex

protected int iArrayIndex
Chunk pointer in the sample array

Constructor Detail

Sample

public Sample()
Default constructor


Sample

public Sample(double[] padData)
Accepts pre-set sample for testing

Parameters:
padData - preset amplitude values

Sample

public Sample(int piFormat)
       throws InvalidSampleFormatException
Constructor with format indication

Parameters:
piFormat - format number for the enumeration
Throws:
InvalidSampleFormatException
Method Detail

getAudioFormat

public final int getAudioFormat()
Returns:
an integer representing the format of the sample

setAudioFormat

public final void setAudioFormat(int piFormat)
                          throws InvalidSampleFormatException
Sets current format of a sample

Parameters:
piFormat - format number from the enumeration
Throws:
InvalidSampleFormatException

setSampleArray

public final void setSampleArray(double[] paSampleArray)
Sets the internal sample array (adSample) with the specified argument. Index gets reset as well.

Parameters:
paSampleArray - an array of doubles

getSampleArray

public final double[] getSampleArray()
Retrieves array containing audio data of the entire sample.

Returns:
double Array

getNextChunk

public final int getNextChunk(double[] chunkArray)
Gets the next chunk of audio data and places it into chunkArray. Similar to readAudioData() method only it reads from the array instead of the audio stream (file).

Parameters:
chunkArray - An array of doubles
Returns:
number of data retrieved

resetArrayMark

public final void resetArrayMark()
Resets the marker used for reading audio data from sample array


getSampleSize

public final long getSampleSize()
Returns the length of the sample.

Returns:
long Array length