WARNING: The online documentation has moved to https://docs.pjsip.org.

Visit the new documentation at https://docs.pjsip.org:

BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJMEDIA Reference

Adaptive Silence Detection

Adaptive Silence Detector. More...

Typedefs

typedef struct pjmedia_silence_det pjmedia_silence_det
 

Functions

pj_status_t pjmedia_silence_det_create (pj_pool_t *pool, unsigned clock_rate, unsigned samples_per_frame, pjmedia_silence_det **p_sd)
 
pj_status_t pjmedia_silence_det_set_name (pjmedia_silence_det *sd, const char *name)
 
pj_status_t pjmedia_silence_det_set_fixed (pjmedia_silence_det *sd, int threshold)
 
pj_status_t pjmedia_silence_det_set_adaptive (pjmedia_silence_det *sd, int threshold)
 
pj_status_t pjmedia_silence_det_set_params (pjmedia_silence_det *sd, int before_silence, int recalc_time1, int recalc_time2)
 
pj_status_t pjmedia_silence_det_disable (pjmedia_silence_det *sd)
 
pj_bool_t pjmedia_silence_det_detect (pjmedia_silence_det *sd, const pj_int16_t samples[], pj_size_t count, pj_int32_t *p_level)
 
pj_int32_t pjmedia_calc_avg_signal (const pj_int16_t samples[], pj_size_t count)
 
pj_bool_t pjmedia_silence_det_apply (pjmedia_silence_det *sd, pj_uint32_t level)
 

Detailed Description

Typedef Documentation

◆ pjmedia_silence_det

Opaque declaration for silence detector.

Function Documentation

◆ pjmedia_silence_det_create()

pj_status_t pjmedia_silence_det_create ( pj_pool_t pool,
unsigned  clock_rate,
unsigned  samples_per_frame,
pjmedia_silence_det **  p_sd 
)

Create voice activity detector with default settings. The default settings are set to adaptive silence detection with the default threshold.

Parameters
poolPool for allocating the structure.
clock_rateClock rate.
samples_per_frameNumber of samples per frame. The clock_rate and samples_per_frame is only used to calculate the frame time, from which some timing parameters are calculated from.
p_sdPointer to receive the silence detector instance.
Returns
PJ_SUCCESS on success.

◆ pjmedia_silence_det_set_name()

pj_status_t pjmedia_silence_det_set_name ( pjmedia_silence_det sd,
const char *  name 
)

Set silence detector name to identify the particular silence detector instance in the log.

Parameters
sdThe silence detector.
nameName.
Returns
PJ_SUCCESS on success.

◆ pjmedia_silence_det_set_fixed()

pj_status_t pjmedia_silence_det_set_fixed ( pjmedia_silence_det sd,
int  threshold 
)

Set the sd to operate in fixed threshold mode. With fixed threshold mode, the threshold will not be changed adaptively.

Parameters
sdThe silence detector
thresholdThe silence threshold, or -1 to use default threshold.
Returns
PJ_SUCCESS on success.

◆ pjmedia_silence_det_set_adaptive()

pj_status_t pjmedia_silence_det_set_adaptive ( pjmedia_silence_det sd,
int  threshold 
)

Set the sd to operate in adaptive mode. This is the default mode when the silence detector is created.

Parameters
sdThe silence detector
thresholdInitial threshold to be set, or -1 to use default threshold.
Returns
PJ_SUCCESS on success.

◆ pjmedia_silence_det_set_params()

pj_status_t pjmedia_silence_det_set_params ( pjmedia_silence_det sd,
int  before_silence,
int  recalc_time1,
int  recalc_time2 
)

Set other silence detector parameters.

Parameters
sdThe silence detector
before_silenceMinimum duration of silence (in msec) before silence is reported. If -1 is specified, then the default value will be used. The default is 400 msec.
recalc_time1The interval (in msec) to recalculate threshold in non-silence condition when adaptive silence detection is set. If -1 is specified, then the default value will be used. The default is 4000 (msec).
recalc_time2The interval (in msec) to recalculate threshold in silence condition when adaptive silence detection is set. If -1 is specified, then the default value will be used. The default value is 2000 (msec).
Returns
PJ_SUCCESS on success.

◆ pjmedia_silence_det_disable()

pj_status_t pjmedia_silence_det_disable ( pjmedia_silence_det sd)

Disable the silence detector.

Parameters
sdThe silence detector
Returns
PJ_SUCCESS on success.

◆ pjmedia_silence_det_detect()

pj_bool_t pjmedia_silence_det_detect ( pjmedia_silence_det sd,
const pj_int16_t  samples[],
pj_size_t  count,
pj_int32_t p_level 
)

Perform voice activity detection on the given input samples. This function uses pjmedia_calc_avg_signal() and pjmedia_silence_det_apply() for its calculation.

Parameters
sdThe silence detector instance.
samplesPointer to 16-bit PCM input samples.
countNumber of samples in the input.
p_levelOptional pointer to receive average signal level of the input samples.
Returns
Non zero if signal is silence.

◆ pjmedia_calc_avg_signal()

pj_int32_t pjmedia_calc_avg_signal ( const pj_int16_t  samples[],
pj_size_t  count 
)

Calculate average signal level for the given samples.

Parameters
samplesPointer to 16-bit PCM samples.
countNumber of samples in the input.
Returns
The average signal level, which simply is total level divided by number of samples.

◆ pjmedia_silence_det_apply()

pj_bool_t pjmedia_silence_det_apply ( pjmedia_silence_det sd,
pj_uint32_t  level 
)

Perform voice activity detection, given the specified average signal level.

Parameters
sdThe silence detector instance.
levelSignal level.
Returns
Non zero if signal is silence.

References PJ_END_DECL.

 


PJMEDIA small footprint Open Source media stack
Copyright (C) 2006-2008 Teluu Inc.