RTS API Documentation
1.10.11
|
#include <libteletone_detect.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <time.h>
#include <fcntl.h>
Go to the source code of this file.
Macros | |
#define | LOW_ENG 10000000 |
#define | ZC 2 |
#define | teletone_goertzel_result(gs) (double)(((gs)->v3 * (gs)->v3 + (gs)->v2 * (gs)->v2 - (gs)->v2 * (gs)->v3 * (gs)->fac)) |
Functions | |
static void | goertzel_init (teletone_goertzel_state_t *goertzel_state, teletone_detection_descriptor_t *tdesc) |
void | teletone_goertzel_update (teletone_goertzel_state_t *goertzel_state, int16_t sample_buffer[], int samples) |
Step through the Goertzel Algorithm for each sample in a buffer. More... | |
void | teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state, int sample_rate) |
Initilize a DTMF detection state object. More... | |
void | teletone_multi_tone_init (teletone_multi_tone_t *mt, teletone_tone_map_t *map) |
Initilize a multi-frequency tone detector. More... | |
int | teletone_multi_tone_detect (teletone_multi_tone_t *mt, int16_t sample_buffer[], int samples) |
Check a sample buffer for the presence of the mulit-frequency tone described by mt. More... | |
teletone_hit_type_t | teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state, int16_t sample_buffer[], int samples) |
Check a sample buffer for the presence of DTMF digits. More... | |
int | teletone_dtmf_get (teletone_dtmf_detect_state_t *dtmf_detect_state, char *buf, unsigned int *dur) |
retrieve any collected digits into a string buffer More... | |
Variables | |
static teletone_detection_descriptor_t | dtmf_detect_row [GRID_FACTOR] |
static teletone_detection_descriptor_t | dtmf_detect_col [GRID_FACTOR] |
static teletone_detection_descriptor_t | dtmf_detect_row_2nd [GRID_FACTOR] |
static teletone_detection_descriptor_t | dtmf_detect_col_2nd [GRID_FACTOR] |
static float | dtmf_row [] = {697.0f, 770.0f, 852.0f, 941.0f} |
static float | dtmf_col [] = {1209.0f, 1336.0f, 1477.0f, 1633.0f} |
static char | dtmf_positions [] = "123A" "456B" "789C" "*0#D" |
#define LOW_ENG 10000000 |
Definition at line 103 of file libteletone_detect.c.
Referenced by teletone_dtmf_detect().
#define teletone_goertzel_result | ( | gs | ) | (double)(((gs)->v3 * (gs)->v3 + (gs)->v2 * (gs)->v2 - (gs)->v2 * (gs)->v3 * (gs)->fac)) |
Definition at line 137 of file libteletone_detect.c.
Referenced by teletone_dtmf_detect(), and teletone_multi_tone_detect().
#define ZC 2 |
Definition at line 104 of file libteletone_detect.c.
Referenced by teletone_dtmf_detect().
|
static |
Definition at line 115 of file libteletone_detect.c.
References teletone_goertzel_state_t::fac, teletone_detection_descriptor_t::fac, teletone_goertzel_state_t::v2, and teletone_goertzel_state_t::v3.
Referenced by teletone_dtmf_detect(), teletone_dtmf_detect_init(), teletone_multi_tone_detect(), and teletone_multi_tone_init().
teletone_hit_type_t teletone_dtmf_detect | ( | teletone_dtmf_detect_state_t * | dtmf_detect_state, |
int16_t | sample_buffer[], | ||
int | samples | ||
) |
Check a sample buffer for the presence of DTMF digits.
dtmf_detect_state | the detection state object to check |
sample_buffer | an array aof 16 bit signed linear samples |
samples | the number of samples present in sample_buffer |
Definition at line 307 of file libteletone_detect.c.
References BLOCK_LEN, teletone_dtmf_detect_state_t::col_out, teletone_dtmf_detect_state_t::col_out2nd, teletone_dtmf_detect_state_t::current_digits, teletone_dtmf_detect_state_t::current_sample, teletone_dtmf_detect_state_t::detected_digits, teletone_dtmf_detect_state_t::digit, teletone_dtmf_detect_state_t::digit_hits, DTMF_2ND_HARMONIC_COL, DTMF_2ND_HARMONIC_ROW, DTMF_NORMAL_TWIST, dtmf_positions, DTMF_RELATIVE_PEAK_COL, DTMF_RELATIVE_PEAK_ROW, DTMF_REVERSE_TWIST, DTMF_THRESHOLD, teletone_dtmf_detect_state_t::dur, teletone_dtmf_detect_state_t::energy, teletone_goertzel_state_t::fac, goertzel_init(), GRID_FACTOR, teletone_dtmf_detect_state_t::hit1, teletone_dtmf_detect_state_t::hit2, teletone_dtmf_detect_state_t::hit3, teletone_dtmf_detect_state_t::lenergy, teletone_dtmf_detect_state_t::lost_digits, LOW_ENG, teletone_dtmf_detect_state_t::row_out, teletone_dtmf_detect_state_t::row_out2nd, teletone_goertzel_result, TELETONE_MAX_DTMF_DIGITS, TT_HIT_BEGIN, TT_HIT_END, TT_HIT_MIDDLE, teletone_goertzel_state_t::v2, teletone_goertzel_state_t::v3, ZC, and teletone_dtmf_detect_state_t::zc.
Referenced by inband_dtmf_callback().
void teletone_dtmf_detect_init | ( | teletone_dtmf_detect_state_t * | dtmf_detect_state, |
int | sample_rate | ||
) |
Initilize a DTMF detection state object.
dtmf_detect_state | the DTMF detection state to initilize |
sample_rate | the desired sample rate |
Definition at line 139 of file libteletone_detect.c.
References teletone_dtmf_detect_state_t::col_out, teletone_dtmf_detect_state_t::col_out2nd, teletone_dtmf_detect_state_t::current_sample, teletone_dtmf_detect_state_t::detected_digits, teletone_dtmf_detect_state_t::digit, dtmf_col, dtmf_row, teletone_dtmf_detect_state_t::dur, teletone_dtmf_detect_state_t::energy, teletone_detection_descriptor_t::fac, goertzel_init(), GRID_FACTOR, teletone_dtmf_detect_state_t::hit1, teletone_dtmf_detect_state_t::hit2, teletone_dtmf_detect_state_t::lost_digits, M_TWO_PI, teletone_dtmf_detect_state_t::row_out, and teletone_dtmf_detect_state_t::row_out2nd.
Referenced by switch_ivr_inband_dtmf_session().
int teletone_dtmf_get | ( | teletone_dtmf_detect_state_t * | dtmf_detect_state, |
char * | buf, | ||
unsigned int * | dur | ||
) |
retrieve any collected digits into a string buffer
dtmf_detect_state | the detection state object to check |
buf | the string buffer to write to |
max | the maximum length of buf |
Definition at line 461 of file libteletone_detect.c.
References teletone_dtmf_detect_state_t::digit, teletone_dtmf_detect_state_t::dur, and teletone_dtmf_detect_state_t::zc.
Referenced by inband_dtmf_callback().
void teletone_goertzel_update | ( | teletone_goertzel_state_t * | goertzel_state, |
int16_t | sample_buffer[], | ||
int | samples | ||
) |
Step through the Goertzel Algorithm for each sample in a buffer.
goertzel_state | the goertzel state to step the samples through |
sample_buffer | an array aof 16 bit signed linear samples |
samples | the number of samples present in sample_buffer |
Definition at line 120 of file libteletone_detect.c.
References teletone_goertzel_state_t::fac, teletone_goertzel_state_t::v2, and teletone_goertzel_state_t::v3.
int teletone_multi_tone_detect | ( | teletone_multi_tone_t * | mt, |
int16_t | sample_buffer[], | ||
int | samples | ||
) |
Check a sample buffer for the presence of the mulit-frequency tone described by mt.
mt | the multi-frequency tone descriptor |
sample_buffer | an array aof 16 bit signed linear samples |
samples | the number of samples present in sample_buffer |
Definition at line 217 of file libteletone_detect.c.
References teletone_multi_tone_t::current_sample, teletone_multi_tone_t::energy, teletone_goertzel_state_t::fac, goertzel_init(), teletone_multi_tone_t::gs, teletone_multi_tone_t::gs2, teletone_multi_tone_t::hit_factor, teletone_multi_tone_t::hits, teletone_multi_tone_t::min_samples, teletone_multi_tone_t::negative_factor, teletone_multi_tone_t::negatives, teletone_multi_tone_t::positive_factor, teletone_multi_tone_t::positives, teletone_multi_tone_t::tdd, teletone_goertzel_result, TELETONE_MAX_TONES, teletone_multi_tone_t::tone_count, teletone_multi_tone_t::total_samples, teletone_goertzel_state_t::v2, and teletone_goertzel_state_t::v3.
Referenced by tone_detect_callback().
void teletone_multi_tone_init | ( | teletone_multi_tone_t * | mt, |
teletone_tone_map_t * | map | ||
) |
Initilize a multi-frequency tone detector.
mt | the multi-frequency tone descriptor |
map | a representation of the multi-frequency tone |
Definition at line 177 of file libteletone_detect.c.
References teletone_detection_descriptor_t::fac, teletone_tone_map_t::freqs, goertzel_init(), teletone_multi_tone_t::gs, teletone_multi_tone_t::gs2, teletone_multi_tone_t::hit_factor, M_TWO_PI, teletone_multi_tone_t::min_samples, teletone_multi_tone_t::negative_factor, teletone_multi_tone_t::positive_factor, teletone_multi_tone_t::sample_rate, teletone_multi_tone_t::tdd, TELETONE_MAX_TONES, and teletone_multi_tone_t::tone_count.
Referenced by switch_ivr_tone_detect_session().
|
static |
Definition at line 111 of file libteletone_detect.c.
Referenced by teletone_dtmf_detect_init().
|
static |
Definition at line 106 of file libteletone_detect.c.
|
static |
Definition at line 108 of file libteletone_detect.c.
|
static |
Definition at line 105 of file libteletone_detect.c.
|
static |
Definition at line 107 of file libteletone_detect.c.
|
static |
Definition at line 113 of file libteletone_detect.c.
Referenced by teletone_dtmf_detect().
|
static |
Definition at line 110 of file libteletone_detect.c.
Referenced by teletone_dtmf_detect_init().