115#define FREQ_ARRAY_SIZE 7
140#define DEFAULT_THRESHOLD 512
151#define DSP_HISTORY 15
153#define TONE_THRESH 10.0
154#define TONE_MIN_THRESH 1e8
166#define MAX_DTMF_DIGITS 128
168#define DTMF_MATRIX_SIZE 4
182#define DTMF_THRESHOLD 8.0e7
183#define TONE_THRESHOLD 7.8e7
185#define DEF_DTMF_NORMAL_TWIST 6.31
186#define DEF_RELAX_DTMF_NORMAL_TWIST 6.31
189#define DEF_DTMF_REVERSE_TWIST 2.51
190#define DEF_RELAX_DTMF_REVERSE_TWIST 6.61
192#define DEF_DTMF_REVERSE_TWIST 2.51
193#define DEF_RELAX_DTMF_REVERSE_TWIST 3.98
196#define DTMF_RELATIVE_PEAK_ROW 6.3
197#define DTMF_RELATIVE_PEAK_COL 6.3
198#define DTMF_TO_TOTAL_ENERGY 42.0
200#define BELL_MF_THRESHOLD 1.6e9
201#define BELL_MF_TWIST 4.0
202#define BELL_MF_RELATIVE_PEAK 12.6
204#if defined(BUSYDETECT_TONEONLY) && defined(BUSYDETECT_COMPARE_TONE_AND_SILENCE)
205#error You cant use BUSYDETECT_TONEONLY together with BUSYDETECT_COMPARE_TONE_AND_SILENCE
211#define FAX_TONE_CNG_FREQ 1100
212#define FAX_TONE_CNG_DURATION 500
213#define FAX_TONE_CNG_DB 16
219#define FAX_TONE_CED_FREQ 2100
220#define FAX_TONE_CED_DURATION 2600
221#define FAX_TONE_CED_DB 16
223#define DEFAULT_SAMPLE_RATE 8000
229#define DTMF_GSIZE 102
234#define DEF_DTMF_HITS_TO_BEGIN 2
239#define DEF_DTMF_MISSES_TO_END 3
247#define CONFIG_FILE_NAME "dsp.conf"
320 697.0, 770.0, 852.0, 941.0
323 1209.0, 1336.0, 1477.0, 1633.0
326 700.0, 900.0, 1100.0, 1300.0, 1500.0, 1700.0
352 s->
v3 = (s->
fac * s->
v2) >> 15;
356 if (
abs(s->
v3) > (1 << 15)) {
375 return (
float)r.
value * (float)(1 << r.
power);
381 s->
fac = (int)(32768.0 * 2.0 *
cos(2.0 *
M_PI * freq / sample_rate));
454 int duration_samples;
456 int periods_in_block;
461 duration_samples = duration * sample_rate / 1000;
463 duration_samples = duration_samples * 9 / 10;
470 periods_in_block = s->
block_size * freq / sample_rate;
475 if (periods_in_block < 5) {
476 periods_in_block = 5;
480 s->
block_size = periods_in_block * sample_rate / freq;
507 x = pow(10.0, amp / 10.0);
553 for (i = 0; i < 6; i++) {
592 for (start = 0; start < samples; start =
end) {
594 limit = samples - start;
600 for (i = limit, ptr = amp ; i > 0; i--, ptr++) {
672 if (mute.
end > samples) {
715 for (sample = 0; sample < samples; sample = limit) {
724 for (j = sample; j < limit; j++) {
750 if (row_energy[i] > row_energy[best_row]) {
754 if (col_energy[i] > col_energy[best_col]) {
758 ast_debug(10,
"DTMF best '%c' Erow=%.4E Ecol=%.4E Erc=%.4E Et=%.4E\n",
760 row_energy[best_row], col_energy[best_col],
761 row_energy[best_row] + col_energy[best_col], s->
td.
dtmf.
energy);
770 if ((i != best_col &&
874 if (squelch && hit) {
892 if (squelch && mute.
end) {
893 if (mute.
end > samples) {
904 int samples,
int squelch,
int relax)
923 for (sample = 0; sample < samples; sample = limit) {
933 for (j = sample; j < limit; j++) {
957 if (energy[0] > energy[1]) {
965 for (i = 2; i < 6; i++) {
967 if (energy[i] >= energy[best]) {
970 }
else if (energy[i] >= energy[second_best]) {
981 for (i = 0; i < 6; i++) {
982 if (i != best && i != second_best) {
993 if (second_best < best) {
998 best = best * 5 + second_best - 1;
1027 if (squelch && hit) {
1037 for (i = 0; i < 6; i++) {
1043 if (squelch && mute.
end) {
1044 if (mute.
end > samples) {
1054static inline int pair_there(
float p1,
float p2,
float i1,
float i2,
float e)
1066 if ((p1 < i1) || (p1 < i2) || (p1 < e)) {
1070 if ((p2 < i1) || (p2 < i2) || (p2 < e)) {
1093 for (x = 0; x <
pass; x++) {
1096 for (y = 0; y < freqcount; y++) {
1153 if (newstate == dsp->
tstate) {
1170 dsp->
features &= ~DSP_FEATURE_CALL_PROGRESS;
1177 dsp->
features &= ~DSP_FEATURE_CALL_PROGRESS;
1184 dsp->
features &= ~DSP_FEATURE_CALL_PROGRESS;
1191 dsp->
features &= ~DSP_FEATURE_CALL_PROGRESS;
1196 ast_debug(1,
"Consider call as answered because of timeout after last ring\n");
1198 dsp->
features &= ~DSP_FEATURE_CALL_PROGRESS;
1202 ast_debug(5,
"Start state %d\n", newstate);
1208 for (x = 0; x < 7; x++) {
1226 ast_log(
LOG_WARNING,
"Can only check call progress in signed-linear frames, %s not supported\n",
1243 for (x = 0; x <
len; x++) {
1271 if (silence1 < silence2) {
1272 if (silence1 + silence1 *
BUSY_PERCENT / 100 >= silence2) {
1278 if (silence1 - silence1 *
BUSY_PERCENT / 100 <= silence2) {
1293 if (frames_energy) {
1294 *frames_energy = accum;
1302#ifndef BUSYDETECT_TONEONLY
1303 int avgsilence = 0, hitsilence = 0;
1305 int avgtone = 0, hittone = 0;
1315#ifndef BUSYDETECT_TONEONLY
1320#ifndef BUSYDETECT_TONEONLY
1325#ifndef BUSYDETECT_TONEONLY
1346#ifndef BUSYDETECT_TONEONLY
1354#ifdef BUSYDETECT_COMPARE_TONE_AND_SILENCE
1355 if (avgtone > avgsilence) {
1356 if (avgtone - avgtone*
BUSY_PERCENT/100 <= avgsilence) {
1360 if (avgtone + avgtone*
BUSY_PERCENT/100 >= avgsilence) {
1398 ast_debug(5,
"errors = %d max = %d\n", errors, errors_max);
1400 if (errors <= errors_max) {
1408#ifdef BUSYDETECT_DEBUG
1409 ast_debug(5,
"busy detector: avgtone of %d not close enough to desired %d\n",
1415#ifndef BUSYDETECT_TONEONLY
1419#ifdef BUSYDETECT_DEBUG
1420 ast_debug(5,
"busy detector: avgsilence of %d not close enough to desired %d\n",
1427#if !defined(BUSYDETECT_TONEONLY) && defined(BUSYDETECT_DEBUG)
1429 ast_debug(5,
"ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence);
1431 ast_debug(5,
"busy detector: FAILED with avgtone: %d, avgsilence %d\n", avgtone, avgsilence);
1442 unsigned char *odata;
1461 for (x = 0; x <
len; x++) {
1466 for (x = 0; x <
len; x++) {
1470 ast_log(
LOG_WARNING,
"Can only calculate silence on signed-linear, alaw or ulaw frames, %s not supported\n",
1503 int digit = 0, fax_digit = 0, custom_freq_digit = 0;
1506 unsigned char *odata;
1525 for (x = 0; x <
len; x++) {
1530 for (x = 0; x <
len; x++) {
1542 ast_log(
LOG_WARNING,
"Can only do DSP on signed-linear, alaw or ulaw frames (%s not supported)\n",
1559 memset(&dsp->
f, 0,
sizeof(dsp->
f));
1566 memset(&dsp->
f, 0,
sizeof(dsp->
f));
1586 custom_freq_digit =
'q';
1598 int event = 0, event_len = 0;
1599 char event_digit = 0;
1626 ast_debug(1,
"DTMF Detected - Reset busydetector\n");
1631 memset(&dsp->
f, 0,
sizeof(dsp->
f));
1634 dsp->
f.
len = event_len;
1644 memset(&dsp->
f, 0,
sizeof(dsp->
f));
1651 if (custom_freq_digit) {
1654 memset(&dsp->
f, 0,
sizeof(dsp->
f));
1670 memset(&dsp->
f, 0,
sizeof(dsp->
f));
1673 dsp->
f.
src =
"dsp_progress";
1693 for (x = 0; x <
len; x++) {
1694 odata[x] =
AST_LIN2MU((
unsigned short) shortdata[x]);
1697 for (x = 0; x <
len; x++) {
1698 odata[x] =
AST_LIN2A((
unsigned short) shortdata[x]);
1818 for (i = 0; i < 6; i++) {
1827 for (i = 0; i < 4; i++) {
1849 for (x = 0; x < 4; x++) {
1946 if (!strcasecmp(v->
name,
"silencethreshold")) {
1947 if (sscanf(v->
value,
"%30d", &cfg_threshold) < 1) {
1949 }
else if (cfg_threshold < 0) {
1950 ast_log(
LOG_WARNING,
"Invalid silence threshold '%d' specified, using default\n", cfg_threshold);
1954 }
else if (!strcasecmp(v->
name,
"dtmf_normal_twist")) {
1955 if (sscanf(v->
value,
"%30f", &cfg_twist) < 1) {
1957 }
else if ((cfg_twist < 2.0) || (cfg_twist > 100.0)) {
1962 }
else if (!strcasecmp(v->
name,
"dtmf_reverse_twist")) {
1963 if (sscanf(v->
value,
"%30f", &cfg_twist) < 1) {
1965 }
else if ((cfg_twist < 2.0) || (cfg_twist > 100.0)) {
1970 }
else if (!strcasecmp(v->
name,
"relax_dtmf_normal_twist")) {
1971 if (sscanf(v->
value,
"%30f", &cfg_twist) < 1) {
1973 }
else if ((cfg_twist < 2.0) || (cfg_twist > 100.0)) {
1978 }
else if (!strcasecmp(v->
name,
"relax_dtmf_reverse_twist")) {
1979 if (sscanf(v->
value,
"%30f", &cfg_twist) < 1) {
1981 }
else if ((cfg_twist < 2.0) || (cfg_twist > 100.0)) {
1986 }
else if (!strcasecmp(v->
name,
"dtmf_hits_to_begin")) {
1987 if (sscanf(v->
value,
"%30d", &cfg_threshold) < 1) {
1989 }
else if (cfg_threshold < 1) {
1994 }
else if (!strcasecmp(v->
name,
"dtmf_misses_to_end")) {
1995 if (sscanf(v->
value,
"%30d", &cfg_threshold) < 1) {
1997 }
else if (cfg_threshold < 1) {
2014#ifdef TEST_FRAMEWORK
2015static void test_tone_sample_gen(
short *slin_buf,
int samples,
int rate,
int freq,
short amplitude)
2018 double sample_step = 2.0 *
M_PI * freq / rate;
2020 for (idx = 0; idx < samples; ++idx) {
2021 slin_buf[idx] = amplitude * sin(sample_step * idx);
2026#ifdef TEST_FRAMEWORK
2027static void test_tone_sample_gen_add(
short *slin_buf,
int samples,
int rate,
int freq,
short amplitude)
2030 double sample_step = 2.0 *
M_PI * freq / rate;
2032 for (idx = 0; idx < samples; ++idx) {
2033 slin_buf[idx] += amplitude * sin(sample_step * idx);
2038#ifdef TEST_FRAMEWORK
2039static void test_dual_sample_gen(
short *slin_buf,
int samples,
int rate,
int f1,
short a1,
int f2,
short a2)
2041 test_tone_sample_gen(slin_buf, samples, rate, f1, a1);
2042 test_tone_sample_gen_add(slin_buf, samples, rate, f2, a2);
2046#ifdef TEST_FRAMEWORK
2047#define TONE_AMPLITUDE_MAX 0x7fff
2048#define TONE_AMPLITUDE_MIN 80
2059 { .amp_val = TONE_AMPLITUDE_MAX, .detect = 1, },
2060 { .amp_val = 10000, .detect = 1, },
2061 { .amp_val = 1000, .detect = 1, },
2062 { .amp_val = 100, .detect = 1, },
2063 { .amp_val = TONE_AMPLITUDE_MIN, .detect = 1, },
2064 { .amp_val = 75, .detect = 0, },
2065 { .amp_val = 10, .detect = 0, },
2066 { .amp_val = 1, .detect = 0, },
2071 for (idx = 0; idx <
ARRAY_LEN(amp_tests); ++idx) {
2075 ast_debug(1,
"Test %d Hz at amplitude %d\n",
2076 tone_state->
freq, amp_tests[idx].amp_val);
2078 tone_state->
freq, amp_tests[idx].amp_val);
2081 for (duration = 0; !detected && duration < tone_state->
hits_required + 3; ++duration) {
2084 if (amp_tests[idx].detect != detected) {
2092 "Test %d Hz at amplitude %d failed. Detected: %s\n",
2093 tone_state->
freq, amp_tests[idx].amp_val,
2094 detected ?
"yes" :
"no");
2096 "Test %d Hz at amplitude %d failed. Detected: %s\n",
2097 tone_state->
freq, amp_tests[idx].amp_val,
2098 detected ?
"yes" :
"no");
2108#ifdef TEST_FRAMEWORK
2109static int test_dtmf_amplitude_sweep(
struct ast_test *
test,
struct ast_dsp *dsp,
int digit_index)
2124 { .amp_val = TONE_AMPLITUDE_MAX/2, .digit =
dtmf_positions[digit_index], },
2132 { .amp_val = 170, .digit = 0, },
2133 { .amp_val = 100, .digit = 0, },
2138 { .amp_val = TONE_AMPLITUDE_MIN, .digit = 0, },
2139 { .amp_val = 75, .digit = 0, },
2140 { .amp_val = 10, .digit = 0, },
2141 { .amp_val = 1, .digit = 0, },
2144 row = (digit_index >> 2) & 0x03;
2145 column = digit_index & 0x03;
2149 for (idx = 0; idx <
ARRAY_LEN(amp_tests); ++idx) {
2153 ast_debug(1,
"Test '%c' at amplitude %d\n",
2156 (
int)
dtmf_row[row], amp_tests[idx].amp_val,
2157 (
int)
dtmf_col[column], amp_tests[idx].amp_val);
2160 for (duration = 0; !
digit && duration < 3; ++duration) {
2172 "Test '%c' at amplitude %d failed. Detected Digit: '%c'\n",
2176 "Test '%c' at amplitude %d failed. Detected Digit: '%c'\n",
2188#ifdef TEST_FRAMEWORK
2189static int test_dtmf_twist_sweep(
struct ast_test *
test,
struct ast_dsp *dsp,
int digit_index)
2208 { .amp_row = 1000 + 1800, .amp_col = 1000 + 0, .digit = 0, },
2209 { .amp_row = 1000 + 1700, .amp_col = 1000 + 0, .digit = 0, },
2211 { .amp_row = 1000 + 1400, .amp_col = 1000 + 0, .digit =
dtmf_positions[digit_index], },
2212 { .amp_row = 1000 + 1300, .amp_col = 1000 + 0, .digit =
dtmf_positions[digit_index], },
2213 { .amp_row = 1000 + 1200, .amp_col = 1000 + 0, .digit =
dtmf_positions[digit_index], },
2214 { .amp_row = 1000 + 1100, .amp_col = 1000 + 0, .digit =
dtmf_positions[digit_index], },
2215 { .amp_row = 1000 + 1000, .amp_col = 1000 + 0, .digit =
dtmf_positions[digit_index], },
2216 { .amp_row = 1000 + 100, .amp_col = 1000 + 0, .digit =
dtmf_positions[digit_index], },
2217 { .amp_row = 1000 + 0, .amp_col = 1000 + 100, .digit =
dtmf_positions[digit_index], },
2218 { .amp_row = 1000 + 0, .amp_col = 1000 + 200, .digit =
dtmf_positions[digit_index], },
2219 { .amp_row = 1000 + 0, .amp_col = 1000 + 300, .digit =
dtmf_positions[digit_index], },
2220 { .amp_row = 1000 + 0, .amp_col = 1000 + 400, .digit =
dtmf_positions[digit_index], },
2221 { .amp_row = 1000 + 0, .amp_col = 1000 + 500, .digit =
dtmf_positions[digit_index], },
2222 { .amp_row = 1000 + 0, .amp_col = 1000 + 550, .digit =
dtmf_positions[digit_index], },
2224 { .amp_row = 1000 + 0, .amp_col = 1000 + 650, .digit = 0, },
2225 { .amp_row = 1000 + 0, .amp_col = 1000 + 700, .digit = 0, },
2226 { .amp_row = 1000 + 0, .amp_col = 1000 + 800, .digit = 0, },
2228 float save_normal_twist;
2229 float save_reverse_twist;
2236 row = (digit_index >> 2) & 0x03;
2237 column = digit_index & 0x03;
2241 for (idx = 0; idx <
ARRAY_LEN(twist_tests); ++idx) {
2245 ast_debug(1,
"Test '%c' twist row %d col %d amplitudes\n",
2247 twist_tests[idx].amp_row, twist_tests[idx].amp_col);
2249 (
int)
dtmf_row[row], twist_tests[idx].amp_row,
2250 (
int)
dtmf_col[column], twist_tests[idx].amp_col);
2253 for (duration = 0; !
digit && duration < 3; ++duration) {
2265 "Test '%c' twist row %d col %d amplitudes failed. Detected Digit: '%c'\n",
2267 twist_tests[idx].amp_row, twist_tests[idx].amp_col,
2270 "Test '%c' twist row %d col %d amplitudes failed. Detected Digit: '%c'\n",
2272 twist_tests[idx].amp_row, twist_tests[idx].amp_col,
2286#ifdef TEST_FRAMEWORK
2296 lower_freq = tone_state->
freq - 4;
2297 upper_freq = tone_state->
freq + 4;
2302 for (freq = 100; freq <= 3500; freq += 1) {
2305 int expect_detection;
2307 if (freq == tone_state->
freq) {
2312 expect_detection = (lower_freq <= freq && freq <= upper_freq) ? 1 : 0;
2314 ast_debug(1,
"Test %d Hz detection given %d Hz tone at amplitude %d. Range:%d-%d Expect detect: %s\n",
2315 tone_state->
freq, freq, amplitude, lower_freq, upper_freq,
2316 expect_detection ?
"yes" :
"no");
2321 for (duration = 0; !detected && duration < tone_state->
hits_required + 3; ++duration) {
2324 if (expect_detection != detected) {
2332 "Test %d Hz detection given %d Hz tone at amplitude %d failed. Range:%d-%d Detected: %s\n",
2333 tone_state->
freq, freq, amplitude, lower_freq, upper_freq,
2334 detected ?
"yes" :
"no");
2336 "Test %d Hz detection given %d Hz tone at amplitude %d failed. Range:%d-%d Detected: %s\n",
2337 tone_state->
freq, freq, amplitude, lower_freq, upper_freq,
2338 detected ?
"yes" :
"no");
2348#ifdef TEST_FRAMEWORK
2357 info->category =
"/main/dsp/";
2358 info->summary =
"DSP fax tone detect unit test";
2360 "Tests fax tone detection code.";
2404#ifdef TEST_FRAMEWORK
2413 info->name =
"dtmf";
2414 info->category =
"/main/dsp/";
2415 info->summary =
"DSP DTMF detect unit test";
2417 "Tests DTMF detection code.";
2431 if (test_dtmf_amplitude_sweep(
test, dsp, idx)) {
2437 if (test_dtmf_twist_sweep(
test, dsp, idx)) {
2478 .
requires =
"extconfig",
A-Law to Signed linear conversion.
Asterisk main include file. File version handling, generic pbx functions.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
#define ast_calloc(num, len)
A wrapper for calloc()
static struct dahdi_ring_cadence cadences[NUM_CADENCE_MAX]
General Asterisk PBX channel definitions.
const char * ast_channel_name(const struct ast_channel *chan)
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
static void ast_mf_detect_init(mf_detect_state_t *s, unsigned int sample_rate)
static int thresholds[THRESHOLD_MAX]
#define DEF_DTMF_HITS_TO_BEGIN
void ast_dsp_set_threshold(struct ast_dsp *dsp, int threshold)
Set the minimum average magnitude threshold to determine talking by the DSP.
#define BELL_MF_THRESHOLD
void ast_dsp_free(struct ast_dsp *dsp)
int ast_dsp_get_tcount(struct ast_dsp *dsp)
Get tcount (Threshold counter)
#define DEFAULT_THRESHOLD
Default minimum average magnitude threshold to determine talking/noise by the DSP.
#define DEF_DTMF_REVERSE_TWIST
static void ast_tone_detect_init(tone_detect_state_t *s, int freq, int duration, int amp, unsigned int sample_rate)
struct ast_frame * ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp, struct ast_frame *af)
Return AST_FRAME_NULL frames when there is silence, AST_FRAME_BUSY on busies, and call progress,...
#define DTMF_TO_TOTAL_ENERGY
#define BELL_MF_RELATIVE_PEAK
#define DEF_DTMF_MISSES_TO_END
static const int DEFAULT_SILENCE_THRESHOLD
The default silence threshold we will use if an alternate configured value is not present or is inval...
static const char dtmf_positions[]
static int __ast_dsp_call_progress(struct ast_dsp *dsp, short *s, int len)
static void goertzel_init(goertzel_state_t *s, float freq, unsigned int sample_rate)
static struct progalias aliases[]
static int _dsp_init(int reload)
static int tone_detect(struct ast_dsp *dsp, tone_detect_state_t *s, int16_t *amp, int samples)
int ast_dsp_silence(struct ast_dsp *dsp, struct ast_frame *f, int *totalsilence)
Process the audio frame for silence.
#define FAX_TONE_CNG_FREQ
void ast_dsp_digitreset(struct ast_dsp *dsp)
Reset DTMF detector.
#define DEF_RELAX_DTMF_NORMAL_TWIST
static int mf_detect(struct ast_dsp *dsp, digit_detect_state_t *s, int16_t amp[], int samples, int squelch, int relax)
struct ast_dsp * ast_dsp_new_with_rate(unsigned int sample_rate)
Allocates a new dsp with a specific internal sample rate used during processing.
#define FAX_TONE_CED_DURATION
static const char bell_mf_positions[]
static void ast_fax_detect_init(struct ast_dsp *s)
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.
#define DEF_DTMF_NORMAL_TWIST
static float goertzel_result(goertzel_state_t *s)
int ast_dsp_call_progress(struct ast_dsp *dsp, struct ast_frame *inf)
Scans for progress indication in audio.
void ast_dsp_reset(struct ast_dsp *dsp)
Reset total silence count.
static void ast_freq_detect_init(struct ast_dsp *s, int freq, int dur, int db, int squelch)
void ast_dsp_set_busy_pattern(struct ast_dsp *dsp, const struct ast_dsp_busy_pattern *cadence)
Set expected lengths of the busy tone.
unsigned int ast_dsp_get_sample_rate(const struct ast_dsp *dsp)
Retrieve the sample rate this DSP structure was created with.
#define FAX_TONE_CED_FREQ
static int reload_module(void)
#define DTMF_RELATIVE_PEAK_COL
static struct progress modes[]
static const float dtmf_row[]
static void goertzel_sample(goertzel_state_t *s, short sample)
#define DEF_RELAX_DTMF_REVERSE_TWIST
static int pair_there(float p1, float p2, float i1, float i2, float e)
static const float mf_tones[]
static float dtmf_reverse_twist
int ast_dsp_get_features(struct ast_dsp *dsp)
Get features.
static int dtmf_detect(struct ast_dsp *dsp, digit_detect_state_t *s, int16_t amp[], int samples, int squelch, int relax)
int ast_dsp_set_digitmode(struct ast_dsp *dsp, int digitmode)
Set digit mode.
static void goertzel_reset(goertzel_state_t *s)
static int ast_dsp_silence_noise_with_energy(struct ast_dsp *dsp, struct ast_frame *f, int *total, int *frames_energy, int noise)
int ast_dsp_get_threshold_from_settings(enum threshold which)
Get silence threshold from dsp.conf.
static void ast_dtmf_detect_init(dtmf_detect_state_t *s, unsigned int sample_rate)
static void mute_fragment(struct ast_dsp *dsp, fragment_t *fragment)
#define DTMF_RELATIVE_PEAK_ROW
static int dtmf_misses_to_end
static int dtmf_hits_to_begin
#define DEFAULT_SAMPLE_RATE
static int load_module(void)
int ast_dsp_noise(struct ast_dsp *dsp, struct ast_frame *f, int *totalnoise)
Process the audio frame for noise.
int ast_dsp_get_tstate(struct ast_dsp *dsp)
Get tstate (Tone State)
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) hap...
static int unload_module(void)
static float relax_dtmf_normal_twist
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 ...
static void store_digit(digit_detect_state_t *s, char digit)
int ast_dsp_set_faxmode(struct ast_dsp *dsp, int faxmode)
Set fax mode.
static void ast_digit_detect_init(digit_detect_state_t *s, int mf, unsigned int sample_rate)
static const float dtmf_col[]
#define FAX_TONE_CNG_DURATION
int ast_dsp_set_freqmode(struct ast_dsp *dsp, int freq, int dur, int db, int squelch)
Set arbitrary frequency detection mode.
static struct ast_dsp * __ast_dsp_new(unsigned int sample_rate)
void ast_dsp_set_busy_count(struct ast_dsp *dsp, int cadences)
Set number of required cadences for busy.
static float dtmf_normal_twist
void ast_dsp_set_features(struct ast_dsp *dsp, int features)
Select feature set.
static float relax_dtmf_reverse_twist
struct ast_dsp * ast_dsp_new(void)
Allocates a new dsp, assumes 8khz for internal sample rate.
static int __ast_dsp_silence_noise(struct ast_dsp *dsp, short *s, int len, int *totalsilence, int *totalnoise, int *frames_energy)
int ast_dsp_set_call_progress_zone(struct ast_dsp *dsp, char *zone)
Set zone for doing progress detection.
static void ast_dsp_prog_reset(struct ast_dsp *dsp)
Convenient Signal Processing routines.
#define DSP_PROGRESS_RINGING
#define DSP_TONE_STATE_SPECIAL3
#define DSP_FEATURE_WAITDIALTONE
#define DSP_TONE_STATE_SPECIAL2
#define DSP_FEATURE_BUSY_DETECT
#define DSP_TONE_STATE_DIALTONE
#define DSP_PROGRESS_TALK
#define DSP_TONE_STATE_SILENCE
#define DSP_DIGITMODE_NOQUELCH
#define DSP_TONE_STATE_BUSY
#define DSP_DIGITMODE_MUTEMAX
#define DSP_FEATURE_DIGIT_DETECT
#define DSP_PROGRESS_BUSY
#define DSP_FEATURE_FAX_DETECT
#define DSP_TONE_STATE_SPECIAL1
#define DSP_FAXMODE_DETECT_SQUELCH
#define DSP_FAXMODE_DETECT_CED
#define DSP_PROGRESS_CONGESTION
#define DSP_FEATURE_CALL_PROGRESS
#define DSP_DIGITMODE_MUTECONF
#define DSP_FAXMODE_DETECT_CNG
#define DSP_FEATURE_SILENCE_SUPPRESS
#define DSP_TONE_STATE_HUNGUP
#define DSP_FEATURE_FREQ_DETECT
#define DSP_TONE_STATE_TALKING
#define DSP_TONE_STATE_RINGING
#define DSP_DIGITMODE_DTMF
#define DSP_DIGITMODE_RELAXDTMF
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Configuration File Parser.
struct ast_config * ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags)
Load a config file.
#define CONFIG_STATUS_FILEMISSING
#define CONFIG_STATUS_FILEUNCHANGED
#define CONFIG_STATUS_FILEINVALID
void ast_config_destroy(struct ast_config *cfg)
Destroys a config.
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
@ CONFIG_FLAG_FILEUNCHANGED
Asterisk internal frame definitions.
#define ast_frisolate(fr)
Makes a frame independent of any static storage.
#define ast_debug(level,...)
Log a DEBUG message.
Asterisk module definitions.
@ AST_MODFLAG_GLOBAL_SYMBOLS
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_FAILURE
Module could not be loaded properly.
@ AST_MODULE_LOAD_SUCCESS
Options provided by main asterisk program.
Main Channel structure associated with a channel.
int historicnoise[DSP_HISTORY]
goertzel_state_t freqs[FREQ_ARRAY_SIZE]
digit_detect_state_t digit_state
tone_detect_state_t ced_tone_state
int historicsilence[DSP_HISTORY]
enum gsamp_size gsamp_size
int display_inband_dtmf_warning
struct ast_dsp_busy_pattern busy_cadence
tone_detect_state_t cng_tone_state
Structure used to handle boolean flags.
struct ast_format * format
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
union ast_frame::@226 data
enum ast_frame_type frametype
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
int digitlen[MAX_DTMF_DIGITS+1]
char digits[MAX_DTMF_DIGITS+1]
union digit_detect_state_t::@345 td
goertzel_state_t row_out[DTMF_MATRIX_SIZE]
goertzel_state_t col_out[DTMF_MATRIX_SIZE]
goertzel_state_t tone_out[6]
int freqs[FREQ_ARRAY_SIZE]
#define AST_TEST_REGISTER(cb)
#define ast_test_status_update(a, b, c...)
#define AST_TEST_UNREGISTER(cb)
#define AST_TEST_DEFINE(hdr)
u-Law to Signed linear conversion