org.xiph.speex

Class NbEncoder

Implemented Interfaces:
Codebook, Encoder

public class NbEncoder
extends NbCodec
implements Encoder

Narrowband Speex Encoder
Version:
$Revision: 1.2 $
Author:
Marc Gimpel, Wimba S.A. (mgimpel@horizonwimba.com)

Field Summary

static int[]
NB_QUALITY_MAP
The Narrowband Quality map indicates which narrowband submode to use for the given narrowband quality setting
protected float
abr_count
protected float
abr_drift
Relative quality that will be needed by VBR
protected float
abr_drift2
protected int
abr_enabled
1 for enabling VAD, 0 otherwise
private float[]
autocorr
2nd temporary buffer
private int
bounded_pitch
private float[]
buf2
Temporary (Hanning) window
private float[]
bw_lpc1
Interpolated LPCs
private float[]
bw_lpc2
LPCs after bandwidth expansion by gamma1 for perceptual weighting
protected int
complexity
private int
dtx_count
State of the VBR data
private float[]
exc2Buf
1-element memory for pre-emphasis
private int
exc2Idx
"Pitch enhanced" excitation
private float[]
innov2
Number of consecutive DTX frames
private float[]
interp_lpc
Interpolated LSPs
private float[]
interp_lsp
LSPs for previous frame
private float[]
lagWindow
auto-correlation
private float[]
lsp
Window applied to auto-correlation
private float[]
mem_exc
Filter memory for perceptually-weighted signal (whole frame)
private float[]
mem_sw
Reflection coefficients
private float[]
mem_sw_whole
Filter memory for perceptually-weighted signal
private float[]
old_lsp
LSPs for current frame
private int[]
pitch
Next frame should not rely on previous frames for pitch
private float
pre_mem2
private float[]
rc
LPCs after bandwidth expansion by gamma2 for perceptual weighting
protected float
relative_quality
Quality setting for VBR encoding
protected int
sampling_rate
protected int
submodeSelect
private float[]
swBuf
"Pitch enhanced" excitation
private int
swIdx
Weighted signal buffer
protected int
vad_enabled
1 for enabling VBR, 0 otherwise
private Vbr
vbr
Filter memory for excitation (whole frame)
protected int
vbr_enabled
Complexity setting (0-10 from least complex to most complex)
protected float
vbr_quality
ABR setting (in bps), 0 if off
private float[]
window
Start of weighted signal frame

Fields inherited from class org.xiph.speex.NbCodec

NB_FRAME_SIZE, NB_SUBMODES, NB_SUBMODE_BITS, VERY_SMALL, awk1, awk2, awk3, bufSize, dtx_enabled, excBuf, excIdx, exc_gain_quant_scal1, exc_gain_quant_scal3, filters, first, frameSize, frmBuf, frmIdx, gamma1, gamma2, innov, interp_qlpc, interp_qlsp, lag_factor, lpc, lpcSize, lpc_floor, m_lsp, max_pitch, mem_sp, min_pitch, nbSubframes, old_qlsp, pi_gain, pre_mem, preemph, qlsp, subframeSize, submodeID, submodes, voc_m1, voc_m2, voc_mean, voc_offset, windowSize

Fields inherited from interface org.xiph.speex.Codebook

NB_CDBK_SIZE, NB_CDBK_SIZE_HIGH1, NB_CDBK_SIZE_HIGH2, NB_CDBK_SIZE_LOW1, NB_CDBK_SIZE_LOW2, cdbk_nb, cdbk_nb_high1, cdbk_nb_high2, cdbk_nb_low1, cdbk_nb_low2, exc_10_16_table, exc_10_32_table, exc_20_32_table, exc_5_256_table, exc_5_64_table, exc_8_128_table, gain_cdbk_lbr, gain_cdbk_nb, h0, h1, hexc_10_32_table, hexc_table, high_lsp_cdbk, high_lsp_cdbk2

Method Summary

