mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-14 01:49:05 +00:00
update teletone see wiki for syntax changes in TTML
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5276 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -98,11 +98,11 @@ extern "C" {
|
||||
#endif
|
||||
#include <libteletone.h>
|
||||
|
||||
/*! \file libteletone_detect.h
|
||||
\brief Tone Detection Routines
|
||||
/*! \file libteletone_detect.h
|
||||
\brief Tone Detection Routines
|
||||
|
||||
This module is responsible for tone detection specifics
|
||||
*/
|
||||
This module is responsible for tone detection specifics
|
||||
*/
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
@@ -111,17 +111,17 @@ extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Basic DTMF specs:
|
||||
*
|
||||
* Minimum tone on = 40ms
|
||||
* Minimum tone off = 50ms
|
||||
* Maximum digit rate = 10 per second
|
||||
* Normal twist <= 8dB accepted
|
||||
* Reverse twist <= 4dB accepted
|
||||
* S/N >= 15dB will detect OK
|
||||
* Attenuation <= 26dB will detect OK
|
||||
* Frequency tolerance +- 1.5% will detect, +-3.5% will reject
|
||||
*/
|
||||
/* Basic DTMF specs:
|
||||
*
|
||||
* Minimum tone on = 40ms
|
||||
* Minimum tone off = 50ms
|
||||
* Maximum digit rate = 10 per second
|
||||
* Normal twist <= 8dB accepted
|
||||
* Reverse twist <= 4dB accepted
|
||||
* S/N >= 15dB will detect OK
|
||||
* Attenuation <= 26dB will detect OK
|
||||
* Frequency tolerance +- 1.5% will detect, +-3.5% will reject
|
||||
*/
|
||||
|
||||
#define DTMF_THRESHOLD 8.0e7
|
||||
#define DTMF_NORMAL_TWIST 6.3 /* 8dB */
|
||||
@@ -134,131 +134,131 @@ extern "C" {
|
||||
#define BLOCK_LEN 102
|
||||
#define M_TWO_PI 2.0*M_PI
|
||||
|
||||
/*! \brief A continer for the elements of a Goertzel Algorithm (The names are from his formula) */
|
||||
typedef struct {
|
||||
teletone_process_t v2;
|
||||
teletone_process_t v3;
|
||||
teletone_process_t fac;
|
||||
} teletone_goertzel_state_t;
|
||||
/*! \brief A continer for the elements of a Goertzel Algorithm (The names are from his formula) */
|
||||
typedef struct {
|
||||
teletone_process_t v2;
|
||||
teletone_process_t v3;
|
||||
teletone_process_t fac;
|
||||
} teletone_goertzel_state_t;
|
||||
|
||||
/*! \brief A container for a DTMF detection state.*/
|
||||
typedef struct {
|
||||
int hit1;
|
||||
int hit2;
|
||||
int hit3;
|
||||
int hit4;
|
||||
int mhit;
|
||||
/*! \brief A container for a DTMF detection state.*/
|
||||
typedef struct {
|
||||
int hit1;
|
||||
int hit2;
|
||||
int hit3;
|
||||
int hit4;
|
||||
int mhit;
|
||||
|
||||
teletone_goertzel_state_t row_out[GRID_FACTOR];
|
||||
teletone_goertzel_state_t col_out[GRID_FACTOR];
|
||||
teletone_goertzel_state_t row_out2nd[GRID_FACTOR];
|
||||
teletone_goertzel_state_t col_out2nd[GRID_FACTOR];
|
||||
teletone_process_t energy;
|
||||
teletone_goertzel_state_t row_out[GRID_FACTOR];
|
||||
teletone_goertzel_state_t col_out[GRID_FACTOR];
|
||||
teletone_goertzel_state_t row_out2nd[GRID_FACTOR];
|
||||
teletone_goertzel_state_t col_out2nd[GRID_FACTOR];
|
||||
teletone_process_t energy;
|
||||
|
||||
int current_sample;
|
||||
char digits[TELETONE_MAX_DTMF_DIGITS + 1];
|
||||
int current_digits;
|
||||
int detected_digits;
|
||||
int lost_digits;
|
||||
int digit_hits[16];
|
||||
} teletone_dtmf_detect_state_t;
|
||||
int current_sample;
|
||||
char digits[TELETONE_MAX_DTMF_DIGITS + 1];
|
||||
int current_digits;
|
||||
int detected_digits;
|
||||
int lost_digits;
|
||||
int digit_hits[16];
|
||||
} teletone_dtmf_detect_state_t;
|
||||
|
||||
/*! \brief An abstraction to store the coefficient of a tone frequency */
|
||||
typedef struct {
|
||||
teletone_process_t fac;
|
||||
} teletone_detection_descriptor_t;
|
||||
/*! \brief An abstraction to store the coefficient of a tone frequency */
|
||||
typedef struct {
|
||||
teletone_process_t fac;
|
||||
} teletone_detection_descriptor_t;
|
||||
|
||||
/*! \brief A container for a single multi-tone detection
|
||||
TELETONE_MAX_TONES dictates the maximum simultaneous tones that can be present
|
||||
in a multi-tone representation.
|
||||
*/
|
||||
typedef struct {
|
||||
int sample_rate;
|
||||
/*! \brief A container for a single multi-tone detection
|
||||
TELETONE_MAX_TONES dictates the maximum simultaneous tones that can be present
|
||||
in a multi-tone representation.
|
||||
*/
|
||||
typedef struct {
|
||||
int sample_rate;
|
||||
|
||||
teletone_detection_descriptor_t tdd[TELETONE_MAX_TONES];
|
||||
teletone_goertzel_state_t gs[TELETONE_MAX_TONES];
|
||||
teletone_goertzel_state_t gs2[TELETONE_MAX_TONES];
|
||||
int tone_count;
|
||||
teletone_detection_descriptor_t tdd[TELETONE_MAX_TONES];
|
||||
teletone_goertzel_state_t gs[TELETONE_MAX_TONES];
|
||||
teletone_goertzel_state_t gs2[TELETONE_MAX_TONES];
|
||||
int tone_count;
|
||||
|
||||
teletone_process_t energy;
|
||||
int current_sample;
|
||||
teletone_process_t energy;
|
||||
int current_sample;
|
||||
|
||||
int min_samples;
|
||||
int total_samples;
|
||||
int min_samples;
|
||||
int total_samples;
|
||||
|
||||
int positives;
|
||||
int negatives;
|
||||
int hits;
|
||||
int positives;
|
||||
int negatives;
|
||||
int hits;
|
||||
|
||||
int positive_factor;
|
||||
int negative_factor;
|
||||
int hit_factor;
|
||||
int positive_factor;
|
||||
int negative_factor;
|
||||
int hit_factor;
|
||||
|
||||
} teletone_multi_tone_t;
|
||||
} teletone_multi_tone_t;
|
||||
|
||||
|
||||
/*!
|
||||
\brief Initilize a multi-frequency tone detector
|
||||
\param mt the multi-frequency tone descriptor
|
||||
\param map a representation of the multi-frequency tone
|
||||
*/
|
||||
void teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *map);
|
||||
/*!
|
||||
\brief Initilize a multi-frequency tone detector
|
||||
\param mt the multi-frequency tone descriptor
|
||||
\param map a representation of the multi-frequency tone
|
||||
*/
|
||||
void teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *map);
|
||||
|
||||
/*!
|
||||
\brief Check a sample buffer for the presence of the mulit-frequency tone described by mt
|
||||
\param mt the multi-frequency tone descriptor
|
||||
\param sample_buffer an array aof 16 bit signed linear samples
|
||||
\param samples the number of samples present in sample_buffer
|
||||
\return true when the tone was detected or false when it is not
|
||||
*/
|
||||
int teletone_multi_tone_detect (teletone_multi_tone_t *mt,
|
||||
int16_t sample_buffer[],
|
||||
int samples);
|
||||
/*!
|
||||
\brief Check a sample buffer for the presence of the mulit-frequency tone described by mt
|
||||
\param mt the multi-frequency tone descriptor
|
||||
\param sample_buffer an array aof 16 bit signed linear samples
|
||||
\param samples the number of samples present in sample_buffer
|
||||
\return true when the tone was detected or false when it is not
|
||||
*/
|
||||
int teletone_multi_tone_detect (teletone_multi_tone_t *mt,
|
||||
int16_t sample_buffer[],
|
||||
int samples);
|
||||
|
||||
/*!
|
||||
\brief Initilize a DTMF detection state object
|
||||
\param dtmf_detect_state the DTMF detection state to initilize
|
||||
\param sample_rate the desired sample rate
|
||||
*/
|
||||
void teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state, int sample_rate);
|
||||
/*!
|
||||
\brief Initilize a DTMF detection state object
|
||||
\param dtmf_detect_state the DTMF detection state to initilize
|
||||
\param sample_rate the desired sample rate
|
||||
*/
|
||||
void teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state, int sample_rate);
|
||||
|
||||
/*!
|
||||
\brief Check a sample buffer for the presence of DTMF digits
|
||||
\param dtmf_detect_state the detection state object to check
|
||||
\param sample_buffer an array aof 16 bit signed linear samples
|
||||
\param samples the number of samples present in sample_buffer
|
||||
\return true when DTMF was detected or false when it is not
|
||||
*/
|
||||
int teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state,
|
||||
int16_t sample_buffer[],
|
||||
int samples);
|
||||
/*!
|
||||
\brief retrieve any collected digits into a string buffer
|
||||
\param dtmf_detect_state the detection state object to check
|
||||
\param buf the string buffer to write to
|
||||
\param max the maximum length of buf
|
||||
\return the number of characters written to buf
|
||||
*/
|
||||
int teletone_dtmf_get (teletone_dtmf_detect_state_t *dtmf_detect_state,
|
||||
char *buf,
|
||||
int max);
|
||||
|
||||
/*!
|
||||
\brief Step through the Goertzel Algorithm for each sample in a buffer
|
||||
\param goertzel_state the goertzel state to step the samples through
|
||||
\param sample_buffer an array aof 16 bit signed linear samples
|
||||
\param samples the number of samples present in sample_buffer
|
||||
*/
|
||||
void teletone_goertzel_update(teletone_goertzel_state_t *goertzel_state,
|
||||
/*!
|
||||
\brief Check a sample buffer for the presence of DTMF digits
|
||||
\param dtmf_detect_state the detection state object to check
|
||||
\param sample_buffer an array aof 16 bit signed linear samples
|
||||
\param samples the number of samples present in sample_buffer
|
||||
\return true when DTMF was detected or false when it is not
|
||||
*/
|
||||
int teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state,
|
||||
int16_t sample_buffer[],
|
||||
int samples);
|
||||
/*!
|
||||
\brief retrieve any collected digits into a string buffer
|
||||
\param dtmf_detect_state the detection state object to check
|
||||
\param buf the string buffer to write to
|
||||
\param max the maximum length of buf
|
||||
\return the number of characters written to buf
|
||||
*/
|
||||
int teletone_dtmf_get (teletone_dtmf_detect_state_t *dtmf_detect_state,
|
||||
char *buf,
|
||||
int max);
|
||||
|
||||
/*!
|
||||
\brief Compute the result of the last applied step of the Goertzel Algorithm
|
||||
\param goertzel_state the goertzel state to retrieve from
|
||||
\return the computed value for consideration in furthur audio tests
|
||||
*/
|
||||
teletone_process_t teletone_goertzel_result (teletone_goertzel_state_t *goertzel_state);
|
||||
/*!
|
||||
\brief Step through the Goertzel Algorithm for each sample in a buffer
|
||||
\param goertzel_state the goertzel state to step the samples through
|
||||
\param sample_buffer an array aof 16 bit signed linear samples
|
||||
\param samples the number of samples present in sample_buffer
|
||||
*/
|
||||
void teletone_goertzel_update(teletone_goertzel_state_t *goertzel_state,
|
||||
int16_t sample_buffer[],
|
||||
int samples);
|
||||
|
||||
/*!
|
||||
\brief Compute the result of the last applied step of the Goertzel Algorithm
|
||||
\param goertzel_state the goertzel state to retrieve from
|
||||
\return the computed value for consideration in furthur audio tests
|
||||
*/
|
||||
teletone_process_t teletone_goertzel_result (teletone_goertzel_state_t *goertzel_state);
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user