Asterisk - The Open Source Telephony Project  21.4.1
Data Structures | Macros | Enumerations | Functions
dsp.h File Reference

Convenient Signal Processing routines. More...

Go to the source code of this file.

Data Structures

struct  ast_dsp_busy_pattern
 

Macros

#define DSP_DIGITMODE_DTMF   0
 
#define DSP_DIGITMODE_MF   1
 
#define DSP_DIGITMODE_MUTECONF   (1 << 9)
 
#define DSP_DIGITMODE_MUTEMAX   (1 << 10)
 
#define DSP_DIGITMODE_NOQUELCH   (1 << 8)
 
#define DSP_DIGITMODE_RELAXDTMF   (1 << 11)
 
#define DSP_FAXMODE_DETECT_ALL   (DSP_FAXMODE_DETECT_CNG | DSP_FAXMODE_DETECT_CED)
 
#define DSP_FAXMODE_DETECT_CED   (1 << 1)
 
#define DSP_FAXMODE_DETECT_CNG   (1 << 0)
 
#define DSP_FAXMODE_DETECT_SQUELCH   (1 << 2)
 
#define DSP_FEATURE_BUSY_DETECT   (1 << 1)
 
#define DSP_FEATURE_CALL_PROGRESS   (DSP_PROGRESS_TALK | DSP_PROGRESS_RINGING | DSP_PROGRESS_BUSY | DSP_PROGRESS_CONGESTION)
 
#define DSP_FEATURE_DIGIT_DETECT   (1 << 3)
 
#define DSP_FEATURE_FAX_DETECT   (1 << 4)
 
#define DSP_FEATURE_FREQ_DETECT   (1 << 21)
 
#define DSP_FEATURE_SILENCE_SUPPRESS   (1 << 0)
 
#define DSP_FEATURE_WAITDIALTONE   (1 << 20)
 
#define DSP_PROGRESS_BUSY   (1 << 18)
 
#define DSP_PROGRESS_CONGESTION   (1 << 19)
 
#define DSP_PROGRESS_RINGING   (1 << 17)
 
#define DSP_PROGRESS_TALK   (1 << 16)
 
#define DSP_TONE_STATE_BUSY   4
 
#define DSP_TONE_STATE_DIALTONE   2
 
#define DSP_TONE_STATE_HUNGUP   8
 
#define DSP_TONE_STATE_RINGING   1
 
#define DSP_TONE_STATE_SILENCE   0
 
#define DSP_TONE_STATE_SPECIAL1   5
 
#define DSP_TONE_STATE_SPECIAL2   6
 
#define DSP_TONE_STATE_SPECIAL3   7
 
#define DSP_TONE_STATE_TALKING   3
 

Enumerations

enum  threshold { THRESHOLD_SILENCE = 0, THRESHOLD_MAX = 1 }
 

Functions

int ast_dsp_busydetect (struct ast_dsp *dsp)
 Return non-zero if historically this should be a busy, request that ast_dsp_silence has already been called.
 
int ast_dsp_call_progress (struct ast_dsp *dsp, struct ast_frame *inf)
 Scans for progress indication in audio.
 
int ast_dsp_digitdetect (struct ast_dsp *dsp, struct ast_frame *f)
 Return non-zero if DTMF hit was found.
 
void ast_dsp_digitreset (struct ast_dsp *dsp)
 Reset DTMF detector.
 
void ast_dsp_free (struct ast_dsp *dsp)
 
int ast_dsp_get_features (struct ast_dsp *dsp)
 Get features.
 
unsigned int ast_dsp_get_sample_rate (const struct ast_dsp *dsp)
 Retrieve the sample rate this DSP structure was created with.
 
int ast_dsp_get_tcount (struct ast_dsp *dsp)
 Get tcount (Threshold counter)
 
int ast_dsp_get_threshold_from_settings (enum threshold which)
 Get silence threshold from dsp.conf. More...
 
int ast_dsp_get_tstate (struct ast_dsp *dsp)
 Get tstate (Tone State)
 
int ast_dsp_getdigits (struct ast_dsp *dsp, char *buf, int max)
 Get pending DTMF/MF digits.
 
struct ast_dspast_dsp_new (void)
 Allocates a new dsp, assumes 8khz for internal sample rate.
 