int
encode(Bits bits, float[] in)
Encode the given input signal.
int
getAbr()
Returns the Average Bit Rate used (0 if ABR is not turned on).
int
getBitRate()
Gets the bitrate.
int
getComplexity()
Returns the algorthmic complexity.
int
getEncodedFrameSize()
Returns the size in bits of an audio frame encoded with the current mode.
int
getLookAhead()
Return LookAhead.
int
getMode()
Returns the encoding submode currently in use.
float
getRelativeQuality()
Returns the relative quality.
int
getSamplingRate()
Returns the sampling rate.
boolean
getVad()
Returns whether or not we are using Voice Activity Detection encoding.
boolean
getVbr()
Returns whether or not we are using Variable Bit Rate encoding.
float
getVbrQuality()
Returns the Varible Bit Rate Quality.
void
init(int frameSize, int subframeSize, int lpcSize, int bufSize)
Initialisation
void
setAbr(int abr)
Sets the Average Bit Rate.
void
setBitRate(int bitrate)
Sets the bitrate.
void
setComplexity(int complexity)
Sets the algorthmic complexity.
void
setDtx(boolean dtx)
Sets whether or not to use Discontinuous Transmission encoding.
void
setMode(int mode)
Sets the encoding submode.
void
setQuality(int quality)
Sets the Quality
void
setSamplingRate(int rate)
Sets the sampling rate.
void
setVad(boolean vad)
Sets whether or not to use Voice Activity Detection encoding.
void
setVbr(boolean vbr)
Sets whether or not to use Variable Bit Rate encoding.
void
setVbrQuality(float quality)
Sets the Varible Bit Rate Quality.

Methods inherited from class org.xiph.speex.NbCodec

buildNbSubModes, getDtx, getExc, getFrameSize, getInnov, getPiGain, init, nbinit

Field Details

NB_QUALITY_MAP

public static final int[] NB_QUALITY_MAP
The Narrowband Quality map indicates which narrowband submode to use for the given narrowband quality setting

abr_count

protected float abr_count

abr_drift

protected float abr_drift
Relative quality that will be needed by VBR

abr_drift2

protected float abr_drift2

abr_enabled

protected int abr_enabled
1 for enabling VAD, 0 otherwise

autocorr

private float[] autocorr
2nd temporary buffer

bounded_pitch

private int bounded_pitch

buf2

private float[] buf2
Temporary (Hanning) window

bw_lpc1

private float[] bw_lpc1
Interpolated LPCs

bw_lpc2

private float[] bw_lpc2
LPCs after bandwidth expansion by gamma1 for perceptual weighting

complexity

protected int complexity

dtx_count

private int dtx_count
State of the VBR data

exc2Buf

private float[] exc2Buf
1-element memory for pre-emphasis

exc2Idx

private int exc2Idx
"Pitch enhanced" excitation

innov2

private float[] innov2
Number of consecutive DTX frames

interp_lpc

private float[] interp_lpc
Interpolated LSPs

interp_lsp

private float[] interp_lsp
LSPs for previous frame

lagWindow

private float[] lagWindow
auto-correlation

lsp

private float[] lsp
Window applied to auto-correlation

mem_exc

private float[] mem_exc
Filter memory for perceptually-weighted signal (whole frame)

mem_sw

private float[] mem_sw
Reflection coefficients

mem_sw_whole

private float[] mem_sw_whole
Filter memory for perceptually-weighted signal

old_lsp

private float[] old_lsp
LSPs for current frame

pitch

private int[] pitch
Next frame should not rely on previous frames for pitch

pre_mem2

private float pre_mem2

rc

private float[] rc
LPCs after bandwidth expansion by gamma2 for perceptual weighting

relative_quality

protected float relative_quality
Quality setting for VBR encoding

sampling_rate

protected int sampling_rate

submodeSelect

protected int submodeSelect

swBuf

private float[] swBuf
"Pitch enhanced" excitation

swIdx

private int swIdx
Weighted signal buffer

vad_enabled

protected int vad_enabled
1 for enabling VBR, 0 otherwise

vbr

private Vbr vbr
Filter memory for excitation (whole frame)

vbr_enabled

protected int vbr_enabled
Complexity setting (0-10 from least complex to most complex)

vbr_quality

protected float vbr_quality
ABR setting (in bps), 0 if off

window

private float[] window
Start of weighted signal frame

Method Details

encode

