Package com.sun.speech.freetts.relp

# Class Sample

java.lang.Object
com.sun.speech.freetts.relp.Sample

public class Sample extends Object
A single short term sample containing Residual Excited Linear Predictive (RELP) frame and residual voice data.

## Constructor Summary

Constructors
Constructor
Description
`Sample(short[] frameData, byte[] residualData)`
Constructs a RELP Sample from its component parts
`Sample(short[] frameData, byte[] residualData, int residualSize)`
Constructs a Sample from its component parts
`Sample(BufferedReader reader, int numChannels)`
Reads a sample from the input reader.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`compare(Sample other)`
Compares two samples.
`void`
`dump()`
Dumps the sample:
`void`
`dumpBinary(DataOutputStream os)`
Dumps the samples to the given stream
`void`
`dumpBinary(ByteBuffer bb)`
Dumps the samples to the given ByteBuffer
`short[]`
`getFrameData()`
Gets the frame data associated with this sample
`int`
`getFrameData(int which)`
Returns the normalized frame data.
`byte[]`
`getResidualData()`
Gets the residual data associated with this sample
`int`
`getResidualData(int which)`
Returns the normalized residual data.
`int`
`getResidualSize()`
Returns the number of residuals in this Sample.
`static Sample`
`loadBinary(DataInputStream dis)`
Loads the samples from the given channel
`static Sample`
`loadBinary(ByteBuffer bb)`
Loads the samples from the byte bufer

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### Sample

public Sample(short[] frameData, byte[] residualData)
Constructs a RELP Sample from its component parts

Parameters:
  `frameData` - the framedata
  `residualData` - the residual data

### Sample

public Sample(short[] frameData, byte[] residualData, int residualSize)
Constructs a Sample from its component parts

Parameters:
  `frameData` - the framedata
  `residualData` - the residual data

### Sample

public Sample(BufferedReader reader, int numChannels)
Reads a sample from the input reader.

Parameters:
  `reader` - the input reader to read the data from
  `numChannels` - the number of channels per frame

## Method Details

### getFrameData

public short[] getFrameData()
Gets the frame data associated with this sample

Returns:
  the frame data associated with this sample

### getResidualData

public byte[] getResidualData()
Gets the residual data associated with this sample

Returns:
  the residual data associated with this sample

### getResidualSize

public int getResidualSize()
Returns the number of residuals in this Sample.

Returns:
  the number of residuals in this sample

### getResidualData

public int getResidualData(int which)
Returns the normalized residual data. You may not want to call this function because of the overhead involved.

Parameters:
  `which` - the index of the data of interest
Returns:
  the normalized data.

### getFrameData

public int getFrameData(int which)
Returns the normalized frame data. You may not want to call this function because of the overhead involved.

Parameters:
  `which` - the index of the data of interest
Returns:
  the normalized data.

### dump

public void dump()
Dumps the sample:

### dumpBinary

public void dumpBinary(ByteBuffer bb) throws IOException
Dumps the samples to the given ByteBuffer

Parameters:
  `bb` - the ByteBuffer to write the data to.
Throws:
  `IOException` - if IO error occurs

### dumpBinary

public void dumpBinary(DataOutputStream os) throws IOException
Dumps the samples to the given stream

Parameters:
  `os` - the DataOutputStream to write the data to.
Throws:
  `IOException` - if IO error occurs

### loadBinary

public static Sample loadBinary(ByteBuffer bb) throws IOException
Loads the samples from the byte bufer

Parameters:
  `bb` - the byte buffer to read the data from.
Throws:
  `IOException` - if IO error occurs

### loadBinary

public static Sample loadBinary(DataInputStream dis) throws IOException
Loads the samples from the given channel

Parameters:
  `dis` - the DataInputStream to read the data from.
Throws:
  `IOException` - if IO error occurs

### compare

public boolean compare(Sample other)
Compares two samples. Note that this is not the same as "equals"

Parameters:
  `other` - the other sample to compare this one to
Returns:
  `true` if they compare; otherwise `false`