Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
83d74318
提交
83d74318
authored
6月 06, 2007
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add dds to teletone
git-svn-id:
http://svn.openzap.org/svn/openzap/trunk@223
a93c3328-9c30-0410-af19-c9cd2b2d52af
上级
886482c1
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
302 行增加
和
159 行删除
+302
-159
Makefile
libs/freetdm/Makefile
+36
-5
general.makefile
libs/freetdm/general.makefile
+2
-2
libteletone.h
libs/freetdm/src/include/libteletone.h
+17
-12
libteletone_generate.h
libs/freetdm/src/include/libteletone_generate.h
+184
-108
openzap.h
libs/freetdm/src/include/openzap.h
+2
-1
libteletone_detect.c
libs/freetdm/src/libteletone_detect.c
+3
-2
libteletone_generate.c
libs/freetdm/src/libteletone_generate.c
+58
-29
没有找到文件。
libs/freetdm/Makefile
浏览文件 @
83d74318
...
@@ -63,8 +63,34 @@ $(SRC)/zap_zt.o \
...
@@ -63,8 +63,34 @@ $(SRC)/zap_zt.o \
$(SRC)
/zap_wanpipe.o
$(SRC)
/zap_wanpipe.o
HEADERS
=
$(SRC)
/isdn/include/Q931.h
\
HEADERS
=
$(SRC)
/include/fsk.h
\
$(SRC)
/include/openzap.h
$(SRC)
/include/g711.h
\
$(SRC)
/include/hashtable.h
\
$(SRC)
/include/hashtable_itr.h
\
$(SRC)
/include/hashtable_private.h
\
$(SRC)
/include/libteletone_detect.h
\
$(SRC)
/include/libteletone_generate.h
\
$(SRC)
/include/libteletone.h
\
$(SRC)
/include/openzap.h
\
$(SRC)
/include/sangoma_tdm_api.h
\
$(SRC)
/include/uart.h
\
$(SRC)
/include/wanpipe_tdm_api_iface.h
\
$(SRC)
/include/zap_analog.h
\
$(SRC)
/include/zap_buffer.h
\
$(SRC)
/include/zap_config.h
\
$(SRC)
/include/zap_isdn.h
\
$(SRC)
/include/zap_skel.h
\
$(SRC)
/include/zap_threadmutex.h
\
$(SRC)
/include/zap_types.h
\
$(SRC)
/include/zap_wanpipe.h
\
$(SRC)
/include/zap_zt.h
\
$(SRC)
/isdn/include/mfifo.h
\
$(SRC)
/isdn/include/national.h
\
$(SRC)
/isdn/include/Q921.h
\
$(SRC)
/isdn/include/Q931.h
\
$(SRC)
/isdn/include/Q931ie.h
\
$(SRC)
/isdn/include/Q932.h
PWD
=
$(
shell
pwd
)
PWD
=
$(
shell
pwd
)
INCS
=
-I
$(PWD)
/
$(SRC)
//include
-I
$(PWD)
/
$(SRC)
//isdn/include
INCS
=
-I
$(PWD)
/
$(SRC)
//include
-I
$(PWD)
/
$(SRC)
//isdn/include
...
@@ -76,10 +102,12 @@ TMP=-I$(LIBPRI) -I$(SRC)/include -I./src -w
...
@@ -76,10 +102,12 @@ TMP=-I$(LIBPRI) -I$(SRC)/include -I./src -w
include
general.makefile
include
general.makefile
$(OBJS)
:
$(HEADERS)
all
:
$(MYLIB)
all
:
$(MYLIB)
$(MYLIB)
:
$(OBJS) $(HEADERS)
$(MYLIB)
:
$(OBJS) $(HEADERS)
ar rcs
$(MYLIB)
$(OBJS)
ar rcs
$(MYLIB)
$(OBJS)
ranlib
$(MYLIB)
ranlib
$(MYLIB)
testapp
:
$(SRC)/testapp.c $(MYLIB)
testapp
:
$(SRC)/testapp.c $(MYLIB)
...
@@ -88,6 +116,9 @@ testapp: $(SRC)/testapp.c $(MYLIB)
...
@@ -88,6 +116,9 @@ testapp: $(SRC)/testapp.c $(MYLIB)
testcid
:
$(SRC)/testcid.c $(MYLIB)
testcid
:
$(SRC)/testcid.c $(MYLIB)
$(CC)
$(INCS)
-L
.
$(SRC)
/testcid.c
-o
testcid
-lopenzap
-lm
-lpthread
$(CC)
$(INCS)
-L
.
$(SRC)
/testcid.c
-o
testcid
-lopenzap
-lm
-lpthread
testtones
:
$(SRC)/testtones.c $(MYLIB)
$(CC)
$(INCS)
-L
.
$(SRC)
/testtones.c
-o
testtones
-lopenzap
-lm
-lpthread
testisdn
:
$(SRC)/testisdn.c $(MYLIB)
testisdn
:
$(SRC)/testisdn.c $(MYLIB)
$(CC)
$(INCS)
-L
.
$(SRC)
/testisdn.c
-o
testisdn
-lopenzap
-lm
-lpthread
$(CC)
$(INCS)
-L
.
$(SRC)
/testisdn.c
-o
testisdn
-lopenzap
-lm
-lpthread
...
@@ -109,7 +140,7 @@ priserver: $(MYLIB) $(SRC)/priserver.o $(SRC)/sangoma_pri.o $(LIBPRI)/$(LIBPRIA)
...
@@ -109,7 +140,7 @@ priserver: $(MYLIB) $(SRC)/priserver.o $(SRC)/sangoma_pri.o $(LIBPRI)/$(LIBPRIA)
$(SRC)/zap_io.o
:
$(SRC)/zap_io.c
$(SRC)/zap_io.o
:
$(SRC)/zap_io.c
$(CC)
$(MOD_CFLAGS)
$(CC_CFLAGS)
$(CFLAGS)
-c
$<
-o
$@
$(CC)
$(MOD_CFLAGS)
$(CC_CFLAGS)
$(CFLAGS)
-c
$<
-o
$@
%.o
:
%.c
%.o
:
%.c
$(CC)
$(CC_CFLAGS)
$(CFLAGS)
-c
$<
-o
$@
$(CC)
$(CC_CFLAGS)
$(CFLAGS)
-c
$<
-o
$@
dox
:
dox
:
...
@@ -127,6 +158,6 @@ mod_openzap-clean:
...
@@ -127,6 +158,6 @@ mod_openzap-clean:
@
if
[
-f
mod_openzap/mod_openzap.so
]
;
then
cd
mod_openzap
&&
make clean
;
fi
@
if
[
-f
mod_openzap/mod_openzap.so
]
;
then
cd
mod_openzap
&&
make clean
;
fi
clean
:
mod_openzap-clean
clean
:
mod_openzap-clean
rm
-f
$(SRC)
/
*
.o
$(SRC)
/isdn/
*
.o
$(MYLIB)
*
~
\#
*
testapp testcid priserver testisdn testanalog
rm
-f
$(SRC)
/
*
.o
$(SRC)
/isdn/
*
.o
$(MYLIB)
*
~
\#
*
testapp testcid
testtones
priserver testisdn testanalog
@
if
[
-f
$(LIBPRI)
/
$(LIBPRIA)
]
;
then
cd
$(LIBPRI)
&&
make clean
;
fi
@
if
[
-f
$(LIBPRI)
/
$(LIBPRIA)
]
;
then
cd
$(LIBPRI)
&&
make clean
;
fi
libs/freetdm/general.makefile
浏览文件 @
83d74318
CC=gcc
CC=gcc
CC_CFLAGS += -Wall -Werror -Wextra -std=c99 -pedantic -
ansi -Wno-unused-parameter
CC_CFLAGS += -Wall -Werror -Wextra -std=c99 -pedantic -
Wno-unused-parameter
libs/freetdm/src/include/libteletone.h
浏览文件 @
83d74318
...
@@ -73,32 +73,37 @@
...
@@ -73,32 +73,37 @@
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#ifdef _doh
}
#endif
#endif
#endif
#define TELETONE_MAX_DTMF_DIGITS 128
#define TELETONE_MAX_DTMF_DIGITS 128
#define TELETONE_MAX_TONES 6
#define TELETONE_MAX_TONES 6
#define TELETONE_TONE_RANGE 127
#define TELETONE_TONE_RANGE 127
typedef
double
teletone_process_t
;
typedef
double
teletone_process_t
;
/*! \file libteletone.h
\brief Top level include file
/*! \file libteletone.h
This file should be included by applications using the library
\brief Top level include file
*/
This file should be included by applications using the library
/*! \brief An abstraction to store a tone mapping */
*/
typedef
struct
{
/*! An array of tone frequencies */
teletone_process_t
freqs
[
TELETONE_MAX_TONES
];
}
teletone_tone_map_t
;
/*! \brief An abstraction to store a tone mapping */
typedef
struct
{
/*! An array of tone frequencies */
teletone_process_t
freqs
[
TELETONE_MAX_TONES
];
}
teletone_tone_map_t
;
#if !defined(M_PI)
#if !defined(M_PI)
/* C99 systems may not define M_PI */
/* C99 systems may not define M_PI */
#define M_PI 3.14159265358979323846264338327
#define M_PI 3.14159265358979323846264338327
#endif
#endif
#ifdef _MSC_VER
#ifdef _MSC_VER
typedef
__int16
int16_t
;
typedef
__int16
int16_t
;
#endif
#endif
#include <libteletone_generate.h>
#include <libteletone_generate.h>
...
...
libs/freetdm/src/include/libteletone_generate.h
浏览文件 @
83d74318
...
@@ -72,13 +72,30 @@
...
@@ -72,13 +72,30 @@
#define LIBTELETONE_GENERATE_H
#define LIBTELETONE_GENERATE_H
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#ifdef _doh
}
#endif
#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <math.h>
#if !defined(powf)
extern
float
powf
(
float
,
float
);
#endif
#endif
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
#include <math.h>
#ifndef _MSC_VER
#ifndef _MSC_VER
#include <unistd.h>
#include <unistd.h>
#include <stdint.h>
#endif
#endif
#include <fcntl.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/types.h>
...
@@ -87,115 +104,174 @@ extern "C" {
...
@@ -87,115 +104,174 @@ extern "C" {
#include <stdarg.h>
#include <stdarg.h>
#include <libteletone.h>
#include <libteletone.h>
#define TELETONE_VOL_DB_MAX 0
#define TELETONE_VOL_DB_MIN -63
struct
teletone_dds_state
{
uint32_t
phase_rate
;
uint32_t
scale_factor
;
uint32_t
phase_accumulator
;
int16_t
sample
;
int32_t
tx_level
;
};
typedef
struct
teletone_dds_state
teletone_dds_state_t
;
#define SINE_TABLE_MAX 128
#define SINE_TABLE_LEN (SINE_TABLE_MAX - 1)
#define MAX_PHASE_ACCUMULATOR 0x10000 * 0x10000
/* 3.14 == the max power on ulaw (alaw is 3.17) */
/* 3.02 represents twice the power */
#define DBM0_MAX_POWER (3.14f + 3.02f)
const
int16_t
TELETONE_SINES
[
SINE_TABLE_MAX
];
static
__inline__
int16_t
teletone_dds_modulate_sample
(
teletone_dds_state_t
*
dds
)
{
int32_t
bitmask
=
dds
->
phase_accumulator
,
sine_index
=
(
bitmask
>>=
23
)
&
SINE_TABLE_LEN
;
int16_t
sample
;
if
(
bitmask
&
SINE_TABLE_MAX
)
{
sine_index
=
SINE_TABLE_LEN
-
sine_index
;
}
sample
=
TELETONE_SINES
[
sine_index
];
if
(
bitmask
&
(
SINE_TABLE_MAX
*
2
))
{
sample
*=
-
1
;
}
dds
->
phase_accumulator
+=
dds
->
phase_rate
;
return
(
int16_t
)
(
sample
*
dds
->
scale_factor
>>
15
);
}
static
__inline__
void
teletone_dds_state_set_tone
(
teletone_dds_state_t
*
dds
,
float
tone
,
uint32_t
rate
,
float
tx_level
)
{
dds
->
phase_accumulator
=
0
;
dds
->
phase_rate
=
(
int32_t
)
((
tone
*
MAX_PHASE_ACCUMULATOR
)
/
rate
);
if
(
dds
->
tx_level
!=
tx_level
||
!
dds
->
scale_factor
)
{
dds
->
scale_factor
=
(
int
)
(
powf
(
10
.
0
f
,
(
tx_level
-
DBM0_MAX_POWER
)
/
20
.
0
f
)
*
(
32767
.
0
f
*
1
.
414214
f
));
}
dds
->
tx_level
=
tx_level
;
}
static
__inline__
void
teletone_dds_state_set_tx_level
(
teletone_dds_state_t
*
dds
,
float
tx_level
)
{
dds
->
scale_factor
=
(
int
)
(
powf
(
10
.
0
f
,
(
tx_level
-
DBM0_MAX_POWER
)
/
20
.
0
f
)
*
(
32767
.
0
f
*
1
.
414214
f
));
}
/*! \file libteletone_generate.h
\brief Tone Generation Routines
This module is responsible for tone generation specifics
*/
typedef
int16_t
teletone_audio_t
;
struct
teletone_generation_session
;
typedef
int
(
*
tone_handler
)(
struct
teletone_generation_session
*
ts
,
teletone_tone_map_t
*
map
);
/*! \brief An abstraction to store a tone generation session */
struct
teletone_generation_session
{
/*! An array of tone mappings to character mappings */
teletone_tone_map_t
TONES
[
TELETONE_TONE_RANGE
];
/*! The number of channels the output audio should be in */
int
channels
;
/*! The Rate in hz of the output audio */
int
rate
;
/*! The duration (in samples) of the output audio */
int
duration
;
/*! The duration of silence to append after the initial audio is generated */
int
wait
;
/*! The duration (in samples) of the output audio (takes prescedence over actual duration value) */
int
tmp_duration
;
/*! The duration of silence to append after the initial audio is generated (takes prescedence over actual wait value)*/
int
tmp_wait
;
/*! Number of loops to repeat a single instruction*/
int
loops
;
/*! Number of loops to repeat the entire set of instructions*/
int
LOOPS
;
/*! Number to mutiply total samples by to determine when to begin ascent or decent e.g. 0=beginning 4=(last 25%) */
float
decay_factor
;
/*! Direction to perform volume increase/decrease 1/-1*/
int
decay_direction
;
/*! Number of samples between increase/decrease of volume */
int
decay_step
;
/*! Volume factor of the tone */
float
volume
;
/*! Debug on/off */
int
debug
;
/*! FILE stream to write debug data to */
FILE
*
debug_stream
;
/*! Extra user data to attach to the session*/
void
*
user_data
;
/*! Buffer for storing sample data (dynamic) */
teletone_audio_t
*
buffer
;
/*! Size of the buffer */
int
datalen
;
/*! In-Use size of the buffer */
int
samples
;
/*! Callback function called during generation */
int
dynamic
;
tone_handler
handler
;
};
typedef
struct
teletone_generation_session
teletone_generation_session_t
;
/*!
\brief Assign a set of tones to a tone_session indexed by a paticular index/character
\param ts the tone generation session
\param index the index to map the tone to
\param ... up to TELETONE_MAX_TONES frequencies terminated by 0.0
\return 0
*/
int
teletone_set_tone
(
teletone_generation_session_t
*
ts
,
int
index
,
...);
/*!
\brief Assign a set of tones to a single tone map
\param map the map to assign the tones to
\param ... up to TELETONE_MAX_TONES frequencies terminated by 0.0
\return 0
*/
int
teletone_set_map
(
teletone_tone_map_t
*
map
,
...);
/*!
\brief Initilize a tone generation session
\param ts the tone generation session to initilize
\param buflen the size of the buffer(in samples) to dynamically allocate
\param handler a callback function to execute when a tone generation instruction is complete
\param user_data optional user data to send
\return 0
*/
int
teletone_init_session
(
teletone_generation_session_t
*
ts
,
int
buflen
,
tone_handler
handler
,
void
*
user_data
);
/*!
\brief Free the buffer allocated by a tone generation session
\param ts the tone generation session to destroy
\return 0
*/
int
teletone_destroy_session
(
teletone_generation_session_t
*
ts
);
/*!
\brief Execute a single tone generation instruction
\param ts the tone generation session to consult for parameters
\param map the tone mapping to use for the frequencies
\return 0
*/
int
teletone_mux_tones
(
teletone_generation_session_t
*
ts
,
teletone_tone_map_t
*
map
);
/*! \file libteletone_generate.h
/*!
\brief Tone Generation Routines
\brief Execute a tone generation script and call callbacks after each instruction
\param ts the tone generation session to execute on
This module is responsible for tone generation specifics
\param cmd the script to execute
*/
\return 0
*/
typedef
int16_t
teletone_audio_t
;
int
teletone_run
(
teletone_generation_session_t
*
ts
,
char
*
cmd
);
struct
teletone_generation_session
;
typedef
int
(
*
tone_handler
)(
struct
teletone_generation_session
*
ts
,
teletone_tone_map_t
*
map
);
/*! \brief An abstraction to store a tone generation session */
struct
teletone_generation_session
{
/*! An array of tone mappings to character mappings */
teletone_tone_map_t
TONES
[
TELETONE_TONE_RANGE
];
/*! The number of channels the output audio should be in */
int
channels
;
/*! The Rate in hz of the output audio */
int
rate
;
/*! The duration (in samples) of the output audio */
int
duration
;
/*! The duration of silence to append after the initial audio is generated */
int
wait
;
/*! The duration (in samples) of the output audio (takes prescedence over actual duration value) */
int
tmp_duration
;
/*! The duration of silence to append after the initial audio is generated (takes prescedence over actual wait value)*/
int
tmp_wait
;
/*! Number of loops to repeat a single instruction*/
int
loops
;
/*! Number of loops to repeat the entire set of instructions*/
int
LOOPS
;
/*! Number to mutiply total samples by to determine when to begin ascent or decent e.g. 0=beginning 4=(last 25%) */
int
decay_factor
;
/*! Direction to perform volume increase/decrease 1/-1*/
int
decay_direction
;
/*! Number of samples between increase/decrease of volume */
int
decay_step
;
/*! Volume factor of the tone */
int
volume
;
/*! Debug on/off */
int
debug
;
/*! FILE stream to write debug data to */
FILE
*
debug_stream
;
/*! Extra user data to attach to the session*/
void
*
user_data
;
/*! Buffer for storing sample data (dynamic) */
teletone_audio_t
*
buffer
;
/*! Size of the buffer */
int
datalen
;
/*! In-Use size of the buffer */
int
samples
;
/*! Callback function called during generation */
int
dynamic
;
tone_handler
handler
;
};
typedef
struct
teletone_generation_session
teletone_generation_session_t
;
/*!
\brief Assign a set of tones to a tone_session indexed by a paticular index/character
\param ts the tone generation session
\param index the index to map the tone to
\param ... up to TELETONE_MAX_TONES frequencies terminated by 0.0
\return 0
*/
int
teletone_set_tone
(
teletone_generation_session_t
*
ts
,
int
index
,
...);
/*!
\brief Assign a set of tones to a single tone map
\param map the map to assign the tones to
\param ... up to TELETONE_MAX_TONES frequencies terminated by 0.0
\return 0
*/
int
teletone_set_map
(
teletone_tone_map_t
*
map
,
...);
/*!
\brief Initilize a tone generation session
\param ts the tone generation session to initilize
\param buflen the size of the buffer(in samples) to dynamically allocate
\param handler a callback function to execute when a tone generation instruction is complete
\param user_data optional user data to send
\return 0
*/
int
teletone_init_session
(
teletone_generation_session_t
*
ts
,
int
buflen
,
tone_handler
handler
,
void
*
user_data
);
/*!
\brief Free the buffer allocated by a tone generation session
\param ts the tone generation session to destroy
\return 0
*/
int
teletone_destroy_session
(
teletone_generation_session_t
*
ts
);
/*!
\brief Execute a single tone generation instruction
\param ts the tone generation session to consult for parameters
\param map the tone mapping to use for the frequencies
\return 0
*/
int
teletone_mux_tones
(
teletone_generation_session_t
*
ts
,
teletone_tone_map_t
*
map
);
/*!
\brief Execute a tone generation script and call callbacks after each instruction
\param ts the tone generation session to execute on
\param cmd the script to execute
\return 0
*/
int
teletone_run
(
teletone_generation_session_t
*
ts
,
char
*
cmd
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
libs/freetdm/src/include/openzap.h
浏览文件 @
83d74318
...
@@ -34,8 +34,9 @@
...
@@ -34,8 +34,9 @@
#ifndef OPENZAP_H
#ifndef OPENZAP_H
#define OPENZAP_H
#define OPENZAP_H
#ifndef _XOPEN_SOURCE
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE
5
00
#define _XOPEN_SOURCE
6
00
#endif
#endif
#ifndef HAVE_STRINGS_H
#ifndef HAVE_STRINGS_H
...
...
libs/freetdm/src/libteletone_detect.c
浏览文件 @
83d74318
...
@@ -90,7 +90,8 @@
...
@@ -90,7 +90,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
#include <math.h>
#include <libteletone_detect.h>
#ifndef _MSC_VER
#ifndef _MSC_VER
#include <stdint.h>
#include <stdint.h>
#endif
#endif
...
@@ -98,7 +99,7 @@
...
@@ -98,7 +99,7 @@
#include <stdio.h>
#include <stdio.h>
#include <time.h>
#include <time.h>
#include <fcntl.h>
#include <fcntl.h>
#include <libteletone_detect.h>
static
teletone_detection_descriptor_t
dtmf_detect_row
[
GRID_FACTOR
];
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_col
[
GRID_FACTOR
];
...
...
libs/freetdm/src/libteletone_generate.c
浏览文件 @
83d74318
...
@@ -70,6 +70,7 @@
...
@@ -70,6 +70,7 @@
*/
*/
#include <libteletone.h>
#include <libteletone.h>
#define SMAX 32767
#define SMAX 32767
#define SMIN -32768
#define SMIN -32768
#define normalize_to_16bit(n) if (n > SMAX) n = SMAX; else if (n < SMIN) n = SMIN;
#define normalize_to_16bit(n) if (n > SMAX) n = SMAX; else if (n < SMIN) n = SMIN;
...
@@ -78,6 +79,25 @@
...
@@ -78,6 +79,25 @@
#pragma warning(disable:4706)
#pragma warning(disable:4706)
#endif
#endif
const
int16_t
TELETONE_SINES
[
SINE_TABLE_MAX
]
=
{
0x00c9
,
0x025b
,
0x03ed
,
0x057f
,
0x0711
,
0x08a2
,
0x0a33
,
0x0bc4
,
0x0d54
,
0x0ee4
,
0x1073
,
0x1201
,
0x138f
,
0x151c
,
0x16a8
,
0x1833
,
0x19be
,
0x1b47
,
0x1cd0
,
0x1e57
,
0x1fdd
,
0x2162
,
0x22e5
,
0x2467
,
0x25e8
,
0x2768
,
0x28e5
,
0x2a62
,
0x2bdc
,
0x2d55
,
0x2ecc
,
0x3042
,
0x31b5
,
0x3327
,
0x3497
,
0x3604
,
0x3770
,
0x38d9
,
0x3a40
,
0x3ba5
,
0x3d08
,
0x3e68
,
0x3fc6
,
0x4121
,
0x427a
,
0x43d1
,
0x4524
,
0x4675
,
0x47c4
,
0x490f
,
0x4a58
,
0x4b9e
,
0x4ce1
,
0x4e21
,
0x4f5e
,
0x5098
,
0x51cf
,
0x5303
,
0x5433
,
0x5560
,
0x568a
,
0x57b1
,
0x58d4
,
0x59f4
,
0x5b10
,
0x5c29
,
0x5d3e
,
0x5e50
,
0x5f5e
,
0x6068
,
0x616f
,
0x6272
,
0x6371
,
0x646c
,
0x6564
,
0x6657
,
0x6747
,
0x6832
,
0x691a
,
0x69fd
,
0x6add
,
0x6bb8
,
0x6c8f
,
0x6d62
,
0x6e31
,
0x6efb
,
0x6fc2
,
0x7083
,
0x7141
,
0x71fa
,
0x72af
,
0x735f
,
0x740b
,
0x74b3
,
0x7556
,
0x75f4
,
0x768e
,
0x7723
,
0x77b4
,
0x7840
,
0x78c8
,
0x794a
,
0x79c9
,
0x7a42
,
0x7ab7
,
0x7b27
,
0x7b92
,
0x7bf9
,
0x7c5a
,
0x7cb7
,
0x7d0f
,
0x7d63
,
0x7db1
,
0x7dfb
,
0x7e3f
,
0x7e7f
,
0x7eba
,
0x7ef0
,
0x7f22
,
0x7f4e
,
0x7f75
,
0x7f98
,
0x7fb5
,
0x7fce
,
0x7fe2
,
0x7ff1
,
0x7ffa
,
0x7fff
};
int
teletone_set_tone
(
teletone_generation_session_t
*
ts
,
int
index
,
...)
int
teletone_set_tone
(
teletone_generation_session_t
*
ts
,
int
index
,
...)
{
{
...
@@ -122,8 +142,9 @@ int teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_ha
...
@@ -122,8 +142,9 @@ int teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_ha
ts
->
tmp_wait
=
-
1
;
ts
->
tmp_wait
=
-
1
;
ts
->
handler
=
handler
;
ts
->
handler
=
handler
;
ts
->
user_data
=
user_data
;
ts
->
user_data
=
user_data
;
ts
->
volume
=
1500
;
ts
->
volume
=
-
7
;
ts
->
decay_step
=
0
;
ts
->
decay_step
=
0
;
ts
->
decay_factor
=
1
;
if
(
buflen
)
{
if
(
buflen
)
{
if
((
ts
->
buffer
=
calloc
(
buflen
,
sizeof
(
teletone_audio_t
)))
==
0
)
{
if
((
ts
->
buffer
=
calloc
(
buflen
,
sizeof
(
teletone_audio_t
)))
==
0
)
{
return
-
1
;
return
-
1
;
...
@@ -181,34 +202,24 @@ static int ensure_buffer(teletone_generation_session_t *ts, int need)
...
@@ -181,34 +202,24 @@ static int ensure_buffer(teletone_generation_session_t *ts, int need)
int
teletone_mux_tones
(
teletone_generation_session_t
*
ts
,
teletone_tone_map_t
*
map
)
int
teletone_mux_tones
(
teletone_generation_session_t
*
ts
,
teletone_tone_map_t
*
map
)
{
{
teletone_process_t
period
=
(
1
.
0
/
ts
->
rate
)
/
ts
->
channels
;
/*teletone_process_t period = (1.0 / ts->rate) / ts->channels;*/
int
i
,
c
;
int
i
,
c
;
int
freqlen
=
0
;
int
freqlen
=
0
;
teletone_
process
_t
tones
[
TELETONE_MAX_TONES
];
teletone_
dds_state
_t
tones
[
TELETONE_MAX_TONES
];
int
decay
=
0
;
//
int decay = 0;
int
duration
;
int
duration
;
int
wait
=
0
;
int
wait
=
0
;
teletone_process_t
sample
;
int32_t
sample
;
int32_t
dc
=
0
;
float
vol
=
ts
->
volume
;
ts
->
samples
=
0
;
ts
->
samples
=
0
;
memset
(
tones
,
0
,
sizeof
(
tones
[
0
])
*
TELETONE_MAX_TONES
);
duration
=
(
ts
->
tmp_duration
>
-
1
)
?
ts
->
tmp_duration
:
ts
->
duration
;
duration
=
(
ts
->
tmp_duration
>
-
1
)
?
ts
->
tmp_duration
:
ts
->
duration
;
wait
=
(
ts
->
tmp_wait
>
-
1
)
?
ts
->
tmp_wait
:
ts
->
wait
;
wait
=
(
ts
->
tmp_wait
>
-
1
)
?
ts
->
tmp_wait
:
ts
->
wait
;
if
(
map
->
freqs
[
0
]
>
0
)
{
if
(
map
->
freqs
[
0
]
>
0
)
{
if
(
ts
->
decay_step
)
{
if
(
ts
->
decay_factor
)
{
decay
=
(
duration
-
(
duration
/
ts
->
decay_factor
));
}
else
{
decay
=
0
;
}
}
if
(
ts
->
volume
<
0
)
{
ts
->
volume
=
0
;
}
for
(
freqlen
=
0
;
map
->
freqs
[
freqlen
]
&&
freqlen
<
TELETONE_MAX_TONES
;
freqlen
++
)
{
for
(
freqlen
=
0
;
map
->
freqs
[
freqlen
]
&&
freqlen
<
TELETONE_MAX_TONES
;
freqlen
++
)
{
t
ones
[
freqlen
]
=
(
teletone_process_t
)
map
->
freqs
[
freqlen
]
*
(
2
*
M_PI
);
t
eletone_dds_state_set_tone
(
&
tones
[
freqlen
],
map
->
freqs
[
freqlen
],
ts
->
rate
,
vol
);
}
}
if
(
ts
->
channels
>
1
)
{
if
(
ts
->
channels
>
1
)
{
...
@@ -220,17 +231,28 @@ int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *m
...
@@ -220,17 +231,28 @@ int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *m
return
-
1
;
return
-
1
;
}
}
}
}
for
(
ts
->
samples
=
0
;
ts
->
samples
<
ts
->
datalen
&&
ts
->
samples
<
duration
;
ts
->
samples
++
)
{
for
(
ts
->
samples
=
0
;
ts
->
samples
<
ts
->
datalen
&&
ts
->
samples
<
duration
;
ts
->
samples
++
)
{
if
(
ts
->
decay_step
&&
!
(
ts
->
samples
%
ts
->
decay_step
)
&&
ts
->
volume
>
0
&&
ts
->
samples
>
decay
)
{
if
(
ts
->
decay_direction
&&
++
dc
>=
ts
->
decay_step
)
{
ts
->
volume
+=
ts
->
decay_direction
;
float
nvol
=
vol
+
ts
->
decay_direction
*
ts
->
decay_factor
;
int
j
;
if
(
nvol
<=
TELETONE_VOL_DB_MAX
&&
nvol
>=
TELETONE_VOL_DB_MIN
)
{
vol
=
nvol
;
for
(
j
=
0
;
map
->
freqs
[
j
]
&&
j
<
TELETONE_MAX_TONES
;
j
++
)
{
teletone_dds_state_set_tx_level
(
&
tones
[
j
],
vol
);
}
dc
=
0
;
}
}
}
sample
=
(
teletone_process_t
)
128
;
sample
=
128
;
for
(
i
=
0
;
i
<
freqlen
;
i
++
)
{
for
(
i
=
0
;
i
<
freqlen
;
i
++
)
{
sample
+=
((
teletone_process_t
)
2
*
(
ts
->
volume
>
0
?
ts
->
volume
:
1
)
*
cos
(
tones
[
i
]
*
ts
->
samples
*
period
));
int32_t
s
=
teletone_dds_modulate_sample
(
&
tones
[
i
]);
sample
+=
s
;
}
}
normalize_to_16bit
(
sample
)
;
sample
/=
freqlen
;
ts
->
buffer
[
ts
->
samples
]
=
(
teletone_audio_t
)
sample
;
ts
->
buffer
[
ts
->
samples
]
=
(
teletone_audio_t
)
sample
;
for
(
c
=
1
;
c
<
ts
->
channels
;
c
++
)
{
for
(
c
=
1
;
c
<
ts
->
channels
;
c
++
)
{
...
@@ -261,7 +283,8 @@ int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *m
...
@@ -261,7 +283,8 @@ int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *m
fprintf
(
ts
->
debug_stream
,
"%s%0.2f"
,
i
==
0
?
""
:
"+"
,
map
->
freqs
[
i
]);
fprintf
(
ts
->
debug_stream
,
"%s%0.2f"
,
i
==
0
?
""
:
"+"
,
map
->
freqs
[
i
]);
}
}
fprintf
(
ts
->
debug_stream
,
") [volume %d; samples %d(%dms) x %d channel%s; wait %d(%dms); decay_factor %d; decay_step %d; wrote %d bytes]
\n
"
,
fprintf
(
ts
->
debug_stream
,
") [volume %0.2fDb; samples %d(%dms) x %d channel%s; wait %d(%dms); decay_factor %0.2f; decay_step %d(%dms); wrote %d bytes]
\n
"
,
ts
->
volume
,
ts
->
volume
,
duration
,
duration
,
duration
/
(
ts
->
rate
/
1000
),
duration
/
(
ts
->
rate
/
1000
),
...
@@ -271,6 +294,7 @@ int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *m
...
@@ -271,6 +294,7 @@ int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *m
wait
/
(
ts
->
rate
/
1000
),
wait
/
(
ts
->
rate
/
1000
),
ts
->
decay_factor
,
ts
->
decay_factor
,
ts
->
decay_step
,
ts
->
decay_step
,
ts
->
decay_step
/
(
ts
->
rate
/
1000
),
ts
->
samples
*
2
);
ts
->
samples
*
2
);
}
}
}
}
...
@@ -330,18 +354,23 @@ int teletone_run(teletone_generation_session_t *ts, char *cmd)
...
@@ -330,18 +354,23 @@ int teletone_run(teletone_generation_session_t *ts, char *cmd)
ts
->
duration
=
atoi
(
cur
+
2
)
*
(
ts
->
rate
/
1000
);
ts
->
duration
=
atoi
(
cur
+
2
)
*
(
ts
->
rate
/
1000
);
break
;
break
;
case
'v'
:
case
'v'
:
ts
->
volume
=
atoi
(
cur
+
2
);
{
float
vol
=
atof
(
cur
+
2
);
if
(
vol
<=
TELETONE_VOL_DB_MAX
&&
vol
>=
TELETONE_VOL_DB_MIN
)
{
ts
->
volume
=
vol
;
}
}
break
;
break
;
case
'>'
:
case
'>'
:
ts
->
decay_
factor
=
atoi
(
cur
+
2
);
ts
->
decay_
step
=
atoi
(
cur
+
2
)
*
(
ts
->
rate
/
1000
);
ts
->
decay_direction
=
-
1
;
ts
->
decay_direction
=
-
1
;
break
;
break
;
case
'<'
:
case
'<'
:
ts
->
decay_
factor
=
atoi
(
cur
+
2
);
ts
->
decay_
step
=
atoi
(
cur
+
2
)
*
(
ts
->
rate
/
1000
);
ts
->
decay_direction
=
1
;
ts
->
decay_direction
=
1
;
break
;
break
;
case
'+'
:
case
'+'
:
ts
->
decay_
step
=
atoi
(
cur
+
2
);
ts
->
decay_
factor
=
atof
(
cur
+
2
);
break
;
break
;
case
'w'
:
case
'w'
:
ts
->
wait
=
atoi
(
cur
+
2
)
*
(
ts
->
rate
/
1000
);
ts
->
wait
=
atoi
(
cur
+
2
)
*
(
ts
->
rate
/
1000
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论