public int encode(Bits bits,
                  float[] in)
Encode the given input signal.
Specified by:
encode in interface Encoder
Parameters:
bits - - Speex bits buffer.
in - - the raw mono audio frame to encode.
Returns:
return 1 if successful.

getAbr

public int getAbr()
Returns the Average Bit Rate used (0 if ABR is not turned on).
Specified by:
getAbr in interface Encoder
Returns:
the Average Bit Rate used (0 if ABR is not turned on).

getBitRate

public int getBitRate()
Gets the bitrate.
Specified by:
getBitRate in interface Encoder
Returns:
the bitrate.

getComplexity

public int getComplexity()
Returns the algorthmic complexity.
Specified by:
getComplexity in interface Encoder
Returns:
the algorthmic complexity.

getEncodedFrameSize

public int getEncodedFrameSize()
Returns the size in bits of an audio frame encoded with the current mode.
Specified by:
getEncodedFrameSize in interface Encoder
Returns:
the size in bits of an audio frame encoded with the current mode.

getLookAhead

public int getLookAhead()
Return LookAhead.
Specified by:
getLookAhead in interface Encoder
Returns:
LookAhead.

getMode

public int getMode()
Returns the encoding submode currently in use.
Specified by:
getMode in interface Encoder
Returns:
the encoding submode currently in use.

getRelativeQuality

public float getRelativeQuality()
Returns the relative quality.
Specified by:
getRelativeQuality in interface Encoder
Returns:
the relative quality.

getSamplingRate

public int getSamplingRate()
Returns the sampling rate.
Specified by:
getSamplingRate in interface Encoder
Returns:
the sampling rate.

getVad

public boolean getVad()
Returns whether or not we are using Voice Activity Detection encoding.
Specified by:
getVad in interface Encoder
Returns:
whether or not we are using Voice Activity Detection encoding.

getVbr

public boolean getVbr()
Returns whether or not we are using Variable Bit Rate encoding.
Specified by:
getVbr in interface Encoder
Returns:
whether or not we are using Variable Bit Rate encoding.

getVbrQuality

public float getVbrQuality()
Returns the Varible Bit Rate Quality.
Specified by:
getVbrQuality in interface Encoder
Returns:
the Varible Bit Rate Quality.

init

public void init(int frameSize,
                 int subframeSize,
                 int lpcSize,
                 int bufSize)
Initialisation
Overrides:
init in interface NbCodec
Parameters:
frameSize -
subframeSize -
lpcSize -
bufSize -

setAbr

public void setAbr(int abr)
Sets the Average Bit Rate.
Specified by:
setAbr in interface Encoder
Parameters:
abr -

setBitRate

public void setBitRate(int bitrate)
Sets the bitrate.
Specified by:
setBitRate in interface Encoder
Parameters:
bitrate -

setComplexity

public void setComplexity(int complexity)
Sets the algorthmic complexity.
Specified by:
setComplexity in interface Encoder
Parameters:
complexity -

setDtx

public void setDtx(boolean dtx)
Sets whether or not to use Discontinuous Transmission encoding.
Specified by:
setDtx in interface Encoder
Parameters:
dtx -

setMode

public void setMode(int mode)
Sets the encoding submode.
Specified by:
setMode in interface Encoder
Parameters:
mode -

setQuality

public void setQuality(int quality)
Sets the Quality
Specified by:
setQuality in interface Encoder
Parameters:
quality -

setSamplingRate

public void setSamplingRate(int rate)
Sets the sampling rate.
Specified by:
setSamplingRate in interface Encoder
Parameters:
rate -

setVad

public void setVad(boolean vad)
Sets whether or not to use Voice Activity Detection encoding.
Specified by:
setVad in interface Encoder
Parameters:
vad -

setVbr

public void setVbr(boolean vbr)
Sets whether or not to use Variable Bit Rate encoding.
Specified by:
setVbr in interface Encoder
Parameters:
vbr -

setVbrQuality

public void setVbrQuality(float quality)
Sets the Varible Bit Rate Quality.
Specified by:
setVbrQuality in interface Encoder
Parameters:
quality -

Copyright © 1999-2004 Wimba S.A. All Rights Reserved.