Home Units Hierarchy Routines All identifiers

Unit unaSpeexAPI

DescriptionUsesClasses, Interfaces, Objects and RecordsFunctions and ProceduresTypesConstantsVariables

Description

libspeex.dll wrapper.

Version 2.5.2010.01 Initial release

Uses

Overview

Classes, Interfaces, Objects and Records

Name Description
packed record SpeexBits  
record SpeexMode  
record tSpeexDSPLibrary_proc  
record tSpeexLibrary_proc  
Class unaSpeexCoder Base class fro Speex encoder and decoder.
Class unaSpeexDecoder Speex Decoder
Class unaSpeexDSP Speex DSP
Class unaSpeexEncoder Speex Encoder.
Class unaSpeexLib Loads Speex DLL into process memory.

Functions and Procedures

function speex_loadDLL(var speexProc: tSpeexLibrary_proc; const pathAndName: wString = c_speexDLL): int;
function speex_unloadDLL(var speexProc: tSpeexLibrary_proc): int;
function speex_loadDSPDLL(var speexDSPProc: tSpeexDSPLibrary_proc; const pathAndName: wString = c_speexDSPDLL): int;
function speex_unloadDSPDLL(var speexDSPProc: tSpeexDSPLibrary_proc): int;

Types

pSpeexBits = ˆSpeexBits;
speex_bits_init = procedure(bits: pSpeexBits); cdecl;
speex_bits_init_buffer = procedure(bits: pSpeexBits; buff: pointer; buf_size: int); cdecl;
speex_bits_set_bit_buffer = procedure(bits: SpeexBits; buff: pointer; buf_size: int); cdecl;
speex_bits_destroy = procedure(bits: pSpeexBits); cdecl;
speex_bits_reset = procedure(bits: pSpeexBits); cdecl;
speex_bits_rewind = procedure(bits: pSpeexBits); cdecl;
speex_bits_read_from = procedure(bits: pSpeexBits; buff: pointer; buf_size: int); cdecl;
speex_bits_read_whole_bytes = procedure(bits: pSpeexBits; buff: pointer; buf_size: int); cdecl;
speex_bits_write = function(bits: pSpeexBits; buff: pointer; max_size: int): int; cdecl;
speex_bits_write_whole_bytes = function(bits: pSpeexBits; buff: pointer; max_size: int): int; cdecl;
speex_bits_pack = procedure(bits: pSpeexBits; data: int; nbBits: int); cdecl;
speex_bits_unpack_signed = function(bits: pSpeexBits; nbBits: int): int; cdecl;
speex_bits_unpack_unsigned = function(bits: pSpeexBits; nbBits: int): unsigned; cdecl;
speex_bits_nbytes = function(bits: pSpeexBits): int; cdecl;
speex_bits_peek_unsigned = function(bits: pSpeexBits; nbBits: int): unsigned; cdecl;
speex_bits_peek = function(bits: pSpeexBits): int; cdecl;
speex_bits_advance = procedure(bits: pSpeexBits; n: int); cdecl;
speex_bits_remaining = function(bits: pSpeexBits): int; cdecl;
speex_bits_insert_terminator = procedure(bits: pSpeexBits); cdecl;
spx_int16_t = int16;
pspx_int16_t = ˆspx_int16_t;
spx_uint32_t = uint32;
spx_int32_t = int32;
pSpeexMode = ˆSpeexMode;
speex_encoder_init = function(mode: pSpeexMode): pointer; cdecl;
speex_encoder_destroy = procedure(state: pointer); cdecl;
speex_encode = function(state: pointer; _in: pFloat; bits: pSpeexBits): int; cdecl;
speex_encode_int = function(state: pointer; _in: pspx_int16_t; bits: pSpeexBits): int; cdecl;
speex_encoder_ctl = function(state: pointer; request: int; ptr: pointer): int; cdecl;
speex_decoder_init = function(mode: pSpeexMode): pointer; cdecl;
speex_decoder_destroy = procedure(state: pointer); cdecl;
speex_decode = function(state: pointer; bits: pSpeexBits; _out: pFloat): int; cdecl;
speex_decode_int = function(state: pointer; bits: pSpeexBits; _out: pspx_int16_t): int; cdecl;
speex_decoder_ctl = function(state: pointer; request: int; ptr: pointer): int; cdecl;
speex_mode_query = function(mode: pSpeexMode; request: int; ptr: pointer): int; cdecl;
speex_lib_ctl = function(request: int; ptr: pointer): int; cdecl;
speex_lib_get_mode = function(mode: int): pSpeexMode; cdecl;
SpeexPreprocessState = pointer;
speex_preprocess_state_init = function (frame_size: int; sampling_rate: int): SpeexPreprocessState; cdecl;
speex_preprocess_state_destroy = procedure (st: SpeexPreprocessState); cdecl;
speex_preprocess_run = function (st: SpeexPreprocessState; x: pspx_int16_t): int; cdecl;
speex_preprocess_estimate_update = procedure(st: SpeexPreprocessState; x: pspx_int16_t); cdecl;
speex_preprocess_ctl = function(st: SpeexPreprocessState; request: int; ptr: pointer): int; cdecl;
SpeexEchoState = pointer;
speex_echo_state_init = function(frame_size: int; filter_length: int): SpeexEchoState; cdecl;
speex_echo_state_destroy = procedure(st: SpeexEchoState); cdecl;
speex_echo_cancellation = procedure(st: SpeexEchoState; rec: pspx_int16_t; play: pspx_int16_t; out_: pspx_int16_t); cdecl;
speex_echo_capture = procedure(st: SpeexEchoState; rec: pspx_int16_t; out_: pspx_int16_t); cdecl;
speex_echo_playback = procedure(st: SpeexEchoState; play: pspx_int16_t); cdecl;
speex_echo_state_reset = procedure(st: SpeexEchoState); cdecl;
speex_echo_ctl = function(st: SpeexEchoState; request: int; ptr: pointer): int; cdecl;
SpeexResamplerState = pointer;
speex_resampler_init = function(nb_channels: spx_uint32_t; in_rate: spx_uint32_t; out_rate: spx_uint32_t; quality: int; var err: int): SpeexResamplerState; cdecl;
speex_resampler_init_frac = function(nb_channels: spx_uint32_t; ratio_num: spx_uint32_t; ratio_den: spx_uint32_t; in_rate: spx_uint32_t; out_rate: spx_uint32_t; quality: int; var err: int): SpeexResamplerState; cdecl;
speex_resampler_destroy = procedure(st: SpeexResamplerState); cdecl;
speex_resampler_process_float = function(st: SpeexResamplerState; channel_index: spx_uint32_t; in_: pFloat; var in_len: spx_uint32_t; out_: pFloat; var out_len: spx_uint32_t): int; cdecl;
speex_resampler_process_int = function(st: SpeexResamplerState; channel_index: spx_uint32_t; in_: pspx_int16_t; var in_len: spx_uint32_t; out_: pspx_int16_t; var out_len: spx_uint32_t): int; cdecl;
speex_resampler_set_quality = function(st: SpeexResamplerState; quality: int): int; cdecl;
speex_resampler_get_quality = procedure(st: SpeexResamplerState; var quality: int); cdecl;
speex_resampler_skip_zeros = function(st: SpeexResamplerState): int; cdecl;
speex_resampler_reset_mem = function(st: SpeexResamplerState): int; cdecl;
speex_resampler_strerror = function(err: int): paChar; cdecl;
pSpeexLibrary_proc = ˆtSpeexLibrary_proc;
pSpeexDSPLibrary_proc = ˆtSpeexDSPLibrary_proc;

Constants

c_speexDLL = 'libspeex.dll';
c_speexDSPDLL = 'libspeexdsp.dll';
RESAMPLER_ERR_ALLOC_FAILED = 1;
RESAMPLER_ERR_BAD_STATE = 2;
RESAMPLER_ERR_INVALID_ARG = 3;
RESAMPLER_ERR_MAX_ERROR = RESAMPLER_ERR_PTR_OVERLAP;
RESAMPLER_ERR_PTR_OVERLAP = 4;
RESAMPLER_ERR_SUCCESS = 0;
SPEEX_ECHO_GET_FRAME_SIZE = 3;
SPEEX_ECHO_GET_SAMPLING_RATE = 25;
SPEEX_ECHO_SET_SAMPLING_RATE = 24;
SPEEX_GET_ABR = 33;
SPEEX_GET_ACTIVITY = 47;
SPEEX_GET_BITRATE = 19;
SPEEX_GET_COMPLEXITY = 17;
SPEEX_GET_DTX = 35;
SPEEX_GET_ENH = 1;
SPEEX_GET_FRAME_SIZE = 3;
SPEEX_GET_HIGHPASS = 45;
SPEEX_GET_HIGH_MODE = 11;
SPEEX_GET_LOOKAHEAD = 39;
SPEEX_GET_LOW_MODE = 9;
SPEEX_GET_MODE = 7;
SPEEX_GET_PF = 1;
SPEEX_GET_PLC_TUNING = 41;
SPEEX_GET_RELATIVE_QUALITY = 29;
SPEEX_GET_SAMPLING_RATE = 25;
SPEEX_GET_SUBMODE_ENCODING = 37;
SPEEX_GET_VAD = 31;
SPEEX_GET_VBR = 13;
SPEEX_GET_VBR_MAX_BITRATE = 43;
SPEEX_GET_VBR_QUALITY = 15;
SPEEX_LIB_GET_EXTRA_VERSION = 7;
SPEEX_LIB_GET_MAJOR_VERSION = 1;
SPEEX_LIB_GET_MICRO_VERSION = 5;
SPEEX_LIB_GET_MINOR_VERSION = 3;
SPEEX_LIB_GET_VERSION_STRING = 9;
SPEEX_MODEID_NB = 0;
SPEEX_MODEID_UWB = 2;
SPEEX_MODEID_WB = 1;
SPEEX_MODE_FRAME_SIZE = 0;
SPEEX_NB_MODES = 3;
SPEEX_PREPROCESS_GET_AGC = 3;
SPEEX_PREPROCESS_GET_AGC_DECREMENT = 29;
SPEEX_PREPROCESS_GET_AGC_INCREMENT = 27;
SPEEX_PREPROCESS_GET_AGC_LEVEL = 7;
SPEEX_PREPROCESS_GET_AGC_LOUDNESS = 33;
SPEEX_PREPROCESS_GET_AGC_MAX_GAIN = 31;
SPEEX_PREPROCESS_GET_DENOISE = 1;
SPEEX_PREPROCESS_GET_DEREVERB = 9;
SPEEX_PREPROCESS_GET_DEREVERB_DECAY = 13;
SPEEX_PREPROCESS_GET_DEREVERB_LEVEL = 11;
SPEEX_PREPROCESS_GET_ECHO_STATE = 25;
SPEEX_PREPROCESS_GET_ECHO_SUPPRESS = 21;
SPEEX_PREPROCESS_GET_ECHO_SUPPRESS_ACTIVE = 23;
SPEEX_PREPROCESS_GET_NOISE_SUPPRESS = 19;
SPEEX_PREPROCESS_GET_PROB_CONTINUE = 17;
SPEEX_PREPROCESS_GET_PROB_START = 15;
SPEEX_PREPROCESS_GET_VAD = 5;
SPEEX_PREPROCESS_SET_AGC = 2;
SPEEX_PREPROCESS_SET_AGC_DECREMENT = 28;
SPEEX_PREPROCESS_SET_AGC_INCREMENT = 26;
SPEEX_PREPROCESS_SET_AGC_LEVEL = 6;
SPEEX_PREPROCESS_SET_AGC_MAX_GAIN = 30;
SPEEX_PREPROCESS_SET_DENOISE = 0;
SPEEX_PREPROCESS_SET_DEREVERB = 8;
SPEEX_PREPROCESS_SET_DEREVERB_DECAY = 12;
SPEEX_PREPROCESS_SET_DEREVERB_LEVEL = 10;
SPEEX_PREPROCESS_SET_ECHO_STATE = 24;
SPEEX_PREPROCESS_SET_ECHO_SUPPRESS = 20;
SPEEX_PREPROCESS_SET_ECHO_SUPPRESS_ACTIVE = 22;
SPEEX_PREPROCESS_SET_NOISE_SUPPRESS = 18;
SPEEX_PREPROCESS_SET_PROB_CONTINUE = 16;
SPEEX_PREPROCESS_SET_PROB_START = 14;
SPEEX_PREPROCESS_SET_VAD = 4;
SPEEX_RESAMPLER_QUALITY_DEFAULT = 4;
SPEEX_RESAMPLER_QUALITY_DESKTOP = 5;
SPEEX_RESAMPLER_QUALITY_MAX = 10;
SPEEX_RESAMPLER_QUALITY_MIN = 0;
SPEEX_RESAMPLER_QUALITY_VOIP = 3;
SPEEX_RESET_STATE = 26;
SPEEX_SET_ABR = 32;
SPEEX_SET_BITRATE = 18;
SPEEX_SET_COMPLEXITY = 16;
SPEEX_SET_DTX = 34;
SPEEX_SET_ENH = 0;
SPEEX_SET_HANDLER = 20;
SPEEX_SET_HIGHPASS = 44;
SPEEX_SET_HIGH_MODE = 10;
SPEEX_SET_LOW_MODE = 8;
SPEEX_SET_MODE = 6;
SPEEX_SET_PF = 0;
SPEEX_SET_PLC_TUNING = 40;
SPEEX_SET_QUALITY = 4;
SPEEX_SET_SAMPLING_RATE = 24;
SPEEX_SET_SUBMODE_ENCODING = 36;
SPEEX_SET_USER_HANDLER = 22;
SPEEX_SET_VAD = 30;
SPEEX_SET_VBR = 12;
SPEEX_SET_VBR_MAX_BITRATE = 42;
SPEEX_SET_VBR_QUALITY = 14;
SPEEX_SUBMODE_BITS_PER_FRAME = 1;

