org.xiph.speex.ant

Class JSpeexEncoderTask


public class JSpeexEncoderTask
extends Task

Ant Task 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

static String
COPYRIGHT
Copyright display String
static int
DEBUG
Print level for messages : Print debug information
static int
ERROR
Print level for messages : Print only errors
static int
FILE_FORMAT_OGG
File format for input or output audio file: Ogg
static int
FILE_FORMAT_RAW
File format for input or output audio file: Raw
static int
FILE_FORMAT_WAVE
File format for input or output audio file: Wave
static int
INFO
Print level for messages : Print basic information
static String
VERSION
Version of the Speex Encoder
static int
WARN
Print level for messages : Print only warnings and errors
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.
private File
destDir
Directory to place destination files
private File
destFile
Destination file of decoded audio
protected int
destFormat
Defines File format for output audio file (Raw or Wave).
protected boolean
dtx
Defines whether or not to use DTX (Discontinuous Transmission).
private boolean
failOnError
protected 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 messages
protected 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 output
protected int
sampleRate
Defines the sampling rate of the audio input.
private File
srcFile
Source file to decode
private Vector
srcFileset
List of source files to decode
protected 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 possible

Method Summary

void
addFileset(FileSet set)
Handles the fileset child element.
private File
buildDestFile(File srcFile)
Builds and returns the destination file.
void
encode(File srcPath, 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 the complexity attribute.
void
setDestdir(File dir)
Handles the destdir attribute.
void
setDestfile(File file)
Handles the destfile attribute.
void
setDtx(boolean dtx)
Handles the dtx attribute.
void
setFailonerror(boolean failOnError)
Handles the failonerror attribute.
void
setMode(String mode)
Handles the mode attribute.
void
setNframes(int nframes)
Handles the nframes attribute.
void
setQuality(float quality)
Handles the quality attribute.
void
setQuiet(boolean quiet)
Handles the quiet attribute.
void
setSrcfile(File file)
Handles the srcfile attribute.
void
setVad(boolean vad)
Handles the vad attribute.
void
setVbr(boolean vbr)
Handles the vbr attribute.
void
setVerbose(boolean verbose)
Handles the verbose attribute.
private void
setupTask(File srcPath, File destPath)
Setup some task variables.
void
version()
Prints the version.

Field Details

COPYRIGHT

public static final String COPYRIGHT
Copyright display String

DEBUG

public static final int DEBUG
Print level for messages : Print debug information
Field Value:
0

ERROR

public static final int ERROR
Print level for messages : Print only errors
Field Value:
3

FILE_FORMAT_OGG

public static final int FILE_FORMAT_OGG
File format for input or output audio file: Ogg
Field Value:
1

FILE_FORMAT_RAW

public static final int FILE_FORMAT_RAW
File format for input or output audio file: Raw
Field Value:
0

FILE_FORMAT_WAVE

public static final int FILE_FORMAT_WAVE
File format for input or output audio file: Wave
Field Value:
2

INFO

public static final int INFO
Print level for messages : Print basic information
Field Value:
1

VERSION

public static final String VERSION
Version of the Speex Encoder

WARN

public static final int WARN
Print level for messages : Print only warnings and errors
Field Value:
2

bitrate

protected int bitrate
Defines the desired bitrate for the encoded audio.

channels

protected int channels
Defines the number of channels of the audio input (1=mono, 2=stereo).

complexity

protected int complexity
Defines the encoders algorithmic complexity.

destDir

private File destDir
Directory to place destination files

destFile

private File destFile
Destination file of decoded audio

destFormat

protected int destFormat
Defines File format for output audio file (Raw or Wave).

dtx

protected boolean dtx
Defines whether or not to use DTX (Discontinuous Transmission).

failOnError

private boolean failOnError

mode

protected int mode
Defines the encoder mode (0=NB, 1=WB and 2-UWB).

modeset

protected boolean modeset
Whether the mode is manualy set or automatically determined.

nframes

protected int nframes
Defines the number of frames per speex packet.

printlevel

private int printlevel
Print level for messages

quality

protected int quality
Defines the encoder quality setting (integer from 0 to 10).

quiet

private boolean quiet
Tells the task to suppress all but the most important output

sampleRate

protected int sampleRate
Defines the sampling rate of the audio input.

srcFile

private File srcFile
Source file to decode

srcFileset

private final Vector srcFileset
List of source files to decode

srcFormat

protected int srcFormat
Defines File format for input audio file (Raw, Ogg or Wave).

vad

protected boolean vad
Defines whether or not to use VAD (Voice Activity Detection).

vbr

protected boolean vbr
Defines whether or not to use VBR (Variable Bit Rate).

vbr_quality

protected float vbr_quality
Defines the encoder VBR quality setting (float from 0 to 10).

verbose

private boolean verbose
Tells the task to output as much information as possible

Method Details

addFileset

public void addFileset(FileSet set)
Handles the fileset child element.
Parameters:
set -

buildDestFile

private File buildDestFile(File srcFile)
Builds and returns the destination file.
Parameters:
srcFile -
Returns:
the destination file.

encode

public void encode(File srcPath,
                   File destPath)
            throws IOException
Encodes a PCM file to Speex.
Parameters:
srcPath -
destPath -

execute

public void execute()
            throws BuildException
The method executing the task.

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.

setComplexity

public void setComplexity(int complexity)
Handles the complexity attribute.
Parameters:
complexity - the attribute value converted to an integer.

setDestdir

public void setDestdir(File dir)
Handles the destdir attribute.
Parameters:
dir - the attribute value converted to a File.

setDestfile

public void setDestfile(File file)
Handles the destfile attribute.
Parameters:
file - the attribute value converted to a File.

setDtx

public void setDtx(boolean dtx)
Handles the dtx attribute.
Parameters:
dtx - the attribute value converted to a boolean.

setFailonerror

public void setFailonerror(boolean failOnError)
Handles the failonerror attribute.
Parameters:
failOnError - the attribute value converted to a boolean.

setMode

public void setMode(String mode)
Handles the mode attribute.
Parameters:
mode - the attribute value converted to a String.

setNframes

public void setNframes(int nframes)
Handles the nframes attribute.
Parameters:
nframes - the attribute value converted to an integer.

setQuality

public void setQuality(float quality)
Handles the quality attribute.
Parameters:
quality - the attribute value converted to a float.

setQuiet

public void setQuiet(boolean quiet)
Handles the quiet attribute.
Parameters:
quiet - the attribute value converted to a boolean.

setSrcfile

public void setSrcfile(File file)
Handles the srcfile attribute.
Parameters:
file - the attribute value converted to a File.

setVad

public void setVad(boolean vad)
Handles the vad attribute.
Parameters:
vad - the attribute value converted to a boolean.

setVbr

public void setVbr(boolean vbr)
Handles the vbr attribute.
Parameters:
vbr - the attribute value converted to a boolean.

setVerbose

public void setVerbose(boolean verbose)
Handles the verbose attribute.
Parameters:
verbose - the attribute value converted to a boolean.

setupTask

private void setupTask(File srcPath,
                       File destPath)
Setup some task variables.
Parameters:
srcPath - the Speex encoded source file.
destPath - the destination file.

version

public void version()
Prints the version.

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