Package com.sun.speech.freetts.relp
Class Sample
- java.lang.Object
-
- com.sun.speech.freetts.relp.Sample
-
public class Sample extends java.lang.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 partsSample(short[] frameData, byte[] residualData, int residualSize)
Constructs a Sample from its component partsSample(java.io.BufferedReader reader, int numChannels)
Reads a sample from the input reader.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
compare(Sample other)
Compares two samples.void
dump()
Dumps the sample:void
dumpBinary(java.io.DataOutputStream os)
Dumps the samples to the given streamvoid
dumpBinary(java.nio.ByteBuffer bb)
Dumps the samples to the given ByteBuffershort[]
getFrameData()
Gets the frame data associated with this sampleint
getFrameData(int which)
Returns the normalized frame data.byte[]
getResidualData()
Gets the residual data associated with this sampleint
getResidualData(int which)
Returns the normalized residual data.int
getResidualSize()
Returns the number of residuals in this Sample.static Sample
loadBinary(java.io.DataInputStream dis)
Loads the samples from the given channelstatic Sample
loadBinary(java.nio.ByteBuffer bb)
Loads the samples from the byte bufer
-
-
-
Constructor Detail
-
Sample
public Sample(short[] frameData, byte[] residualData)
Constructs a RELP Sample from its component parts- Parameters:
frameData
- the framedataresidualData
- the residual data
-
Sample
public Sample(short[] frameData, byte[] residualData, int residualSize)
Constructs a Sample from its component parts- Parameters:
frameData
- the framedataresidualData
- the residual data
-
Sample
public Sample(java.io.BufferedReader reader, int numChannels)
Reads a sample from the input reader.- Parameters:
reader
- the input reader to read the data fromnumChannels
- the number of channels per frame
-
-
Method Detail
-
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(java.nio.ByteBuffer bb) throws java.io.IOException
Dumps the samples to the given ByteBuffer- Parameters:
bb
- the ByteBuffer to write the data to.- Throws:
java.io.IOException
- if IO error occurs
-
dumpBinary
public void dumpBinary(java.io.DataOutputStream os) throws java.io.IOException
Dumps the samples to the given stream- Parameters:
os
- the DataOutputStream to write the data to.- Throws:
java.io.IOException
- if IO error occurs
-
loadBinary
public static Sample loadBinary(java.nio.ByteBuffer bb) throws java.io.IOException
Loads the samples from the byte bufer- Parameters:
bb
- the byte buffer to read the data from.- Throws:
java.io.IOException
- if IO error occurs
-
loadBinary
public static Sample loadBinary(java.io.DataInputStream dis) throws java.io.IOException
Loads the samples from the given channel- Parameters:
dis
- the DataInputStream to read the data from.- Throws:
java.io.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; otherwisefalse
-
-