org.xiph.speex.ant

Class JSpeexDecoderTask


public class JSpeexDecoderTask
extends 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

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
private int
channels
If input is raw, defines th number of channels (1=mono, 2=stereo).
private File
destDir
Directory to place destination files
private File
destFile
Destination file of decoded audio
private int
destFormat
Defines File format for output audio file (Raw or Wave).
private boolean
enhanced
Defines whether or not the perceptual enhancement is used.
private boolean
failOnError
private int
loss
The percentage of packets to lose in the packet loss simulation.
private int
mode
If input is raw, defines the decoder mode (0=NB, 1=WB and 2-UWB).
private int
nframes
If input is raw, defines the number of frmaes per packet.
private int
printlevel
Print level for messages
private int
quality
If input is raw, defines the quality setting used by the encoder.
private boolean
quiet
Tells the task to suppress all but the most important output
protected static Random
random
Random number generator for packet loss simulation.
private int
sampleRate
If input is raw, defines the sample rate of the audio.
protected SpeexDecoder
speexDecoder
Speex Decoder
private File
srcFile
Source file to decode
private Vector
srcFileset
List of source files to decode
private int
srcFormat
Defines File format for input audio file (Raw, Ogg or Wave).
private boolean
vbr
private float
vbr_quality
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
decode(File srcPath, File destPath)
Decodes a spx file to wave.
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).
private boolean
readSpeexHeader(byte[] packet, int offset, int bytes)
Reads the header packet.
void
setDestdir(File dir)
Handles the destdir attribute.
void
setDestfile(File file)
Handles the destfile attribute.
void
setEnhanced(boolean enhanced)
Handles the enhanced attribute.
void
setFailonerror(boolean failOnError)
Handles the failonerror attribute.
void
setQuiet(boolean quiet)
Handles the quiet attribute.
void
setSrcfile(File file)
Handles the srcfile 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

channels

private int channels
If input is raw, defines th number of channels (1=mono, 2=stereo).

destDir

private File destDir
Directory to place destination files

destFile

private File destFile
Destination file of decoded audio

destFormat

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

enhanced

private boolean enhanced
Defines whether or not the perceptual enhancement is used.

failOnError

private boolean failOnError

loss

private int loss
The percentage of packets to lose in the packet loss simulation.

mode

private int mode
If input is raw, defines the decoder mode (0=NB, 1=WB and 2-UWB).

nframes

private int nframes
If input is raw, defines the number of frmaes per packet.

printlevel

private int printlevel
Print level for messages

quality

private int quality
If input is raw, defines the quality setting used by the encoder.

quiet

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

random

protected static Random random
Random number generator for packet loss simulation.

sampleRate

private int sampleRate
If input is raw, defines the sample rate of the audio.

speexDecoder

protected SpeexDecoder speexDecoder
Speex Decoder

srcFile

private File srcFile
Source file to decode

srcFileset

private final Vector srcFileset
List of source files to decode

srcFormat

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

vbr

private boolean vbr

vbr_quality

private float vbr_quality

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.

decode

public void decode(File srcPath,
                   File destPath)
            throws IOException
Decodes a spx file to wave.
Parameters:
srcPath - the Speex encoded source file.
destPath - the destination file.

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.

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.

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.

setEnhanced

public void setEnhanced(boolean enhanced)
Handles the enhanced attribute.
Parameters:
enhanced - 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.

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.

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.