Debian Codegraph @

external/espeak/intonation.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2005 to 2007 by Jonathan Duddington
3 * email: [email protected]
4 * Copyright (C) 2015-2016 Reece H. Dunn
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see: <http://www.gnu.org/licenses/>.
18 */
19
20 #include "espeak__config.h"cxx . . $ `<file>/external/espeak/espeak__config.h`/
21
22 #include <stdint.h>
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26
27 #include "espeak_ng.h"cxx . . $ `<file>/external/espeak/espeak_ng.h`/
28 #include "speak_lib.h"cxx . . $ `<file>/external/espeak/speak_lib.h`/
29 #include "encoding.h"cxx . . $ `<file>/external/espeak/encoding.h`/
30
31 #include "intonation.h"cxx . . $ `<file>/external/espeak/intonation.h`/
32 #include "phoneme.h"cxx . . $ `<file>/external/espeak/phoneme.h`/ // for PHONEME_TAB, PhonemeCode2, phonPAUSE, phPAUSE
33 #include "synthdata.h"cxx . . $ `<file>/external/espeak/synthdata.h`/ // for PhonemeCode
34 #include "synthesize.h"cxx . . $ `<file>/external/espeak/synthesize.h`/ // for PHONEME_LIST, TUNE, phoneme_list, phoneme_tab
35 #include "translate.h"cxx . . $ `<file>/external/espeak/translate.h`/ // for Translator, LANGUAGE_OPTIONS, L, OPTION_EMPH...
36
37 /* Note this module is mostly old code that needs to be rewritten to
38 provide a more flexible intonation system.
39 */
40
41 // bits in SYLLABLE.flags
42 #define SYL_RISEcxx . . $ `external/espeak/intonation.cpp:42:9`! 1
43 #define SYL_EMPHASIScxx . . $ `external/espeak/intonation.cpp:43:9`! 2
44 #define SYL_END_CLAUSEcxx . . $ `external/espeak/intonation.cpp:44:9`! 4
45
46 typedef structcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0# {
47 char stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress.;
48 char envcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#env.;
49 char flagscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#flags.; // bit 0=pitch rising, bit1=emnphasized, bit2=end of clause
50 char nextph_typecxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#nextph_type.;
51 unsigned char pitch1cxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#pitch1.;
52 unsigned char pitch2cxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#pitch2.;
53 } SYLLABLEcxx . . $ SYLLABLE#;
54
55 static int tone_pitch_envcxx . . $ tone_pitch_env.; // used to return pitch envelope
56
57 /* Pitch data for tone types */
58 /*****************************/
59
60 #define PITCHfallcxx . . $ `external/espeak/intonation.cpp:60:9`! 0
61 #define PITCHrisecxx . . $ `external/espeak/intonation.cpp:61:9`! 2
62 #define PITCHfrisecxx . . $ `external/espeak/intonation.cpp:62:9`! 4 // and 3 must be for the variant preceded by 'r'
63 #define PITCHfrise2cxx . . $ `external/espeak/intonation.cpp:63:9`! 6 // and 5 must be the 'r' variant
64
65 const unsigned char env_fallcxx . . $ env_fall.[128] = {
66 0xff, 0xfd, 0xfa, 0xf8, 0xf6, 0xf4, 0xf2, 0xf0, 0xee, 0xec, 0xea, 0xe8, 0xe6, 0xe4, 0xe2, 0xe0,
67 0xde, 0xdc, 0xda, 0xd8, 0xd6, 0xd4, 0xd2, 0xd0, 0xce, 0xcc, 0xca, 0xc8, 0xc6, 0xc4, 0xc2, 0xc0,
68 0xbe, 0xbc, 0xba, 0xb8, 0xb6, 0xb4, 0xb2, 0xb0, 0xae, 0xac, 0xaa, 0xa8, 0xa6, 0xa4, 0xa2, 0xa0,
69 0x9e, 0x9c, 0x9a, 0x98, 0x96, 0x94, 0x92, 0x90, 0x8e, 0x8c, 0x8a, 0x88, 0x86, 0x84, 0x82, 0x80,
70 0x7e, 0x7c, 0x7a, 0x78, 0x76, 0x74, 0x72, 0x70, 0x6e, 0x6c, 0x6a, 0x68, 0x66, 0x64, 0x62, 0x60,
71 0x5e, 0x5c, 0x5a, 0x58, 0x56, 0x54, 0x52, 0x50, 0x4e, 0x4c, 0x4a, 0x48, 0x46, 0x44, 0x42, 0x40,
72 0x3e, 0x3c, 0x3a, 0x38, 0x36, 0x34, 0x32, 0x30, 0x2e, 0x2c, 0x2a, 0x28, 0x26, 0x24, 0x22, 0x20,
73 0x1e, 0x1c, 0x1a, 0x18, 0x16, 0x14, 0x12, 0x10, 0x0e, 0x0c, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x00
74 };
75
76 static const unsigned char env_risecxx . . $ env_rise.[128] = {
77 0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e,
78 0x20, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2c, 0x2e, 0x30, 0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e,
79 0x40, 0x42, 0x44, 0x46, 0x48, 0x4a, 0x4c, 0x4e, 0x50, 0x52, 0x54, 0x56, 0x58, 0x5a, 0x5c, 0x5e,
80 0x60, 0x62, 0x64, 0x66, 0x68, 0x6a, 0x6c, 0x6e, 0x70, 0x72, 0x74, 0x76, 0x78, 0x7a, 0x7c, 0x7e,
81 0x80, 0x82, 0x84, 0x86, 0x88, 0x8a, 0x8c, 0x8e, 0x90, 0x92, 0x94, 0x96, 0x98, 0x9a, 0x9c, 0x9e,
82 0xa0, 0xa2, 0xa4, 0xa6, 0xa8, 0xaa, 0xac, 0xae, 0xb0, 0xb2, 0xb4, 0xb6, 0xb8, 0xba, 0xbc, 0xbe,
83 0xc0, 0xc2, 0xc4, 0xc6, 0xc8, 0xca, 0xcc, 0xce, 0xd0, 0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc, 0xde,
84 0xe0, 0xe2, 0xe4, 0xe6, 0xe8, 0xea, 0xec, 0xee, 0xf0, 0xf2, 0xf4, 0xf6, 0xf8, 0xfa, 0xfd, 0xff
85 };
86
87 static const unsigned char env_frisecxx . . $ env_frise.[128] = {
88 0xff, 0xf4, 0xea, 0xe0, 0xd6, 0xcc, 0xc3, 0xba, 0xb1, 0xa8, 0x9f, 0x97, 0x8f, 0x87, 0x7f, 0x78,
89 0x71, 0x6a, 0x63, 0x5c, 0x56, 0x50, 0x4a, 0x44, 0x3f, 0x39, 0x34, 0x2f, 0x2b, 0x26, 0x22, 0x1e,
90 0x1a, 0x17, 0x13, 0x10, 0x0d, 0x0b, 0x08, 0x06, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
91 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x07, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x13, 0x15, 0x17,
92 0x1a, 0x1d, 0x1f, 0x22, 0x25, 0x28, 0x2c, 0x2e, 0x30, 0x32, 0x34, 0x36, 0x39, 0x3b, 0x3d, 0x40,
93 0x42, 0x45, 0x47, 0x4a, 0x4c, 0x4f, 0x51, 0x54, 0x57, 0x5a, 0x5d, 0x5f, 0x62, 0x65, 0x68, 0x6b,
94 0x6e, 0x71, 0x74, 0x78, 0x7b, 0x7e, 0x81, 0x85, 0x88, 0x8b, 0x8f, 0x92, 0x96, 0x99, 0x9d, 0xa0,
95 0xa4, 0xa8, 0xac, 0xaf, 0xb3, 0xb7, 0xbb, 0xbf, 0xc3, 0xc7, 0xcb, 0xcf, 0xd3, 0xd7, 0xdb, 0xe0
96 };
97
98 static const unsigned char env_r_frisecxx . . $ env_r_frise.[128] = {
99 0xcf, 0xcc, 0xc9, 0xc6, 0xc3, 0xc0, 0xbd, 0xb9, 0xb4, 0xb0, 0xab, 0xa7, 0xa2, 0x9c, 0x97, 0x92,
100 0x8c, 0x86, 0x81, 0x7b, 0x75, 0x6f, 0x69, 0x63, 0x5d, 0x57, 0x50, 0x4a, 0x44, 0x3e, 0x38, 0x33,
101 0x2d, 0x27, 0x22, 0x1c, 0x17, 0x12, 0x0d, 0x08, 0x04, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00,
102 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x07, 0x08, 0x0a, 0x0c, 0x0d, 0x0f, 0x12, 0x14, 0x16,
103 0x19, 0x1b, 0x1e, 0x21, 0x24, 0x27, 0x2a, 0x2d, 0x30, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3f, 0x41,
104 0x43, 0x46, 0x48, 0x4b, 0x4d, 0x50, 0x52, 0x55, 0x58, 0x5a, 0x5d, 0x60, 0x63, 0x66, 0x69, 0x6c,
105 0x6f, 0x72, 0x75, 0x78, 0x7b, 0x7e, 0x81, 0x85, 0x88, 0x8b, 0x8f, 0x92, 0x96, 0x99, 0x9d, 0xa0,
106 0xa4, 0xa8, 0xac, 0xaf, 0xb3, 0xb7, 0xbb, 0xbf, 0xc3, 0xc7, 0xcb, 0xcf, 0xd3, 0xd7, 0xdb, 0xe0
107 };
108
109 static const unsigned char env_frise2cxx . . $ env_frise2.[128] = {
110 0xff, 0xf9, 0xf4, 0xee, 0xe9, 0xe4, 0xdf, 0xda, 0xd5, 0xd0, 0xcb, 0xc6, 0xc1, 0xbd, 0xb8, 0xb3,
111 0xaf, 0xaa, 0xa6, 0xa1, 0x9d, 0x99, 0x95, 0x90, 0x8c, 0x88, 0x84, 0x80, 0x7d, 0x79, 0x75, 0x71,
112 0x6e, 0x6a, 0x67, 0x63, 0x60, 0x5d, 0x59, 0x56, 0x53, 0x50, 0x4d, 0x4a, 0x47, 0x44, 0x41, 0x3e,
113 0x3c, 0x39, 0x37, 0x34, 0x32, 0x2f, 0x2d, 0x2b, 0x28, 0x26, 0x24, 0x22, 0x20, 0x1e, 0x1c, 0x1a,
114 0x19, 0x17, 0x15, 0x14, 0x12, 0x11, 0x0f, 0x0e, 0x0d, 0x0c, 0x0a, 0x09, 0x08, 0x07, 0x06, 0x05,
115 0x05, 0x04, 0x03, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
116 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x04, 0x04, 0x05, 0x06, 0x07, 0x08,
117 0x09, 0x0a, 0x0b, 0x0c, 0x0e, 0x0f, 0x10, 0x12, 0x13, 0x15, 0x17, 0x18, 0x1a, 0x1c, 0x1e, 0x20
118 };
119
120 static const unsigned char env_r_frise2cxx . . $ env_r_frise2.[128] = {
121 0xd0, 0xce, 0xcd, 0xcc, 0xca, 0xc8, 0xc7, 0xc5, 0xc3, 0xc1, 0xc0, 0xbd, 0xbb, 0xb8, 0xb5, 0xb3,
122 0xb0, 0xad, 0xaa, 0xa7, 0xa3, 0xa0, 0x9d, 0x99, 0x96, 0x92, 0x8f, 0x8b, 0x87, 0x84, 0x80, 0x7c,
123 0x78, 0x74, 0x70, 0x6d, 0x69, 0x65, 0x61, 0x5d, 0x59, 0x55, 0x51, 0x4d, 0x4a, 0x46, 0x42, 0x3e,
124 0x3b, 0x37, 0x34, 0x31, 0x2f, 0x2d, 0x2a, 0x28, 0x26, 0x24, 0x22, 0x20, 0x1e, 0x1c, 0x1a, 0x19,
125 0x17, 0x15, 0x14, 0x12, 0x11, 0x0f, 0x0e, 0x0d, 0x0c, 0x0a, 0x09, 0x08, 0x07, 0x06, 0x05, 0x05,
126 0x04, 0x03, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
127 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x04, 0x04, 0x05, 0x06, 0x07, 0x08,
128 0x09, 0x0a, 0x0b, 0x0c, 0x0e, 0x0f, 0x10, 0x12, 0x13, 0x15, 0x17, 0x18, 0x1a, 0x1c, 0x1e, 0x20
129 };
130
131 static const unsigned char env_risefallcxx . . $ env_risefall.[128] = {
132 0x98, 0x99, 0x99, 0x9a, 0x9c, 0x9d, 0x9f, 0xa1, 0xa4, 0xa7, 0xa9, 0xac, 0xb0, 0xb3, 0xb6, 0xba,
133 0xbe, 0xc1, 0xc5, 0xc9, 0xcd, 0xd1, 0xd4, 0xd8, 0xdc, 0xdf, 0xe3, 0xe6, 0xea, 0xed, 0xf0, 0xf2,
134 0xf5, 0xf7, 0xf9, 0xfb, 0xfc, 0xfd, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfd,
135 0xfb, 0xfa, 0xf8, 0xf6, 0xf3, 0xf1, 0xee, 0xec, 0xe9, 0xe6, 0xe4, 0xe0, 0xdd, 0xda, 0xd7, 0xd3,
136 0xd0, 0xcc, 0xc8, 0xc4, 0xc0, 0xbc, 0xb8, 0xb4, 0xb0, 0xac, 0xa7, 0xa3, 0x9f, 0x9a, 0x96, 0x91,
137 0x8d, 0x88, 0x84, 0x7f, 0x7b, 0x76, 0x72, 0x6d, 0x69, 0x65, 0x60, 0x5c, 0x58, 0x54, 0x50, 0x4c,
138 0x48, 0x44, 0x40, 0x3c, 0x39, 0x35, 0x32, 0x2f, 0x2b, 0x28, 0x26, 0x23, 0x20, 0x1d, 0x1a, 0x17,
139 0x15, 0x12, 0x0f, 0x0d, 0x0a, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00
140 };
141
142 static const unsigned char env_rise2cxx . . $ env_rise2.[128] = {
143 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x04, 0x04, 0x05, 0x06, 0x06,
144 0x07, 0x08, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14,
145 0x16, 0x17, 0x18, 0x19, 0x1b, 0x1c, 0x1d, 0x1f, 0x20, 0x22, 0x23, 0x25, 0x26, 0x28, 0x29, 0x2b,
146 0x2d, 0x2f, 0x30, 0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e, 0x40, 0x42, 0x44, 0x47, 0x49, 0x4b,
147 0x4e, 0x50, 0x52, 0x55, 0x57, 0x5a, 0x5d, 0x5f, 0x62, 0x65, 0x67, 0x6a, 0x6d, 0x70, 0x73, 0x76,
148 0x79, 0x7c, 0x7f, 0x82, 0x86, 0x89, 0x8c, 0x90, 0x93, 0x96, 0x9a, 0x9d, 0xa0, 0xa3, 0xa6, 0xa9,
149 0xac, 0xaf, 0xb2, 0xb5, 0xb8, 0xbb, 0xbe, 0xc1, 0xc4, 0xc7, 0xca, 0xcd, 0xd0, 0xd3, 0xd6, 0xd9,
150 0xdc, 0xdf, 0xe2, 0xe4, 0xe7, 0xe9, 0xec, 0xee, 0xf0, 0xf2, 0xf4, 0xf6, 0xf8, 0xfa, 0xfb, 0xfd
151 };
152
153 static const unsigned char env_fall2cxx . . $ env_fall2.[128] = {
154 0xfe, 0xfe, 0xfd, 0xfd, 0xfc, 0xfb, 0xfb, 0xfa, 0xfa, 0xf9, 0xf8, 0xf8, 0xf7, 0xf7, 0xf6, 0xf6,
155 0xf5, 0xf4, 0xf4, 0xf3, 0xf3, 0xf2, 0xf2, 0xf1, 0xf0, 0xf0, 0xef, 0xee, 0xee, 0xed, 0xec, 0xeb,
156 0xea, 0xea, 0xe9, 0xe8, 0xe7, 0xe6, 0xe5, 0xe4, 0xe3, 0xe2, 0xe1, 0xe0, 0xde, 0xdd, 0xdc, 0xdb,
157 0xd9, 0xd8, 0xd6, 0xd5, 0xd3, 0xd2, 0xd0, 0xce, 0xcc, 0xcb, 0xc9, 0xc7, 0xc5, 0xc3, 0xc0, 0xbe,
158 0xbc, 0xb9, 0xb7, 0xb5, 0xb2, 0xaf, 0xad, 0xaa, 0xa7, 0xa4, 0xa1, 0x9e, 0x9a, 0x97, 0x94, 0x90,
159 0x8d, 0x89, 0x85, 0x81, 0x7d, 0x79, 0x75, 0x71, 0x6d, 0x68, 0x64, 0x61, 0x5e, 0x5b, 0x57, 0x54,
160 0x51, 0x4d, 0x4a, 0x46, 0x43, 0x40, 0x3c, 0x39, 0x35, 0x32, 0x2e, 0x2a, 0x27, 0x23, 0x1f, 0x1c,
161 0x18, 0x14, 0x11, 0x0d, 0x0b, 0x09, 0x07, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00
162 };
163
164 static const unsigned char env_fallrise3cxx . . $ env_fallrise3.[128] = {
165 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfd, 0xfc, 0xfa, 0xf8, 0xf6, 0xf4, 0xf1, 0xee, 0xeb,
166 0xe8, 0xe5, 0xe1, 0xde, 0xda, 0xd6, 0xd2, 0xcd, 0xc9, 0xc4, 0xbf, 0xba, 0xb6, 0xb0, 0xab, 0xa6,
167 0xa1, 0x9c, 0x96, 0x91, 0x8b, 0x86, 0x80, 0x7b, 0x75, 0x6f, 0x6a, 0x64, 0x5f, 0x59, 0x54, 0x4f,
168 0x49, 0x44, 0x3f, 0x3a, 0x35, 0x30, 0x2b, 0x26, 0x22, 0x1d, 0x19, 0x15, 0x11, 0x0d, 0x0a, 0x07,
169 0x04, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x04, 0x05,
170 0x07, 0x09, 0x0b, 0x0d, 0x10, 0x12, 0x15, 0x18, 0x1b, 0x1e, 0x22, 0x25, 0x29, 0x2d, 0x31, 0x35,
171 0x3a, 0x3e, 0x43, 0x48, 0x4c, 0x51, 0x57, 0x5b, 0x5e, 0x62, 0x65, 0x68, 0x6b, 0x6e, 0x71, 0x74,
172 0x76, 0x78, 0x7b, 0x7c, 0x7e, 0x80, 0x81, 0x82, 0x83, 0x83, 0x84, 0x84, 0x83, 0x83, 0x82, 0x81
173 };
174
175 static const unsigned char env_fallrise4cxx . . $ env_fallrise4.[128] = {
176 0x72, 0x72, 0x71, 0x71, 0x70, 0x6f, 0x6d, 0x6c, 0x6a, 0x68, 0x66, 0x64, 0x61, 0x5f, 0x5c, 0x5a,
177 0x57, 0x54, 0x51, 0x4e, 0x4b, 0x48, 0x45, 0x42, 0x3f, 0x3b, 0x38, 0x35, 0x32, 0x2f, 0x2c, 0x29,
178 0x26, 0x23, 0x20, 0x1d, 0x1b, 0x18, 0x16, 0x14, 0x12, 0x10, 0x0e, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
179 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x06,
180 0x07, 0x07, 0x08, 0x09, 0x0a, 0x0c, 0x0d, 0x0f, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1b, 0x1d, 0x20,
181 0x23, 0x26, 0x29, 0x2c, 0x2f, 0x33, 0x37, 0x3b, 0x3f, 0x43, 0x47, 0x4c, 0x51, 0x56, 0x5b, 0x60,
182 0x65, 0x6a, 0x6f, 0x74, 0x79, 0x7f, 0x84, 0x89, 0x8f, 0x95, 0x9b, 0xa1, 0xa7, 0xad, 0xb3, 0xba,
183 0xc0, 0xc7, 0xce, 0xd5, 0xdc, 0xe3, 0xea, 0xf1, 0xf5, 0xf7, 0xfa, 0xfc, 0xfd, 0xfe, 0xff, 0xff
184 };
185
186 static const unsigned char env_risefallrisecxx . . $ env_risefallrise.[128] = {
187 0x7f, 0x7f, 0x7f, 0x80, 0x81, 0x83, 0x84, 0x87, 0x89, 0x8c, 0x8f, 0x92, 0x96, 0x99, 0x9d, 0xa1,
188 0xa5, 0xaa, 0xae, 0xb2, 0xb7, 0xbb, 0xc0, 0xc5, 0xc9, 0xcd, 0xd2, 0xd6, 0xda, 0xde, 0xe2, 0xe6,
189 0xea, 0xed, 0xf0, 0xf3, 0xf5, 0xf8, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xfe, 0xfd, 0xfc, 0xfb, 0xf9,
190 0xf7, 0xf4, 0xf0, 0xec, 0xe7, 0xe2, 0xdc, 0xd5, 0xce, 0xc6, 0xbd, 0xb4, 0xa9, 0x9e, 0x92, 0x88,
191 0x82, 0x7d, 0x77, 0x72, 0x6c, 0x66, 0x60, 0x5a, 0x54, 0x4e, 0x49, 0x42, 0x3c, 0x37, 0x32, 0x2d,
192 0x28, 0x24, 0x1f, 0x1b, 0x18, 0x14, 0x11, 0x0e, 0x0c, 0x09, 0x07, 0x06, 0x05, 0x04, 0x04, 0x04,
193 0x04, 0x05, 0x06, 0x08, 0x0a, 0x0d, 0x10, 0x14, 0x18, 0x1d, 0x23, 0x29, 0x2f, 0x37, 0x3e, 0x47,
194 0x50, 0x5a, 0x64, 0x70, 0x7c, 0x83, 0x85, 0x88, 0x8a, 0x8c, 0x8e, 0x8f, 0x91, 0x92, 0x93, 0x93
195 };
196
197 const unsigned char *const envelope_datacxx . . $ envelope_data.[N_ENVELOPE_DATAcxx . . $ `external/espeak/synthesize.h:449:9`!] = {
198 env_fallcxx . . $ env_fall., env_fallcxx . . $ env_fall.,
199 env_risecxx . . $ env_rise., env_risecxx . . $ env_rise.,
200 env_frisecxx . . $ env_frise., env_r_frisecxx . . $ env_r_frise.,
201 env_frise2cxx . . $ env_frise2., env_r_frise2cxx . . $ env_r_frise2.,
202 env_risefallcxx . . $ env_risefall., env_risefallcxx . . $ env_risefall.,
203
204 env_fallrise3cxx . . $ env_fallrise3., env_fallrise3cxx . . $ env_fallrise3.,
205 env_fallrise4cxx . . $ env_fallrise4., env_fallrise4cxx . . $ env_fallrise4.,
206 env_fall2cxx . . $ env_fall2., env_fall2cxx . . $ env_fall2.,
207 env_rise2cxx . . $ env_rise2., env_rise2cxx . . $ env_rise2.,
208 env_risefallrisecxx . . $ env_risefallrise., env_risefallrisecxx . . $ env_risefallrise.
209 };
210
211 // indexed by stress
212 static const int min_dropcxx . . $ min_drop.[] = { 6, 7, 9, 9, 20, 20, 20, 25 };
213
214 // pitch change during the main part of the clause
215 static const int drops_0cxx . . $ drops_0.[8] = { 9, 9, 16, 16, 16, 23, 55, 32 };
216
217 // overflow table values are 64ths of the body pitch range (between body_start and body_end)
218 static const signed char oflowcxx . . $ oflow.[] = { 0, 40, 24, 8, 0 };
219 static const signed char oflow_emfcxx . . $ oflow_emf.[] = { 10, 52, 32, 20, 10 };
220 static const signed char oflow_lesscxx . . $ oflow_less.[] = { 6, 38, 24, 14, 4 };
221
222 #define N_TONE_HEAD_TABLEcxx . . $ `external/espeak/intonation.cpp:222:9`! 13
223 #define N_TONE_NUCLEUS_TABLEcxx . . $ `external/espeak/intonation.cpp:223:9`! 13
224
225 typedef structcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1# {
226 unsigned char pre_startcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1#pre_start.;
227 unsigned char pre_endcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1#pre_end.;
228
229 unsigned char body_startcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1#body_start.;
230 unsigned char body_endcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1#body_end.;
231
232 const int *body_dropscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1#body_drops.;
233 unsigned char body_max_stepscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1#body_max_steps.;
234 char body_lower_ucxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1#body_lower_u.;
235
236 unsigned char n_overflowcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1#n_overflow.;
237 const signed char *overflowcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1#overflow.;
238 } TONE_HEADcxx . . $ TONE_HEAD#;
239
240 typedef structcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2# {
241 unsigned char pitch_env0cxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2#pitch_env0.; // pitch envelope, tonic syllable at end
242 unsigned char tonic_max0cxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2#tonic_max0.;
243 unsigned char tonic_min0cxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2#tonic_min0.;
244
245 unsigned char pitch_env1cxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2#pitch_env1.; // followed by unstressed
246 unsigned char tonic_max1cxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2#tonic_max1.;
247 unsigned char tonic_min1cxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2#tonic_min1.;
248
249 short *backwardscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2#backwards.;
250
251 unsigned char tail_startcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2#tail_start.;
252 unsigned char tail_endcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2#tail_end.;
253 unsigned char flagscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2#flags.;
254 } TONE_NUCLEUScxx . . $ TONE_NUCLEUS#;
255
256 #define T_EMPHcxx . . $ `external/espeak/intonation.cpp:256:9`! 1
257
258 static const TONE_HEADcxx . . $ TONE_HEAD# tone_head_tablecxx . . $ tone_head_table.[N_TONE_HEAD_TABLEcxx . . $ `external/espeak/intonation.cpp:222:9`!] = {
259 { 46, 57, 78, 50, drops_0cxx . . $ drops_0., 3, 7, 5, oflowcxx . . $ oflow. }, // 0 statement
260 { 46, 57, 78, 46, drops_0cxx . . $ drops_0., 3, 7, 5, oflowcxx . . $ oflow. }, // 1 comma
261 { 46, 57, 78, 46, drops_0cxx . . $ drops_0., 3, 7, 5, oflowcxx . . $ oflow. }, // 2 question
262 { 46, 57, 90, 50, drops_0cxx . . $ drops_0., 3, 9, 5, oflow_emfcxx . . $ oflow_emf. }, // 3 exclamation
263 { 46, 57, 78, 50, drops_0cxx . . $ drops_0., 3, 7, 5, oflowcxx . . $ oflow. }, // 4 statement, emphatic
264 { 46, 57, 74, 55, drops_0cxx . . $ drops_0., 4, 7, 5, oflow_lesscxx . . $ oflow_less. }, // 5 statement, less intonation
265 { 46, 57, 74, 55, drops_0cxx . . $ drops_0., 4, 7, 5, oflow_lesscxx . . $ oflow_less. }, // 6 comma, less intonation
266 { 46, 57, 74, 55, drops_0cxx . . $ drops_0., 4, 7, 5, oflow_lesscxx . . $ oflow_less. }, // 7 comma, less intonation, less rise
267 { 46, 57, 78, 50, drops_0cxx . . $ drops_0., 3, 7, 5, oflowcxx . . $ oflow. }, // 8 pitch raises at end of sentence
268 { 46, 57, 78, 46, drops_0cxx . . $ drops_0., 3, 7, 5, oflowcxx . . $ oflow. }, // 9 comma
269 { 46, 57, 78, 50, drops_0cxx . . $ drops_0., 3, 7, 5, oflowcxx . . $ oflow. }, // 10 question
270 { 34, 41, 41, 32, drops_0cxx . . $ drops_0., 3, 7, 5, oflow_lesscxx . . $ oflow_less. }, // 11 test
271 { 46, 57, 55, 50, drops_0cxx . . $ drops_0., 3, 7, 5, oflow_lesscxx . . $ oflow_less. }, // 12 test
272 };
273
274 static const TONE_NUCLEUScxx . . $ TONE_NUCLEUS# tone_nucleus_tablecxx . . $ tone_nucleus_table.[N_TONE_NUCLEUS_TABLEcxx . . $ `external/espeak/intonation.cpp:223:9`!] = {
275 { PITCHfallcxx . . $ `external/espeak/intonation.cpp:60:9`!, 64, 8, PITCHfallcxx . . $ `external/espeak/intonation.cpp:60:9`!, 70, 18, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 24, 12, 0 }, // 0 statement
276 { PITCHfrisecxx . . $ `external/espeak/intonation.cpp:62:9`!, 80, 18, PITCHfrise2cxx . . $ `external/espeak/intonation.cpp:63:9`!, 78, 22, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 34, 52, 0 }, // 1 comma
277 { PITCHfrisecxx . . $ `external/espeak/intonation.cpp:62:9`!, 88, 22, PITCHfrise2cxx . . $ `external/espeak/intonation.cpp:63:9`!, 82, 22, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 34, 64, 0 }, // 2 question
278 { PITCHfallcxx . . $ `external/espeak/intonation.cpp:60:9`!, 92, 8, PITCHfallcxx . . $ `external/espeak/intonation.cpp:60:9`!, 92, 80, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 76, 8, T_EMPHcxx . . $ `external/espeak/intonation.cpp:256:9`! }, // 3 exclamation
279 { PITCHfallcxx . . $ `external/espeak/intonation.cpp:60:9`!, 86, 4, PITCHfallcxx . . $ `external/espeak/intonation.cpp:60:9`!, 94, 66, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 34, 10, 0 }, // 4 statement, emphatic
280 { PITCHfallcxx . . $ `external/espeak/intonation.cpp:60:9`!, 62, 10, PITCHfallcxx . . $ `external/espeak/intonation.cpp:60:9`!, 62, 20, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 28, 16, 0 }, // 5 statement, less intonation
281 { PITCHfrisecxx . . $ `external/espeak/intonation.cpp:62:9`!, 68, 18, PITCHfrise2cxx . . $ `external/espeak/intonation.cpp:63:9`!, 68, 22, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 30, 44, 0 }, // 6 comma, less intonation
282 { PITCHfrise2cxx . . $ `external/espeak/intonation.cpp:63:9`!, 64, 16, PITCHfallcxx . . $ `external/espeak/intonation.cpp:60:9`!, 66, 32, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 32, 18, 0 }, // 7 comma, less intonation, less rise
283 { PITCHrisecxx . . $ `external/espeak/intonation.cpp:61:9`!, 68, 46, PITCHfallcxx . . $ `external/espeak/intonation.cpp:60:9`!, 42, 32, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 46, 58, 0 }, // 8 pitch raises at end of sentence
284 { PITCHfrisecxx . . $ `external/espeak/intonation.cpp:62:9`!, 78, 24, PITCHfrise2cxx . . $ `external/espeak/intonation.cpp:63:9`!, 72, 22, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 42, 52, 0 }, // 9 comma
285 { PITCHfrisecxx . . $ `external/espeak/intonation.cpp:62:9`!, 88, 34, PITCHfallcxx . . $ `external/espeak/intonation.cpp:60:9`!, 64, 32, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 46, 82, 0 }, // 10 question
286 { PITCHfallcxx . . $ `external/espeak/intonation.cpp:60:9`!, 56, 12, PITCHfallcxx . . $ `external/espeak/intonation.cpp:60:9`!, 56, 20, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 24, 12, 0 }, // 11 test
287 { PITCHfallcxx . . $ `external/espeak/intonation.cpp:60:9`!, 70, 18, PITCHfallcxx . . $ `external/espeak/intonation.cpp:60:9`!, 70, 24, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 32, 20, 0 }, // 12 test
288 };
289
290 #define SECONDARYcxx . . $ `external/espeak/intonation.cpp:290:9`! 3
291 #define PRIMARYcxx . . $ `external/espeak/intonation.cpp:291:9`! 4
292 #define PRIMARY_STRESSEDcxx . . $ `external/espeak/intonation.cpp:292:9`! 6
293 #define PRIMARY_LASTcxx . . $ `external/espeak/intonation.cpp:293:9`! 7
294
295 static int number_precxx . . $ number_pre.;
296 static int number_tailcxx . . $ number_tail.;
297 static int last_primarycxx . . $ last_primary.;
298 static int tone_posncxx . . $ tone_posn.;
299 static int tone_posn2cxx . . $ tone_posn2.;
300 static int no_toniccxx . . $ no_tonic.;
301
302 static void count_pitch_vowelscxx . . $ count_pitch_vowels(94c804bd0ff4d6cf).(SYLLABLEcxx . . $ SYLLABLE# *syllable_tab, int start, int end, int clause_end)
303 {
304 int ix;
305 int stress;
306 int max_stress = 0;
307 int max_stress_posn = 0; // last syllable ot the highest stress
308 int max_stress_posn2 = 0; // penuntimate syllable of the highest stress
309
310 number_precxx . . $ number_pre. = -1; // number of vowels before 1st primary stress
311 number_tailcxx . . $ number_tail. = 0; // number between tonic syllable and next primary
312 last_primarycxx . . $ last_primary. = -1;
313
314 for (ix = start; ix < end; ix++) {
315 stress = syllable_tab[ix].stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress.; // marked stress level
316
317 if (stress >= max_stress) {
318 if (stress > max_stress)
319 max_stress_posn2 = ix;
320 else
321 max_stress_posn2 = max_stress_posn;
322 max_stress_posn = ix;
323 max_stress = stress;
324 }
325 if (stress >= PRIMARYcxx . . $ `external/espeak/intonation.cpp:291:9`!) {
326 if (number_precxx . . $ number_pre. < 0)
327 number_precxx . . $ number_pre. = ix - start;
328
329 last_primarycxx . . $ last_primary. = ix;
330 }
331 }
332
333 if (number_precxx . . $ number_pre. < 0)
334 number_precxx . . $ number_pre. = end;
335
336 number_tailcxx . . $ number_tail. = end - max_stress_posn - 1;
337 tone_posncxx . . $ tone_posn. = max_stress_posn;
338 tone_posn2cxx . . $ tone_posn2. = max_stress_posn2;
339
340 if (no_toniccxx . . $ no_tonic.)
341 tone_posncxx . . $ tone_posn. = tone_posn2cxx . . $ tone_posn2. = end; // next position after the end of the truncated clause
342 else if (last_primarycxx . . $ last_primary. >= 0) {
343 if (end == clause_end)
344 syllable_tab[last_primarycxx . . $ last_primary.].stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. = PRIMARY_LASTcxx . . $ `external/espeak/intonation.cpp:293:9`!;
345 } else {
346 // no primary stress. Use the highest stress
347 syllable_tab[tone_posncxx . . $ tone_posn.].stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. = PRIMARY_LASTcxx . . $ `external/espeak/intonation.cpp:293:9`!;
348 }
349 }
350
351 // Count number of primary stresses up to tonic syllable or body_reset
352 static int count_incrementscxx . . $ count_increments(510c9c30ecbf73).(SYLLABLEcxx . . $ SYLLABLE# *syllable_tab, int ix, int end_ix, int min_stress)
353 {
354 int count = 0;
355 int stress;
356
357 while (ix < end_ix) {
358 stress = syllable_tab[ix++].stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress.;
359 if (stress >= PRIMARY_LASTcxx . . $ `external/espeak/intonation.cpp:293:9`!)
360 break;
361
362 if (stress >= min_stress)
363 count++;
364 }
365 return count;
366 }
367
368 // Set the pitch of a vowel in syllable_tab
369 static void set_pitchcxx . . $ set_pitch(bb1885ad957de506).(SYLLABLEcxx . . $ SYLLABLE# *syl, int base, int drop)
370 {
371 int pitch1, pitch2;
372 int flags = 0;
373
374 if (base < 0) base = 0;
375
376 pitch2 = base;
377
378 if (drop < 0) {
379 flags = SYL_RISEcxx . . $ `external/espeak/intonation.cpp:42:9`!;
380 drop = -drop;
381 }
382
383 pitch1 = pitch2 + drop;
384 if (pitch1 < 0)
385 pitch1 = 0;
386
387 if (pitch1 > 254) pitch1 = 254;
388 if (pitch2 > 254) pitch2 = 254;
389
390 syl->pitch1cxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#pitch1. = pitch1;
391 syl->pitch2cxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#pitch2. = pitch2;
392 syl->flagscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#flags. |= flags;
393 }
394
395 static int CountUnstressedcxx . . $ CountUnstressed(510c9c30ecbf73).(SYLLABLEcxx . . $ SYLLABLE# *syllable_tab, int start, int end, int limit)
396 {
397 int ix;
398
399 for (ix = start; ix <= end; ix++) {
400 if (syllable_tab[ix].stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. >= limit)
401 break;
402 }
403 return ix - start;
404 }
405
406 static int SetHeadIntonationcxx . . $ SetHeadIntonation(e5383c6110a47816).(SYLLABLEcxx . . $ SYLLABLE# *syllable_tab, TUNE *tune, int syl_ix, int end_ix)
407 {
408 int stress;
409 SYLLABLEcxx . . $ SYLLABLE# *syl;
410 int ix;
411 int pitch = 0;
412 int increment = 0;
413 int n_steps = 0;
414 int stage; // onset, head, last
415 bool initial;
416 int overflow_ix = 0;
417 int pitch_range;
418 int pitch_range_abs;
419 const int *drops;
420 int n_unstressed = 0;
421 int unstressed_ix = 0;
422 int unstressed_inc;
423 bool used_onset = false;
424 int head_final = end_ix;
425 int secondary = 2;
426
427 pitch_range = (tune->head_end - tune->head_start) * 256;
428 pitch_range_abs = abscxx . . $ abs(a1851578aea3f541).(pitch_range);
429 drops = drops_0cxx . . $ drops_0.; // this should be controlled by tune->head_drops
430 initial = true;
431
432 stage = 0;
433 if (tune->onset == 255)
434 stage = 1; // no onset specified
435
436 if (tune->head_last != 255) {
437 // find the last primary stress in the body
438 for (ix = end_ix-1; ix >= syl_ix; ix--) {
439 if (syllable_tab[ix].stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. >= 4) {
440 head_final = ix;
441 break;
442 }
443 }
444 }
445
446 while (syl_ix < end_ix) {
447 syl = &syllable_tab[syl_ix];
448 stress = syl->stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress.;
449
450 if (initial || (stress >= 4)) {
451 // a primary stress
452
453 if ((initial) || (stress == 5)) {
454 initial = false;
455 overflow_ix = 0;
456
457 if (tune->onset == 255) {
458 n_steps = count_incrementscxx . . $ count_increments(510c9c30ecbf73).(syllable_tab, syl_ix, head_final, 4);
459 pitch = tune->head_start * 256;
460 } else {
461 // a pitch has been specified for the onset syllable, don't include it in the pitch incrementing
462 n_steps = count_incrementscxx . . $ count_increments(510c9c30ecbf73).(syllable_tab, syl_ix+1, head_final, 4);
463 pitch = tune->onset * 256;
464 used_onset = true;
465 }
466
467 if (n_steps > tune->head_max_steps)
468 n_steps = tune->head_max_steps;
469
470 if (n_steps > 1)
471 increment = pitch_range / (n_steps -1);
472 else
473 increment = 0;
474 } else if (syl_ix == head_final) {
475 // a pitch has been specified for the last primary stress before the nucleus
476 pitch = tune->head_last * 256;
477 stage = 2;
478 } else {
479 if (used_onset) {
480 stage = 1;
481 used_onset = false;
482 pitch = tune->head_start * 256;
483 n_steps++;
484 } else if (n_steps > 0)
485 pitch += increment;
486 else {
487 pitch = (tune->head_end * 256) + (pitch_range_abs * tune->head_extend[overflow_ix++])/64;
488 if (overflow_ix >= tune->n_head_extend)
489 overflow_ix = 0;
490 }
491 }
492
493 n_steps--;
494 }
495
496 if (stress >= PRIMARYcxx . . $ `external/espeak/intonation.cpp:291:9`!) {
497 n_unstressed = CountUnstressedcxx . . $ CountUnstressed(510c9c30ecbf73).(syllable_tab, syl_ix+1, end_ix, secondary);
498 unstressed_ix = 0;
499 syl->stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. = PRIMARY_STRESSEDcxx . . $ `external/espeak/intonation.cpp:292:9`!;
500 syl->envcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#env. = tune->stressed_env;
501 set_pitchcxx . . $ set_pitch(bb1885ad957de506).(syl, (pitch / 256), tune->stressed_drop);
502 } else if (stress >= secondary) {
503 n_unstressed = CountUnstressedcxx . . $ CountUnstressed(510c9c30ecbf73).(syllable_tab, syl_ix+1, end_ix, secondary);
504 unstressed_ix = 0;
505 set_pitchcxx . . $ set_pitch(bb1885ad957de506).(syl, (pitch / 256), drops[stress]);
506 } else {
507 if (n_unstressed > 1)
508 unstressed_inc = (tune->unstr_end[stage] - tune->unstr_start[stage]) / (n_unstressed - 1);
509 else
510 unstressed_inc = 0;
511
512 set_pitchcxx . . $ set_pitch(bb1885ad957de506).(syl, (pitch / 256) + tune->unstr_start[stage] + (unstressed_inc * unstressed_ix), drops[stress]);
513 unstressed_ix++;
514 }
515
516 syl_ix++;
517 }
518 return syl_ix;
519 }
520
521 /* Calculate pitches until next RESET or tonic syllable, or end.
522 Increment pitch if stress is >= min_stress.
523 Used for tonic segment */
524 static int calc_pitch_segmentcxx . . $ calc_pitch_segment(884bb55f50f9c43d).(SYLLABLEcxx . . $ SYLLABLE# *syllable_tab, int ix, int end_ix, const TONE_HEADcxx . . $ TONE_HEAD# *th, const TONE_NUCLEUScxx . . $ TONE_NUCLEUS# *tn, int min_stress, bool continuing)
525 {
526 int stress;
527 int pitch = 0;
528 int increment = 0;
529 int n_primary = 0;
530 int n_steps = 0;
531 bool initial;
532 int overflow = 0;
533 int n_overflow;
534 int pitch_range;
535 int pitch_range_abs;
536 const int *drops;
537 const signed char *overflow_tab;
538 SYLLABLEcxx . . $ SYLLABLE# *syl;
539
540 static const signed char continue_tab[5] = { -26, 32, 20, 8, 0 };
541
542 drops = th->body_dropscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1#body_drops.;
543 pitch_range = (th->body_endcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1#body_end. - th->body_startcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1#body_start.) * 256;
544 pitch_range_abs = abscxx . . $ abs(a1851578aea3f541).(pitch_range);
545
546 if (continuing) {
547 initial = false;
548 overflow = 0;
549 n_overflow = 5;
550 overflow_tab = continue_tab;
551 increment = pitch_range / (th->body_max_stepscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1#body_max_steps. -1);
552 } else {
553 n_overflow = th->n_overflowcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1#n_overflow.;
554 overflow_tab = th->overflowcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1#overflow.;
555 initial = true;
556 }
557
558 while (ix < end_ix) {
559 syl = &syllable_tab[ix];
560 stress = syl->stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress.;
561
562 if (initial || (stress >= min_stress)) {
563 // a primary stress
564
565 if ((initial) || (stress == 5)) {
566 initial = false;
567 overflow = 0;
568 n_steps = n_primary = count_incrementscxx . . $ count_increments(510c9c30ecbf73).(syllable_tab, ix, end_ix, min_stress);
569
570 if (n_steps > th->body_max_stepscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1#body_max_steps.)
571 n_steps = th->body_max_stepscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1#body_max_steps.;
572
573 if (n_steps > 1)
574 increment = pitch_range / (n_steps -1);
575 else
576 increment = 0;
577
578 pitch = th->body_startcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1#body_start. * 256;
579 } else {
580 if (n_steps > 0)
581 pitch += increment;
582 else {
583 pitch = (th->body_endcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1#body_end. * 256) + (pitch_range_abs * overflow_tab[overflow++])/64;
584 if (overflow >= n_overflow) {
585 overflow = 0;
586 overflow_tab = th->overflowcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1#overflow.;
587 }
588 }
589 }
590
591 n_steps--;
592
593 n_primary--;
594 if ((tn->backwardscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2#backwards.) && (n_primary < 2))
595 pitch = tn->backwardscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2#backwards.[n_primary] * 256;
596 }
597
598 if (stress >= PRIMARYcxx . . $ `external/espeak/intonation.cpp:291:9`!) {
599 syl->stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. = PRIMARY_STRESSEDcxx . . $ `external/espeak/intonation.cpp:292:9`!;
600 set_pitchcxx . . $ set_pitch(bb1885ad957de506).(syl, (pitch / 256), drops[stress]);
601 } else if (stress >= SECONDARYcxx . . $ `external/espeak/intonation.cpp:290:9`!)
602 set_pitchcxx . . $ set_pitch(bb1885ad957de506).(syl, (pitch / 256), drops[stress]);
603 else {
604 // unstressed, drop pitch if preceded by PRIMARY
605 if ((syllable_tab[ix-1].stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. & 0x3f) >= SECONDARYcxx . . $ `external/espeak/intonation.cpp:290:9`!)
606 set_pitchcxx . . $ set_pitch(bb1885ad957de506).(syl, (pitch / 256) - th->body_lower_ucxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1#body_lower_u., drops[stress]);
607 else
608 set_pitchcxx . . $ set_pitch(bb1885ad957de506).(syl, (pitch / 256), drops[stress]);
609 }
610
611 ix++;
612 }
613 return ix;
614 }
615
616 static void SetPitchGradientcxx . . $ SetPitchGradient(98db052f094c8e44).(SYLLABLEcxx . . $ SYLLABLE# *syllable_tab, int start_ix, int end_ix, int start_pitch, int end_pitch)
617 {
618 // Set a linear pitch change over a number of syllables.
619 // Used for pre-head, unstressed syllables in the body, and the tail
620
621 int ix;
622 int stress;
623 int pitch;
624 int increment;
625 int n_increments;
626 int drop;
627 SYLLABLEcxx . . $ SYLLABLE# *syl;
628
629 increment = (end_pitch - start_pitch) * 256;
630 n_increments = end_ix - start_ix;
631
632 if (n_increments <= 0)
633 return;
634
635 if (n_increments > 1)
636 increment = increment / n_increments;
637
638 pitch = start_pitch * 256;
639
640 for (ix = start_ix; ix < end_ix; ix++) {
641 syl = &syllable_tab[ix];
642 stress = syl->stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress.;
643
644 if (increment > 0) {
645 set_pitchcxx . . $ set_pitch(bb1885ad957de506).(syl, (pitch / 256), -(increment / 256));
646 pitch += increment;
647 } else {
648 drop = -(increment / 256);
649 if (drop < min_dropcxx . . $ min_drop.[stress])
650 drop = min_dropcxx . . $ min_drop.[stress];
651
652 pitch += increment;
653
654 if (drop > 18)
655 drop = 18;
656 set_pitchcxx . . $ set_pitch(bb1885ad957de506).(syl, (pitch / 256), drop);
657 }
658 }
659 }
660
661 // Calculate pitch values for the vowels in this tone group
662 static int calc_pitches2cxx . . $ calc_pitches2(510c9c30ecbf73).(SYLLABLEcxx . . $ SYLLABLE# *syllable_tab, int start, int end, int tune_number)
663 {
664 int ix;
665 TUNE *tune;
666 int drop;
667
668 tune = &tunes[tune_number];
669 ix = start;
670
671 // vowels before the first primary stress
672
673 SetPitchGradientcxx . . $ SetPitchGradient(98db052f094c8e44).(syllable_tab, ix, ix+number_precxx . . $ number_pre., tune->prehead_start, tune->prehead_end);
674 ix += number_precxx . . $ number_pre.;
675
676 // body of tonic segment
677
678 if (option_tone_flags & OPTION_EMPHASIZE_PENULTIMATEcxx . . $ `external/espeak/translate.h:614:9`!)
679 tone_posncxx . . $ tone_posn. = tone_posn2cxx . . $ tone_posn2.; // put tone on the penultimate stressed word
680 ix = SetHeadIntonationcxx . . $ SetHeadIntonation(e5383c6110a47816).(syllable_tab, tune, ix, tone_posncxx . . $ tone_posn.);
681
682 if (no_toniccxx . . $ no_tonic.)
683 return 0;
684
685 // tonic syllable
686
687 if (number_tailcxx . . $ number_tail. == 0) {
688 tone_pitch_envcxx . . $ tone_pitch_env. = tune->nucleus0_env;
689 drop = tune->nucleus0_max - tune->nucleus0_min;
690 set_pitchcxx . . $ set_pitch(bb1885ad957de506).(&syllable_tab[ix++], tune->nucleus0_min, drop);
691 } else {
692 tone_pitch_envcxx . . $ tone_pitch_env. = tune->nucleus1_env;
693 drop = tune->nucleus1_max - tune->nucleus1_min;
694 set_pitchcxx . . $ set_pitch(bb1885ad957de506).(&syllable_tab[ix++], tune->nucleus1_min, drop);
695 }
696
697 syllable_tab[tone_posncxx . . $ tone_posn.].envcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#env. = tone_pitch_envcxx . . $ tone_pitch_env.;
698 if (syllable_tab[tone_posncxx . . $ tone_posn.].stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. == PRIMARYcxx . . $ `external/espeak/intonation.cpp:291:9`!)
699 syllable_tab[tone_posncxx . . $ tone_posn.].stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. = PRIMARY_STRESSEDcxx . . $ `external/espeak/intonation.cpp:292:9`!;
700
701 // tail, after the tonic syllable
702
703 SetPitchGradientcxx . . $ SetPitchGradient(98db052f094c8e44).(syllable_tab, ix, end, tune->tail_start, tune->tail_end);
704
705 return tone_pitch_envcxx . . $ tone_pitch_env.;
706 }
707
708 // Calculate pitch values for the vowels in this tone group
709 static int calc_pitchescxx . . $ calc_pitches(1b2399585a35852b).(SYLLABLEcxx . . $ SYLLABLE# *syllable_tab, int control, int start, int end, int tune_number)
710 {
711 int ix;
712 const TONE_HEADcxx . . $ TONE_HEAD# *th;
713 const TONE_NUCLEUScxx . . $ TONE_NUCLEUS# *tn;
714 int drop;
715 bool continuing = false;
716
717 if (control == 0)
718 return calc_pitches2cxx . . $ calc_pitches2(510c9c30ecbf73).(syllable_tab, start, end, tune_number);
719
720 if (start > 0)
721 continuing = true;
722
723 th = &tone_head_tablecxx . . $ tone_head_table.[tune_number];
724 tn = &tone_nucleus_tablecxx . . $ tone_nucleus_table.[tune_number];
725 ix = start;
726
727 // vowels before the first primary stress
728
729 SetPitchGradientcxx . . $ SetPitchGradient(98db052f094c8e44).(syllable_tab, ix, ix+number_precxx . . $ number_pre., th->pre_startcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1#pre_start., th->pre_endcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_1#pre_end.);
730 ix += number_precxx . . $ number_pre.;
731
732 // body of tonic segment
733
734 if (option_tone_flags & OPTION_EMPHASIZE_PENULTIMATEcxx . . $ `external/espeak/translate.h:614:9`!)
735 tone_posncxx . . $ tone_posn. = tone_posn2cxx . . $ tone_posn2.; // put tone on the penultimate stressed word
736 ix = calc_pitch_segmentcxx . . $ calc_pitch_segment(884bb55f50f9c43d).(syllable_tab, ix, tone_posncxx . . $ tone_posn., th, tn, PRIMARYcxx . . $ `external/espeak/intonation.cpp:291:9`!, continuing);
737
738 if (no_toniccxx . . $ no_tonic.)
739 return 0;
740
741 // tonic syllable
742
743 if (tn->flagscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2#flags. & T_EMPHcxx . . $ `external/espeak/intonation.cpp:256:9`!)
744 syllable_tab[ix].flagscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#flags. |= SYL_EMPHASIScxx . . $ `external/espeak/intonation.cpp:43:9`!;
745
746 if (number_tailcxx . . $ number_tail. == 0) {
747 tone_pitch_envcxx . . $ tone_pitch_env. = tn->pitch_env0cxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2#pitch_env0.;
748 drop = tn->tonic_max0cxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2#tonic_max0. - tn->tonic_min0cxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2#tonic_min0.;
749 set_pitchcxx . . $ set_pitch(bb1885ad957de506).(&syllable_tab[ix++], tn->tonic_min0cxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2#tonic_min0., drop);
750 } else {
751 tone_pitch_envcxx . . $ tone_pitch_env. = tn->pitch_env1cxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2#pitch_env1.;
752 drop = tn->tonic_max1cxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2#tonic_max1. - tn->tonic_min1cxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2#tonic_min1.;
753 set_pitchcxx . . $ set_pitch(bb1885ad957de506).(&syllable_tab[ix++], tn->tonic_min1cxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2#tonic_min1., drop);
754 }
755
756 syllable_tab[tone_posncxx . . $ tone_posn.].envcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#env. = tone_pitch_envcxx . . $ tone_pitch_env.;
757 if (syllable_tab[tone_posncxx . . $ tone_posn.].stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. == PRIMARYcxx . . $ `external/espeak/intonation.cpp:291:9`!)
758 syllable_tab[tone_posncxx . . $ tone_posn.].stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. = PRIMARY_STRESSEDcxx . . $ `external/espeak/intonation.cpp:292:9`!;
759
760 // tail, after the tonic syllable
761
762 SetPitchGradientcxx . . $ SetPitchGradient(98db052f094c8e44).(syllable_tab, ix, end, tn->tail_startcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2#tail_start., tn->tail_endcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_2#tail_end.);
763
764 return tone_pitch_envcxx . . $ tone_pitch_env.;
765 }
766
767 static void CalcPitches_Tonecxx . . $ CalcPitches_Tone(801a8dd91605e066).(Translator *tr)
768 {
769 PHONEME_LIST *p;
770 int ix;
771 int final_stressed = 0;
772
773 int tone_ph;
774 bool pause;
775 bool tone_promoted;
776 PHONEME_TAB *tph;
777 PHONEME_TAB *prev_tph; // forget across word boundary
778 PHONEME_TAB *prevw_tph; // remember across word boundary
779 PHONEME_LIST *prev_p;
780
781 int pitch_adjust = 0; // pitch gradient through the clause - initial value
782 int pitch_decrement = 0; // decrease by this for each stressed syllable
783 int pitch_low = 0; // until it drops to this
784 int pitch_high = 0; // then reset to this
785
786 // count number of stressed syllables
787 p = &phoneme_list[0];
788 for (ix = 0; ix < n_phoneme_list; ix++, p++) {
789 if ((p->type == phVOWELcxx . . $ `external/espeak/phoneme.h:134:9`!) && (p->stresslevel >= 4)) {
790 final_stressed = ix;
791 }
792 }
793
794 phoneme_list[final_stressed].stresslevel = 7;
795
796 // language specific, changes to tones
797 if (tr->translator_name == Lcxx . . $ `external/espeak/translate.h:33:9`!('v', 'i')) {
798 // LANG=vi
799 p = &phoneme_list[final_stressed];
800 if (p->tone_ph == 0)
801 p->tone_ph = PhonemeCode('7'); // change default tone (tone 1) to falling tone at end of clause
802 }
803
804 pause = true;
805 tone_promoted = false;
806
807 prev_p = p = &phoneme_list[0];
808 prev_tph = prevw_tph = phoneme_tab[phonPAUSEcxx . . $ `external/espeak/phoneme.h:207:9`!];
809
810 // perform tone sandhi
811 for (ix = 0; ix < n_phoneme_list; ix++, p++) {
812 if ((p->type == phPAUSEcxx . . $ `external/espeak/phoneme.h:132:9`!) && (p->ph->std_length > 50)) {
813 pause = true; // there is a pause since the previous vowel
814 prevw_tph = phoneme_tab[phonPAUSEcxx . . $ `external/espeak/phoneme.h:207:9`!]; // forget previous tone
815 }
816
817 if (p->newword)
818 prev_tph = phoneme_tab[phonPAUSEcxx . . $ `external/espeak/phoneme.h:207:9`!]; // forget across word boundaries
819
820 if (p->synthflags & SFLAG_SYLLABLEcxx . . $ `external/espeak/synthesize.h:54:9`!) {
821 tone_ph = p->tone_ph;
822 tph = phoneme_tab[tone_ph];
823
824 /* Hakka
825 ref.:https://en.wikipedia.org/wiki/Sixian_dialect#Tone_sandhi */
826 if (tr->translator_name == L3cxx . . $ `external/espeak/translate.h:34:9`!('h','a','k')){
827 if (prev_tph->mnemonic == 0x31){ // [previous one is 1st tone]
828 // [this one is 1st, 4th, or 6th tone]
829 if (tph->mnemonic == 0x31 || tph->mnemonic == 0x34 ||
830 tph->mnemonic == 0x36){
831 /* trigger the tone sandhi of the prev. syllable
832 from 1st tone ->2nd tone */
833 prev_p->tone_ph = PhonemeCode('2');
834 }
835 }
836 }
837 // Mandarin
838 if (tr->translator_name == Lcxx . . $ `external/espeak/translate.h:33:9`!('z', 'h') || tr->translator_name == L3cxx . . $ `external/espeak/translate.h:34:9`!('c', 'm', 'n')) {
839 if (tone_ph == 0) {
840 if (pause || tone_promoted) {
841 tone_ph = PhonemeCode2cxx . . $ `external/espeak/phoneme.h:278:9`!('5', '5'); // no previous vowel, use tone 1
842 tone_promoted = true;
843 } else
844 tone_ph = PhonemeCode2cxx . . $ `external/espeak/phoneme.h:278:9`!('1', '1'); // default tone 5
845
846 p->tone_ph = tone_ph;
847 tph = phoneme_tab[tone_ph];
848 } else
849 tone_promoted = false;
850
851 if (ix == final_stressed) {
852 if ((tph->mnemonic == 0x3535 ) || (tph->mnemonic == 0x3135)) {
853 // change sentence final tone 1 or 4 to stress 6, not 7
854 phoneme_list[final_stressed].stresslevel = 6;
855 }
856 }
857
858 if (prevw_tph->mnemonic == 0x343132) { // [214]
859 if (tph->mnemonic == 0x343132) // [214]
860 prev_p->tone_ph = PhonemeCode2cxx . . $ `external/espeak/phoneme.h:278:9`!('3', '5');
861 else
862 prev_p->tone_ph = PhonemeCode2cxx . . $ `external/espeak/phoneme.h:278:9`!('2', '1');
863 }
864 if ((prev_tph->mnemonic == 0x3135) && (tph->mnemonic == 0x3135)) // [51] + [51]
865 prev_p->tone_ph = PhonemeCode2cxx . . $ `external/espeak/phoneme.h:278:9`!('5', '3');
866
867 if (tph->mnemonic == 0x3131) { // [11] Tone 5
868 // tone 5, change its level depending on the previous tone (across word boundaries)
869 if (prevw_tph->mnemonic == 0x3535)
870 p->tone_ph = PhonemeCode2cxx . . $ `external/espeak/phoneme.h:278:9`!('2', '2');
871 if (prevw_tph->mnemonic == 0x3533)
872 p->tone_ph = PhonemeCode2cxx . . $ `external/espeak/phoneme.h:278:9`!('3', '3');
873 if (prevw_tph->mnemonic == 0x343132)
874 p->tone_ph = PhonemeCode2cxx . . $ `external/espeak/phoneme.h:278:9`!('4', '4');
875
876 // tone 5 is unstressed (shorter)
877 p->stresslevel = 0; // diminished stress
878 }
879 }
880
881 prev_p = p;
882 prevw_tph = prev_tph = tph;
883 pause = false;
884 }
885 }
886
887 // convert tone numbers to pitch
888 p = &phoneme_list[0];
889 for (ix = 0; ix < n_phoneme_list; ix++, p++) {
890 if (p->synthflags & SFLAG_SYLLABLEcxx . . $ `external/espeak/synthesize.h:54:9`!) {
891 tone_ph = p->tone_ph;
892
893 if (p->stresslevel != 0) { // TEST, consider all syllables as stressed
894 if (ix == final_stressed) {
895 // the last stressed syllable
896 pitch_adjust = pitch_low;
897 } else {
898 pitch_adjust -= pitch_decrement;
899 if (pitch_adjust <= pitch_low)
900 pitch_adjust = pitch_high;
901 }
902 }
903
904 if (tone_ph == 0) {
905 tone_ph = phonDEFAULTTONEcxx . . $ `external/espeak/phoneme.h:214:9`!; // no tone specified, use default tone 1
906 p->tone_ph = tone_ph;
907 }
908 p->pitch1 = pitch_adjust + phoneme_tab[tone_ph]->start_type;
909 p->pitch2 = pitch_adjust + phoneme_tab[tone_ph]->end_type;
910 }
911 }
912 }
913
914 void CalcPitchescxx . . $ CalcPitches(44ca618724cd7367).(Translator *tr, int clause_type)
915 {
916 // clause_type: 0=. 1=, 2=?, 3=! 4=none
917
918 PHONEME_LIST *p;
919 SYLLABLEcxx . . $ SYLLABLE# *syl;
920 int ix;
921 int x;
922 int st_ix;
923 int n_st;
924 int option;
925 int group_tone;
926 int group_tone_comma;
927 int ph_start = 0;
928 int st_start;
929 int st_clause_end;
930 int count;
931 int n_primary;
932 int count_primary;
933 PHONEME_TAB *ph;
934 int ph_end = n_phoneme_list;
935
936 SYLLABLEcxx . . $ SYLLABLE# syllable_tab[N_PHONEME_LISTcxx . . $ `external/espeak/synthesize.h:35:9`!];
937 n_st = 0;
938 n_primary = 0;
939 for (ix = 0; ix < (n_phoneme_list-1); ix++) {
940 p = &phoneme_list[ix];
941 syllable_tab[ix].flagscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#flags. = 0;
942 if (p->synthflags & SFLAG_SYLLABLEcxx . . $ `external/espeak/synthesize.h:54:9`!) {
943 syllable_tab[n_st].envcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#env. = PITCHfallcxx . . $ `external/espeak/intonation.cpp:60:9`!;
944 syllable_tab[n_st].nextph_typecxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#nextph_type. = phoneme_list[ix+1].type;
945 syllable_tab[n_st++].stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. = p->stresslevel;
946
947 if (p->stresslevel >= 4)
948 n_primary++;
949 } else if ((p->ph->code == phonPAUSE_CLAUSEcxx . . $ `external/espeak/phoneme.h:224:9`!) && (n_st > 0))
950 syllable_tab[n_st-1].flagscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#flags. |= SYL_END_CLAUSEcxx . . $ `external/espeak/intonation.cpp:44:9`!;
951 }
952 syllable_tab[n_st].stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. = 0; // extra 0 entry at the end
953
954 if (n_st == 0)
955 return; // nothing to do
956
957 if (tr->langopts.tone_language == 1) {
958 CalcPitches_Tonecxx . . $ CalcPitches_Tone(801a8dd91605e066).(tr);
959 return;
960 }
961
962 option = tr->langopts.intonation_group;
963 if (option >= INTONATION_TYPEScxx . . $ `external/espeak/translate.h:571:10`!)
964 option = 1;
965
966 if (option == 0) {
967 group_tone = tr->langopts.tunes[clause_type];
968 group_tone_comma = tr->langopts.tunes[1];
969 } else {
970 group_tone = tr->punct_to_tone[option][clause_type];
971 group_tone_comma = tr->punct_to_tone[option][1]; // emphatic form of statement
972 }
973
974 if (clause_type == 4)
975 no_toniccxx . . $ no_tonic. = 1; // incomplete clause, used for abbreviations such as Mr. Dr. Mrs.
976 else
977 no_toniccxx . . $ no_tonic. = 0;
978
979 st_start = 0;
980 count_primary = 0;
981 for (st_ix = 0; st_ix < n_st; st_ix++) {
982 syl = &syllable_tab[st_ix];
983
984 if (syl->stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. >= 4)
985 count_primary++;
986
987 if (syl->stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. == 6) {
988 // reduce the stress of the previous stressed syllable (review only the previous few syllables)
989 for (ix = st_ix-1; ix >= st_start && ix >= (st_ix-3); ix--) {
990 if (syllable_tab[ix].stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. == 6)
991 break;
992 if (syllable_tab[ix].stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. == 4) {
993 syllable_tab[ix].stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. = 3;
994 break;
995 }
996 }
997
998 // are the next primary syllables also emphasized ?
999 for (ix = st_ix+1; ix < n_st; ix++) {
1000 if (syllable_tab[ix].stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. == 4)
1001 break;
1002 if (syllable_tab[ix].stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. == 6) {
1003 // emphasize this syllable, but don't end the current tone group
1004 syllable_tab[st_ix].flagscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#flags. = SYL_EMPHASIScxx . . $ `external/espeak/intonation.cpp:43:9`!;
1005 syl->stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. = 5;
1006 break;
1007 }
1008 }
1009 }
1010
1011 if (syl->stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. == 6) {
1012 // an emphasized syllable, end the tone group after the next primary stress
1013 syllable_tab[st_ix].flagscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#flags. = SYL_EMPHASIScxx . . $ `external/espeak/intonation.cpp:43:9`!;
1014
1015 count = 0;
1016 if ((n_primary - count_primary) > 1)
1017 count = 1;
1018
1019 for (ix = st_ix+1; ix < n_st; ix++) {
1020 if (syllable_tab[ix].stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. > 4)
1021 break;
1022 if (syllable_tab[ix].stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress. == 4) {
1023 count++;
1024 if (count > 1)
1025 break;
1026 }
1027 }
1028
1029 count_pitch_vowelscxx . . $ count_pitch_vowels(94c804bd0ff4d6cf).(syllable_tab, st_start, ix, n_st);
1030 if ((ix < n_st) || (clause_type == 0)) {
1031 calc_pitchescxx . . $ calc_pitches(1b2399585a35852b).(syllable_tab, option, st_start, ix, group_tone); // split into > 1 tone groups
1032
1033 if ((clause_type == 1) || (clause_type == 2))
1034 group_tone = tr->langopts.tunes[1]; // , or ? remainder has comma-tone
1035 else
1036 group_tone = tr->langopts.tunes[0]; // . or ! remainder has statement tone
1037 } else
1038 calc_pitchescxx . . $ calc_pitches(1b2399585a35852b).(syllable_tab, option, st_start, ix, group_tone);
1039
1040 st_start = ix;
1041 }
1042 if ((st_start < st_ix) && (syl->flagscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#flags. & SYL_END_CLAUSEcxx . . $ `external/espeak/intonation.cpp:44:9`!)) {
1043 // end of clause after this syllable, indicated by a phonPAUSE_CLAUSE phoneme
1044 st_clause_end = st_ix+1;
1045 count_pitch_vowelscxx . . $ count_pitch_vowels(94c804bd0ff4d6cf).(syllable_tab, st_start, st_clause_end, st_clause_end);
1046 calc_pitchescxx . . $ calc_pitches(1b2399585a35852b).(syllable_tab, option, st_start, st_clause_end, group_tone_comma);
1047 st_start = st_clause_end;
1048 }
1049 }
1050
1051 if (st_start < st_ix) {
1052 count_pitch_vowelscxx . . $ count_pitch_vowels(94c804bd0ff4d6cf).(syllable_tab, st_start, st_ix, n_st);
1053 calc_pitchescxx . . $ calc_pitches(1b2399585a35852b).(syllable_tab, option, st_start, st_ix, group_tone);
1054 }
1055
1056 // unpack pitch data
1057 st_ix = 0;
1058 for (ix = ph_start; ix < ph_end; ix++) {
1059 p = &phoneme_list[ix];
1060 p->stresslevel = syllable_tab[st_ix].stresscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#stress.;
1061
1062 if (p->synthflags & SFLAG_SYLLABLEcxx . . $ `external/espeak/synthesize.h:54:9`!) {
1063 syl = &syllable_tab[st_ix];
1064
1065 p->pitch1 = syl->pitch1cxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#pitch1.;
1066 p->pitch2 = syl->pitch2cxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#pitch2.;
1067
1068 p->env = PITCHfallcxx . . $ `external/espeak/intonation.cpp:60:9`!;
1069 if (syl->flagscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#flags. & SYL_RISEcxx . . $ `external/espeak/intonation.cpp:42:9`!)
1070 p->env = PITCHrisecxx . . $ `external/espeak/intonation.cpp:61:9`!;
1071 else if (p->stresslevel > 5)
1072 p->env = syl->envcxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#env.;
1073
1074 if (p->pitch1 > p->pitch2) {
1075 // swap so that pitch2 is the higher
1076 x = p->pitch1;
1077 p->pitch1 = p->pitch2;
1078 p->pitch2 = x;
1079 }
1080
1081 if (p->tone_ph) {
1082 ph = phoneme_tab[p->tone_ph];
1083 x = (p->pitch1 + p->pitch2)/2;
1084 p->pitch2 = x + ph->end_type;
1085 p->pitch1 = x + ph->start_type;
1086 }
1087
1088 if (syl->flagscxx . . $ $anonymous_type_ddcdbf2df18f0cf7_0#flags. & SYL_EMPHASIScxx . . $ `external/espeak/intonation.cpp:43:9`!)
1089 p->stresslevel |= 8; // emphasized
1090
1091 st_ix++;
1092 }
1093 }
1094 }