struct ast_dspast_dsp_new_with_rate (unsigned int sample_rate)
 Allocates a new dsp with a specific internal sample rate used during processing.
 
int ast_dsp_noise (struct ast_dsp *dsp, struct ast_frame *f, int *totalnoise)
 Process the audio frame for noise. More...
 
struct ast_frameast_dsp_process (struct ast_channel *chan, struct ast_dsp *dsp, struct ast_frame *inf)
 Return AST_FRAME_NULL frames when there is silence, AST_FRAME_BUSY on busies, and call progress, all dependent upon which features are enabled.
 
void ast_dsp_reset (struct ast_dsp *dsp)
 Reset total silence count.
 
void ast_dsp_set_busy_count (struct ast_dsp *dsp, int cadences)
 Set number of required cadences for busy.
 
void ast_dsp_set_busy_pattern (struct ast_dsp *dsp, const struct ast_dsp_busy_pattern *cadence)
 Set expected lengths of the busy tone.
 
int ast_dsp_set_call_progress_zone (struct ast_dsp *dsp, char *zone)
 Set zone for doing progress detection.
 
int ast_dsp_set_digitmode (struct ast_dsp *dsp, int digitmode)
 Set digit mode. More...
 
int ast_dsp_set_faxmode (struct ast_dsp *dsp, int faxmode)
 Set fax mode.
 
void ast_dsp_set_features (struct ast_dsp *dsp, int features)
 Select feature set.
 
int ast_dsp_set_freqmode (struct ast_dsp *dsp, int freq, int dur, int db, int squelch)
 Set arbitrary frequency detection mode.
 
void ast_dsp_set_threshold (struct ast_dsp *dsp, int threshold)
 Set the minimum average magnitude threshold to determine talking by the DSP.
 
int ast_dsp_silence (struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence)
 Process the audio frame for silence. More...
 
int ast_dsp_silence_with_energy (struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence, int *frames_energy)
 Process the audio frame for silence. More...
 
int ast_dsp_was_muted (struct ast_dsp *dsp)
 Returns true if DSP code was muting any fragment of the last processed frame. Muting (squelching) happens when DSP code removes DTMF/MF/generic tones from the audio. More...
 

Detailed Description

Convenient Signal Processing routines.

Definition in file dsp.h.

Macro Definition Documentation

#define DSP_DIGITMODE_DTMF   0

Detect DTMF digits

Definition at line 31 of file dsp.h.

Referenced by ast_dsp_process(), ast_dsp_set_digitmode(), dahdi_setoption(), mbl_load_device(), and mkintf().

#define DSP_DIGITMODE_MF   1

Detect MF digits

Definition at line 32 of file dsp.h.

Referenced by ast_dsp_digitreset(), ast_dsp_process(), ast_dsp_set_digitmode(), and read_mf_digits().

#define DSP_DIGITMODE_MUTECONF   (1 << 9)

Mute conference

Definition at line 35 of file dsp.h.

Referenced by ast_dsp_set_digitmode(), and dahdi_setoption().

#define DSP_DIGITMODE_MUTEMAX   (1 << 10)

Delay audio by a frame to try to extra quelch

Definition at line 36 of file dsp.h.

Referenced by ast_dsp_set_digitmode(), and dahdi_setoption().

#define DSP_DIGITMODE_NOQUELCH   (1 << 8)

Do not quelch DTMF from in-band

Definition at line 34 of file dsp.h.

Referenced by ast_dsp_process().

#define DSP_DIGITMODE_RELAXDTMF   (1 << 11)

"Radio" mode (relaxed DTMF)

Definition at line 37 of file dsp.h.

Referenced by ast_dsp_process(), dahdi_setoption(), and mbl_load_device().

#define DSP_FEATURE_FREQ_DETECT   (1 << 21)

Enable arbitrary tone detection

Definition at line 45 of file dsp.h.

Referenced by ast_dsp_process(), and read_sf_digits().

#define DSP_FEATURE_WAITDIALTONE   (1 << 20)

Enable dial tone detection

Definition at line 44 of file dsp.h.

Referenced by ast_dsp_process().

#define DSP_PROGRESS_BUSY   (1 << 18)

Enable busy tone detection

Definition at line 41 of file dsp.h.

#define DSP_PROGRESS_CONGESTION   (1 << 19)

Enable congestion tone detection

Definition at line 42 of file dsp.h.

#define DSP_PROGRESS_RINGING   (1 << 17)

Enable calling tone detection

Definition at line 40 of file dsp.h.

#define DSP_PROGRESS_TALK   (1 << 16)

Enable talk detection

Definition at line 39 of file dsp.h.

Function Documentation

int ast_dsp_get_threshold_from_settings ( enum threshold  which)

Get silence threshold from dsp.conf.

Since
1.6.1

Definition at line 2009 of file dsp.c.

Referenced by ast_record_review(), load_config(), and setup_privacy_args().

2010 {
2011  return thresholds[which];
2012 }
int ast_dsp_noise ( struct ast_dsp dsp,
struct ast_frame f,
int *  totalnoise 
)

Process the audio frame for noise.

Since
1.6.1
Parameters
dspDSP processing audio media.
fAudio frame to process.
totalnoiseVariable to set to the total accumulated noise in ms seen by the DSP since the last silence.
Returns
Non-zero if the frame is silence.

Definition at line 1493 of file dsp.c.

1494 {
1495  return ast_dsp_silence_noise_with_energy(dsp, f, totalnoise, NULL, 1);
1496 }
int ast_dsp_set_digitmode ( struct ast_dsp dsp,
int  digitmode 
)

Set digit mode.

Version
1.6.1 renamed from ast_dsp_digitmode to ast_dsp_set_digitmode

Definition at line 1857 of file dsp.c.

References DSP_DIGITMODE_DTMF, DSP_DIGITMODE_MF, DSP_DIGITMODE_MUTECONF, and DSP_DIGITMODE_MUTEMAX.

Referenced by dahdi_setoption(), mbl_load_device(), mkintf(), and read_mf_digits().

1858 {
1859  int new;
1860  int old;
1861 
1864  if (old != new) {
1865  /* Must initialize structures if switching from MF to DTMF or vice-versa */
1866  ast_digit_detect_init(&dsp->digit_state, new & DSP_DIGITMODE_MF, dsp->sample_rate);
1867  }
1868  dsp->digitmode = digitmode;
1869  return 0;
1870 }
#define DSP_DIGITMODE_DTMF
Definition: dsp.h:31
#define DSP_DIGITMODE_MF
Definition: dsp.h:32
#define DSP_DIGITMODE_MUTECONF
Definition: dsp.h:35
#define DSP_DIGITMODE_MUTEMAX
Definition: dsp.h:36
int ast_dsp_silence ( struct ast_dsp dsp,
struct ast_frame f,
int *  totalsilence 
)

Process the audio frame for silence.

Parameters
dspDSP processing audio media.
fAudio frame to process.
totalsilenceVariable to set to the total accumulated silence in ms seen by the DSP since the last noise.
Returns
Non-zero if the frame is silence.

Definition at line 1488 of file dsp.c.

Referenced by __ast_play_and_record().

1489 {
1490  return ast_dsp_silence_noise_with_energy(dsp, f, totalsilence, NULL, 0);
1491 }
int ast_dsp_silence_with_energy ( struct ast_dsp dsp,
struct ast_frame f,
int *  totalsilence,
int *  frames_energy 
)

Process the audio frame for silence.

Parameters
dspDSP processing audio media.
fAudio frame to process.
totalsilenceVariable to set to the total accumulated silence in ms seen by the DSP since the last noise.
frames_energyVariable to set to the average energy of the samples in the frame.
Returns
Non-zero if the frame is silence.

Definition at line 1483 of file dsp.c.

1484 {
1485  return ast_dsp_silence_noise_with_energy(dsp, f, totalsilence, frames_energy, 0);
1486 }
int ast_dsp_was_muted ( struct ast_dsp dsp)

Returns true if DSP code was muting any fragment of the last processed frame. Muting (squelching) happens when DSP code removes DTMF/MF/generic tones from the audio.

Since
1.6.1

Definition at line 1906 of file dsp.c.

1907 {
1908  return (dsp->mute_fragments > 0);
1909 }