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++) {
603 s->
energy += (int32_t) samp * (int32_t) samp;
674 if (mute.
end > samples) {
717 for (sample = 0; sample < samples; sample = limit) {
726 for (j = sample; j < limit; j++) {
752 if (row_energy[i] > row_energy[best_row]) {
756 if (col_energy[i] > col_energy[best_col]) {
760 ast_debug(10,
"DTMF best '%c' Erow=%.4E Ecol=%.4E Erc=%.4E Et=%.4E\n",
762 row_energy[best_row], col_energy[best_col],
763 row_energy[best_row] + col_energy[best_col], s->
td.
dtmf.
energy);
772 if ((i != best_col &&
876 if (squelch && hit) {
894 if (squelch && mute.
end) {
895 if (mute.
end > samples) {
906 int samples,
int squelch,
int relax)
925 for (sample = 0; sample < samples; sample = limit) {
935 for (j = sample; j < limit; j++) {
959 if (energy[0] > energy[1]) {
967 for (i = 2; i < 6; i++) {
969 if (energy[i] >= energy[best]) {
972 }
else if (energy[i] >= energy[second_best]) {
983 for (i = 0; i < 6; i++) {
984 if (i != best && i != second_best) {
995 if (second_best < best) {
1000 best = best * 5 + second_best - 1;
1029 if (squelch && hit) {
1039 for (i = 0; i < 6; i++) {
1045 if (squelch && mute.
end) {
1046 if (mute.
end > samples) {
1056static inline int pair_there(
float p1,
float p2,
float i1,
float i2,
float e)
1068 if ((p1 < i1) || (p1 < i2) || (p1 < e)) {
1072 if ((p2 < i1) || (p2 < i2) || (p2 < e)) {
1095 for (x = 0; x <
pass; x++) {
1097 dsp->
genergy += (int32_t) samp * (int32_t) samp;
1098 for (y = 0; y < freqcount; y++) {
1155 if (newstate == dsp->
tstate) {
1172 dsp->
features &= ~DSP_FEATURE_CALL_PROGRESS;
1179 dsp->
features &= ~DSP_FEATURE_CALL_PROGRESS;
1186 dsp->
features &= ~DSP_FEATURE_CALL_PROGRESS;
1193 dsp->
features &= ~DSP_FEATURE_CALL_PROGRESS;
1198 ast_debug(1,
"Consider call as answered because of timeout after last ring\n");
1200 dsp->
features &= ~DSP_FEATURE_CALL_PROGRESS;
1204 ast_debug(5,
"Start state %d\n", newstate);
1210 for (x = 0; x < 7; x++) {
1228 ast_log(
LOG_WARNING,
"Can only check call progress in signed-linear frames, %s not supported\n",
1245 for (x = 0; x <
len; x++) {
1273 if (silence1 < silence2) {
1274 if (silence1 + silence1 *
BUSY_PERCENT / 100 >= silence2) {
1280 if (silence1 - silence1 *
BUSY_PERCENT / 100 <= silence2) {
1295 if (frames_energy) {
1296 *frames_energy = accum;
1304#ifndef BUSYDETECT_TONEONLY
1305 int avgsilence = 0, hitsilence = 0;
1307 int avgtone = 0, hittone = 0;
1317#ifndef BUSYDETECT_TONEONLY
1322#ifndef BUSYDETECT_TONEONLY
1327#ifndef BUSYDETECT_TONEONLY
1348#ifndef BUSYDETECT_TONEONLY
1356#ifdef BUSYDETECT_COMPARE_TONE_AND_SILENCE
1357 if (avgtone > avgsilence) {
1358 if (avgtone - avgtone*
BUSY_PERCENT/100 <= avgsilence) {
1362 if (avgtone + avgtone*
BUSY_PERCENT/100 >= avgsilence) {
1400 ast_debug(5,
"errors = %d max = %d\n", errors, errors_max);
1402 if (errors <= errors_max) {
1410#ifdef BUSYDETECT_DEBUG
1411 ast_debug(5,
"busy detector: avgtone of %d not close enough to desired %d\n",
1417#ifndef BUSYDETECT_TONEONLY
1421#ifdef BUSYDETECT_DEBUG
1422 ast_debug(5,
"busy detector: avgsilence of %d not close enough to desired %d\n",
1429#if !defined(BUSYDETECT_TONEONLY) && defined(BUSYDETECT_DEBUG)
1431 ast_debug(5,
"ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence);
1433 ast_debug(5,
"busy detector: FAILED with avgtone: %d, avgsilence %d\n", avgtone, avgsilence);
1444 unsigned char *odata;
1463 for (x = 0; x <
len; x++) {
1468 for (x = 0; x <
len; x++) {
1472 ast_log(
LOG_WARNING,
"Can only calculate silence on signed-linear, alaw or ulaw frames, %s not supported\n",
1505 int digit = 0, fax_digit = 0, custom_freq_digit = 0;
1508 unsigned char *odata;
1527 for (x = 0; x <
len; x++) {
1532 for (x = 0; x <
len; x++) {
1544 ast_log(
LOG_WARNING,
"Can only do DSP on signed-linear, alaw or ulaw frames (%s not supported)\n",
1561 memset(&dsp->
f, 0,
sizeof(dsp->
f));
1568 memset(&dsp->
f, 0,
sizeof(dsp->
f));
1588 custom_freq_digit =
'q';
1600 int event = 0, event_len = 0;
1601 char event_digit = 0;
1628 ast_debug(1,
"DTMF Detected - Reset busydetector\n");
1633 memset(&dsp->
f, 0,
sizeof(dsp->
f));
1636 dsp->
f.
len = event_len;
1646 memset(&dsp->
f, 0,
sizeof(dsp->
f));
1653 if (custom_freq_digit) {
1656 memset(&dsp->
f, 0,
sizeof(dsp->
f));
1672 memset(&dsp->
f, 0,
sizeof(dsp->
f));
1675 dsp->
f.
src =
"dsp_progress";
1695 for (x = 0; x <
len; x++) {
1696 odata[x] =
AST_LIN2MU((
unsigned short) shortdata[x]);
1699 for (x = 0; x <
len; x++) {
1700 odata[x] =
AST_LIN2A((
unsigned short) shortdata[x]);
1820 for (i = 0; i < 6; i++) {
1829 for (i = 0; i < 4; i++) {
1851 for (x = 0; x < 4; x++) {
1948 if (!strcasecmp(v->
name,
"silencethreshold")) {
1949 if (sscanf(v->
value,
"%30d", &cfg_threshold) < 1) {
1951 }
else if (cfg_threshold < 0) {
1952 ast_log(
LOG_WARNING,
"Invalid silence threshold '%d' specified, using default\n", cfg_threshold);
1956 }
else if (!strcasecmp(v->
name,
"dtmf_normal_twist")) {
1957 if (sscanf(v->
value,
"%30f", &cfg_twist) < 1) {
1959 }
else if ((cfg_twist < 2.0) || (cfg_twist > 100.0)) {
1964 }
else if (!strcasecmp(v->
name,
"dtmf_reverse_twist")) {
1965 if (sscanf(v->
value,
"%30f", &cfg_twist) < 1) {
1967 }
else if ((cfg_twist < 2.0) || (cfg_twist > 100.0)) {
1972 }
else if (!strcasecmp(v->
name,
"relax_dtmf_normal_twist")) {
1973 if (sscanf(v->
value,
"%30f", &cfg_twist) < 1) {
1975 }
else if ((cfg_twist < 2.0) || (cfg_twist > 100.0)) {
1980 }
else if (!strcasecmp(v->
name,
"relax_dtmf_reverse_twist")) {
1981 if (sscanf(v->
value,
"%30f", &cfg_twist) < 1) {
1983 }
else if ((cfg_twist < 2.0) || (cfg_twist > 100.0)) {
1988 }
else if (!strcasecmp(v->
name,
"dtmf_hits_to_begin")) {
1989 if (sscanf(v->
value,
"%30d", &cfg_threshold) < 1) {
1991 }
else if (cfg_threshold < 1) {
1996 }
else if (!strcasecmp(v->
name,
"dtmf_misses_to_end")) {
1997 if (sscanf(v->
value,
"%30d", &cfg_threshold) < 1) {
1999 }
else if (cfg_threshold < 1) {
2016#ifdef TEST_FRAMEWORK
2017static void test_tone_sample_gen(
short *slin_buf,
int samples,
int rate,
int freq,
short amplitude)
2020 double sample_step = 2.0 *
M_PI * freq / rate;
2022 for (idx = 0; idx < samples; ++idx) {
2023 slin_buf[idx] = amplitude * sin(sample_step * idx);
2028#ifdef TEST_FRAMEWORK
2029static void test_tone_sample_gen_add(
short *slin_buf,
int samples,
int rate,
int freq,
short amplitude)
2032 double sample_step = 2.0 *
M_PI * freq / rate;
2034 for (idx = 0; idx < samples; ++idx) {
2035 slin_buf[idx] += amplitude * sin(sample_step * idx);
2040#ifdef TEST_FRAMEWORK
2041static void test_dual_sample_gen(
short *slin_buf,
int samples,
int rate,
int f1,
short a1,
int f2,
short a2)
2043 test_tone_sample_gen(slin_buf, samples, rate, f1, a1);
2044 test_tone_sample_gen_add(slin_buf, samples, rate, f2, a2);
2048#ifdef TEST_FRAMEWORK
2049#define TONE_AMPLITUDE_MAX 0x7fff
2050#define TONE_AMPLITUDE_MIN 80
2061 { .amp_val = TONE_AMPLITUDE_MAX, .detect = 1, },
2062 { .amp_val = 10000, .detect = 1, },
2063 { .amp_val = 1000, .detect = 1, },
2064 { .amp_val = 100, .detect = 1, },
2065 { .amp_val = TONE_AMPLITUDE_MIN, .detect = 1, },
2066 { .amp_val = 75, .detect = 0, },
2067 { .amp_val = 10, .detect = 0, },
2068 { .amp_val = 1, .detect = 0, },
2073 for (idx = 0; idx <
ARRAY_LEN(amp_tests); ++idx) {
2077 ast_debug(1,
"Test %d Hz at amplitude %d\n",
2078 tone_state->
freq, amp_tests[idx].amp_val);
2080 tone_state->
freq, amp_tests[idx].amp_val);
2083 for (duration = 0; !detected && duration < tone_state->
hits_required + 3; ++duration) {
2086 if (amp_tests[idx].detect != detected) {
2094 "Test %d Hz at amplitude %d failed. Detected: %s\n",
2095 tone_state->
freq, amp_tests[idx].amp_val,
2096 detected ?
"yes" :
"no");
2098 "Test %d Hz at amplitude %d failed. Detected: %s\n",
2099 tone_state->
freq, amp_tests[idx].amp_val,
2100 detected ?
"yes" :
"no");
2110#ifdef TEST_FRAMEWORK
2111static int test_dtmf_amplitude_sweep(
struct ast_test *
test,
struct ast_dsp *dsp,
int digit_index)
2126 { .amp_val = TONE_AMPLITUDE_MAX/2, .digit =
dtmf_positions[digit_index], },
2134 { .amp_val = 170, .digit = 0, },
2135 { .amp_val = 100, .digit = 0, },
2140 { .amp_val = TONE_AMPLITUDE_MIN, .digit = 0, },
2141 { .amp_val = 75, .digit = 0, },
2142 { .amp_val = 10, .digit = 0, },
2143 { .amp_val = 1, .digit = 0, },
2146 row = (digit_index >> 2) & 0x03;
2147 column = digit_index & 0x03;
2151 for (idx = 0; idx <
ARRAY_LEN(amp_tests); ++idx) {
2155 ast_debug(1,
"Test '%c' at amplitude %d\n",
2158 (
int)
dtmf_row[row], amp_tests[idx].amp_val,
2159 (
int)
dtmf_col[column], amp_tests[idx].amp_val);
2162 for (duration = 0; !
digit && duration < 3; ++duration) {
2174 "Test '%c' at amplitude %d failed. Detected Digit: '%c'\n",
2178 "Test '%c' at amplitude %d failed. Detected Digit: '%c'\n",
2190#ifdef TEST_FRAMEWORK
2191static int test_dtmf_twist_sweep(
struct ast_test *
test,
struct ast_dsp *dsp,
int digit_index)
2210 { .amp_row = 1000 + 1800, .amp_col = 1000 + 0, .digit = 0, },
2211 { .amp_row = 1000 + 1700, .amp_col = 1000 + 0, .digit = 0, },
2213 { .amp_row = 1000 + 1400, .amp_col = 1000 + 0, .digit =
dtmf_positions[digit_index], },
2214 { .amp_row = 1000 + 1300, .amp_col = 1000 + 0, .digit =
dtmf_positions[digit_index], },
2215 { .amp_row = 1000 + 1200, .amp_col = 1000 + 0, .digit =
dtmf_positions[digit_index], },
2216 { .amp_row = 1000 + 1100, .amp_col = 1000 + 0, .digit =
dtmf_positions[digit_index], },
2217 { .amp_row = 1000 + 1000, .amp_col = 1000 + 0, .digit =
dtmf_positions[digit_index], },
2218 { .amp_row = 1000 + 100, .amp_col = 1000 + 0, .digit =
dtmf_positions[digit_index], },
2219 { .amp_row = 1000 + 0, .amp_col = 1000 + 100, .digit =
dtmf_positions[digit_index], },
2220 { .amp_row = 1000 + 0, .amp_col = 1000 + 200, .digit =
dtmf_positions[digit_index], },
2221 { .amp_row = 1000 + 0, .amp_col = 1000 + 300, .digit =
dtmf_positions[digit_index], },
2222 { .amp_row = 1000 + 0, .amp_col = 1000 + 400, .digit =
dtmf_positions[digit_index], },
2223 { .amp_row = 1000 + 0, .amp_col = 1000 + 500, .digit =
dtmf_positions[digit_index], },
2224 { .amp_row = 1000 + 0, .amp_col = 1000 + 550, .digit =
dtmf_positions[digit_index], },
2226 { .amp_row = 1000 + 0, .amp_col = 1000 + 650, .digit = 0, },
2227 { .amp_row = 1000 + 0, .amp_col = 1000 + 700, .digit = 0, },
2228 { .amp_row = 1000 + 0, .amp_col = 1000 + 800, .digit = 0, },
2230 float save_normal_twist;
2231 float save_reverse_twist;
2238 row = (digit_index >> 2) & 0x03;
2239 column = digit_index & 0x03;
2243 for (idx = 0; idx <
ARRAY_LEN(twist_tests); ++idx) {
2247 ast_debug(1,
"Test '%c' twist row %d col %d amplitudes\n",
2249 twist_tests[idx].amp_row, twist_tests[idx].amp_col);
2251 (
int)
dtmf_row[row], twist_tests[idx].amp_row,
2252 (
int)
dtmf_col[column], twist_tests[idx].amp_col);
2255 for (duration = 0; !
digit && duration < 3; ++duration) {
2267 "Test '%c' twist row %d col %d amplitudes failed. Detected Digit: '%c'\n",
2269 twist_tests[idx].amp_row, twist_tests[idx].amp_col,
2272 "Test '%c' twist row %d col %d amplitudes failed. Detected Digit: '%c'\n",
2274 twist_tests[idx].amp_row, twist_tests[idx].amp_col,
2288#ifdef TEST_FRAMEWORK
2298 lower_freq = tone_state->
freq - 4;
2299 upper_freq = tone_state->
freq + 4;
2304 for (freq = 100; freq <= 3500; freq += 1) {
2307 int expect_detection;
2309 if (freq == tone_state->
freq) {
2314 expect_detection = (lower_freq <= freq && freq <= upper_freq) ? 1 : 0;
2316 ast_debug(1,
"Test %d Hz detection given %d Hz tone at amplitude %d. Range:%d-%d Expect detect: %s\n",
2317 tone_state->
freq, freq, amplitude, lower_freq, upper_freq,
2318 expect_detection ?
"yes" :
"no");
2323 for (duration = 0; !detected && duration < tone_state->
hits_required + 3; ++duration) {
2326 if (expect_detection != detected) {
2334 "Test %d Hz detection given %d Hz tone at amplitude %d failed. Range:%d-%d Detected: %s\n",
2335 tone_state->
freq, freq, amplitude, lower_freq, upper_freq,
2336 detected ?
"yes" :
"no");
2338 "Test %d Hz detection given %d Hz tone at amplitude %d failed. Range:%d-%d Detected: %s\n",
2339 tone_state->
freq, freq, amplitude, lower_freq, upper_freq,
2340 detected ?
"yes" :
"no");
2350#ifdef TEST_FRAMEWORK
2359 info->category =
"/main/dsp/";
2360 info->summary =
"DSP fax tone detect unit test";
2362 "Tests fax tone detection code.";
2406#ifdef TEST_FRAMEWORK
2415 info->name =
"dtmf";
2416 info->category =
"/main/dsp/";
2417 info->summary =
"DSP DTMF detect unit test";
2419 "Tests DTMF detection code.";
2433 if (test_dtmf_amplitude_sweep(
test, dsp, idx)) {
2439 if (test_dtmf_twist_sweep(
test, dsp, idx)) {
2480 .
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.
@ CONFIG_FLAG_FILEUNCHANGED
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category_name)
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
enum ast_frame_type frametype
union ast_frame::@231 data
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
union digit_detect_state_t::@351 td
int digitlen[MAX_DTMF_DIGITS+1]
char digits[MAX_DTMF_DIGITS+1]
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