diff options
Diffstat (limited to 'codec2.h')
-rw-r--r-- | codec2.h | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/codec2.h b/codec2.h new file mode 100644 index 0000000..60532ca --- /dev/null +++ b/codec2.h | |||
@@ -0,0 +1,127 @@ | |||
1 | /*---------------------------------------------------------------------------*\ | ||
2 | |||
3 | FILE........: codec2.h | ||
4 | AUTHOR......: David Rowe | ||
5 | DATE CREATED: 21 August 2010 | ||
6 | |||
7 | Codec 2 fully quantised encoder and decoder functions. If you want use | ||
8 | Codec 2, these are the functions you need to call. | ||
9 | |||
10 | \*---------------------------------------------------------------------------*/ | ||
11 | |||
12 | /* | ||
13 | Copyright (C) 2010 David Rowe | ||
14 | |||
15 | All rights reserved. | ||
16 | |||
17 | This program is free software; you can redistribute it and/or modify | ||
18 | it under the terms of the GNU Lesser General Public License version 2.1, as | ||
19 | published by the Free Software Foundation. This program is | ||
20 | distributed in the hope that it will be useful, but WITHOUT ANY | ||
21 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
22 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public | ||
23 | License for more details. | ||
24 | |||
25 | You should have received a copy of the GNU Lesser General Public License | ||
26 | along with this program; if not, see <http://www.gnu.org/licenses/>. | ||
27 | */ | ||
28 | |||
29 | #ifdef __cplusplus | ||
30 | extern "C" { | ||
31 | #endif | ||
32 | |||
33 | #ifndef __CODEC2__ | ||
34 | #define __CODEC2__ | ||
35 | |||
36 | #include <version.h> | ||
37 | |||
38 | #define CODEC2_MODE_3200 0 | ||
39 | #define CODEC2_MODE_2400 1 | ||
40 | #define CODEC2_MODE_1600 2 | ||
41 | #define CODEC2_MODE_1400 3 | ||
42 | #define CODEC2_MODE_1300 4 | ||
43 | #define CODEC2_MODE_1200 5 | ||
44 | #define CODEC2_MODE_700 6 | ||
45 | #define CODEC2_MODE_700B 7 | ||
46 | #define CODEC2_MODE_700C 8 | ||
47 | #define CODEC2_MODE_450 10 | ||
48 | #define CODEC2_MODE_450PWB 11 | ||
49 | |||
50 | #ifndef CODEC2_MODE_EN_DEFAULT | ||
51 | #define CODEC2_MODE_EN_DEFAULT 1 | ||
52 | #endif | ||
53 | |||
54 | // by default we enable all modes | ||
55 | // disable during compile time with -DCODEC2_MODE_1600_EN=0 | ||
56 | // all but CODEC2 1600 are enabled then | ||
57 | |||
58 | //or the other way round | ||
59 | // -DCODEC2_MODE_EN_DEFAULT=0 -DCODEC2_MODE_1600_EN=1 | ||
60 | // only CODEC2 Mode 1600 | ||
61 | |||
62 | #if !defined(CODEC2_MODE_3200_EN) | ||
63 | #define CODEC2_MODE_3200_EN CODEC2_MODE_EN_DEFAULT | ||
64 | #endif | ||
65 | #if !defined(CODEC2_MODE_2400_EN) | ||
66 | #define CODEC2_MODE_2400_EN CODEC2_MODE_EN_DEFAULT | ||
67 | #endif | ||
68 | #if !defined(CODEC2_MODE_1600_EN) | ||
69 | #define CODEC2_MODE_1600_EN CODEC2_MODE_EN_DEFAULT | ||
70 | #endif | ||
71 | #if !defined(CODEC2_MODE_1400_EN) | ||
72 | #define CODEC2_MODE_1400_EN CODEC2_MODE_EN_DEFAULT | ||
73 | #endif | ||
74 | #if !defined(CODEC2_MODE_1300_EN) | ||
75 | #define CODEC2_MODE_1300_EN CODEC2_MODE_EN_DEFAULT | ||
76 | #endif | ||
77 | #if !defined(CODEC2_MODE_1200_EN) | ||
78 | #define CODEC2_MODE_1200_EN CODEC2_MODE_EN_DEFAULT | ||
79 | #endif | ||
80 | #if !defined(CODEC2_MODE_700_EN) | ||
81 | #define CODEC2_MODE_700_EN CODEC2_MODE_EN_DEFAULT | ||
82 | #endif | ||
83 | #if !defined(CODEC2_MODE_700B_EN) | ||
84 | #define CODEC2_MODE_700B_EN CODEC2_MODE_EN_DEFAULT | ||
85 | #endif | ||
86 | #if !defined(CODEC2_MODE_700C_EN) | ||
87 | #define CODEC2_MODE_700C_EN CODEC2_MODE_EN_DEFAULT | ||
88 | #endif | ||
89 | #if !defined(CODEC2_MODE_450_EN) | ||
90 | #define CODEC2_MODE_450_EN CODEC2_MODE_EN_DEFAULT | ||
91 | #endif | ||
92 | #if !defined(CODEC2_MODE_450PWB_EN) | ||
93 | #define CODEC2_MODE_450PWB_EN CODEC2_MODE_EN_DEFAULT | ||
94 | #endif | ||
95 | |||
96 | #define CODEC2_MODE_ACTIVE(mode_name, var) ((mode_name##_EN) == 0 ? 0: (var) == mode_name) | ||
97 | |||
98 | struct CODEC2; | ||
99 | |||
100 | struct CODEC2 * codec2_create(int mode); | ||
101 | void codec2_destroy(struct CODEC2 *codec2_state); | ||
102 | void codec2_encode(struct CODEC2 *codec2_state, unsigned char * bits, short speech_in[]); | ||
103 | void codec2_decode(struct CODEC2 *codec2_state, short speech_out[], const unsigned char *bits); | ||
104 | void codec2_decode_ber(struct CODEC2 *codec2_state, short speech_out[], const unsigned char *bits, float ber_est); | ||
105 | int codec2_samples_per_frame(struct CODEC2 *codec2_state); | ||
106 | int codec2_bits_per_frame(struct CODEC2 *codec2_state); | ||
107 | |||
108 | void codec2_set_lpc_post_filter(struct CODEC2 *codec2_state, int enable, int bass_boost, float beta, float gamma); | ||
109 | int codec2_get_spare_bit_index(struct CODEC2 *codec2_state); | ||
110 | int codec2_rebuild_spare_bit(struct CODEC2 *codec2_state, int unpacked_bits[]); | ||
111 | void codec2_set_natural_or_gray(struct CODEC2 *codec2_state, int gray); | ||
112 | void codec2_set_softdec(struct CODEC2 *c2, float *softdec); | ||
113 | float codec2_get_energy(struct CODEC2 *codec2_state, const unsigned char *bits); | ||
114 | |||
115 | // support for ML and VQ experiments | ||
116 | void codec2_open_mlfeat(struct CODEC2 *codec2_state, char *filename); | ||
117 | void codec2_load_codebook(struct CODEC2 *codec2_state, int num, char *filename); | ||
118 | float codec2_get_var(struct CODEC2 *codec2_state); | ||
119 | float *codec2_enable_user_ratek(struct CODEC2 *codec2_state, int *K); | ||
120 | void codec2_700c_post_filter(struct CODEC2 *codec2_state, int en); | ||
121 | |||
122 | #endif | ||
123 | |||
124 | #ifdef __cplusplus | ||
125 | } | ||
126 | #endif | ||
127 | |||