Modifier and Type | Class and Description |
---|---|
private static class |
LPCResult.Wave
A Wave is an immutable class that contains the AudioFormat and
the actual wave samples, which currently is in the form
of AudioInputStream.
|
Modifier and Type | Field and Description |
---|---|
private short[][] |
frames |
private int |
frameSize |
private float |
lpcMinimum |
private float |
lpcRange |
private static int |
MAX_SAMPLE_SIZE |
private int |
numberOfChannels |
private int |
numberOfFrames |
private static double |
POST_EMPHASIS |
private int |
residualFold |
private byte[] |
residuals
this is a normalized version of the residuals; to normalize it,
add 128 to it
|
private static float[] |
residualToFloatMap
Given a residual, maps it using WaveUtils.ulawToShort() to a float.
|
private int |
sampleRate |
private int[] |
sizes |
private int[] |
times |
Constructor and Description |
---|
LPCResult() |
Modifier and Type | Method and Description |
---|---|
void |
copyResiduals(byte[] source,
int targetPosition,
int targetSize)
Copies the information in the given unit to the array of residuals,
starting at the given index, up until targetSize chars.
|
void |
copyResidualsPulse(byte[] source,
int targetPosition,
int targetSize)
Copies the residual puse in the given unit to the array of residuals,
starting at the given index, up until targetSize chars.
|
void |
dump()
Dumps this LPCResult to standard out
|
void |
dump(Writer writer)
Dumps this LPCResult to the given stream.
|
void |
dumpASCII()
Dumps the wave data associated with this result
|
void |
dumpASCII(String path)
Dumps the wave data associated with this result
|
void |
dumpASCII(Writer writer)
Dumps the wave out to the given stream
|
short[] |
getFrame(int index)
Returns the frame at the given index.
|
int |
getFrameShift(int frameIndex)
Returns the time difference of the frame at the given position
with the frame prior to that.
|
int |
getFrameSize()
Returns the sizes of frames in this LPC.
|
float |
getLPCMin()
Returns the LPC minimum.
|
float |
getLPCRange()
Returns the LPC range.
|
int |
getNumberOfChannels()
Returns the number of channels in this LPCResult.
|
int |
getNumberOfFrames()
Returns the number of frames in this LPCResult.
|
int |
getNumberOfSamples()
Returns the number of samples in this LPC result
|
byte[] |
getResiduals()
Returns the array of residuals.
|
int[] |
getResidualSizes()
Returns the array of residuals sizes.
|
int |
getSampleRate()
Returns the sample rate.
|
int[] |
getTimes()
Returns the array of times.
|
private LPCResult.Wave |
getWave()
Synthesize a Wave from this LPCResult
|
byte[] |
getWaveSamples() |
private byte[] |
getWaveSamples(int numberSamples,
Utterance utterance)
get the samples for this utterance
|
private static byte |
hibyte(int val)
Given a 16 bit value (represented as an int), extract
the high eight bits and return them
|
private static byte |
lobyte(int val)
Given a 16 bit value (represented as an int), extract
the low eight bits and return them
|
boolean |
playWave(AudioPlayer player,
Utterance utterance)
Synthesize a Wave from this LPCResult
|
private boolean |
playWaveSamples(AudioPlayer player,
FreeTTSSpeakable speakable,
int numberSamples)
Play the sample data on the given player
|
void |
resizeFrames(int numberOfFrames)
Resets the number of frames in this LPCResult.
|
void |
resizeResiduals(int numberOfSamples)
Resets the number of residuals, and initialize all of them to 255
(which is 0 for mulaw).
|
void |
setFrame(int index,
short[] newFrames)
Sets the frame at the given index.
|
void |
setFrameSize(int frameSize)
Sets the sizes of frames in this LPC to the given size.
|
void |
setLPCMin(float min)
Sets the LPC minimum.
|
void |
setLPCRange(float range)
Sets the LPC range.
|
void |
setNumberOfChannels(int numberOfChannels)
Sets the number of channels.
|
void |
setNumberOfFrames(int numberFrames)
Sets the number of frames in this LPC Result.
|
void |
setResidualSizes(int[] sizes)
Sets the array of residual sizes.
|
void |
setSampleRate(int rate)
Sets the sample rate.
|
void |
setTimes(int[] times)
Sets the array of times.
|
void |
setValues(int numberOfChannels,
int sampleRate,
int residualFold,
float lpcMin,
float lpcRange)
A convenience method for setting the LPC values.
|
private static final double POST_EMPHASIS
private int frameSize
private int numberOfFrames
private short[][] frames
private int[] times
private int[] sizes
private byte[] residuals
private int numberOfChannels
private int sampleRate
private int residualFold
private float lpcMinimum
private float lpcRange
private static final int MAX_SAMPLE_SIZE
private static final float[] residualToFloatMap
public LPCResult()
public void resizeFrames(int numberOfFrames)
numberOfFrames
- the number of frames in this LPC resultpublic void resizeResiduals(int numberOfSamples)
numberOfSamples
- the number of samples in this LPC resultpublic void setValues(int numberOfChannels, int sampleRate, int residualFold, float lpcMin, float lpcRange)
numberOfChannels
- the number of channelssampleRate
- the sample ratelpcMin
- the LPC minimumlpcRange
- the LPC rangepublic int getFrameShift(int frameIndex)
frameIndex
- the position of the framepublic int getFrameSize()
public short[] getFrame(int index)
index
- the index of interestpublic int[] getTimes()
public int getNumberOfFrames()
public int getNumberOfChannels()
public float getLPCMin()
public float getLPCRange()
public int getNumberOfSamples()
public int getSampleRate()
public int[] getResidualSizes()
public byte[] getResiduals()
public void setFrameSize(int frameSize)
frameSize
- the new frame sizepublic void setNumberOfFrames(int numberFrames)
numberFrames
- the number of frames in this resultpublic void setFrame(int index, short[] newFrames)
index
- the position of the frame to setnewFrames
- new frame datapublic void setTimes(int[] times)
times
- the times datapublic void setNumberOfChannels(int numberOfChannels)
numberOfChannels
- the number of channelspublic void setLPCMin(float min)
min
- the LPC minimumpublic void setLPCRange(float range)
range
- the LPC rangepublic void setSampleRate(int rate)
rate
- the sample ratepublic void setResidualSizes(int[] sizes)
sizes
- the new residual sizespublic void copyResiduals(byte[] source, int targetPosition, int targetSize)
source
- the unit that holds the information sourcetargetPosition
- start position in the array of residualstargetSize
- the maximum number of characters to copypublic void copyResidualsPulse(byte[] source, int targetPosition, int targetSize)
source
- the unit that holds the information sourcetargetPosition
- start position in the array of residualstargetSize
- the maximum number of characters to copyprivate static final byte hibyte(int val)
val
- the 16 bit valueprivate static final byte lobyte(int val)
val
- the 16 bit valuepublic boolean playWave(AudioPlayer player, Utterance utterance) throws IOException
IOException
- if an error occurs while writing the audio datapublic byte[] getWaveSamples()
private byte[] getWaveSamples(int numberSamples, Utterance utterance)
numberSamples
- the number of samples desirredutterance
- the utterance
[[[ TODO: well there is a bunch of duplicated code here ..
these should be combined into one routine.
]]]private boolean playWaveSamples(AudioPlayer player, FreeTTSSpeakable speakable, int numberSamples) throws IOException
player
- where to send the audionumberSamples
- the number of samplesIOException
- if an error occurs while writing the audio datapublic void dump()
public void dump(Writer writer)
writer
- the output streampublic void dumpASCII()
public void dumpASCII(String path) throws IOException
path
- the path where the wave data is appended toIOException
- if an IO error occursprivate LPCResult.Wave getWave()
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses