- Main Page
- Modules
- Namespaces
- Classes
- Files
- Directories
- Related Pages

# SpeexPreprocessState: The Speex preprocessor

## Defines
#define | SPEEX_PREPROCESS_SET_DENOISE 0
#define | SPEEX_PREPROCESS_GET_DENOISE 1
#define | SPEEX_PREPROCESS_SET_AGC 2
#define | SPEEX_PREPROCESS_GET_AGC 3
#define | SPEEX_PREPROCESS_SET_VAD 4
#define | SPEEX_PREPROCESS_GET_VAD 5
#define | SPEEX_PREPROCESS_SET_AGC_LEVEL 6
#define | SPEEX_PREPROCESS_GET_AGC_LEVEL 7
#define | SPEEX_PREPROCESS_SET_DEREVERB 8
#define | SPEEX_PREPROCESS_GET_DEREVERB 9
#define | SPEEX_PREPROCESS_SET_DEREVERB_LEVEL 10
#define | SPEEX_PREPROCESS_GET_DEREVERB_LEVEL 11
#define | SPEEX_PREPROCESS_SET_DEREVERB_DECAY 12
#define | SPEEX_PREPROCESS_GET_DEREVERB_DECAY 13
#define | SPEEX_PREPROCESS_SET_PROB_START 14
#define | SPEEX_PREPROCESS_GET_PROB_START 15
#define | SPEEX_PREPROCESS_SET_PROB_CONTINUE 16
#define | SPEEX_PREPROCESS_GET_PROB_CONTINUE 17
#define | SPEEX_PREPROCESS_SET_NOISE_SUPPRESS 18
#define | SPEEX_PREPROCESS_GET_NOISE_SUPPRESS 19
#define | SPEEX_PREPROCESS_SET_ECHO_SUPPRESS 20
#define | SPEEX_PREPROCESS_GET_ECHO_SUPPRESS 21
#define | SPEEX_PREPROCESS_SET_ECHO_SUPPRESS_ACTIVE 22
#define | SPEEX_PREPROCESS_GET_ECHO_SUPPRESS_ACTIVE 23
#define | SPEEX_PREPROCESS_SET_ECHO_STATE 24
#define | SPEEX_PREPROCESS_GET_ECHO_STATE 25
#define | SPEEX_PREPROCESS_SET_AGC_INCREMENT 26
#define | SPEEX_PREPROCESS_GET_AGC_INCREMENT 27
#define | SPEEX_PREPROCESS_SET_AGC_DECREMENT 28
#define | SPEEX_PREPROCESS_GET_AGC_DECREMENT 29
#define | SPEEX_PREPROCESS_SET_AGC_MAX_GAIN 30
#define | SPEEX_PREPROCESS_GET_AGC_MAX_GAIN 31
#define | SPEEX_PREPROCESS_GET_AGC_LOUDNESS 33
## Typedefs
typedef SpeexPreprocessState_ | SpeexPreprocessState
## Functions
SpeexPreprocessState * | speex_preprocess_state_init (int frame_size, int sampling_rate)
void | speex_preprocess_state_destroy (SpeexPreprocessState *st)
int | speex_preprocess_run (SpeexPreprocessState *st, spx_int16_t *x)
int | speex_preprocess (SpeexPreprocessState *st, spx_int16_t *x, spx_int32_t *echo)
void | speex_preprocess_estimate_update (SpeexPreprocessState *st, spx_int16_t *x)
int | speex_preprocess_ctl (SpeexPreprocessState *st, int request, void *ptr)

## Detailed Description

This is the Speex preprocessor. The preprocess can do noise suppression, residual echo suppression (after using the echo canceller), automatic gain control (AGC) and voice activity detection (VAD).

## Define Documentation

#define SPEEX_PREPROCESS_GET_AGC 3

Get preprocessor Automatic Gain Control state

#define SPEEX_PREPROCESS_GET_AGC_DECREMENT 29

Get maximal gain decrease in dB/second (int32)

#define SPEEX_PREPROCESS_GET_AGC_INCREMENT 27

Get maximal gain increase in dB/second (int32)

#define SPEEX_PREPROCESS_GET_AGC_LEVEL 7

Get preprocessor Automatic Gain Control level

#define SPEEX_PREPROCESS_GET_AGC_LOUDNESS 33

Get loudness

#define SPEEX_PREPROCESS_GET_AGC_MAX_GAIN 31

Get maximal gain in dB (int32)

#define SPEEX_PREPROCESS_GET_DENOISE 1

Get preprocessor denoiser state

#define SPEEX_PREPROCESS_GET_DEREVERB 9

Get preprocessor dereverb state

#define SPEEX_PREPROCESS_GET_DEREVERB_DECAY 13

Get preprocessor dereverb decay

#define SPEEX_PREPROCESS_GET_DEREVERB_LEVEL 11

Get preprocessor dereverb level

#define SPEEX_PREPROCESS_GET_ECHO_STATE 25

Get the corresponding echo canceller state

#define SPEEX_PREPROCESS_GET_ECHO_SUPPRESS 21

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

#define SPEEX_PREPROCESS_GET_ECHO_SUPPRESS_ACTIVE 23

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

#define SPEEX_PREPROCESS_GET_NOISE_SUPPRESS 19

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

#define SPEEX_PREPROCESS_GET_PROB_CONTINUE 17

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

#define SPEEX_PREPROCESS_GET_PROB_START 15

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

#define SPEEX_PREPROCESS_GET_VAD 5

Get preprocessor Voice Activity Detection state

#define SPEEX_PREPROCESS_SET_AGC 2

Set preprocessor Automatic Gain Control state

#define SPEEX_PREPROCESS_SET_AGC_DECREMENT 28

Set maximal gain decrease in dB/second (int32)

#define SPEEX_PREPROCESS_SET_AGC_INCREMENT 26

Set maximal gain increase in dB/second (int32)

#define SPEEX_PREPROCESS_SET_AGC_LEVEL 6

Set preprocessor Automatic Gain Control level

#define SPEEX_PREPROCESS_SET_AGC_MAX_GAIN 30

Set maximal gain in dB (int32)

#define SPEEX_PREPROCESS_SET_DENOISE 0

Set preprocessor denoiser state

#define SPEEX_PREPROCESS_SET_DEREVERB 8

Set preprocessor dereverb state

#define SPEEX_PREPROCESS_SET_DEREVERB_DECAY 12

Set preprocessor dereverb decay

#define SPEEX_PREPROCESS_SET_DEREVERB_LEVEL 10

Set preprocessor dereverb level

#define 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)

#define SPEEX_PREPROCESS_SET_ECHO_SUPPRESS 20

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

#define SPEEX_PREPROCESS_SET_ECHO_SUPPRESS_ACTIVE 22

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

#define SPEEX_PREPROCESS_SET_NOISE_SUPPRESS 18

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

#define SPEEX_PREPROCESS_SET_PROB_CONTINUE 16

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

#define SPEEX_PREPROCESS_SET_PROB_START 14

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

#define SPEEX_PREPROCESS_SET_VAD 4

Set preprocessor Voice Activity Detection state

## Typedef Documentation

typedef struct SpeexPreprocessState_ SpeexPreprocessState

State of the preprocessor (one per channel). Should never be accessed directly.

## Function Documentation

int speex_preprocess | ( | SpeexPreprocessState * | st,
|  | spx_int16_t * | x,
|  | spx_int32_t * | echo |
| ) |  |  |

Preprocess a frame (deprecated, use speex_preprocess_run() instead)

int speex_preprocess_ctl | ( | SpeexPreprocessState * | st,
|  | int | request,
|  | void * | ptr |
| ) |  |  |

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

void speex_preprocess_estimate_update | ( | SpeexPreprocessState * | st,
|  | spx_int16_t * | x |
| ) |  |  |

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().

int speex_preprocess_run | ( | SpeexPreprocessState * | st,
|  | spx_int16_t * | x |
| ) |  |  |

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.

void speex_preprocess_state_destroy | ( | SpeexPreprocessState * | st | ) |

Destroys a preprocessor state

Parameters:

  | st | Preprocessor state to destroy

SpeexPreprocessState* speex_preprocess_state_init | ( | int | frame_size,
|  | int | sampling_rate |
| ) |  |  |

Creates a new preprocessing state. You MUST create one state per channel processed.

Parameters:

  | frame_size | Number of samples to process at one time (should correspond to 10-20 ms). Must be the same value as that used for the echo canceller for residual echo cancellation to work.
  | sampling_rate | Sampling rate used for the input.

Returns:
  Newly created preprocessor state