lpcnet  1.0-98-ged4b6a5
Neural Vocoder.
lpcnet.h
1 /* Copyright (c) 2018 Mozilla */
2 /*
3  Redistribution and use in source and binary forms, with or without
4  modification, are permitted provided that the following conditions
5  are met:
6 
7  - Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9 
10  - Redistributions in binary form must reproduce the above copyright
11  notice, this list of conditions and the following disclaimer in the
12  documentation and/or other materials provided with the distribution.
13 
14  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15  ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
18  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
22  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 
27 #ifndef _LPCNET_H_
28 #define _LPCNET_H_
29 
30 #ifndef LPCNET_EXPORT
31 # if defined(WIN32)
32 # if defined(LPCNET_BUILD) && defined(DLL_EXPORT)
33 # define LPCNET_EXPORT __declspec(dllexport)
34 # else
35 # define LPCNET_EXPORT
36 # endif
37 # elif defined(__GNUC__) && defined(LPCNET_BUILD)
38 # define LPCNET_EXPORT __attribute__ ((visibility ("default")))
39 # else
40 # define LPCNET_EXPORT
41 # endif
42 #endif
43 
44 
45 #define NB_FEATURES 20
46 #define NB_TOTAL_FEATURES 36
47 
49 #define LPCNET_COMPRESSED_SIZE 8
51 #define LPCNET_PACKET_SAMPLES (4*160)
53 #define LPCNET_FRAME_SIZE (160)
54 
55 typedef struct LPCNetState LPCNetState;
56 
57 typedef struct LPCNetDecState LPCNetDecState;
58 
59 typedef struct LPCNetEncState LPCNetEncState;
60 
61 typedef struct LPCNetPLCState LPCNetPLCState;
62 
63 
67 LPCNET_EXPORT int lpcnet_decoder_get_size(void);
68 
76 LPCNET_EXPORT int lpcnet_decoder_init(LPCNetDecState *st);
77 
81 LPCNET_EXPORT LPCNetDecState *lpcnet_decoder_create(void);
82 
86 LPCNET_EXPORT void lpcnet_decoder_destroy(LPCNetDecState *st);
87 
94 LPCNET_EXPORT int lpcnet_decode(LPCNetDecState *st, const unsigned char *buf, short *pcm);
95 
96 
97 
101 LPCNET_EXPORT int lpcnet_encoder_get_size(void);
102 
110 LPCNET_EXPORT int lpcnet_encoder_init(LPCNetEncState *st);
111 
115 LPCNET_EXPORT LPCNetEncState *lpcnet_encoder_create(void);
116 
120 LPCNET_EXPORT void lpcnet_encoder_destroy(LPCNetEncState *st);
121 
128 LPCNET_EXPORT int lpcnet_encode(LPCNetEncState *st, const short *pcm, unsigned char *buf);
129 
136 LPCNET_EXPORT int lpcnet_compute_features(LPCNetEncState *st, const short *pcm, float features[4][NB_TOTAL_FEATURES]);
137 
144 LPCNET_EXPORT int lpcnet_compute_single_frame_features(LPCNetEncState *st, const short *pcm, float features[NB_TOTAL_FEATURES]);
145 
149 LPCNET_EXPORT int lpcnet_get_size(void);
150 
158 LPCNET_EXPORT int lpcnet_init(LPCNetState *st);
159 
163 LPCNET_EXPORT LPCNetState *lpcnet_create(void);
164 
168 LPCNET_EXPORT void lpcnet_destroy(LPCNetState *st);
169 
177 LPCNET_EXPORT void lpcnet_synthesize(LPCNetState *st, const float *features, short *output, int N);
178 
179 
180 #define LPCNET_PLC_CAUSAL 0
181 #define LPCNET_PLC_NONCAUSAL 1
182 #define LPCNET_PLC_CODEC 2
183 
184 #define LPCNET_PLC_DC_FILTER 4
185 
186 LPCNET_EXPORT int lpcnet_plc_get_size(void);
187 
188 LPCNET_EXPORT int lpcnet_plc_init(LPCNetPLCState *st, int options);
189 
190 LPCNET_EXPORT LPCNetPLCState *lpcnet_plc_create(int options);
191 
192 LPCNET_EXPORT void lpcnet_plc_destroy(LPCNetPLCState *st);
193 
194 LPCNET_EXPORT int lpcnet_plc_update(LPCNetPLCState *st, short *pcm);
195 
196 LPCNET_EXPORT int lpcnet_plc_conceal(LPCNetPLCState *st, short *pcm);
197 
198 LPCNET_EXPORT void lpcnet_plc_fec_add(LPCNetPLCState *st, const float *features);
199 
200 #endif