]> git.mxchange.org Git - flightgear.git/blob - 3rdparty/hts_engine_API/lib/HTS_hidden.h
295bc2fd44c77187e1b3d6275be153ba51faa55b
[flightgear.git] / 3rdparty / hts_engine_API / lib / HTS_hidden.h
1 /* ----------------------------------------------------------------- */
2 /*           The HMM-Based Speech Synthesis Engine "hts_engine API"  */
3 /*           developed by HTS Working Group                          */
4 /*           http://hts-engine.sourceforge.net/                      */
5 /* ----------------------------------------------------------------- */
6 /*                                                                   */
7 /*  Copyright (c) 2001-2013  Nagoya Institute of Technology          */
8 /*                           Department of Computer Science          */
9 /*                                                                   */
10 /*                2001-2008  Tokyo Institute of Technology           */
11 /*                           Interdisciplinary Graduate School of    */
12 /*                           Science and Engineering                 */
13 /*                                                                   */
14 /* All rights reserved.                                              */
15 /*                                                                   */
16 /* Redistribution and use in source and binary forms, with or        */
17 /* without modification, are permitted provided that the following   */
18 /* conditions are met:                                               */
19 /*                                                                   */
20 /* - Redistributions of source code must retain the above copyright  */
21 /*   notice, this list of conditions and the following disclaimer.   */
22 /* - Redistributions in binary form must reproduce the above         */
23 /*   copyright notice, this list of conditions and the following     */
24 /*   disclaimer in the documentation and/or other materials provided */
25 /*   with the distribution.                                          */
26 /* - Neither the name of the HTS working group nor the names of its  */
27 /*   contributors may be used to endorse or promote products derived */
28 /*   from this software without specific prior written permission.   */
29 /*                                                                   */
30 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND            */
31 /* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,       */
32 /* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF          */
33 /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE          */
34 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS */
35 /* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,          */
36 /* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED   */
37 /* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,     */
38 /* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
39 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,   */
40 /* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY    */
41 /* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE           */
42 /* POSSIBILITY OF SUCH DAMAGE.                                       */
43 /* ----------------------------------------------------------------- */
44
45 #ifndef HTS_HIDDEN_H
46 #define HTS_HIDDEN_H
47
48 #ifdef __cplusplus
49 #define HTS_HIDDEN_H_START extern "C" {
50 #define HTS_HIDDEN_H_END   }
51 #else
52 #define HTS_HIDDEN_H_START
53 #define HTS_HIDDEN_H_END
54 #endif                          /* __CPLUSPLUS */
55
56 HTS_HIDDEN_H_START;
57
58 /* hts_engine libraries */
59 #include "HTS_engine.h"
60
61 /* common ---------------------------------------------------------- */
62
63 #define HTS_MAXBUFLEN 1024
64
65 #if !defined(WORDS_BIGENDIAN) && !defined(WORDS_LITTLEENDIAN)
66 #define WORDS_LITTLEENDIAN
67 #endif                          /* !WORDS_BIGENDIAN && !WORDS_LITTLEENDIAN */
68 #if defined(WORDS_BIGENDIAN) && defined(WORDS_LITTLEENDIAN)
69 #undef WORDS_BIGENDIAN
70 #endif                          /* WORDS_BIGENDIAN && WORDS_LITTLEENDIAN */
71
72 #define MAX_F0    20000.0
73 #define MIN_F0    20.0
74 #define MAX_LF0   9.9034875525361280454891979401956     /* log(20000.0) */
75 #define MIN_LF0   2.9957322735539909934352235761425     /* log(20.0) */
76 #define HALF_TONE 0.05776226504666210911810267678818    /* log(2.0) / 12.0 */
77 #define DB        0.11512925464970228420089957273422    /* log(10.0) / 20.0 */
78
79 /* misc ------------------------------------------------------------ */
80
81 typedef struct _HTS_File {
82    unsigned char type;
83    void *pointer;
84 } HTS_File;
85
86 /* HTS_fopen: wrapper for fopen */
87 HTS_File *HTS_fopen_from_fn(const char *name, const char *opt);
88
89 /* HTS_fopen_from_fp: wrapper for fopen */
90 HTS_File *HTS_fopen_from_fp(HTS_File * fp, size_t size);
91
92 /* HTS_fopen_from_data: wrapper for fopen */
93 HTS_File *HTS_fopen_from_data(void *data, size_t size);
94
95 /* HTS_fclose: wrapper for fclose */
96 void HTS_fclose(HTS_File * fp);
97
98 /* HTS_fgetc: wrapper for fgetc */
99 int HTS_fgetc(HTS_File * fp);
100
101 /* HTS_feof: wrapper for feof */
102 int HTS_feof(HTS_File * fp);
103
104 /* HTS_fseek: wrapper for fseek */
105 int HTS_fseek(HTS_File * fp, long offset, int origin);
106
107 /* HTS_ftell: wrapper for ftell */
108 size_t HTS_ftell(HTS_File * fp);
109
110 /* HTS_fread_big_endiana: fread with byteswap */
111 size_t HTS_fread_big_endian(void *buf, size_t size, size_t n, HTS_File * fp);
112
113 /* HTS_fread_little_endiana: fread with byteswap */
114 size_t HTS_fread_little_endian(void *buf, size_t size, size_t n, HTS_File * fp);
115
116 /* HTS_fwrite_little_endian: fwrite with byteswap */
117 size_t HTS_fwrite_little_endian(const void *buf, size_t size, size_t n, FILE * fp);
118
119 /* HTS_get_pattern_token: get pattern token (single/double quote can be used) */
120 HTS_Boolean HTS_get_pattern_token(HTS_File * fp, char *buff);
121
122 /* HTS_get_token: get token from file pointer (separators are space,tab,line break) */
123 HTS_Boolean HTS_get_token_from_fp(HTS_File * fp, char *buff);
124
125 /* HTS_get_token: get token from file pointer with specified separator */
126 HTS_Boolean HTS_get_token_from_fp_with_separator(HTS_File * fp, char *buff, char separator);
127
128 /* HTS_get_token_from_string: get token from string (separator are space,tab,line break) */
129 HTS_Boolean HTS_get_token_from_string(const char *string, size_t * index, char *buff);
130
131 /* HTS_get_token_from_string_with_separator: get token from string with specified separator */
132 HTS_Boolean HTS_get_token_from_string_with_separator(const char *str, size_t * index, char *buff, char separator);
133
134 /* HTS_calloc: wrapper for calloc */
135 void *HTS_calloc(const size_t num, const size_t size);
136
137 /* HTS_strdup: wrapper for strdup */
138 char *HTS_strdup(const char *string);
139
140 /* HTS_calloc_matrix: allocate double matrix */
141 double **HTS_alloc_matrix(size_t x, size_t y);
142
143 /* HTS_free_matrix: free double matrix */
144 void HTS_free_matrix(double **p, size_t x);
145
146 /* HTS_Free: wrapper for free */
147 void HTS_free(void *p);
148
149 /* HTS_error: output error message */
150 void HTS_error(int error, const char *message, ...);
151
152 /* audio ----------------------------------------------------------- */
153
154 /* HTS_Audio_initialize: initialize audio */
155 void HTS_Audio_initialize(HTS_Audio * audio);
156
157 /* HTS_Audio_set_parameter: set parameters for audio */
158 void HTS_Audio_set_parameter(HTS_Audio * audio, size_t sampling_frequency, size_t max_buff_size);
159
160 /* HTS_Audio_write: send data to audio */
161 void HTS_Audio_write(HTS_Audio * audio, short data);
162
163 /* HTS_Audio_flush: flush remain data */
164 void HTS_Audio_flush(HTS_Audio * audio);
165
166 /* HTS_Audio_clear: free audio */
167 void HTS_Audio_clear(HTS_Audio * audio);
168
169 /* model ----------------------------------------------------------- */
170
171 /* HTS_ModelSet_initialize: initialize model set */
172 void HTS_ModelSet_initialize(HTS_ModelSet * ms);
173
174 /* HTS_ModelSet_load: load HTS voices */
175 HTS_Boolean HTS_ModelSet_load(HTS_ModelSet * ms, char **voices, size_t num_voices);
176
177 /* HTS_ModelSet_get_sampling_frequency: get sampling frequency of HTS voices */
178 size_t HTS_ModelSet_get_sampling_frequency(HTS_ModelSet * ms);
179
180 /* HTS_ModelSet_get_fperiod: get frame period of HTS voices */
181 size_t HTS_ModelSet_get_fperiod(HTS_ModelSet * ms);
182
183 /* HTS_ModelSet_get_fperiod: get stream option */
184 const char *HTS_ModelSet_get_option(HTS_ModelSet * ms, size_t stream_index);
185
186 /* HTS_ModelSet_get_gv_flag: get GV flag */
187 HTS_Boolean HTS_ModelSet_get_gv_flag(HTS_ModelSet * ms, const char *string);
188
189 /* HTS_ModelSet_get_nstate: get number of state */
190 size_t HTS_ModelSet_get_nstate(HTS_ModelSet * ms);
191
192 /* HTS_ModelSet_get_nstream: get number of stream */
193 size_t HTS_ModelSet_get_nstream(HTS_ModelSet * ms);
194
195 /* HTS_ModelSet_get_nvoices: get number of HTS voices */
196 size_t HTS_ModelSet_get_nvoices(HTS_ModelSet * ms);
197
198 /* HTS_ModelSet_get_vector_length: get vector length */
199 size_t HTS_ModelSet_get_vector_length(HTS_ModelSet * ms, size_t stream_index);
200
201 /* HTS_ModelSet_is_msd: get MSD flag */
202 HTS_Boolean HTS_ModelSet_is_msd(HTS_ModelSet * ms, size_t stream_index);
203
204 /* HTS_ModelSet_get_window_size: get dynamic window size */
205 size_t HTS_ModelSet_get_window_size(HTS_ModelSet * ms, size_t stream_index);
206
207 /* HTS_ModelSet_get_window_left_width: get left width of dynamic window */
208 int HTS_ModelSet_get_window_left_width(HTS_ModelSet * ms, size_t stream_index, size_t window_index);
209
210 /* HTS_ModelSet_get_window_right_width: get right width of dynamic window */
211 int HTS_ModelSet_get_window_right_width(HTS_ModelSet * ms, size_t stream_index, size_t window_index);
212
213 /* HTS_ModelSet_get_window_coefficient: get coefficient of dynamic window */
214 double HTS_ModelSet_get_window_coefficient(HTS_ModelSet * ms, size_t stream_index, size_t window_index, size_t coefficient_index);
215
216 /* HTS_ModelSet_get_window_max_width: get max width of dynamic window */
217 size_t HTS_ModelSet_get_window_max_width(HTS_ModelSet * ms, size_t stream_index);
218
219 /* HTS_ModelSet_use_gv: get GV flag */
220 HTS_Boolean HTS_ModelSet_use_gv(HTS_ModelSet * ms, size_t stream_index);
221
222 /* HTS_ModelSet_get_duration_index: get index of duration tree and PDF */
223 void HTS_ModelSet_get_duration_index(HTS_ModelSet * ms, size_t voice_index, const char *string, size_t * tree_index, size_t * pdf_index);
224
225 /* HTS_ModelSet_get_duration: get duration using interpolation weight */
226 void HTS_ModelSet_get_duration(HTS_ModelSet * ms, const char *string, const double *iw, double *mean, double *vari);
227
228 /* HTS_ModelSet_get_parameter_index: get index of parameter tree and PDF */
229 void HTS_ModelSet_get_parameter_index(HTS_ModelSet * ms, size_t voice_index, size_t stream_index, size_t state_index, const char *string, size_t * tree_index, size_t * pdf_index);
230
231 /* HTS_ModelSet_get_parameter: get parameter using interpolation weight */
232 void HTS_ModelSet_get_parameter(HTS_ModelSet * ms, size_t stream_index, size_t state_index, const char *string, const double *iw, double *mean, double *vari, double *msd);
233
234 void HTS_ModelSet_get_gv_index(HTS_ModelSet * ms, size_t voice_index, size_t stream_index, const char *string, size_t * tree_index, size_t * pdf_index);
235
236 /* HTS_ModelSet_get_gv: get GV using interpolation weight */
237 void HTS_ModelSet_get_gv(HTS_ModelSet * ms, size_t stream_index, const char *string, const double *iw, double *mean, double *vari);
238
239 /* HTS_ModelSet_clear: free model set */
240 void HTS_ModelSet_clear(HTS_ModelSet * ms);
241
242 /* label ----------------------------------------------------------- */
243
244 /* HTS_Label_initialize: initialize label */
245 void HTS_Label_initialize(HTS_Label * label);
246
247 /* HTS_Label_load_from_fn: load label from file name */
248 void HTS_Label_load_from_fn(HTS_Label * label, size_t sampling_rate, size_t fperiod, const char *fn);
249
250 /* HTS_Label_load_from_strings: load label list from string list */
251 void HTS_Label_load_from_strings(HTS_Label * label, size_t sampling_rate, size_t fperiod, char **lines, size_t num_lines);
252
253 /* HTS_Label_get_size: get number of label string */
254 size_t HTS_Label_get_size(HTS_Label * label);
255
256 /* HTS_Label_get_string: get label string */
257 const char *HTS_Label_get_string(HTS_Label * label, size_t index);
258
259 /* HTS_Label_get_start_frame: get start frame */
260 double HTS_Label_get_start_frame(HTS_Label * label, size_t index);
261
262 /* HTS_Label_get_end_frame: get end frame */
263 double HTS_Label_get_end_frame(HTS_Label * label, size_t index);
264
265 /* HTS_Label_clear: free label */
266 void HTS_Label_clear(HTS_Label * label);
267
268 /* sstream --------------------------------------------------------- */
269
270 /* HTS_SStreamSet_initialize: initialize state stream set */
271 void HTS_SStreamSet_initialize(HTS_SStreamSet * sss);
272
273 /* HTS_SStreamSet_create: parse label and determine state duration */
274 HTS_Boolean HTS_SStreamSet_create(HTS_SStreamSet * sss, HTS_ModelSet * ms, HTS_Label * label, HTS_Boolean phoneme_alignment_flag, double speed, double *duration_iw, double **parameter_iw, double **gv_iw);
275
276 /* HTS_SStreamSet_get_nstream: get number of stream */
277 size_t HTS_SStreamSet_get_nstream(HTS_SStreamSet * sss);
278
279 /* HTS_SStreamSet_get_vector_length: get vector length */
280 size_t HTS_SStreamSet_get_vector_length(HTS_SStreamSet * sss, size_t stream_index);
281
282 /* HTS_SStreamSet_is_msd: get MSD flag */
283 HTS_Boolean HTS_SStreamSet_is_msd(HTS_SStreamSet * sss, size_t stream_index);
284
285 /* HTS_SStreamSet_get_total_state: get total number of state */
286 size_t HTS_SStreamSet_get_total_state(HTS_SStreamSet * sss);
287
288 /* HTS_SStreamSet_get_total_frame: get total number of frame */
289 size_t HTS_SStreamSet_get_total_frame(HTS_SStreamSet * sss);
290
291 /* HTS_SStreamSet_get_msd: get msd parameter */
292 double HTS_SStreamSet_get_msd(HTS_SStreamSet * sss, size_t stream_index, size_t state_index);
293
294 /* HTS_SStreamSet_window_size: get dynamic window size */
295 size_t HTS_SStreamSet_get_window_size(HTS_SStreamSet * sss, size_t stream_index);
296
297 /* HTS_SStreamSet_get_window_left_width: get left width of dynamic window */
298 int HTS_SStreamSet_get_window_left_width(HTS_SStreamSet * sss, size_t stream_index, size_t window_index);
299
300 /* HTS_SStreamSet_get_window_right_width: get right width of dynamic window */
301 int HTS_SStreamSet_get_window_right_width(HTS_SStreamSet * sss, size_t stream_index, size_t window_index);
302
303 /* HTS_SStreamSet_get_window_coefficient: get coefficient of dynamic window */
304 double HTS_SStreamSet_get_window_coefficient(HTS_SStreamSet * sss, size_t stream_index, size_t window_index, int coefficient_index);
305
306 /* HTS_SStreamSet_get_window_max_width: get max width of dynamic window */
307 size_t HTS_SStreamSet_get_window_max_width(HTS_SStreamSet * sss, size_t stream_index);
308
309 /* HTS_SStreamSet_use_gv: get GV flag */
310 HTS_Boolean HTS_SStreamSet_use_gv(HTS_SStreamSet * sss, size_t stream_index);
311
312 /* HTS_SStreamSet_get_duration: get state duration */
313 size_t HTS_SStreamSet_get_duration(HTS_SStreamSet * sss, size_t state_index);
314
315 /* HTS_SStreamSet_get_mean: get mean parameter */
316 double HTS_SStreamSet_get_mean(HTS_SStreamSet * sss, size_t stream_index, size_t state_index, size_t vector_index);
317
318 /* HTS_SStreamSet_set_mean: set mean parameter */
319 void HTS_SStreamSet_set_mean(HTS_SStreamSet * sss, size_t stream_index, size_t state_index, size_t vector_index, double f);
320
321 /* HTS_SStreamSet_get_vari: get variance parameter */
322 double HTS_SStreamSet_get_vari(HTS_SStreamSet * sss, size_t stream_index, size_t state_index, size_t vector_index);
323
324 /* HTS_SStreamSet_set_vari: set variance parameter */
325 void HTS_SStreamSet_set_vari(HTS_SStreamSet * sss, size_t stream_index, size_t state_index, size_t vector_index, double f);
326
327 /* HTS_SStreamSet_get_gv_mean: get GV mean parameter */
328 double HTS_SStreamSet_get_gv_mean(HTS_SStreamSet * sss, size_t stream_index, size_t vector_index);
329
330 /* HTS_SStreamSet_get_gv_mean: get GV variance parameter */
331 double HTS_SStreamSet_get_gv_vari(HTS_SStreamSet * sss, size_t stream_index, size_t vector_index);
332
333 /* HTS_SStreamSet_set_gv_switch: set GV switch */
334 void HTS_SStreamSet_set_gv_switch(HTS_SStreamSet * sss, size_t stream_index, size_t state_index, HTS_Boolean i);
335
336 /* HTS_SStreamSet_get_gv_switch: get GV switch */
337 HTS_Boolean HTS_SStreamSet_get_gv_switch(HTS_SStreamSet * sss, size_t stream_index, size_t state_index);
338
339 /* HTS_SStreamSet_clear: free state stream set */
340 void HTS_SStreamSet_clear(HTS_SStreamSet * sss);
341
342 /* pstream --------------------------------------------------------- */
343
344 /* check variance in finv() */
345 #define INFTY   ((double) 1.0e+38)
346 #define INFTY2  ((double) 1.0e+19)
347 #define INVINF  ((double) 1.0e-38)
348 #define INVINF2 ((double) 1.0e-19)
349
350 /* GV */
351 #define STEPINIT 0.1
352 #define STEPDEC  0.5
353 #define STEPINC  1.2
354 #define W1       1.0
355 #define W2       1.0
356 #define GV_MAX_ITERATION 5
357
358 /* HTS_PStreamSet_initialize: initialize parameter stream set */
359 void HTS_PStreamSet_initialize(HTS_PStreamSet * pss);
360
361 /* HTS_PStreamSet_create: parameter generation using GV weight */
362 HTS_Boolean HTS_PStreamSet_create(HTS_PStreamSet * pss, HTS_SStreamSet * sss, double *msd_threshold, double *gv_weight);
363
364 /* HTS_PStreamSet_get_nstream: get number of stream */
365 size_t HTS_PStreamSet_get_nstream(HTS_PStreamSet * pss);
366
367 /* HTS_PStreamSet_get_static_length: get features length */
368 size_t HTS_PStreamSet_get_vector_length(HTS_PStreamSet * pss, size_t stream_index);
369
370 /* HTS_PStreamSet_get_total_frame: get total number of frame */
371 size_t HTS_PStreamSet_get_total_frame(HTS_PStreamSet * pss);
372
373 /* HTS_PStreamSet_get_parameter: get parameter */
374 double HTS_PStreamSet_get_parameter(HTS_PStreamSet * pss, size_t stream_index, size_t frame_index, size_t vector_index);
375
376 /* HTS_PStreamSet_get_parameter_vector: get parameter vector */
377 double *HTS_PStreamSet_get_parameter_vector(HTS_PStreamSet * pss, size_t stream_index, size_t frame_index);
378
379 /* HTS_PStreamSet_get_msd_flag: get generated MSD flag per frame */
380 HTS_Boolean HTS_PStreamSet_get_msd_flag(HTS_PStreamSet * pss, size_t stream_index, size_t frame_index);
381
382 /* HTS_PStreamSet_is_msd: get MSD flag */
383 HTS_Boolean HTS_PStreamSet_is_msd(HTS_PStreamSet * pss, size_t stream_index);
384
385 /* HTS_PStreamSet_clear: free parameter stream set */
386 void HTS_PStreamSet_clear(HTS_PStreamSet * pss);
387
388 /* gstream --------------------------------------------------------- */
389
390 /* HTS_GStreamSet_initialize: initialize generated parameter stream set */
391 void HTS_GStreamSet_initialize(HTS_GStreamSet * gss);
392
393 /* HTS_GStreamSet_create: generate speech */
394 HTS_Boolean HTS_GStreamSet_create(HTS_GStreamSet * gss, HTS_PStreamSet * pss, size_t stage, HTS_Boolean use_log_gain, size_t sampling_rate, size_t fperiod, double alpha, double beta, HTS_Boolean * stop, double volume, HTS_Audio * audio);
395
396 /* HTS_GStreamSet_get_total_nsamples: get total number of sample */
397 size_t HTS_GStreamSet_get_total_nsamples(HTS_GStreamSet * gss);
398
399 /* HTS_GStreamSet_get_total_frame: get total number of frame */
400 size_t HTS_GStreamSet_get_total_frame(HTS_GStreamSet * gss);
401
402 /* HTS_GStreamSet_get_static_length: get features length */
403 size_t HTS_GStreamSet_get_vector_length(HTS_GStreamSet * gss, size_t stream_index);
404
405 /* HTS_GStreamSet_get_speech: get synthesized speech parameter */
406 double HTS_GStreamSet_get_speech(HTS_GStreamSet * gss, size_t sample_index);
407
408 /* HTS_GStreamSet_get_parameter: get generated parameter */
409 double HTS_GStreamSet_get_parameter(HTS_GStreamSet * gss, size_t stream_index, size_t frame_index, size_t vector_index);
410
411 /* HTS_GStreamSet_clear: free generated parameter stream set */
412 void HTS_GStreamSet_clear(HTS_GStreamSet * gss);
413
414 /* vocoder --------------------------------------------------------- */
415
416 #ifndef LZERO
417 #define LZERO (-1.0e+10)        /* ~log(0) */
418 #endif                          /* !LZERO */
419
420 #ifndef ZERO
421 #define ZERO  (1.0e-10)         /* ~(0) */
422 #endif                          /* !ZERO */
423
424 #ifndef PI
425 #define PI  3.14159265358979323846
426 #endif                          /* !PI */
427
428 #ifndef PI2
429 #define PI2 6.28318530717958647692
430 #endif                          /* !PI2 */
431
432 #define RANDMAX 32767
433
434 #define SEED    1
435 #define B0      0x00000001
436 #define B28     0x10000000
437 #define B31     0x80000000
438 #define B31_    0x7fffffff
439 #define Z       0x00000000
440
441 #ifdef HTS_EMBEDDED
442 #define GAUSS     FALSE
443 #define PADEORDER 4             /* pade order (for MLSA filter) */
444 #define IRLENG    384           /* length of impulse response */
445 #else
446 #define GAUSS     TRUE
447 #define PADEORDER 5
448 #define IRLENG    576
449 #endif                          /* HTS_EMBEDDED */
450
451 #define CHECK_LSP_STABILITY_MIN 0.25
452 #define CHECK_LSP_STABILITY_NUM 4
453
454 /* for MGLSA filter */
455 #define NORMFLG1 TRUE
456 #define NORMFLG2 FALSE
457 #define MULGFLG1 TRUE
458 #define MULGFLG2 FALSE
459 #define NGAIN    FALSE
460
461 /* HTS_Vocoder: structure for setting of vocoder */
462 typedef struct _HTS_Vocoder {
463    HTS_Boolean is_first;
464    size_t stage;                /* Gamma=-1/stage: if stage=0 then Gamma=0 */
465    double gamma;                /* Gamma */
466    HTS_Boolean use_log_gain;    /* log gain flag (for LSP) */
467    size_t fprd;                 /* frame shift */
468    unsigned long next;          /* temporary variable for random generator */
469    HTS_Boolean gauss;           /* flag to use Gaussian noise */
470    double rate;                 /* sampling rate */
471    double pitch_of_curr_point;  /* used in excitation generation */
472    double pitch_counter;        /* used in excitation generation */
473    double pitch_inc_per_point;  /* used in excitation generation */
474    double *excite_ring_buff;    /* used in excitation generation */
475    size_t excite_buff_size;     /* used in excitation generation */
476    size_t excite_buff_index;    /* used in excitation generation */
477    unsigned char sw;            /* switch used in random generator */
478    int x;                       /* excitation signal */
479    double *freqt_buff;          /* used in freqt */
480    size_t freqt_size;           /* buffer size for freqt */
481    double *spectrum2en_buff;    /* used in spectrum2en */
482    size_t spectrum2en_size;     /* buffer size for spectrum2en */
483    double r1, r2, s;            /* used in random generator */
484    double *postfilter_buff;     /* used in postfiltering */
485    size_t postfilter_size;      /* buffer size for postfiltering */
486    double *c, *cc, *cinc, *d1;  /* used in the MLSA/MGLSA filter */
487    double *lsp2lpc_buff;        /* used in lsp2lpc */
488    size_t lsp2lpc_size;         /* buffer size of lsp2lpc */
489    double *gc2gc_buff;          /* used in gc2gc */
490    size_t gc2gc_size;           /* buffer size for gc2gc */
491 } HTS_Vocoder;
492
493 /* HTS_Vocoder_initialize: initialize vocoder */
494 void HTS_Vocoder_initialize(HTS_Vocoder * v, size_t m, size_t stage, HTS_Boolean use_log_gain, size_t rate, size_t fperiod);
495
496 /* HTS_Vocoder_synthesize: pulse/noise excitation and MLSA/MGLSA filster based waveform synthesis */
497 void HTS_Vocoder_synthesize(HTS_Vocoder * v, size_t m, double lf0, double *spectrum, size_t nlpf, double *lpf, double alpha, double beta, double volume, double *rawdata, HTS_Audio * audio);
498
499 /* HTS_Vocoder_clear: clear vocoder */
500 void HTS_Vocoder_clear(HTS_Vocoder * v);
501
502 HTS_HIDDEN_H_END;
503
504 #endif                          /* !HTS_HIDDEN_H */