Package org.xiph.speex.ant
Class JSpeexDecoderTask
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.xiph.speex.ant.JSpeexDecoderTask
- All Implemented Interfaces:
Cloneable
public class JSpeexDecoderTask
extends org.apache.tools.ant.Task
Ant
Task to Decode an audio file from Speex to PCM Wave.
Here is an usage example:
- Version:
- $Revision: 1.2 $
- Author:
- Marc Gimpel, Wimba S.A. (mgimpel@horizonwimba.com)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intIf input is raw, defines th number of channels (1=mono, 2=stereo).static final StringCopyright display Stringstatic final intPrint level for messages : Print debug informationprivate FileDirectory to place destination filesprivate FileDestination file of decoded audioprivate intDefines File format for output audio file (Raw or Wave).private booleanDefines whether or not the perceptual enhancement is used.static final intPrint level for messages : Print only errorsprivate booleanstatic final intFile format for input or output audio file: Oggstatic final intFile format for input or output audio file: Rawstatic final intFile format for input or output audio file: Wavestatic final intPrint level for messages : Print basic informationprivate intThe percentage of packets to lose in the packet loss simulation.private intIf input is raw, defines the decoder mode (0=NB, 1=WB and 2-UWB).private intIf input is raw, defines the number of frmaes per packet.private intPrint level for messagesprivate intIf input is raw, defines the quality setting used by the encoder.private booleanTells the task to suppress all but the most important outputprotected static RandomRandom number generator for packet loss simulation.private intIf input is raw, defines the sample rate of the audio.protected SpeexDecoderSpeex Decoderprivate FileSource file to decodeprivate final VectorList of source files to decodeprivate intDefines File format for input audio file (Raw, Ogg or Wave).private booleanprivate floatprivate booleanTells the task to output as much information as possiblestatic final StringVersion of the Speex Encoderstatic final intPrint level for messages : Print only warnings and errorsFields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapperFields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFileset(org.apache.tools.ant.types.FileSet set) Handles thefilesetchild element.private FilebuildDestFile(File srcFile) Builds and returns the destination file.voidDecodes a spx file to wave.voidexecute()The method executing the task.protected static intreadInt(byte[] data, int offset) Converts Little Endian (Windows) bytes to an int (Java uses Big Endian).protected static intreadShort(byte[] data, int offset) Converts Little Endian (Windows) bytes to an short (Java uses Big Endian).private booleanreadSpeexHeader(byte[] packet, int offset, int bytes) Reads the header packet.voidsetDestdir(File dir) Handles thedestdirattribute.voidsetDestfile(File file) Handles thedestfileattribute.voidsetEnhanced(boolean enhanced) Handles theenhancedattribute.voidsetFailonerror(boolean failOnError) Handles thefailonerrorattribute.voidsetQuiet(boolean quiet) Handles thequietattribute.voidsetSrcfile(File file) Handles thesrcfileattribute.private voidSetup some task variables.voidsetVerbose(boolean verbose) Handles theverboseattribute.voidversion()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, setTaskTypeMethods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
-
Field Details
-
VERSION
Version of the Speex Encoder- See Also:
-
COPYRIGHT
Copyright display String- See Also:
-
DEBUG
public static final int DEBUGPrint level for messages : Print debug information- See Also:
-
INFO
public static final int INFOPrint level for messages : Print basic information- See Also:
-
WARN
public static final int WARNPrint level for messages : Print only warnings and errors- See Also:
-
ERROR
public static final int ERRORPrint level for messages : Print only errors- See Also:
-
FILE_FORMAT_RAW
public static final int FILE_FORMAT_RAWFile format for input or output audio file: Raw- See Also:
-
FILE_FORMAT_OGG
public static final int FILE_FORMAT_OGGFile format for input or output audio file: Ogg- See Also:
-
FILE_FORMAT_WAVE
public static final int FILE_FORMAT_WAVEFile format for input or output audio file: Wave- See Also:
-
random
Random number generator for packet loss simulation. -
speexDecoder
Speex Decoder -
srcFile
Source file to decode -
srcFileset
List of source files to decode -
destFile
Destination file of decoded audio -
destDir
Directory to place destination files -
failOnError
private boolean failOnError -
printlevel
private int printlevelPrint level for messages -
quiet
private boolean quietTells the task to suppress all but the most important output -
verbose
private boolean verboseTells the task to output as much information as possible -
srcFormat
private int srcFormatDefines File format for input audio file (Raw, Ogg or Wave). -
destFormat
private int destFormatDefines File format for output audio file (Raw or Wave). -
enhanced
private boolean enhancedDefines whether or not the perceptual enhancement is used. -
mode
private int modeIf input is raw, defines the decoder mode (0=NB, 1=WB and 2-UWB). -
quality
private int qualityIf input is raw, defines the quality setting used by the encoder. -
nframes
private int nframesIf input is raw, defines the number of frmaes per packet. -
sampleRate
private int sampleRateIf input is raw, defines the sample rate of the audio. -
vbr_quality
private float vbr_quality -
vbr
private boolean vbr -
channels
private int channelsIf input is raw, defines th number of channels (1=mono, 2=stereo). -
loss
private int lossThe percentage of packets to lose in the packet loss simulation.
-
-
Constructor Details
-
JSpeexDecoderTask
public JSpeexDecoderTask()
-
-
Method Details
-
execute
public void execute() throws org.apache.tools.ant.BuildExceptionThe method executing the task.- Overrides:
executein classorg.apache.tools.ant.Task- Throws:
org.apache.tools.ant.BuildException
-
buildDestFile
Builds and returns the destination file.- Parameters:
srcFile-- Returns:
- the destination file.
-
setupTask
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 thefilesetchild element.- Parameters:
set-
-
setSrcfile
Handles thesrcfileattribute.- Parameters:
file- the attribute value converted to a File.
-
setDestfile
Handles thedestfileattribute.- Parameters:
file- the attribute value converted to a File.
-
setDestdir
Handles thedestdirattribute.- Parameters:
dir- the attribute value converted to a File.
-
setFailonerror
public void setFailonerror(boolean failOnError) Handles thefailonerrorattribute.- Parameters:
failOnError- the attribute value converted to a boolean.
-
setQuiet
public void setQuiet(boolean quiet) Handles thequietattribute.- Parameters:
quiet- the attribute value converted to a boolean.
-
setVerbose
public void setVerbose(boolean verbose) Handles theverboseattribute.- Parameters:
verbose- the attribute value converted to a boolean.
-
setEnhanced
public void setEnhanced(boolean enhanced) Handles theenhancedattribute.- Parameters:
enhanced- the attribute value converted to a boolean.
-
version
public void version()Prints the version. -
decode
Decodes a spx file to wave.- Parameters:
srcPath- the Speex encoded source file.destPath- the destination file.- Throws:
IOException
-
readSpeexHeader
private boolean readSpeexHeader(byte[] packet, int offset, int bytes) Reads the header packet.0 - 7: speex_string: "Speex " 8 - 27: speex_version: "speex-1.0" 28 - 31: speex_version_id: 1 32 - 35: header_size: 80 36 - 39: rate 40 - 43: mode: 0=narrowband, 1=wb, 2=uwb 44 - 47: mode_bitstream_version: 4 48 - 51: nb_channels 52 - 55: bitrate: -1 56 - 59: frame_size: 160 60 - 63: vbr 64 - 67: frames_per_packet 68 - 71: extra_headers: 0 72 - 75: reserved1 76 - 79: reserved2
- Parameters:
packet-offset-bytes-- Returns:
- true if the Speex header was successfully parsed, false otherwise.
-
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.
-