Package org.xiph.speex.ant
Class JSpeexEncoderTask
- java.lang.Object
-
- org.apache.tools.ant.ProjectComponent
-
- org.apache.tools.ant.Task
-
- org.xiph.speex.ant.JSpeexEncoderTask
-
- All Implemented Interfaces:
java.lang.Cloneable
public class JSpeexEncoderTask extends org.apache.tools.ant.Task
AntTask
to Encode an audio file from PCM Wave to Speex. Here is an usage example:- Version:
- $Revision: 1.2 $
- Author:
- Marc Gimpel, Wimba S.A. (mgimpel@horizonwimba.com)
-
-
Field Summary
Fields Modifier and Type Field Description protected int
bitrate
Defines the desired bitrate for the encoded audio.protected int
channels
Defines the number of channels of the audio input (1=mono, 2=stereo).protected int
complexity
Defines the encoders algorithmic complexity.static java.lang.String
COPYRIGHT
Copyright display Stringstatic int
DEBUG
Print level for messages : Print debug informationprivate java.io.File
destDir
Directory to place destination filesprivate java.io.File
destFile
Destination file of decoded audioprotected int
destFormat
Defines File format for output audio file (Raw or Wave).protected boolean
dtx
Defines whether or not to use DTX (Discontinuous Transmission).static int
ERROR
Print level for messages : Print only errorsprivate boolean
failOnError
static int
FILE_FORMAT_OGG
File format for input or output audio file: Oggstatic int
FILE_FORMAT_RAW
File format for input or output audio file: Rawstatic int
FILE_FORMAT_WAVE
File format for input or output audio file: Wavestatic int
INFO
Print level for messages : Print basic informationprotected int
mode
Defines the encoder mode (0=NB, 1=WB and 2-UWB).protected boolean
modeset
Whether the mode is manualy set or automatically determined.protected int
nframes
Defines the number of frames per speex packet.private int
printlevel
Print level for messagesprotected int
quality
Defines the encoder quality setting (integer from 0 to 10).private boolean
quiet
Tells the task to suppress all but the most important outputprotected int
sampleRate
Defines the sampling rate of the audio input.private java.io.File
srcFile
Source file to decodeprivate java.util.Vector
srcFileset
List of source files to decodeprotected int
srcFormat
Defines File format for input audio file (Raw, Ogg or Wave).protected boolean
vad
Defines whether or not to use VAD (Voice Activity Detection).protected boolean
vbr
Defines whether or not to use VBR (Variable Bit Rate).protected float
vbr_quality
Defines the encoder VBR quality setting (float from 0 to 10).private boolean
verbose
Tells the task to output as much information as possiblestatic java.lang.String
VERSION
Version of the Speex Encoderstatic int
WARN
Print level for messages : Print only warnings and errors
-
Constructor Summary
Constructors Constructor Description JSpeexEncoderTask()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFileset(org.apache.tools.ant.types.FileSet set)
Handles thefileset
child element.private java.io.File
buildDestFile(java.io.File srcFile)
Builds and returns the destination file.void
encode(java.io.File srcPath, java.io.File destPath)
Encodes a PCM file to Speex.void
execute()
The method executing the task.protected static int
readInt(byte[] data, int offset)
Converts Little Endian (Windows) bytes to an int (Java uses Big Endian).protected static int
readShort(byte[] data, int offset)
Converts Little Endian (Windows) bytes to an short (Java uses Big Endian).void
setComplexity(int complexity)
Handles thecomplexity
attribute.void
setDestdir(java.io.File dir)
Handles thedestdir
attribute.void
setDestfile(java.io.File file)
Handles thedestfile
attribute.void
setDtx(boolean dtx)
Handles thedtx
attribute.void
setFailonerror(boolean failOnError)
Handles thefailonerror
attribute.void
setMode(java.lang.String mode)
Handles themode
attribute.void
setNframes(int nframes)
Handles thenframes
attribute.void
setQuality(float quality)
Handles thequality
attribute.void
setQuiet(boolean quiet)
Handles thequiet
attribute.void
setSrcfile(java.io.File file)
Handles thesrcfile
attribute.private void
setupTask(java.io.File srcPath, java.io.File destPath)
Setup some task variables.void
setVad(boolean vad)
Handles thevad
attribute.void
setVbr(boolean vbr)
Handles thevbr
attribute.void
setVerbose(boolean verbose)
Handles theverbose
attribute.void
version()
Prints the version.-
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
-
-
-
-
Field Detail
-
VERSION
public static final java.lang.String VERSION
Version of the Speex Encoder- See Also:
- Constant Field Values
-
COPYRIGHT
public static final java.lang.String COPYRIGHT
Copyright display String- See Also:
- Constant Field Values
-
DEBUG
public static final int DEBUG
Print level for messages : Print debug information- See Also:
- Constant Field Values
-
INFO
public static final int INFO
Print level for messages : Print basic information- See Also:
- Constant Field Values
-
WARN
public static final int WARN
Print level for messages : Print only warnings and errors- See Also:
- Constant Field Values
-
ERROR
public static final int ERROR
Print level for messages : Print only errors- See Also:
- Constant Field Values
-
FILE_FORMAT_RAW
public static final int FILE_FORMAT_RAW
File format for input or output audio file: Raw- See Also:
- Constant Field Values
-
FILE_FORMAT_OGG
public static final int FILE_FORMAT_OGG
File format for input or output audio file: Ogg- See Also:
- Constant Field Values
-
FILE_FORMAT_WAVE
public static final int FILE_FORMAT_WAVE
File format for input or output audio file: Wave- See Also:
- Constant Field Values
-
srcFile
private java.io.File srcFile
Source file to decode
-
srcFileset
private final java.util.Vector srcFileset
List of source files to decode
-
destFile
private java.io.File destFile
Destination file of decoded audio
-
destDir
private java.io.File destDir
Directory to place destination files
-
failOnError
private boolean failOnError
-
printlevel
private int printlevel
Print level for messages
-
quiet
private boolean quiet
Tells the task to suppress all but the most important output
-
verbose
private boolean verbose
Tells the task to output as much information as possible
-
srcFormat
protected int srcFormat
Defines File format for input audio file (Raw, Ogg or Wave).
-
destFormat
protected int destFormat
Defines File format for output audio file (Raw or Wave).
-
modeset
protected boolean modeset
Whether the mode is manualy set or automatically determined.
-
mode
protected int mode
Defines the encoder mode (0=NB, 1=WB and 2-UWB).
-
quality
protected int quality
Defines the encoder quality setting (integer from 0 to 10).
-
complexity
protected int complexity
Defines the encoders algorithmic complexity.
-
nframes
protected int nframes
Defines the number of frames per speex packet.
-
bitrate
protected int bitrate
Defines the desired bitrate for the encoded audio.
-
sampleRate
protected int sampleRate
Defines the sampling rate of the audio input.
-
channels
protected int channels
Defines the number of channels of the audio input (1=mono, 2=stereo).
-
vbr_quality
protected float vbr_quality
Defines the encoder VBR quality setting (float from 0 to 10).
-
vbr
protected boolean vbr
Defines whether or not to use VBR (Variable Bit Rate).
-
vad
protected boolean vad
Defines whether or not to use VAD (Voice Activity Detection).
-
dtx
protected boolean dtx
Defines whether or not to use DTX (Discontinuous Transmission).
-
-
Method Detail
-
execute
public void execute() throws org.apache.tools.ant.BuildException
The method executing the task.- Overrides:
execute
in classorg.apache.tools.ant.Task
- Throws:
org.apache.tools.ant.BuildException
-
buildDestFile
private java.io.File buildDestFile(java.io.File srcFile)
Builds and returns the destination file.- Parameters:
srcFile
-- Returns:
- the destination file.
-
setupTask
private void setupTask(java.io.File srcPath, java.io.File destPath)
Setup some task variables.- Parameters:
srcPath
- the Speex encoded source file.destPath
- the destination file.
-
addFileset
public void addFileset(org.apache.tools.ant.types.FileSet set)
Handles thefileset
child element.- Parameters:
set
-
-
setSrcfile
public void setSrcfile(java.io.File file)
Handles thesrcfile
attribute.- Parameters:
file
- the attribute value converted to a File.
-
setDestfile
public void setDestfile(java.io.File file)
Handles thedestfile
attribute.- Parameters:
file
- the attribute value converted to a File.
-
setDestdir
public void setDestdir(java.io.File dir)
Handles thedestdir
attribute.- Parameters:
dir
- the attribute value converted to a File.
-
setFailonerror
public void setFailonerror(boolean failOnError)
Handles thefailonerror
attribute.- Parameters:
failOnError
- the attribute value converted to a boolean.
-
setQuiet
public void setQuiet(boolean quiet)
Handles thequiet
attribute.- Parameters:
quiet
- the attribute value converted to a boolean.
-
setVerbose
public void setVerbose(boolean verbose)
Handles theverbose
attribute.- Parameters:
verbose
- the attribute value converted to a boolean.
-
setQuality
public void setQuality(float quality)
Handles thequality
attribute.- Parameters:
quality
- the attribute value converted to a float.
-
setComplexity
public void setComplexity(int complexity)
Handles thecomplexity
attribute.- Parameters:
complexity
- the attribute value converted to an integer.
-
setNframes
public void setNframes(int nframes)
Handles thenframes
attribute.- Parameters:
nframes
- the attribute value converted to an integer.
-
setVbr
public void setVbr(boolean vbr)
Handles thevbr
attribute.- Parameters:
vbr
- the attribute value converted to a boolean.
-
setVad
public void setVad(boolean vad)
Handles thevad
attribute.- Parameters:
vad
- the attribute value converted to a boolean.
-
setDtx
public void setDtx(boolean dtx)
Handles thedtx
attribute.- Parameters:
dtx
- the attribute value converted to a boolean.
-
setMode
public void setMode(java.lang.String mode)
Handles themode
attribute.- Parameters:
mode
- the attribute value converted to a String.
-
version
public void version()
Prints the version.
-
encode
public void encode(java.io.File srcPath, java.io.File destPath) throws java.io.IOException
Encodes a PCM file to Speex.- Parameters:
srcPath
-destPath
-- Throws:
java.io.IOException
-
readInt
protected static int readInt(byte[] data, int offset)
Converts Little Endian (Windows) bytes to an int (Java uses Big Endian).- Parameters:
data
- the data to read.offset
- the offset from which to start reading.- Returns:
- the integer value of the reassembled bytes.
-
readShort
protected static int readShort(byte[] data, int offset)
Converts Little Endian (Windows) bytes to an short (Java uses Big Endian).- Parameters:
data
- the data to read.offset
- the offset from which to start reading.- Returns:
- the integer value of the reassembled bytes.
-
-