spandsp
0.0.6
telephony.h
1
/*
2
* SpanDSP - a series of DSP components for telephony
3
*
4
* telephony.h - some very basic telephony definitions
5
*
6
* Written by Steve Underwood <steveu@coppice.org>
7
*
8
* Copyright (C) 2003 Steve Underwood
9
*
10
* All rights reserved.
11
*
12
* This program is free software; you can redistribute it and/or modify
13
* it under the terms of the GNU Lesser General Public License version 2.1,
14
* as published by the Free Software Foundation.
15
*
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU Lesser General Public License for more details.
20
*
21
* You should have received a copy of the GNU Lesser General Public
22
* License along with this program; if not, write to the Free Software
23
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24
*/
25
26
#if !defined(_SPANDSP_TELEPHONY_H_)
27
#define _SPANDSP_TELEPHONY_H_
28
29
#if defined(_M_IX86) || defined(_M_X64)
30
#if defined(LIBSPANDSP_EXPORTS)
31
#define SPAN_DECLARE(type) __declspec(dllexport) type __stdcall
32
#define SPAN_DECLARE_NONSTD(type) __declspec(dllexport) type __cdecl
33
#define SPAN_DECLARE_DATA __declspec(dllexport)
34
#else
35
#define SPAN_DECLARE(type) __declspec(dllimport) type __stdcall
36
#define SPAN_DECLARE_NONSTD(type) __declspec(dllimport) type __cdecl
37
#define SPAN_DECLARE_DATA __declspec(dllimport)
38
#endif
39
#elif defined(SPANDSP_USE_EXPORT_CAPABILITY) && (defined(__GNUC__) || defined(__SUNCC__))
40
#define SPAN_DECLARE(type) __attribute__((visibility("default"))) type
41
#define SPAN_DECLARE_NONSTD(type) __attribute__((visibility("default"))) type
42
#define SPAN_DECLARE_DATA __attribute__((visibility("default")))
43
#else
44
#define SPAN_DECLARE(type)
/**/
type
45
#define SPAN_DECLARE_NONSTD(type)
/**/
type
46
#define SPAN_DECLARE_DATA
/**/
47
#endif
48
49
#define SAMPLE_RATE 8000
50
51
/* This is based on A-law, but u-law is only 0.03dB different */
52
#define DBM0_MAX_POWER (3.14f + 3.02f)
53
#define DBM0_MAX_SINE_POWER (3.14f)
54
/* This is based on the ITU definition of dbOv in G.100.1 */
55
#define DBOV_MAX_POWER (0.0f)
56
#define DBOV_MAX_SINE_POWER (-3.02f)
57
58
/*! \brief A handler for pure receive. The buffer cannot be altered. */
59
typedef
int (span_rx_handler_t)(
void
*s,
const
int16_t amp[],
int
len);
60
61
/*! \brief A handler for receive, where the buffer can be altered. */
62
typedef
int (span_mod_handler_t)(
void
*s, int16_t amp[],
int
len);
63
64
/*! \brief A handler for missing receive data fill-in. */
65
typedef
int (span_rx_fillin_handler_t)(
void
*s,
int
len);
66
67
/*! \brief A handler for transmit, where the buffer will be filled. */
68
typedef
int (span_tx_handler_t)(
void
*s, int16_t amp[],
int
max_len);
69
70
#define ms_to_samples(t) ((t)*(SAMPLE_RATE/1000))
71
#define us_to_samples(t) ((t)/(1000000/SAMPLE_RATE))
72
73
#if !defined(FALSE)
74
#define FALSE 0
75
#endif
76
#if !defined(TRUE)
77
#define TRUE (!FALSE)
78
#endif
79
80
/* Fixed point constant macros */
81
#define FP_Q_9_7(x) ((int16_t) (128.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
82
#define FP_Q_8_8(x) ((int16_t) (256.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
83
#define FP_Q_7_9(x) ((int16_t) (512.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
84
#define FP_Q_6_10(x) ((int16_t) (1024.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
85
#define FP_Q_5_11(x) ((int16_t) (2048.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
86
#define FP_Q_4_12(x) ((int16_t) (4096.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
87
#define FP_Q_3_13(x) ((int16_t) (8192.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
88
#define FP_Q_2_14(x) ((int16_t) (16384.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
89
#define FP_Q_1_15(x) ((int16_t) (32768.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
90
91
#define FP_Q_9_23(x) ((int32_t) (65536.0*128.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
92
#define FP_Q_8_24(x) ((int32_t) (65536.0*256.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
93
#define FP_Q_7_25(x) ((int32_t) (65536.0*512.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
94
#define FP_Q_6_26(x) ((int32_t) (65536.0*1024.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
95
#define FP_Q_5_27(x) ((int32_t) (65536.0*2048.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
96
#define FP_Q_4_28(x) ((int32_t) (65536.0*4096.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
97
#define FP_Q_3_29(x) ((int32_t) (65536.0*8192.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
98
#define FP_Q_2_30(x) ((int32_t) (65536.0*16384.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
99
#define FP_Q_1_31(x) ((int32_t) (65536.0*32768.0*x + ((x >= 0.0) ? 0.5 : -0.5)))
100
101
#if defined(__cplusplus)
102
/* C++ doesn't seem to have sane rounding functions/macros yet */
103
#if !defined(WIN32)
104
#define lrint(x) ((long int) (x))
105
#define lrintf(x) ((long int) (x))
106
#endif
107
#endif
108
109
#endif
110
/*- End of file ------------------------------------------------------------*/
src
spandsp
telephony.h
Generated by
1.8.14