Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
64741d84
提交
64741d84
authored
6月 16, 2007
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix tones stuff on 64bit
git-svn-id:
http://svn.openzap.org/svn/openzap/trunk@263
a93c3328-9c30-0410-af19-c9cd2b2d52af
上级
ffbf2620
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
23 行增加
和
34 行删除
+23
-34
libteletone_detect.h
libs/freetdm/src/include/libteletone_detect.h
+6
-13
libteletone_detect.c
libs/freetdm/src/libteletone_detect.c
+17
-21
没有找到文件。
libs/freetdm/src/include/libteletone_detect.h
浏览文件 @
64741d84
...
...
@@ -136,9 +136,9 @@ extern "C" {
/*! \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
;
floa
t
v2
;
floa
t
v3
;
double
fac
;
}
teletone_goertzel_state_t
;
/*! \brief A container for a DTMF detection state.*/
...
...
@@ -153,7 +153,7 @@ extern "C" {
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
;
floa
t
energy
;
int
current_sample
;
char
digits
[
TELETONE_MAX_DTMF_DIGITS
+
1
];
...
...
@@ -165,7 +165,7 @@ extern "C" {
/*! \brief An abstraction to store the coefficient of a tone frequency */
typedef
struct
{
teletone_process_
t
fac
;
floa
t
fac
;
}
teletone_detection_descriptor_t
;
/*! \brief A container for a single multi-tone detection
...
...
@@ -180,7 +180,7 @@ extern "C" {
teletone_goertzel_state_t
gs2
[
TELETONE_MAX_TONES
];
int
tone_count
;
teletone_process_
t
energy
;
floa
t
energy
;
int
current_sample
;
int
min_samples
;
...
...
@@ -253,13 +253,6 @@ extern "C" {
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
);
#ifdef __cplusplus
...
...
libs/freetdm/src/libteletone_detect.c
浏览文件 @
64741d84
...
...
@@ -106,9 +106,8 @@ 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
teletone_process_t
dtmf_row
[]
=
{
697
.
0
,
770
.
0
,
852
.
0
,
941
.
0
};
static
teletone_process_t
dtmf_col
[]
=
{
1209
.
0
,
1336
.
0
,
1477
.
0
,
1633
.
0
};
static
float
dtmf_row
[]
=
{
697
.
0
f
,
770
.
0
f
,
852
.
0
f
,
941
.
0
f
};
static
float
dtmf_col
[]
=
{
1209
.
0
f
,
1336
.
0
f
,
1477
.
0
f
,
1633
.
0
f
};
static
char
dtmf_positions
[]
=
"123A"
"456B"
"789C"
"*0#D"
;
...
...
@@ -122,7 +121,7 @@ void teletone_goertzel_update(teletone_goertzel_state_t *goertzel_state,
int
samples
)
{
int
i
;
teletone_process_
t
v1
;
floa
t
v1
;
for
(
i
=
0
;
i
<
samples
;
i
++
)
{
v1
=
goertzel_state
->
v2
;
...
...
@@ -131,29 +130,26 @@ void teletone_goertzel_update(teletone_goertzel_state_t *goertzel_state,
}
}
teletone_process_t
teletone_goertzel_result
(
teletone_goertzel_state_t
*
goertzel_state
)
{
return
goertzel_state
->
v3
*
goertzel_state
->
v3
+
goertzel_state
->
v2
*
goertzel_state
->
v2
-
goertzel_state
->
v2
*
goertzel_state
->
v3
*
goertzel_state
->
fac
;
}
#define teletone_goertzel_result(gs) ((gs)->v3 * (gs)->v3 + (gs)->v2 * (gs)->v2 - (gs)->v2 * (gs)->v3 * (gs)->fac)
void
teletone_dtmf_detect_init
(
teletone_dtmf_detect_state_t
*
dtmf_detect_state
,
int
sample_rate
)
{
int
i
;
teletone_process_
t
theta
;
floa
t
theta
;
dtmf_detect_state
->
hit1
=
dtmf_detect_state
->
hit2
=
0
;
for
(
i
=
0
;
i
<
GRID_FACTOR
;
i
++
)
{
theta
=
M_TWO_PI
*
(
dtmf_row
[
i
]
/
(
teletone_process_
t
)
sample_rate
);
theta
=
M_TWO_PI
*
(
dtmf_row
[
i
]
/
(
floa
t
)
sample_rate
);
dtmf_detect_row
[
i
].
fac
=
2
.
0
*
cos
(
theta
);
theta
=
M_TWO_PI
*
(
dtmf_col
[
i
]
/
(
teletone_process_
t
)
sample_rate
);
theta
=
M_TWO_PI
*
(
dtmf_col
[
i
]
/
(
floa
t
)
sample_rate
);
dtmf_detect_col
[
i
].
fac
=
2
.
0
*
cos
(
theta
);
theta
=
M_TWO_PI
*
(
dtmf_row
[
i
]
*
2
.
0
/
(
teletone_process_
t
)
sample_rate
);
theta
=
M_TWO_PI
*
(
dtmf_row
[
i
]
*
2
.
0
/
(
floa
t
)
sample_rate
);
dtmf_detect_row_2nd
[
i
].
fac
=
2
.
0
*
cos
(
theta
);
theta
=
M_TWO_PI
*
(
dtmf_col
[
i
]
*
2
.
0
/
(
teletone_process_
t
)
sample_rate
);
theta
=
M_TWO_PI
*
(
dtmf_col
[
i
]
*
2
.
0
/
(
floa
t
)
sample_rate
);
dtmf_detect_col_2nd
[
i
].
fac
=
2
.
0
*
cos
(
theta
);
goertzel_init
(
&
dtmf_detect_state
->
row_out
[
i
],
&
dtmf_detect_row
[
i
]);
...
...
@@ -172,7 +168,7 @@ void teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state,
void
teletone_multi_tone_init
(
teletone_multi_tone_t
*
mt
,
teletone_tone_map_t
*
map
)
{
teletone_process_
t
theta
=
0
;
floa
t
theta
=
0
;
int
x
=
0
;
if
(
!
mt
->
min_samples
)
{
...
...
@@ -200,7 +196,7 @@ void teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *ma
break
;
}
mt
->
tone_count
++
;
theta
=
M_TWO_PI
*
(
map
->
freqs
[
x
]
/
(
teletone_process_
t
)
mt
->
sample_rate
);
theta
=
M_TWO_PI
*
(
map
->
freqs
[
x
]
/
(
floa
t
)
mt
->
sample_rate
);
mt
->
tdd
[
x
].
fac
=
2
.
0
*
cos
(
theta
);
goertzel_init
(
&
mt
->
gs
[
x
],
&
mt
->
tdd
[
x
]);
goertzel_init
(
&
mt
->
gs2
[
x
],
&
mt
->
tdd
[
x
]);
...
...
@@ -213,8 +209,8 @@ int teletone_multi_tone_detect (teletone_multi_tone_t *mt,
int
samples
)
{
int
sample
,
limit
,
j
,
x
=
0
;
teletone_process_
t
v1
,
famp
;
teletone_process_
t
eng_sum
=
0
,
eng_all
[
TELETONE_MAX_TONES
];
floa
t
v1
,
famp
;
floa
t
eng_sum
=
0
,
eng_all
[
TELETONE_MAX_TONES
];
int
gtest
=
0
,
see_hit
=
0
;
for
(
sample
=
0
;
sample
<
samples
;
sample
=
limit
)
{
...
...
@@ -299,10 +295,10 @@ int teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state,
int16_t
sample_buffer
[],
int
samples
)
{
teletone_process_
t
row_energy
[
GRID_FACTOR
];
teletone_process_
t
col_energy
[
GRID_FACTOR
];
teletone_process_
t
famp
;
teletone_process_
t
v1
;
floa
t
row_energy
[
GRID_FACTOR
];
floa
t
col_energy
[
GRID_FACTOR
];
floa
t
famp
;
floa
t
v1
;
int
i
;
int
j
;
int
sample
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论