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-2011  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 HTS106_HIDDEN_H
46 #define HTS106_HIDDEN_H
47 
48 #ifdef __cplusplus
49 #define HTS106_HIDDEN_H_START extern "C" {
50 #define HTS106_HIDDEN_H_END   }
51 #else
52 #define HTS106_HIDDEN_H_START
53 #define HTS106_HIDDEN_H_END
54 #endif                          /* __CPLUSPLUS */
55 
56 HTS106_HIDDEN_H_START;
57 
58 /* hts_engine libraries */
59 #include "HTS106_engine.h"
60 
61 /*  -------------------------- misc -------------------------------  */
62 
63 #if !defined(WORDS_BIGENDIAN) && !defined(WORDS_LITTLEENDIAN)
64 #define WORDS_LITTLEENDIAN
65 #endif                          /* !WORDS_BIGENDIAN && !WORDS_LITTLEENDIAN */
66 #if defined(WORDS_BIGENDIAN) && defined(WORDS_LITTLEENDIAN)
67 #undef WORDS_BIGENDIAN
68 #endif                          /* WORDS_BIGENDIAN && WORDS_LITTLEENDIAN */
69 
70 #define HTS106_MAXBUFLEN 1024
71 
72 /* HTS106_error: output error message */
73 void HTS106_error(const int error, char *message, ...);
74 
75 /* HTS106_fgetc: wrapper for fgetc */
76 int HTS106_fgetc(HTS106_File * fp);
77 
78 /* HTS106_feof: wrapper for feof */
79 int HTS106_feof(HTS106_File * fp);
80 
81 /* HTS106_get_pattern_token: get pattern token */
82 HTS106_Boolean HTS106_get_pattern_token(HTS106_File * fp, char *buff);
83 
84 /* HTS106_get_token: get token (separator are space,tab,line break) */
85 HTS106_Boolean HTS106_get_token(HTS106_File * fp, char *buff);
86 
87 /* HTS106_get_token_from_string: get token from string (separator are space,tab,line break) */
88 HTS106_Boolean HTS106_get_token_from_string(char *string, int *index, char *buff);
89 
90 /* HTS106_fwrite_little_endian: fwrite with byteswap */
91 int HTS106_fwrite_little_endian(void *p, const int size, const int num, HTS106_File * fp);
92 
93 /* HTS106_fread_big_endiana: fread with byteswap */
94 int HTS106_fread_big_endian(void *p, const int size, const int num, HTS106_File * fp);
95 
96 /* HTS106_calloc: wrapper for calloc */
97 char *HTS106_calloc(const size_t num, const size_t size);
98 
99 /* HTS106_strdup: wrapper for strdup */
100 char *HTS106_strdup(const char *string);
101 
102 /* HTS106_calloc_matrix: allocate double matrix */
103 double **HTS106_alloc_matrix(const int x, const int y);
104 
105 /* HTS106_free_matrix: free double matrix */
106 void HTS106_free_matrix(double **p, const int x);
107 
108 /* HTS106_Free: wrapper for free */
109 void HTS106_free(void *p);
110 
111 /*  -------------------------- pstream ----------------------------  */
112 
113 /* check variance in finv() */
114 #define INFTY   ((double) 1.0e+38)
115 #define INFTY2  ((double) 1.0e+19)
116 #define INVINF  ((double) 1.0e-38)
117 #define INVINF2 ((double) 1.0e-19)
118 
119 /* GV */
120 #define STEPINIT 0.1
121 #define STEPDEC  0.5
122 #define STEPINC  1.2
123 #define W1       1.0
124 #define W2       1.0
125 #define GV_MAX_ITERATION 5
126 
127 /*  -------------------------- vocoder ----------------------------  */
128 
129 #ifndef PI
130 #define PI  3.14159265358979323846
131 #endif                          /* !PI */
132 #ifndef PI2
133 #define PI2 6.28318530717958647692
134 #endif                          /* !PI2 */
135 
136 #define RANDMAX 32767
137 
138 #define IPERIOD 1
139 #define SEED    1
140 #define B0      0x00000001
141 #define B28     0x10000000
142 #define B31     0x80000000
143 #define B31_    0x7fffffff
144 #define Z       0x00000000
145 
146 #ifdef HTS106_EMBEDDED
147 #define GAUSS     FALSE
148 #define PADEORDER 4             /* pade order (for MLSA filter) */
149 #define IRLENG    64            /* length of impulse response */
150 #else
151 #define GAUSS     TRUE
152 #define PADEORDER 5
153 #define IRLENG    96
154 #endif                          /* HTS106_EMBEDDED */
155 
156 #define PULSELISTSIZE 1024
157 
158 /* for MGLSA filter */
159 #define NORMFLG1 TRUE
160 #define NORMFLG2 FALSE
161 #define MULGFLG1 TRUE
162 #define MULGFLG2 FALSE
163 #define NGAIN    FALSE
164 
165 HTS106_HIDDEN_H_END;
166 
167 #endif                          /* !HTS106_HIDDEN_H */
168