marf.Storage
Class Sample

java.lang.Object
  |
  +--marf.Storage.Sample

public class Sample
extends java.lang.Object

Class Sample

$Header: /cvsroot/marf/marf/src/marf/Storage/Sample.java,v 1.21 2002/12/16 19:17:02 mokhov Exp $


Field Summary
protected  double[] adSample
          Sample data array (amplitudes)
protected  int ArrayIndex
          Chunk pointer in the sample array
private static int HIGHEST_FORMAT
          Highest possible sample format value.
protected  int iFormat
          Sample's format
private static int LOWEST_FORMAT
          Lowest possible sample format value.
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 (adSample).
 void setAudioFormat(int piFormat)
           
 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

LOWEST_FORMAT

private static final int LOWEST_FORMAT
Lowest possible sample format value. For boundaries check.

See Also:
Constant Field Values

HIGHEST_FORMAT

private static final int HIGHEST_FORMAT
Highest possible sample format value. For boundaries check.

See Also:
Constant Field Values

iFormat

protected int iFormat
Sample's format


adSample

protected double[] adSample
Sample data array (amplitudes)


ArrayIndex

protected int ArrayIndex
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
Method Detail

getAudioFormat

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

setAudioFormat

public void setAudioFormat(int piFormat)
                    throws InvalidSampleFormatException
Parameters:
piFormat - format number from the enumeration
InvalidSampleFormatException

setSampleArray

public 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 double[] getSampleArray()
Retrieves array containing audio data of the entire sample.

Returns:
double Array

getNextChunk

public int getNextChunk(double[] chunkArray)
                 throws java.lang.Exception
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
Throws:
java.lang.Exception

resetArrayMark

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


getSampleSize

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

Returns:
long Array length