Variables

c_opt4RTP_numbytes: int = 1100;
c_opt4RTP_numframes: int = 5;

Description

Functions and Procedures

function speex_loadDLL(var speexProc: tSpeexLibrary_proc; const pathAndName: wString = c_speexDLL): int;

Loads the Speex DLL.

Returns

0 if successuf, -1 is some API is missing or Windows specific error code.

function speex_unloadDLL(var speexProc: tSpeexLibrary_proc): int;

Unloads the Speex DLL.

Returns

0 if successuf, or Windows specific error code.

function speex_loadDSPDLL(var speexDSPProc: tSpeexDSPLibrary_proc; const pathAndName: wString = c_speexDSPDLL): int;

Loads the Speex DSP DLL.

Returns

0 if successuf, -1 is some API is missing or Windows specific error code.

function speex_unloadDSPDLL(var speexDSPProc: tSpeexDSPLibrary_proc): int;

Unloads the Speex DSP DLL.

Returns

0 if successuf, or Windows specific error code.

Types

pSpeexBits = ˆSpeexBits;

* Bit-packing data structure representing (part of) a bit-stream. */

speex_bits_init = procedure(bits: pSpeexBits); cdecl;

*< Reserved for future use */ * Initializes and allocates resources for a SpeexBits struct */

speex_bits_init_buffer = procedure(bits: pSpeexBits; buff: pointer; buf_size: int); cdecl;

* Initializes SpeexBits struct using a pre-allocated buffer*/

speex_bits_set_bit_buffer = procedure(bits: SpeexBits; buff: pointer; buf_size: int); cdecl;

* Sets the bits in a SpeexBits struct to use data from an existing buffer (for decoding without copying data) */

speex_bits_destroy = procedure(bits: pSpeexBits); cdecl;

* Frees all resources associated to a SpeexBits struct. Right now this does nothing since no resources are allocated, but this could change in the future.*/

speex_bits_reset = procedure(bits: pSpeexBits); cdecl;

* Resets bits to initial value (just after initialization, erasing content)*/

speex_bits_rewind = procedure(bits: pSpeexBits); cdecl;

* Rewind the bit-stream to the beginning (ready for read) without erasing the content */

speex_bits_read_from = procedure(bits: pSpeexBits; buff: pointer; buf_size: int); cdecl;

* Initializes the bit-stream from the data in an area of memory */

speex_bits_read_whole_bytes = procedure(bits: pSpeexBits; buff: pointer; buf_size: int); cdecl;

Append bytes to the bit-stream * * * *

Parameters
bits
Bit-stream to operate on
bytes
pointer to the bytes what will be appended
len
Number of bytes of append
speex_bits_write = function(bits: pSpeexBits; buff: pointer; max_size: int): int; cdecl;

Write the content of a bit-stream to an area of memory * * * * *

Parameters
bits
Bit-stream to operate on
bytes
Memory location where to write the bits
max_len
Maximum number of bytes to write (i.e. size of the "bytes" buffer)
Returns

Number of bytes written to the "bytes" buffer

speex_bits_write_whole_bytes = function(bits: pSpeexBits; buff: pointer; max_size: int): int; cdecl;

* Like speex_bits_write, but writes only the complete bytes in the stream. Also removes the written bytes from the stream */

speex_bits_pack = procedure(bits: pSpeexBits; data: int; nbBits: int); cdecl;

Append bits to the bit-stream * * *

Parameters
bits
Bit-stream to operate on
data
Value to append as integer
nbBits
number of bits to consider in "data"
speex_bits_unpack_signed = function(bits: pSpeexBits; nbBits: int): int; cdecl;

Interpret the next bits in the bit-stream as a signed integer * * * *

Parameters
bits
Bit-stream to operate on
nbBits
Number of bits to interpret
Returns

A signed integer represented by the bits read

speex_bits_unpack_unsigned = function(bits: pSpeexBits; nbBits: int): unsigned; cdecl;

Interpret the next bits in the bit-stream as an unsigned integer * * * *

Parameters
bits
Bit-stream to operate on
nbBits
Number of bits to interpret
Returns

An unsigned integer represented by the bits read

speex_bits_nbytes = function(bits: pSpeexBits): int; cdecl;

Returns the number of bytes in the bit-stream, including the last one even if it is not "full" * * *

Parameters
bits
Bit-stream to operate on
Returns

Number of bytes in the stream

speex_bits_peek_unsigned = function(bits: pSpeexBits; nbBits: int): unsigned; cdecl;

Same as speex_bits_unpack_unsigned, but without modifying the cursor position * * * *

Parameters
bits
Bit-stream to operate on
nbBits
Number of bits to look for
Returns

Value of the bits peeked, interpreted as unsigned

speex_bits_peek = function(bits: pSpeexBits): int; cdecl;

Get the value of the next bit in the stream, without modifying the * "cursor" position * * *

Parameters
bits
Bit-stream to operate on
Returns

Value of the bit peeked (one bit only)

speex_bits_advance = procedure(bits: pSpeexBits; n: int); cdecl;

Advances the position of the "bit cursor" in the stream * * *

Parameters
bits
Bit-stream to operate on
n
Number of bits to advance
speex_bits_remaining = function(bits: pSpeexBits): int; cdecl;

Returns the number of bits remaining to be read in a stream * * *

Parameters
bits
Bit-stream to operate on
Returns

Number of bits that can still be read from the stream

speex_bits_insert_terminator = procedure(bits: pSpeexBits); cdecl;

Insert a terminator so that the data can be sent as a packet while auto-detecting * the number of frames in each packet * *

Parameters
bits
Bit-stream to operate on
spx_int16_t = int16;

#ifndef _SPEEX_TYPES_H #define _SPEEX_TYPES_H #if defined(_WIN32)

pspx_int16_t = ˆspx_int16_t;
 
spx_uint32_t = uint32;
 
spx_int32_t = int32;
 
pSpeexMode = ˆSpeexMode;
 
speex_encoder_init = function(mode: pSpeexMode): pointer; cdecl;

* Returns a handle to a newly created Speex encoder state structure. For now, * the "mode" argument can be &nb_mode or &wb_mode . In the future, more modes * may be added. Note that for now if you have more than one channels to * encode, you need one state per channel. * * *

Parameters
mode
The mode to use (either speex_nb_mode or speex_wb.mode)
Returns

A newly created encoder state or NULL if state allocation fails

speex_encoder_destroy = procedure(state: pointer); cdecl;

Frees all resources associated to an existing Speex encoder state. *

Parameters
state
Encoder state to be destroyed
speex_encode = function(state: pointer; _in: pFloat; bits: pSpeexBits): int; cdecl;

Uses an existing encoder state to encode one frame of speech pointed to by "in". The encoded bit-stream is saved in "bits". overwritten by the encoder and should be considered uninitialised after the call.

Parameters
state
Encoder state
in
Frame that will be encoded with a +-2ˆ15 range. This data MAY be
bits
Bit-stream where the data will be written
Returns

0 if frame needs not be transmitted (DTX only), 1 otherwise

speex_encode_int = function(state: pointer; _in: pspx_int16_t; bits: pSpeexBits): int; cdecl;

Uses an existing encoder state to encode one frame of speech pointed to by "in". The encoded bit-stream is saved in "bits".

Parameters
state
Encoder state
in
Frame that will be encoded with a +-2ˆ15 range
bits
Bit-stream where the data will be written
Returns

0 if frame needs not be transmitted (DTX only), 1 otherwise

speex_encoder_ctl = function(state: pointer; request: int; ptr: pointer): int; cdecl;

Used like the ioctl function to control the encoder parameters * * * * *

Parameters
state
Encoder state
request
ioctl-type request (one of the SPEEX_* macros)
ptr
Data exchanged to-from function
Returns

0 if no error, -1 if request in unknown, -2 for invalid parameter

speex_decoder_init = function(mode: pSpeexMode): pointer; cdecl;

Returns a handle to a newly created decoder state structure. For now, * the mode argument can be &nb_mode or &wb_mode . In the future, more modes * may be added. Note that for now if you have more than one channels to * decode, you need one state per channel. * * *

Parameters
mode
Speex mode (one of speex_nb_mode or speex_wb_mode)
Returns

A newly created decoder state or NULL if state allocation fails

speex_decoder_destroy = procedure(state: pointer); cdecl;

Frees all resources associated to an existing decoder state. * *

Parameters
state
State to be destroyed
speex_decode = function(state: pointer; bits: pSpeexBits; _out: pFloat): int; cdecl;

Uses an existing decoder state to decode one frame of speech from * bit-stream bits. The output speech is saved written to out. * * * * *

Parameters
state
Decoder state
bits
Bit-stream from which to decode the frame (NULL if the packet was lost)
out
Where to write the decoded frame
Returns

return status (0 for no error, -1 for end of stream, -2 corrupt stream)

speex_decode_int = function(state: pointer; bits: pSpeexBits; _out: pspx_int16_t): int; cdecl;

Uses an existing decoder state to decode one frame of speech from * bit-stream bits. The output speech is saved written to out. * * * * *

Parameters
state
Decoder state
bits
Bit-stream from which to decode the frame (NULL if the packet was lost)
out
Where to write the decoded frame
Returns

return status (0 for no error, -1 for end of stream, -2 corrupt stream)

speex_decoder_ctl = function(state: pointer; request: int; ptr: pointer): int; cdecl;

Used like the ioctl function to control the encoder parameters * * * * *

Parameters
state
Decoder state
request
ioctl-type request (one of the SPEEX_* macros)
ptr
Data exchanged to-from function
Returns

0 if no error, -1 if request in unknown, -2 for invalid parameter

speex_mode_query = function(mode: pSpeexMode; request: int; ptr: pointer): int; cdecl;

Query function for mode information * * * * *

Parameters
mode
Speex mode
request
ioctl-type request (one of the SPEEX_* macros)
ptr
Data exchanged to-from function
Returns

0 if no error, -1 if request in unknown, -2 for invalid parameter

speex_lib_ctl = function(request: int; ptr: pointer): int; cdecl;

Functions for controlling the behavior of libspeex * * *

Parameters
request
ioctl-type request (one of the SPEEX_LIB_* macros)
ptr
Data exchanged to-from function
Returns

0 if no error, -1 if request in unknown, -2 for invalid parameter

speex_lib_get_mode = function(mode: int): pSpeexMode; cdecl;

* Default narrowband mode */ extern const SpeexMode speex_nb_mode; * Default wideband mode */ extern const SpeexMode speex_wb_mode; * Default "ultra-wideband" mode */ extern const SpeexMode speex_uwb_mode; * List of all modes available */ extern const SpeexMode * const speex_mode_list[SPEEX_NB_MODES]; * Obtain one of the modes available */

SpeexPreprocessState = pointer;

#include "speex/speex_types.h" * State of the preprocessor (one per channel). Should never be accessed directly. */ SpeexPreprocessState_ = pointer; * State of the preprocessor (one per channel). Should never be accessed directly. */

speex_preprocess_state_init = function (frame_size: int; sampling_rate: int): SpeexPreprocessState; cdecl;

Creates a new preprocessing state. You MUST create one state per channel processed. * * the same value as that used for the echo canceller for residual echo cancellation to work. * *

Parameters
frame_size
Number of samples to process at one time (should correspond to 10-20 ms). Must be
sampling_rate
Sampling rate used for the input.
Returns

Newly created preprocessor state

speex_preprocess_state_destroy = procedure (st: SpeexPreprocessState); cdecl;

Destroys a preprocessor state *

Parameters
st
Preprocessor state to destroy
speex_preprocess_run = function (st: SpeexPreprocessState; x: pspx_int16_t): int; cdecl;

Preprocess a frame * * *

Parameters
st
Preprocessor state
x
Audio sample vector (in and out). Must be same size as specified in speex_preprocess_state_init().
Returns

Bool value for voice activity (1 for speech, 0 for noise/silence), ONLY if VAD turned on.

speex_preprocess_estimate_update = procedure(st: SpeexPreprocessState; x: pspx_int16_t); cdecl;

Update preprocessor state, but do not compute the output * *

Parameters
st
Preprocessor state
x
Audio sample vector (in only). Must be same size as specified in speex_preprocess_state_init().
speex_preprocess_ctl = function(st: SpeexPreprocessState; request: int; ptr: pointer): int; cdecl;

Used like the ioctl function to control the preprocessor parameters * * * *

Parameters
st
Preprocessor state
request
ioctl-type request (one of the SPEEX_PREPROCESS_* macros)
ptr
Data exchanged to-from function
Returns

0 if no error, -1 if request in unknown

SpeexEchoState = pointer;

* Internal echo canceller state. Should never be accessed directly. */

speex_echo_state_init = function(frame_size: int; filter_length: int): SpeexEchoState; cdecl;

Creates a new echo canceller state * * *

Parameters
frame_size
Number of samples to process at one time (should correspond to 10-20 ms)
filter_length
Number of samples of echo to cancel (should generally correspond to 100-500 ms)
Returns

Newly-created echo canceller state

speex_echo_state_destroy = procedure(st: SpeexEchoState); cdecl;

Destroys an echo canceller state *

Parameters
st
Echo canceller state
speex_echo_cancellation = procedure(st: SpeexEchoState; rec: pspx_int16_t; play: pspx_int16_t; out_: pspx_int16_t); cdecl;

Performs echo cancellation a frame, based on the audio sent to the speaker (no delay is added * to playback in this form) * * * * *

Parameters
st
Echo canceller state
rec
Signal from the microphone (near end + far end echo)
play
Signal played to the speaker (received from far end)
out
Returns near-end signal with echo removed
speex_echo_capture = procedure(st: SpeexEchoState; rec: pspx_int16_t; out_: pspx_int16_t); cdecl;

Perform echo cancellation using internal playback buffer, which is delayed by two frames * to account for the delay introduced by most soundcards (but it could be off!) * * *

Parameters
st
Echo canceller state
rec
Signal from the microphone (near end + far end echo)
out
Returns near-end signal with echo removed
speex_echo_playback = procedure(st: SpeexEchoState; play: pspx_int16_t); cdecl;

Let the echo canceller know that a frame was just queued to the soundcard * *

Parameters
st
Echo canceller state
play
Signal played to the speaker (received from far end)
speex_echo_state_reset = procedure(st: SpeexEchoState); cdecl;

Reset the echo canceller to its original state *

Parameters
st
Echo canceller state
speex_echo_ctl = function(st: SpeexEchoState; request: int; ptr: pointer): int; cdecl;

Used like the ioctl function to control the echo canceller parameters * * * * *

Parameters
st
Echo canceller state
request
ioctl-type request (one of the SPEEX_ECHO_* macros)
ptr
Data exchanged to-from function
Returns

0 if no error, -1 if request in unknown

SpeexResamplerState = pointer;
 
speex_resampler_init = function(nb_channels: spx_uint32_t; in_rate: spx_uint32_t; out_rate: spx_uint32_t; quality: int; var err: int): SpeexResamplerState; cdecl;

Create a new resampler with integer input and output rates. * * * * * and 10 has very high quality. * *

Parameters
nb_channels
Number of channels to be processed
in_rate
Input sampling rate (integer number of Hz).
out_rate
Output sampling rate (integer number of Hz).
quality
Resampling quality between 0 and 10, where 0 has poor quality
Returns

NULL Error: not enough memory

speex_resampler_init_frac = function(nb_channels: spx_uint32_t; ratio_num: spx_uint32_t; ratio_den: spx_uint32_t; in_rate: spx_uint32_t; out_rate: spx_uint32_t; quality: int; var err: int): SpeexResamplerState; cdecl;

Create a new resampler with fractional input/output rates. The sampling * rate ratio is an arbitrary rational number with both the numerator and * denominator being 32-bit integers. * * * * * * * and 10 has very high quality. * *

Parameters
nb_channels
Number of channels to be processed
ratio_num
Numerator of the sampling rate ratio
ratio_den
Denominator of the sampling rate ratio
in_rate
Input sampling rate rounded to the nearest integer (in Hz).
out_rate
Output sampling rate rounded to the nearest integer (in Hz).
quality
Resampling quality between 0 and 10, where 0 has poor quality
Returns

NULL Error: not enough memory

speex_resampler_destroy = procedure(st: SpeexResamplerState); cdecl;

Destroy a resampler state. *

Parameters
st
Resampler state
speex_resampler_process_float = function(st: SpeexResamplerState; channel_index: spx_uint32_t; in_: pFloat; var in_len: spx_uint32_t; out_: pFloat; var out_len: spx_uint32_t): int; cdecl;

Resample a float array. The input and output buffers must *not* overlap. * * * base (0 otherwise) * * * number of samples processed * *

Parameters
st
Resampler state
channel_index
Index of the channel to process for the multi-channel
in
Input buffer
in_len
Number of input samples in the input buffer. Returns the
out
Output buffer
out_len
Size of the output buffer. Returns the number of samples written
speex_resampler_process_int = function(st: SpeexResamplerState; channel_index: spx_uint32_t; in_: pspx_int16_t; var in_len: spx_uint32_t; out_: pspx_int16_t; var out_len: spx_uint32_t): int; cdecl;

Resample an int array. The input and output buffers must *not* overlap. * * * base (0 otherwise) * * * of samples processed * *

Parameters
st
Resampler state
channel_index
Index of the channel to process for the multi-channel
in
Input buffer
in_len
Number of input samples in the input buffer. Returns the number
out
Output buffer
out_len
Size of the output buffer. Returns the number of samples written
speex_resampler_set_quality = function(st: SpeexResamplerState; quality: int): int; cdecl;

Set (change) the conversion quality. * * * quality and 10 has very high quality.

Parameters
st
Resampler state
quality
Resampling quality between 0 and 10, where 0 has poor
speex_resampler_get_quality = procedure(st: SpeexResamplerState; var quality: int); cdecl;

Get the conversion quality. * * * quality and 10 has very high quality.

Parameters
st
Resampler state
quality
Resampling quality between 0 and 10, where 0 has poor
speex_resampler_skip_zeros = function(st: SpeexResamplerState): int; cdecl;

Make sure that the first samples to go out of the resamplers don't have * leading zeros. This is only useful before starting to use a newly created * resampler. It is recommended to use that when resampling an audio file, as * it will generate a file with the same length. For real-time processing, * it is probably easier not to use this call (so that the output duration * is the same for the first frame). *

Parameters
st
Resampler state
speex_resampler_reset_mem = function(st: SpeexResamplerState): int; cdecl;

Reset a resampler so a new (unrelated) stream can be processed. *

Parameters
st
Resampler state
speex_resampler_strerror = function(err: int): paChar; cdecl;

Returns the English meaning for an error code * *

Parameters
err
Error code
Returns

English string

pSpeexLibrary_proc = ˆtSpeexLibrary_proc;

Holds Speex library proc entries.

pSpeexDSPLibrary_proc = ˆtSpeexDSPLibrary_proc;

Holds Speex DSP library proc entries.

Constants

c_speexDLL = 'libspeex.dll';
 
c_speexDSPDLL = 'libspeexdsp.dll';
 
RESAMPLER_ERR_ALLOC_FAILED = 1;
 
RESAMPLER_ERR_BAD_STATE = 2;
 
RESAMPLER_ERR_INVALID_ARG = 3;
 
RESAMPLER_ERR_MAX_ERROR = RESAMPLER_ERR_PTR_OVERLAP;
 
RESAMPLER_ERR_PTR_OVERLAP = 4;
 
RESAMPLER_ERR_SUCCESS = 0;
 
SPEEX_ECHO_GET_FRAME_SIZE = 3;

#include "speex/speex_types.h" * Obtain frame size used by the AEC */

SPEEX_ECHO_GET_SAMPLING_RATE = 25;

* Get sampling rate */

SPEEX_ECHO_SET_SAMPLING_RATE = 24;

* Set sampling rate */

SPEEX_GET_ABR = 33;

* Get Average Bit-Rate (ABR) setting (in bps) */

SPEEX_GET_ACTIVITY = 47;

* Get "activity level" of the last decoded frame, i.e. how much damage we cause if we remove the frame */

SPEEX_GET_BITRATE = 19;

* Get current bit-rate used by the encoder or decoder */

SPEEX_GET_COMPLEXITY = 17;

* Get current complexity of the encoder (0-10) */

SPEEX_GET_DTX = 35;

* Get DTX status (1 for on, 0 for off) */

SPEEX_GET_ENH = 1;

* Get enhancement state (decoder only) */

SPEEX_GET_FRAME_SIZE = 3;

Would be SPEEX_SET_FRAME_SIZE, but it's (currently) invalid*/ * Obtain frame size used by encoder/decoder */

SPEEX_GET_HIGHPASS = 45;

* Get status of input/output high-pass filtering */

SPEEX_GET_HIGH_MODE = 11;

* Get current high-band mode in use (wideband only)*/

SPEEX_GET_LOOKAHEAD = 39;

#define SPEEX_SET_LOOKAHEAD 38*/ * Returns the lookahead used by Speex */

SPEEX_GET_LOW_MODE = 9;

* Get current low-band mode in use (wideband only)*/

SPEEX_GET_MODE = 7;

* Get current sub-mode in use */

SPEEX_GET_PF = 1;

* Equivalent to SPEEX_GET_ENH */

SPEEX_GET_PLC_TUNING = 41;

* Gets tuning for PLC */

SPEEX_GET_RELATIVE_QUALITY = 29;

* Get VBR info (mostly used internally) */

SPEEX_GET_SAMPLING_RATE = 25;

* Get sampling rate used in bit-rate computation */

SPEEX_GET_SUBMODE_ENCODING = 37;

* Get submode encoding in each frame */

SPEEX_GET_VAD = 31;

* Get VAD status (1 for on, 0 for off) */

SPEEX_GET_VBR = 13;

* Get VBR status (1 for on, 0 for off) */

SPEEX_GET_VBR_MAX_BITRATE = 43;

* Gets the max bit-rate allowed in VBR mode */

SPEEX_GET_VBR_QUALITY = 15;

* Get current quality value for VBR encoding (0-10) */

SPEEX_LIB_GET_EXTRA_VERSION = 7;

* Get extra Speex version */

SPEEX_LIB_GET_MAJOR_VERSION = 1;

* Get major Speex version */

SPEEX_LIB_GET_MICRO_VERSION = 5;

* Get micro Speex version */

SPEEX_LIB_GET_MINOR_VERSION = 3;

* Get minor Speex version */

SPEEX_LIB_GET_VERSION_STRING = 9;

* Get Speex version string */

SPEEX_MODEID_NB = 0;

* modeID for the defined narrowband mode */

SPEEX_MODEID_UWB = 2;

* modeID for the defined ultra-wideband mode */

SPEEX_MODEID_WB = 1;

* modeID for the defined wideband mode */

SPEEX_MODE_FRAME_SIZE = 0;

Values allowed for mode queries */ * Query the frame size of a mode */

SPEEX_NB_MODES = 3;

* Number of defined modes in Speex */

SPEEX_PREPROCESS_GET_AGC = 3;

* Get preprocessor Automatic Gain Control state */

SPEEX_PREPROCESS_GET_AGC_DECREMENT = 29;

* Get maximal gain decrease in dB/second (int32) */

SPEEX_PREPROCESS_GET_AGC_INCREMENT = 27;

* Get maximal gain increase in dB/second (int32) */

SPEEX_PREPROCESS_GET_AGC_LEVEL = 7;

* Get preprocessor Automatic Gain Control level */

SPEEX_PREPROCESS_GET_AGC_LOUDNESS = 33;

Can't set loudness */ * Get loudness */

SPEEX_PREPROCESS_GET_AGC_MAX_GAIN = 31;

* Get maximal gain in dB (int32) */

SPEEX_PREPROCESS_GET_DENOISE = 1;

* Get preprocessor denoiser state */

SPEEX_PREPROCESS_GET_DEREVERB = 9;

* Get preprocessor dereverb state */

SPEEX_PREPROCESS_GET_DEREVERB_DECAY = 13;

* Get preprocessor dereverb decay */

SPEEX_PREPROCESS_GET_DEREVERB_LEVEL = 11;

* Get preprocessor dereverb level */

SPEEX_PREPROCESS_GET_ECHO_STATE = 25;

* Get the corresponding echo canceller state */

SPEEX_PREPROCESS_GET_ECHO_SUPPRESS = 21;

* Get maximum attenuation of the residual echo in dB (negative number) */

SPEEX_PREPROCESS_GET_ECHO_SUPPRESS_ACTIVE = 23;

* Get maximum attenuation of the residual echo in dB when near end is active (negative number) */

SPEEX_PREPROCESS_GET_NOISE_SUPPRESS = 19;

* Get maximum attenuation of the noise in dB (negative number) */

SPEEX_PREPROCESS_GET_PROB_CONTINUE = 17;

* Get probability required for the VAD to stay in the voice state (integer percent) */

SPEEX_PREPROCESS_GET_PROB_START = 15;

* Get probability required for the VAD to go from silence to voice */

SPEEX_PREPROCESS_GET_VAD = 5;

* Get preprocessor Voice Activity Detection state */

SPEEX_PREPROCESS_SET_AGC = 2;

* Set preprocessor Automatic Gain Control state */

SPEEX_PREPROCESS_SET_AGC_DECREMENT = 28;

* Set maximal gain decrease in dB/second (int32) */

SPEEX_PREPROCESS_SET_AGC_INCREMENT = 26;

* Set maximal gain increase in dB/second (int32) */

SPEEX_PREPROCESS_SET_AGC_LEVEL = 6;

* Set preprocessor Automatic Gain Control level */

SPEEX_PREPROCESS_SET_AGC_MAX_GAIN = 30;

* Set maximal gain in dB (int32) */

SPEEX_PREPROCESS_SET_DENOISE = 0;

* Set preprocessor denoiser state */

SPEEX_PREPROCESS_SET_DEREVERB = 8;

* Set preprocessor dereverb state */

SPEEX_PREPROCESS_SET_DEREVERB_DECAY = 12;

* Set preprocessor dereverb decay */

SPEEX_PREPROCESS_SET_DEREVERB_LEVEL = 10;

* Set preprocessor dereverb level */

SPEEX_PREPROCESS_SET_ECHO_STATE = 24;

* Set the corresponding echo canceller state so that residual echo suppression can be performed (NULL for no residual echo suppression) */

SPEEX_PREPROCESS_SET_ECHO_SUPPRESS = 20;

* Set maximum attenuation of the residual echo in dB (negative number) */

SPEEX_PREPROCESS_SET_ECHO_SUPPRESS_ACTIVE = 22;

* Set maximum attenuation of the residual echo in dB when near end is active (negative number) */

SPEEX_PREPROCESS_SET_NOISE_SUPPRESS = 18;

* Set maximum attenuation of the noise in dB (negative number) */

SPEEX_PREPROCESS_SET_PROB_CONTINUE = 16;

* Set probability required for the VAD to stay in the voice state (integer percent) */

SPEEX_PREPROCESS_SET_PROB_START = 14;

* Set probability required for the VAD to go from silence to voice */

SPEEX_PREPROCESS_SET_VAD = 4;

* Set preprocessor Voice Activity Detection state */

SPEEX_RESAMPLER_QUALITY_DEFAULT = 4;
 
SPEEX_RESAMPLER_QUALITY_DESKTOP = 5;
 
SPEEX_RESAMPLER_QUALITY_MAX = 10;

#ifndef SPEEX_RESAMPLER_H #define SPEEX_RESAMPLER_H

SPEEX_RESAMPLER_QUALITY_MIN = 0;
 
SPEEX_RESAMPLER_QUALITY_VOIP = 3;
 
SPEEX_RESET_STATE = 26;

* Reset the encoder/decoder memories to zero*/

SPEEX_SET_ABR = 32;

* Set Average Bit-Rate (ABR) to n bits per seconds */

SPEEX_SET_BITRATE = 18;

* Set bit-rate used by the encoder (or lower) */

SPEEX_SET_COMPLEXITY = 16;

* Set complexity of the encoder (0-10) */

SPEEX_SET_DTX = 34;

* Set DTX status (1 for on, 0 for off) */

SPEEX_SET_ENH = 0;

#endif /* _SPEEX_TYPES_H */ Values allowed for *ctl() requests */ * Set enhancement on/off (decoder only) */

SPEEX_SET_HANDLER = 20;

* Define a handler function for in-band Speex request*/

SPEEX_SET_HIGHPASS = 44;

* Turn on/off input/output high-pass filtering */

SPEEX_SET_HIGH_MODE = 10;

* Set high-band sub-mode to use (wideband only)*/

SPEEX_SET_LOW_MODE = 8;

* Set low-band sub-mode to use (wideband only)*/

SPEEX_SET_MODE = 6;

* Get current quality setting */ SPEEX_GET_QUALITY = 5; // – Doesn't make much sense, does it? */ * Set sub-mode to use */

SPEEX_SET_PF = 0;

Preserving compatibility:*/ * Equivalent to SPEEX_SET_ENH */

SPEEX_SET_PLC_TUNING = 40;

* Sets tuning for packet-loss concealment (expected loss rate) */

SPEEX_SET_QUALITY = 4;

* Set quality value */

SPEEX_SET_SAMPLING_RATE = 24;

* Set sampling rate used in bit-rate computation */

SPEEX_SET_SUBMODE_ENCODING = 36;

* Set submode encoding in each frame (1 for yes, 0 for no, setting to no breaks the standard) */

SPEEX_SET_USER_HANDLER = 22;

* Define a handler function for in-band user-defined request*/

SPEEX_SET_VAD = 30;

* Set VAD status (1 for on, 0 for off) */

SPEEX_SET_VBR = 12;

* Set VBR on (1) or off (0) */

SPEEX_SET_VBR_MAX_BITRATE = 42;

* Sets the max bit-rate allowed in VBR mode */

SPEEX_SET_VBR_QUALITY = 14;

* Set quality value for VBR encoding (0-10) */

SPEEX_SUBMODE_BITS_PER_FRAME = 1;

* Query the size of an encoded frame for a particular sub-mode */

Variables

c_opt4RTP_numbytes: int = 1100;

pack up to 5 frames (100 ms) when optimizing for RTP

c_opt4RTP_numframes: int = 5;

#endif ///////////////////////////////////////////////// Delphi code starts below /// /////////////////////////////////////////////////

Author

(c) 2012 Lake of Soft


Generated by PasDoc 0.12.1 on 2012-10-09