| 1 | /* |
| 2 | * Copyright (C) 2008 by Jonathan Duddington |
| 3 | * email: [email protected] |
| 4 | * Copyright (C) 2013-2016 Reece H. Dunn |
| 5 | * |
| 6 | * Based on a re-implementation by: |
| 7 | * (c) 1993,94 Jon Iles and Nick Ing-Simmons |
| 8 | * of the Klatt cascade-parallel formant synthesizer |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 3 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, see: <http://www.gnu.org/licenses/>. |
| 22 | */ |
| 23 | |
| 24 | // See URL: ftp://svr-ftp.eng.cam.ac.uk/pub/comp.speech/synthesis/klatt.3.04.tar.gz |
| 25 | |
| 26 | #include "espeak__config.h"cxx . . $ `<file>/external/espeak/espeak__config.h`/ |
| 27 | |
| 28 | #include <math.h> |
| 29 | #include <stdint.h> |
| 30 | #include <stdio.h> |
| 31 | #include <stdlib.h> |
| 32 | #include <string.h> |
| 33 | |
| 34 | #include "espeak_ng.h"cxx . . $ `<file>/external/espeak/espeak_ng.h`/ |
| 35 | #include "speak_lib.h"cxx . . $ `<file>/external/espeak/speak_lib.h`/ |
| 36 | |
| 37 | #include "klatt.h"cxx . . $ `<file>/external/espeak/klatt.h`/ |
| 38 | #include "common.h"cxx . . $ `<file>/external/espeak/common.h`/ // for espeak_rand |
| 39 | #include "synthesize.h"cxx . . $ `<file>/external/espeak/synthesize.h`/ // for frame_t, WGEN_DATA, STEPSIZE, N_KLATTP, echo... |
| 40 | #include "voice.h"cxx . . $ `<file>/external/espeak/voice.h`/ // for voice_t, N_PEAKS |
| 41 | #if USE_SPEECHPLAYERcxx . . $ `external/espeak/espeak__config.h:15:9`! |
| 42 | #include "sPlayer.h" |
| 43 | #endif |
| 44 | |
| 45 | extern unsigned char *out_ptrcxx . . $ out_ptr.; |
| 46 | extern unsigned char *out_endcxx . . $ out_end.; |
| 47 | static int nsamplescxx . . $ nsamples.; |
| 48 | static int sample_countcxx . . $ sample_count.; |
| 49 | |
| 50 | #define getrandomcxx . . $ `external/espeak/klatt.cpp:50:9`!(min, max) espeak_rand((min), (max)) |
| 51 | |
| 52 | // function prototypes for functions private to this file |
| 53 | |
| 54 | static void fluttercxx . . $ flutter(9c370aab8c75c9fc).(klatt_frame_ptr); |
| 55 | static double sampled_sourcecxx . . $ sampled_source(4badf5dbac1308a7).(int); |
| 56 | static double impulsive_sourcecxx . . $ impulsive_source(31fa7155c10fdd13).(void); |
| 57 | static double natural_sourcecxx . . $ natural_source(31fa7155c10fdd13).(void); |
| 58 | static void pitch_synch_par_resetcxx . . $ pitch_synch_par_reset(9c370aab8c75c9fc).(klatt_frame_ptr); |
| 59 | static double gen_noisecxx . . $ gen_noise(447c67c6676f75c3).(double); |
| 60 | static double DBtoLINcxx . . $ DBtoLIN(66f4a6ec74012662).(long); |
| 61 | static void frame_initcxx . . $ frame_init(9c370aab8c75c9fc).(klatt_frame_ptr); |
| 62 | static void setabccxx . . $ setabc(a0a3dbb240eaa8cd).(long, long, resonator_ptr); |
| 63 | static void SetSynth_Klattcxx . . $ SetSynth_Klatt(b51b8c334121c45d).(int length, frame_t *fr1, frame_t *fr2, voice_t *v, int control); |
| 64 | static void setzeroabccxx . . $ setzeroabc(a0a3dbb240eaa8cd).(long, long, resonator_ptr); |
| 65 | |
| 66 | static klatt_frame_t kt_framecxx . . $ kt_frame.; |
| 67 | static klatt_global_t kt_globalscxx . . $ kt_globals.; |
| 68 | |
| 69 | #define NUMBER_OF_SAMPLEScxx . . $ `external/espeak/klatt.cpp:69:9`! 100 |
| 70 | |
| 71 | static const int scale_wav_tabcxx . . $ scale_wav_tab.[] = { 45, 38, 45, 45, 55, 45 }; // scale output from different voicing sources |
| 72 | |
| 73 | // For testing, this can be overwritten in KlattInit() |
| 74 | static const short natural_samples2cxx . . $ natural_samples2.[256] = { |
| 75 | 2583, 2516, 2450, 2384, 2319, 2254, 2191, 2127, |
| 76 | 2067, 2005, 1946, 1890, 1832, 1779, 1726, 1675, |
| 77 | 1626, 1579, 1533, 1491, 1449, 1409, 1372, 1336, |
| 78 | 1302, 1271, 1239, 1211, 1184, 1158, 1134, 1111, |
| 79 | 1089, 1069, 1049, 1031, 1013, 996, 980, 965, |
| 80 | 950, 936, 921, 909, 895, 881, 869, 855, |
| 81 | 843, 830, 818, 804, 792, 779, 766, 754, |
| 82 | 740, 728, 715, 702, 689, 676, 663, 651, |
| 83 | 637, 626, 612, 601, 588, 576, 564, 552, |
| 84 | 540, 530, 517, 507, 496, 485, 475, 464, |
| 85 | 454, 443, 434, 424, 414, 404, 394, 385, |
| 86 | 375, 366, 355, 347, 336, 328, 317, 308, |
| 87 | 299, 288, 280, 269, 260, 250, 240, 231, |
| 88 | 220, 212, 200, 192, 181, 172, 161, 152, |
| 89 | 142, 133, 123, 113, 105, 94, 86, 76, |
| 90 | 67, 57, 49, 39, 30, 22, 11, 4, |
| 91 | -5, -14, -23, -32, -41, -50, -60, -69, |
| 92 | -78, -87, -96, -107, -115, -126, -134, -144, |
| 93 | -154, -164, -174, -183, -193, -203, -213, -222, |
| 94 | -233, -242, -252, -262, -271, -281, -291, -301, |
| 95 | -310, -320, -330, -339, -349, -357, -368, -377, |
| 96 | -387, -397, -406, -417, -426, -436, -446, -456, |
| 97 | -467, -477, -487, -499, -509, -521, -532, -543, |
| 98 | -555, -567, -579, -591, -603, -616, -628, -641, |
| 99 | -653, -666, -679, -692, -705, -717, -732, -743, |
| 100 | -758, -769, -783, -795, -808, -820, -834, -845, |
| 101 | -860, -872, -885, -898, -911, -926, -939, -955, |
| 102 | -968, -986, -999, -1018, -1034, -1054, -1072, -1094, |
| 103 | -1115, -1138, -1162, -1188, -1215, -1244, -1274, -1307, |
| 104 | -1340, -1377, -1415, -1453, -1496, -1538, -1584, -1631, |
| 105 | -1680, -1732, -1783, -1839, -1894, -1952, -2010, -2072, |
| 106 | -2133, -2196, -2260, -2325, -2390, -2456, -2522, -2589, |
| 107 | }; |
| 108 | static const short natural_samplescxx . . $ natural_samples.[100] = { |
| 109 | -310, -400, 530, 356, 224, 89, 23, -10, -58, -16, 461, 599, 536, 701, 770, |
| 110 | 605, 497, 461, 560, 404, 110, 224, 131, 104, -97, 155, 278, -154, -1165, |
| 111 | -598, 737, 125, -592, 41, 11, -247, -10, 65, 92, 80, -304, 71, 167, -1, 122, |
| 112 | 233, 161, -43, 278, 479, 485, 407, 266, 650, 134, 80, 236, 68, 260, 269, 179, |
| 113 | 53, 140, 275, 293, 296, 104, 257, 152, 311, 182, 263, 245, 125, 314, 140, 44, |
| 114 | 203, 230, -235, -286, 23, 107, 92, -91, 38, 464, 443, 176, 98, -784, -2449, |
| 115 | -1891, -1045, -1600, -1462, -1384, -1261, -949, -730 |
| 116 | }; |
| 117 | |
| 118 | /* |
| 119 | function RESONATOR |
| 120 | |
| 121 | This is a generic resonator function. Internal memory for the resonator |
| 122 | is stored in the globals structure. |
| 123 | */ |
| 124 | |
| 125 | static double resonatorcxx . . $ resonator(737208046921dbd8).(resonator_ptr r, double input) |
| 126 | { |
| 127 | double x; |
| 128 | |
| 129 | x = (double)((double)r->a * (double)input + (double)r->b * (double)r->p1 + (double)r->c * (double)r->p2); |
| 130 | r->p2 = (double)r->p1; |
| 131 | r->p1 = (double)x; |
| 132 | |
| 133 | return (double)x; |
| 134 | } |
| 135 | |
| 136 | /* |
| 137 | function ANTIRESONATOR |
| 138 | |
| 139 | This is a generic anti-resonator function. The code is the same as resonator |
| 140 | except that a,b,c need to be set with setzeroabc() and we save inputs in |
| 141 | p1/p2 rather than outputs. There is currently only one of these - "rnz" |
| 142 | Output = (rnz.a * input) + (rnz.b * oldin1) + (rnz.c * oldin2) |
| 143 | */ |
| 144 | |
| 145 | static double antiresonatorcxx . . $ antiresonator(737208046921dbd8).(resonator_ptr r, double input) |
| 146 | { |
| 147 | /*register*/ double x = (double)r->a * (double)input + (double)r->b * (double)r->p1 + (double)r->c * (double)r->p2; |
| 148 | r->p2 = (double)r->p1; |
| 149 | r->p1 = (double)input; |
| 150 | return (double)x; |
| 151 | } |
| 152 | |
| 153 | /* |
| 154 | function FLUTTER |
| 155 | |
| 156 | This function adds F0 flutter, as specified in: |
| 157 | |
| 158 | "Analysis, synthesis and perception of voice quality variations among |
| 159 | female and male talkers" D.H. Klatt and L.C. Klatt JASA 87(2) February 1990. |
| 160 | |
| 161 | Flutter is added by applying a quasi-random element constructed from three |
| 162 | slowly varying sine waves. |
| 163 | */ |
| 164 | |
| 165 | static void fluttercxx . . $ flutter(9c370aab8c75c9fc).(klatt_frame_ptr frame) |
| 166 | { |
| 167 | static int time_count; |
| 168 | double delta_f0; |
| 169 | double fla, flb, flc, fld, fle; |
| 170 | |
| 171 | fla = (double)kt_globalscxx . . $ kt_globals..f0_flutter / 50; |
| 172 | flb = (double)kt_globalscxx . . $ kt_globals..original_f0 / 100; |
| 173 | flc = sincxx . . $ sin(fee4f1d22bc8e617).(M_PIcxx . . $ `melder/NUMmath.h:48:9`!*12.7*time_count); // because we are calling flutter() more frequently, every 2.9mS |
| 174 | fld = sincxx . . $ sin(fee4f1d22bc8e617).(M_PIcxx . . $ `melder/NUMmath.h:48:9`!*7.1*time_count); |
| 175 | fle = sincxx . . $ sin(fee4f1d22bc8e617).(M_PIcxx . . $ `melder/NUMmath.h:48:9`!*4.7*time_count); |
| 176 | delta_f0 = fla * flb * (flc + fld + fle) * 10; |
| 177 | frame->F0hz10 = frame->F0hz10 + (long)delta_f0; |
| 178 | time_count++; |
| 179 | } |
| 180 | |
| 181 | /* |
| 182 | function SAMPLED_SOURCE |
| 183 | |
| 184 | Allows the use of a glottal excitation waveform sampled from a real |
| 185 | voice. |
| 186 | */ |
| 187 | |
| 188 | static double sampled_sourcecxx . . $ sampled_source(4badf5dbac1308a7).(int source_num) |
| 189 | { |
| 190 | int itemp; |
| 191 | double ftemp; |
| 192 | double result; |
| 193 | double diff_value; |
| 194 | int current_value; |
| 195 | int next_value; |
| 196 | double temp_diff; |
| 197 | const short *samples; |
| 198 | |
| 199 | if (source_num == 0) { |
| 200 | samples = natural_samplescxx . . $ natural_samples.; |
| 201 | kt_globalscxx . . $ kt_globals..num_samples = 100; |
| 202 | } else { |
| 203 | samples = natural_samples2cxx . . $ natural_samples2.; |
| 204 | kt_globalscxx . . $ kt_globals..num_samples = 256; |
| 205 | } |
| 206 | |
| 207 | if (kt_globalscxx . . $ kt_globals..T0 != 0) { |
| 208 | ftemp = (double)kt_globalscxx . . $ kt_globals..nper; |
| 209 | ftemp = ftemp / kt_globalscxx . . $ kt_globals..T0; |
| 210 | ftemp = ftemp * kt_globalscxx . . $ kt_globals..num_samples; |
| 211 | itemp = (int)ftemp; |
| 212 | |
| 213 | temp_diff = ftemp - (double)itemp; |
| 214 | |
| 215 | current_value = samples[(itemp) % kt_globalscxx . . $ kt_globals..num_samples]; |
| 216 | next_value = samples[(itemp+1) % kt_globalscxx . . $ kt_globals..num_samples]; |
| 217 | |
| 218 | diff_value = (double)next_value - (double)current_value; |
| 219 | diff_value = diff_value * temp_diff; |
| 220 | |
| 221 | result = samples[(itemp) % kt_globalscxx . . $ kt_globals..num_samples] + diff_value; |
| 222 | result = result * kt_globalscxx . . $ kt_globals..sample_factor; |
| 223 | } else |
| 224 | result = 0; |
| 225 | return result; |
| 226 | } |
| 227 | |
| 228 | /* |
| 229 | function PARWAVE |
| 230 | |
| 231 | Converts synthesis parameters to a waveform. |
| 232 | */ |
| 233 | |
| 234 | static int parwavecxx . . $ parwave(552c95723cfdbe41).(klatt_frame_ptr frame, WGEN_DATA *wdata) |
| 235 | { |
| 236 | double temp; |
| 237 | int value; |
| 238 | double outbypas; |
| 239 | double out; |
| 240 | long n4; |
| 241 | double frics; |
| 242 | double glotout; |
| 243 | double aspiration; |
| 244 | double casc_next_in; |
| 245 | double par_glotout; |
| 246 | static double noise; |
| 247 | static double klattVoice; |
| 248 | static double vlast; |
| 249 | static double glotlast; |
| 250 | static double sourc; |
| 251 | int ix; |
| 252 | |
| 253 | fluttercxx . . $ flutter(9c370aab8c75c9fc).(frame); // add f0 flutter |
| 254 | |
| 255 | // MAIN LOOP, for each output sample of current frame: |
| 256 | |
| 257 | for (kt_globalscxx . . $ kt_globals..ns = 0; kt_globalscxx . . $ kt_globals..ns < kt_globalscxx . . $ kt_globals..nspfr; kt_globalscxx . . $ kt_globals..ns++) { |
| 258 | // Get low-passed random number for aspiration and frication noise |
| 259 | noise = gen_noisecxx . . $ gen_noise(447c67c6676f75c3).(noise); |
| 260 | |
| 261 | // Amplitude modulate noise (reduce noise amplitude during |
| 262 | // second half of glottal period) if voicing simultaneously present. |
| 263 | |
| 264 | if (kt_globalscxx . . $ kt_globals..nper > kt_globalscxx . . $ kt_globals..nmod) |
| 265 | noise *= (double)0.5; |
| 266 | |
| 267 | // Compute frication noise |
| 268 | frics = kt_globalscxx . . $ kt_globals..amp_frica * noise; |
| 269 | |
| 270 | // Compute voicing waveform. Run glottal source simulation at 4 |
| 271 | // times normal sample rate to minimize quantization noise in |
| 272 | // period of female voice. |
| 273 | |
| 274 | for (n4 = 0; n4 < 4; n4++) { |
| 275 | switch (kt_globalscxx . . $ kt_globals..glsource) |
| 276 | { |
| 277 | case IMPULSIVEcxx . . $ `external/espeak/klatt.h:38:9`!: |
| 278 | klattVoice = impulsive_sourcecxx . . $ impulsive_source(31fa7155c10fdd13).(); |
| 279 | break; |
| 280 | case NATURALcxx . . $ `external/espeak/klatt.h:39:9`!: |
| 281 | klattVoice = natural_sourcecxx . . $ natural_source(31fa7155c10fdd13).(); |
| 282 | break; |
| 283 | case SAMPLEDcxx . . $ `external/espeak/klatt.h:40:9`!: |
| 284 | klattVoice = sampled_sourcecxx . . $ sampled_source(4badf5dbac1308a7).(0); |
| 285 | break; |
| 286 | case SAMPLED2cxx . . $ `external/espeak/klatt.h:41:9`!: |
| 287 | klattVoice = sampled_sourcecxx . . $ sampled_source(4badf5dbac1308a7).(1); |
| 288 | break; |
| 289 | } |
| 290 | |
| 291 | // Reset period when counter 'nper' reaches T0 |
| 292 | if (kt_globalscxx . . $ kt_globals..nper >= kt_globalscxx . . $ kt_globals..T0) { |
| 293 | kt_globalscxx . . $ kt_globals..nper = 0; |
| 294 | pitch_synch_par_resetcxx . . $ pitch_synch_par_reset(9c370aab8c75c9fc).(frame); |
| 295 | } |
| 296 | |
| 297 | // Low-pass filter voicing waveform before downsampling from 4*samrate |
| 298 | // to samrate samples/sec. Resonator f=.09*samrate, bw=.06*samrate |
| 299 | |
| 300 | klattVoice = resonatorcxx . . $ resonator(737208046921dbd8).(&(kt_globalscxx . . $ kt_globals..rsn[RLPcxx . . $ `external/espeak/klatt.h:118:9`!]), klattVoice); |
| 301 | |
| 302 | // Increment counter that keeps track of 4*samrate samples per sec |
| 303 | kt_globalscxx . . $ kt_globals..nper++; |
| 304 | } |
| 305 | |
| 306 | if(kt_globalscxx . . $ kt_globals..glsource==5) { |
| 307 | double v=(kt_globalscxx . . $ kt_globals..nper/(double)kt_globalscxx . . $ kt_globals..T0); |
| 308 | v=(v*2)-1; |
| 309 | klattVoice=v*6000; |
| 310 | } |
| 311 | |
| 312 | // Tilt spectrum of voicing source down by soft low-pass filtering, amount |
| 313 | // of tilt determined by TLTdb |
| 314 | |
| 315 | klattVoice = (klattVoice * kt_globalscxx . . $ kt_globals..onemd) + (vlast * kt_globalscxx . . $ kt_globals..decay); |
| 316 | vlast = klattVoice; |
| 317 | |
| 318 | // Add breathiness during glottal open phase. Amount of breathiness |
| 319 | // determined by parameter Aturb Use nrand rather than noise because |
| 320 | // noise is low-passed. |
| 321 | |
| 322 | if (kt_globalscxx . . $ kt_globals..nper < kt_globalscxx . . $ kt_globals..nopen) |
| 323 | klattVoice += kt_globalscxx . . $ kt_globals..amp_breth * kt_globalscxx . . $ kt_globals..nrand; |
| 324 | |
| 325 | // Set amplitude of voicing |
| 326 | glotout = kt_globalscxx . . $ kt_globals..amp_voice * klattVoice; |
| 327 | par_glotout = kt_globalscxx . . $ kt_globals..par_amp_voice * klattVoice; |
| 328 | |
| 329 | // Compute aspiration amplitude and add to voicing source |
| 330 | aspiration = kt_globalscxx . . $ kt_globals..amp_aspir * noise; |
| 331 | glotout += aspiration; |
| 332 | |
| 333 | par_glotout += aspiration; |
| 334 | |
| 335 | // Cascade vocal tract, excited by laryngeal sources. |
| 336 | // Nasal antiresonator, then formants FNP, F5, F4, F3, F2, F1 |
| 337 | |
| 338 | out = 0; |
| 339 | if (kt_globalscxx . . $ kt_globals..synthesis_model != ALL_PARALLELcxx . . $ `external/espeak/klatt.h:36:9`!) { |
| 340 | casc_next_in = antiresonatorcxx . . $ antiresonator(737208046921dbd8).(&(kt_globalscxx . . $ kt_globals..rsn[Rnzcxx . . $ `external/espeak/klatt.h:100:9`!]), glotout); |
| 341 | casc_next_in = resonatorcxx . . $ resonator(737208046921dbd8).(&(kt_globalscxx . . $ kt_globals..rsn[Rnpccxx . . $ `external/espeak/klatt.h:109:9`!]), casc_next_in); |
| 342 | casc_next_in = resonatorcxx . . $ resonator(737208046921dbd8).(&(kt_globalscxx . . $ kt_globals..rsn[R8ccxx . . $ `external/espeak/klatt.h:108:9`!]), casc_next_in); |
| 343 | casc_next_in = resonatorcxx . . $ resonator(737208046921dbd8).(&(kt_globalscxx . . $ kt_globals..rsn[R7ccxx . . $ `external/espeak/klatt.h:107:9`!]), casc_next_in); |
| 344 | casc_next_in = resonatorcxx . . $ resonator(737208046921dbd8).(&(kt_globalscxx . . $ kt_globals..rsn[R6ccxx . . $ `external/espeak/klatt.h:106:9`!]), casc_next_in); |
| 345 | casc_next_in = resonatorcxx . . $ resonator(737208046921dbd8).(&(kt_globalscxx . . $ kt_globals..rsn[R5ccxx . . $ `external/espeak/klatt.h:105:9`!]), casc_next_in); |
| 346 | casc_next_in = resonatorcxx . . $ resonator(737208046921dbd8).(&(kt_globalscxx . . $ kt_globals..rsn[R4ccxx . . $ `external/espeak/klatt.h:104:9`!]), casc_next_in); |
| 347 | casc_next_in = resonatorcxx . . $ resonator(737208046921dbd8).(&(kt_globalscxx . . $ kt_globals..rsn[R3ccxx . . $ `external/espeak/klatt.h:103:9`!]), casc_next_in); |
| 348 | casc_next_in = resonatorcxx . . $ resonator(737208046921dbd8).(&(kt_globalscxx . . $ kt_globals..rsn[R2ccxx . . $ `external/espeak/klatt.h:102:9`!]), casc_next_in); |
| 349 | out = resonatorcxx . . $ resonator(737208046921dbd8).(&(kt_globalscxx . . $ kt_globals..rsn[R1ccxx . . $ `external/espeak/klatt.h:101:9`!]), casc_next_in); |
| 350 | } |
| 351 | |
| 352 | // Excite parallel F1 and FNP by voicing waveform |
| 353 | sourc = par_glotout; // Source is voicing plus aspiration |
| 354 | |
| 355 | // Standard parallel vocal tract Formants F6,F5,F4,F3,F2, |
| 356 | // outputs added with alternating sign. Sound source for other |
| 357 | // parallel resonators is frication plus first difference of |
| 358 | // voicing waveform. |
| 359 | |
| 360 | out += resonatorcxx . . $ resonator(737208046921dbd8).(&(kt_globalscxx . . $ kt_globals..rsn[R1pcxx . . $ `external/espeak/klatt.h:113:9`!]), sourc); |
| 361 | out += resonatorcxx . . $ resonator(737208046921dbd8).(&(kt_globalscxx . . $ kt_globals..rsn[Rnppcxx . . $ `external/espeak/klatt.h:112:9`!]), sourc); |
| 362 | |
| 363 | sourc = frics + par_glotout - glotlast; |
| 364 | glotlast = par_glotout; |
| 365 | |
| 366 | for (ix = R2pcxx . . $ `external/espeak/klatt.h:114:9`!; ix <= R6pcxx . . $ `external/espeak/klatt.h:115:9`!; ix++) |
| 367 | out = resonatorcxx . . $ resonator(737208046921dbd8).(&(kt_globalscxx . . $ kt_globals..rsn[ix]), sourc) - out; |
| 368 | |
| 369 | outbypas = kt_globalscxx . . $ kt_globals..amp_bypas * sourc; |
| 370 | |
| 371 | out = outbypas - out; |
| 372 | |
| 373 | out = resonatorcxx . . $ resonator(737208046921dbd8).(&(kt_globalscxx . . $ kt_globals..rsn[Routcxx . . $ `external/espeak/klatt.h:119:9`!]), out); |
| 374 | temp = (int)(out * wdata->amplitude * kt_globalscxx . . $ kt_globals..amp_gain0); // Convert back to integer |
| 375 | |
| 376 | // mix with a recorded WAV if required for this phoneme |
| 377 | signed char c; |
| 378 | int sample; |
| 379 | |
| 380 | if (wdata->mix_wavefile_ix < wdata->n_mix_wavefile) { |
| 381 | if (wdata->mix_wave_scale == 0) { |
| 382 | // a 16 bit sample |
| 383 | c = wdata->mix_wavefile[wdata->mix_wavefile_ix+1]; |
| 384 | sample = wdata->mix_wavefile[wdata->mix_wavefile_ix] + (c * 256); |
| 385 | wdata->mix_wavefile_ix += 2; |
| 386 | } else { |
| 387 | // a 8 bit sample, scaled |
| 388 | sample = (signed char)wdata->mix_wavefile[wdata->mix_wavefile_ix++] * wdata->mix_wave_scale; |
| 389 | } |
| 390 | int z2 = sample * wdata->amplitude_v / 1024; |
| 391 | z2 = (z2 * wdata->mix_wave_amp)/40; |
| 392 | temp += z2; |
| 393 | } |
| 394 | |
| 395 | if (kt_globalscxx . . $ kt_globals..fadein < 64) { |
| 396 | temp = (temp * kt_globalscxx . . $ kt_globals..fadein) / 64; |
| 397 | ++kt_globalscxx . . $ kt_globals..fadein; |
| 398 | } |
| 399 | |
| 400 | // if fadeout is set, fade to zero over 64 samples, to avoid clicks at end of synthesis |
| 401 | if (kt_globalscxx . . $ kt_globals..fadeout > 0) { |
| 402 | kt_globalscxx . . $ kt_globals..fadeout--; |
| 403 | temp = (temp * kt_globalscxx . . $ kt_globals..fadeout) / 64; |
| 404 | if (kt_globalscxx . . $ kt_globals..fadeout == 0) |
| 405 | kt_globalscxx . . $ kt_globals..fadein = 0; |
| 406 | } |
| 407 | |
| 408 | value = (int)temp + ((echo_buf[echo_tail++]*echo_amp) >> 8); |
| 409 | if (echo_tail >= N_ECHO_BUFcxx . . $ `external/espeak/synthesize.h:427:9`!) |
| 410 | echo_tail = 0; |
| 411 | |
| 412 | if (value < -32768) |
| 413 | value = -32768; |
| 414 | |
| 415 | if (value > 32767) |
| 416 | value = 32767; |
| 417 | |
| 418 | *out_ptrcxx . . $ out_ptr.++ = value; |
| 419 | *out_ptrcxx . . $ out_ptr.++ = value >> 8; |
| 420 | |
| 421 | echo_buf[echo_head++] = value; |
| 422 | if (echo_head >= N_ECHO_BUFcxx . . $ `external/espeak/synthesize.h:427:9`!) |
| 423 | echo_head = 0; |
| 424 | |
| 425 | sample_countcxx . . $ sample_count.++; |
| 426 | if (out_ptrcxx . . $ out_ptr. + 2 > out_endcxx . . $ out_end.) |
| 427 | return 1; |
| 428 | } |
| 429 | return 0; |
| 430 | } |
| 431 | |
| 432 | void KlattResetcxx . . $ KlattReset(d4f767463ce0a6b3).(int control) |
| 433 | { |
| 434 | int r_ix; |
| 435 | |
| 436 | #if USE_SPEECHPLAYERcxx . . $ `external/espeak/espeak__config.h:15:9`! |
| 437 | KlattResetSP(); |
| 438 | #endif |
| 439 | |
| 440 | if (control == 2) { |
| 441 | // Full reset |
| 442 | kt_globalscxx . . $ kt_globals..FLPhz = (950 * kt_globalscxx . . $ kt_globals..samrate) / 10000; |
| 443 | kt_globalscxx . . $ kt_globals..BLPhz = (630 * kt_globalscxx . . $ kt_globals..samrate) / 10000; |
| 444 | kt_globalscxx . . $ kt_globals..minus_pi_t = -M_PIcxx . . $ `melder/NUMmath.h:48:9`! / kt_globalscxx . . $ kt_globals..samrate; |
| 445 | kt_globalscxx . . $ kt_globals..two_pi_t = -2.0 * kt_globalscxx . . $ kt_globals..minus_pi_t; |
| 446 | setabccxx . . $ setabc(a0a3dbb240eaa8cd).(kt_globalscxx . . $ kt_globals..FLPhz, kt_globalscxx . . $ kt_globals..BLPhz, &(kt_globalscxx . . $ kt_globals..rsn[RLPcxx . . $ `external/espeak/klatt.h:118:9`!])); |
| 447 | } |
| 448 | |
| 449 | if (control > 0) { |
| 450 | kt_globalscxx . . $ kt_globals..nper = 0; |
| 451 | kt_globalscxx . . $ kt_globals..T0 = 0; |
| 452 | kt_globalscxx . . $ kt_globals..nopen = 0; |
| 453 | kt_globalscxx . . $ kt_globals..nmod = 0; |
| 454 | |
| 455 | for (r_ix = RGLcxx . . $ `external/espeak/klatt.h:117:9`!; r_ix < N_RSNcxx . . $ `external/espeak/klatt.h:99:9`!; r_ix++) { |
| 456 | kt_globalscxx . . $ kt_globals..rsn[r_ix].p1 = 0; |
| 457 | kt_globalscxx . . $ kt_globals..rsn[r_ix].p2 = 0; |
| 458 | } |
| 459 | } |
| 460 | |
| 461 | for (r_ix = 0; r_ix <= R6pcxx . . $ `external/espeak/klatt.h:115:9`!; r_ix++) { |
| 462 | kt_globalscxx . . $ kt_globals..rsn[r_ix].p1 = 0; |
| 463 | kt_globalscxx . . $ kt_globals..rsn[r_ix].p2 = 0; |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | void KlattFinicxx . . $ KlattFini(49f6e7a06ebc5aa8).(void) |
| 468 | { |
| 469 | #if USE_SPEECHPLAYERcxx . . $ `external/espeak/espeak__config.h:15:9`! |
| 470 | KlattFiniSP(); |
| 471 | #endif |
| 472 | } |
| 473 | |
| 474 | /* |
| 475 | function FRAME_INIT |
| 476 | |
| 477 | Use parameters from the input frame to set up resonator coefficients. |
| 478 | */ |
| 479 | |
| 480 | static void frame_initcxx . . $ frame_init(9c370aab8c75c9fc).(klatt_frame_ptr frame) |
| 481 | { |
| 482 | double amp_par[7]; |
| 483 | static const double amp_par_factor[7] = { 0.6, 0.4, 0.15, 0.06, 0.04, 0.022, 0.03 }; |
| 484 | long Gain0_tmp; |
| 485 | int ix; |
| 486 | |
| 487 | kt_globalscxx . . $ kt_globals..original_f0 = frame->F0hz10 / 10; |
| 488 | |
| 489 | frame->AVdb_tmp = frame->AVdb - 7; |
| 490 | if (frame->AVdb_tmp < 0) |
| 491 | frame->AVdb_tmp = 0; |
| 492 | |
| 493 | kt_globalscxx . . $ kt_globals..amp_aspir = DBtoLINcxx . . $ DBtoLIN(66f4a6ec74012662).(frame->ASP) * 0.05; |
| 494 | kt_globalscxx . . $ kt_globals..amp_frica = DBtoLINcxx . . $ DBtoLIN(66f4a6ec74012662).(frame->AF) * 0.25; |
| 495 | kt_globalscxx . . $ kt_globals..par_amp_voice = DBtoLINcxx . . $ DBtoLIN(66f4a6ec74012662).(frame->AVpdb); |
| 496 | kt_globalscxx . . $ kt_globals..amp_bypas = DBtoLINcxx . . $ DBtoLIN(66f4a6ec74012662).(frame->AB) * 0.05; |
| 497 | |
| 498 | for (ix = 0; ix <= 6; ix++) { |
| 499 | // parallel amplitudes F1 to F6, and parallel nasal pole |
| 500 | amp_par[ix] = DBtoLINcxx . . $ DBtoLIN(66f4a6ec74012662).(frame->Ap[ix]) * amp_par_factor[ix]; |
| 501 | } |
| 502 | |
| 503 | Gain0_tmp = frame->Gain0 - 3; |
| 504 | if (Gain0_tmp <= 0) |
| 505 | Gain0_tmp = 57; |
| 506 | kt_globalscxx . . $ kt_globals..amp_gain0 = DBtoLINcxx . . $ DBtoLIN(66f4a6ec74012662).(Gain0_tmp) / kt_globalscxx . . $ kt_globals..scale_wav; |
| 507 | |
| 508 | // Set coefficients of variable cascade resonators |
| 509 | for (ix = 1; ix <= 9; ix++) { |
| 510 | // formants 1 to 8, plus nasal pole |
| 511 | setabccxx . . $ setabc(a0a3dbb240eaa8cd).(frame->Fhz[ix], frame->Bhz[ix], &(kt_globalscxx . . $ kt_globals..rsn[ix])); |
| 512 | |
| 513 | if (ix <= 5) { |
| 514 | setabccxx . . $ setabc(a0a3dbb240eaa8cd).(frame->Fhz_next[ix], frame->Bhz_next[ix], &(kt_globalscxx . . $ kt_globals..rsn_next[ix])); |
| 515 | |
| 516 | kt_globalscxx . . $ kt_globals..rsn[ix].a_inc = (kt_globalscxx . . $ kt_globals..rsn_next[ix].a - kt_globalscxx . . $ kt_globals..rsn[ix].a) / 64.0; |
| 517 | kt_globalscxx . . $ kt_globals..rsn[ix].b_inc = (kt_globalscxx . . $ kt_globals..rsn_next[ix].b - kt_globalscxx . . $ kt_globals..rsn[ix].b) / 64.0; |
| 518 | kt_globalscxx . . $ kt_globals..rsn[ix].c_inc = (kt_globalscxx . . $ kt_globals..rsn_next[ix].c - kt_globalscxx . . $ kt_globals..rsn[ix].c) / 64.0; |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | // nasal zero anti-resonator |
| 523 | setzeroabccxx . . $ setzeroabc(a0a3dbb240eaa8cd).(frame->Fhz[F_NZcxx . . $ `external/espeak/klatt.h:128:9`!], frame->Bhz[F_NZcxx . . $ `external/espeak/klatt.h:128:9`!], &(kt_globalscxx . . $ kt_globals..rsn[Rnzcxx . . $ `external/espeak/klatt.h:100:9`!])); |
| 524 | setzeroabccxx . . $ setzeroabc(a0a3dbb240eaa8cd).(frame->Fhz_next[F_NZcxx . . $ `external/espeak/klatt.h:128:9`!], frame->Bhz_next[F_NZcxx . . $ `external/espeak/klatt.h:128:9`!], &(kt_globalscxx . . $ kt_globals..rsn_next[Rnzcxx . . $ `external/espeak/klatt.h:100:9`!])); |
| 525 | kt_globalscxx . . $ kt_globals..rsn[F_NZcxx . . $ `external/espeak/klatt.h:128:9`!].a_inc = (kt_globalscxx . . $ kt_globals..rsn_next[F_NZcxx . . $ `external/espeak/klatt.h:128:9`!].a - kt_globalscxx . . $ kt_globals..rsn[F_NZcxx . . $ `external/espeak/klatt.h:128:9`!].a) / 64.0; |
| 526 | kt_globalscxx . . $ kt_globals..rsn[F_NZcxx . . $ `external/espeak/klatt.h:128:9`!].b_inc = (kt_globalscxx . . $ kt_globals..rsn_next[F_NZcxx . . $ `external/espeak/klatt.h:128:9`!].b - kt_globalscxx . . $ kt_globals..rsn[F_NZcxx . . $ `external/espeak/klatt.h:128:9`!].b) / 64.0; |
| 527 | kt_globalscxx . . $ kt_globals..rsn[F_NZcxx . . $ `external/espeak/klatt.h:128:9`!].c_inc = (kt_globalscxx . . $ kt_globals..rsn_next[F_NZcxx . . $ `external/espeak/klatt.h:128:9`!].c - kt_globalscxx . . $ kt_globals..rsn[F_NZcxx . . $ `external/espeak/klatt.h:128:9`!].c) / 64.0; |
| 528 | |
| 529 | // Set coefficients of parallel resonators, and amplitude of outputs |
| 530 | |
| 531 | for (ix = 0; ix <= 6; ix++) { |
| 532 | setabccxx . . $ setabc(a0a3dbb240eaa8cd).(frame->Fhz[ix], frame->Bphz[ix], &(kt_globalscxx . . $ kt_globals..rsn[Rparallelcxx . . $ `external/espeak/klatt.h:111:9`!+ix])); |
| 533 | kt_globalscxx . . $ kt_globals..rsn[Rparallelcxx . . $ `external/espeak/klatt.h:111:9`!+ix].a *= amp_par[ix]; |
| 534 | } |
| 535 | |
| 536 | // output low-pass filter |
| 537 | |
| 538 | setabccxx . . $ setabc(a0a3dbb240eaa8cd).((long)0.0, (long)(kt_globalscxx . . $ kt_globals..samrate/2), &(kt_globalscxx . . $ kt_globals..rsn[Routcxx . . $ `external/espeak/klatt.h:119:9`!])); |
| 539 | } |
| 540 | |
| 541 | /* |
| 542 | function IMPULSIVE_SOURCE |
| 543 | |
| 544 | Generate a low pass filtered train of impulses as an approximation of |
| 545 | a natural excitation waveform. Low-pass filter the differentiated impulse |
| 546 | with a critically-damped second-order filter, time constant proportional |
| 547 | to Kopen. |
| 548 | */ |
| 549 | |
| 550 | static double impulsive_sourcecxx . . $ impulsive_source(31fa7155c10fdd13).(void) |
| 551 | { |
| 552 | static const double doublet[] = { 0.0, 13000000.0, -13000000.0 }; |
| 553 | static double vwave; |
| 554 | |
| 555 | if (kt_globalscxx . . $ kt_globals..nper < 3) |
| 556 | vwave = doublet[kt_globalscxx . . $ kt_globals..nper]; |
| 557 | else |
| 558 | vwave = 0.0; |
| 559 | |
| 560 | return resonatorcxx . . $ resonator(737208046921dbd8).(&(kt_globalscxx . . $ kt_globals..rsn[RGLcxx . . $ `external/espeak/klatt.h:117:9`!]), vwave); |
| 561 | } |
| 562 | |
| 563 | /* |
| 564 | function NATURAL_SOURCE |
| 565 | |
| 566 | Vwave is the differentiated glottal flow waveform, there is a weak |
| 567 | spectral zero around 800 Hz, magic constants a,b reset pitch synchronously. |
| 568 | */ |
| 569 | |
| 570 | static double natural_sourcecxx . . $ natural_source(31fa7155c10fdd13).(void) |
| 571 | { |
| 572 | double lgtemp; |
| 573 | static double vwave; |
| 574 | |
| 575 | if (kt_globalscxx . . $ kt_globals..nper < kt_globalscxx . . $ kt_globals..nopen) { |
| 576 | kt_globalscxx . . $ kt_globals..pulse_shape_a -= kt_globalscxx . . $ kt_globals..pulse_shape_b; |
| 577 | vwave += kt_globalscxx . . $ kt_globals..pulse_shape_a; |
| 578 | lgtemp = vwave * 0.028; |
| 579 | |
| 580 | return lgtemp; |
| 581 | } |
| 582 | vwave = 0.0; |
| 583 | return 0.0; |
| 584 | } |
| 585 | |
| 586 | /* |
| 587 | function PITCH_SYNC_PAR_RESET |
| 588 | |
| 589 | Reset selected parameters pitch-synchronously. |
| 590 | |
| 591 | |
| 592 | Constant B0 controls shape of glottal pulse as a function |
| 593 | of desired duration of open phase N0 |
| 594 | (Note that N0 is specified in terms of 40,000 samples/sec of speech) |
| 595 | |
| 596 | Assume voicing waveform V(t) has form: k1 t**2 - k2 t**3 |
| 597 | |
| 598 | If the radiation characterivative, a temporal derivative |
| 599 | is folded in, and we go from continuous time to discrete |
| 600 | integers n: dV/dt = vwave[n] |
| 601 | = sum over i=1,2,...,n of { a - (i * b) } |
| 602 | = a n - b/2 n**2 |
| 603 | |
| 604 | where the constants a and b control the detailed shape |
| 605 | and amplitude of the voicing waveform over the open |
| 606 | potion of the voicing cycle "nopen". |
| 607 | |
| 608 | Let integral of dV/dt have no net dc flow --> a = (b * nopen) / 3 |
| 609 | |
| 610 | Let maximum of dUg(n)/dn be constant --> b = gain / (nopen * nopen) |
| 611 | meaning as nopen gets bigger, V has bigger peak proportional to n |
| 612 | |
| 613 | Thus, to generate the table below for 40 <= nopen <= 263: |
| 614 | |
| 615 | B0[nopen - 40] = 1920000 / (nopen * nopen) |
| 616 | */ |
| 617 | |
| 618 | static void pitch_synch_par_resetcxx . . $ pitch_synch_par_reset(9c370aab8c75c9fc).(klatt_frame_ptr frame) |
| 619 | { |
| 620 | long temp; |
| 621 | double temp1; |
| 622 | static long skew; |
| 623 | static const short B0[224] = { |
| 624 | 1200, 1142, 1088, 1038, 991, 948, 907, 869, 833, 799, 768, 738, 710, 683, 658, |
| 625 | 634, 612, 590, 570, 551, 533, 515, 499, 483, 468, 454, 440, 427, 415, 403, |
| 626 | 391, 380, 370, 360, 350, 341, 332, 323, 315, 307, 300, 292, 285, 278, 272, |
| 627 | 265, 259, 253, 247, 242, 237, 231, 226, 221, 217, 212, 208, 204, 199, 195, |
| 628 | 192, 188, 184, 180, 177, 174, 170, 167, 164, 161, 158, 155, 153, 150, 147, |
| 629 | 145, 142, 140, 137, 135, 133, 131, 128, 126, 124, 122, 120, 119, 117, 115, |
| 630 | 113, 111, 110, 108, 106, 105, 103, 102, 100, 99, 97, 96, 95, 93, 92, 91, 90, |
| 631 | 88, 87, 86, 85, 84, 83, 82, 80, 79, 78, 77, 76, 75, 75, 74, 73, 72, 71, |
| 632 | 70, 69, 68, 68, 67, 66, 65, 64, 64, 63, 62, 61, 61, 60, 59, 59, 58, 57, |
| 633 | 57, 56, 56, 55, 55, 54, 54, 53, 53, 52, 52, 51, 51, 50, 50, 49, 49, 48, 48, |
| 634 | 47, 47, 46, 46, 45, 45, 44, 44, 43, 43, 42, 42, 41, 41, 41, 41, 40, 40, |
| 635 | 39, 39, 38, 38, 38, 38, 37, 37, 36, 36, 36, 36, 35, 35, 35, 35, 34, 34, 33, |
| 636 | 33, 33, 33, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 30, 29, 29, 29, 29, |
| 637 | 28, 28, 28, 28, 27, 27 |
| 638 | }; |
| 639 | |
| 640 | if (frame->F0hz10 > 0) { |
| 641 | // T0 is 4* the number of samples in one pitch period |
| 642 | |
| 643 | kt_globalscxx . . $ kt_globals..T0 = (40 * kt_globalscxx . . $ kt_globals..samrate) / frame->F0hz10; |
| 644 | |
| 645 | kt_globalscxx . . $ kt_globals..amp_voice = DBtoLINcxx . . $ DBtoLIN(66f4a6ec74012662).(frame->AVdb_tmp); |
| 646 | |
| 647 | // Duration of period before amplitude modulation |
| 648 | |
| 649 | kt_globalscxx . . $ kt_globals..nmod = kt_globalscxx . . $ kt_globals..T0; |
| 650 | if (frame->AVdb_tmp > 0) |
| 651 | kt_globalscxx . . $ kt_globals..nmod >>= 1; |
| 652 | |
| 653 | // Breathiness of voicing waveform |
| 654 | |
| 655 | kt_globalscxx . . $ kt_globals..amp_breth = DBtoLINcxx . . $ DBtoLIN(66f4a6ec74012662).(frame->Aturb) * 0.1; |
| 656 | |
| 657 | // Set open phase of glottal period where 40 <= open phase <= 263 |
| 658 | |
| 659 | kt_globalscxx . . $ kt_globals..nopen = 4 * frame->Kopen; |
| 660 | |
| 661 | if ((kt_globalscxx . . $ kt_globals..glsource == IMPULSIVEcxx . . $ `external/espeak/klatt.h:38:9`!) && (kt_globalscxx . . $ kt_globals..nopen > 263)) |
| 662 | kt_globalscxx . . $ kt_globals..nopen = 263; |
| 663 | |
| 664 | if (kt_globalscxx . . $ kt_globals..nopen >= (kt_globalscxx . . $ kt_globals..T0-1)) |
| 665 | kt_globalscxx . . $ kt_globals..nopen = kt_globalscxx . . $ kt_globals..T0 - 2; |
| 666 | |
| 667 | if (kt_globalscxx . . $ kt_globals..nopen < 40) { |
| 668 | // F0 max = 1000 Hz |
| 669 | kt_globalscxx . . $ kt_globals..nopen = 40; |
| 670 | } |
| 671 | |
| 672 | // Reset a & b, which determine shape of "natural" glottal waveform |
| 673 | |
| 674 | kt_globalscxx . . $ kt_globals..pulse_shape_b = B0[kt_globalscxx . . $ kt_globals..nopen-40]; |
| 675 | kt_globalscxx . . $ kt_globals..pulse_shape_a = (kt_globalscxx . . $ kt_globals..pulse_shape_b * kt_globalscxx . . $ kt_globals..nopen) * 0.333; |
| 676 | |
| 677 | // Reset width of "impulsive" glottal pulse |
| 678 | |
| 679 | temp = kt_globalscxx . . $ kt_globals..samrate / kt_globalscxx . . $ kt_globals..nopen; |
| 680 | |
| 681 | setabccxx . . $ setabc(a0a3dbb240eaa8cd).((long)0, temp, &(kt_globalscxx . . $ kt_globals..rsn[RGLcxx . . $ `external/espeak/klatt.h:117:9`!])); |
| 682 | |
| 683 | // Make gain at F1 about constant |
| 684 | |
| 685 | temp1 = kt_globalscxx . . $ kt_globals..nopen *.00833; |
| 686 | kt_globalscxx . . $ kt_globals..rsn[RGLcxx . . $ `external/espeak/klatt.h:117:9`!].a *= temp1 * temp1; |
| 687 | |
| 688 | // Truncate skewness so as not to exceed duration of closed phase |
| 689 | // of glottal period. |
| 690 | |
| 691 | temp = kt_globalscxx . . $ kt_globals..T0 - kt_globalscxx . . $ kt_globals..nopen; |
| 692 | if (frame->Kskew > temp) |
| 693 | frame->Kskew = temp; |
| 694 | if (skew >= 0) |
| 695 | skew = frame->Kskew; |
| 696 | else |
| 697 | skew = -frame->Kskew; |
| 698 | |
| 699 | // Add skewness to closed portion of voicing period |
| 700 | kt_globalscxx . . $ kt_globals..T0 = kt_globalscxx . . $ kt_globals..T0 + skew; |
| 701 | skew = -skew; |
| 702 | } else { |
| 703 | kt_globalscxx . . $ kt_globals..T0 = 4; // Default for f0 undefined |
| 704 | kt_globalscxx . . $ kt_globals..amp_voice = 0.0; |
| 705 | kt_globalscxx . . $ kt_globals..nmod = kt_globalscxx . . $ kt_globals..T0; |
| 706 | kt_globalscxx . . $ kt_globals..amp_breth = 0.0; |
| 707 | kt_globalscxx . . $ kt_globals..pulse_shape_a = 0.0; |
| 708 | kt_globalscxx . . $ kt_globals..pulse_shape_b = 0.0; |
| 709 | } |
| 710 | |
| 711 | // Reset these pars pitch synchronously or at update rate if f0=0 |
| 712 | |
| 713 | if ((kt_globalscxx . . $ kt_globals..T0 != 4) || (kt_globalscxx . . $ kt_globals..ns == 0)) { |
| 714 | // Set one-pole low-pass filter that tilts glottal source |
| 715 | |
| 716 | kt_globalscxx . . $ kt_globals..decay = (0.033 * frame->TLTdb); |
| 717 | |
| 718 | if (kt_globalscxx . . $ kt_globals..decay > 0.0) |
| 719 | kt_globalscxx . . $ kt_globals..onemd = 1.0 - kt_globalscxx . . $ kt_globals..decay; |
| 720 | else |
| 721 | kt_globalscxx . . $ kt_globals..onemd = 1.0; |
| 722 | } |
| 723 | } |
| 724 | |
| 725 | /* |
| 726 | function SETABC |
| 727 | |
| 728 | Convert formant frequencies and bandwidth into resonator difference |
| 729 | equation constants. |
| 730 | */ |
| 731 | |
| 732 | static void setabccxx . . $ setabc(a0a3dbb240eaa8cd).(long int f, long int bw, resonator_ptr rp) |
| 733 | { |
| 734 | double r; |
| 735 | double arg; |
| 736 | |
| 737 | // Let r = exp(-pi bw t) |
| 738 | arg = kt_globalscxx . . $ kt_globals..minus_pi_t * bw; |
| 739 | r = expcxx . . $ exp(fee4f1d22bc8e617).(arg); |
| 740 | |
| 741 | // Let c = -r**2 |
| 742 | rp->c = -(r * r); |
| 743 | |
| 744 | // Let b = r * 2*cos(2 pi f t) |
| 745 | arg = kt_globalscxx . . $ kt_globals..two_pi_t * f; |
| 746 | rp->b = r * coscxx . . $ cos(fee4f1d22bc8e617).(arg) * 2.0; |
| 747 | |
| 748 | // Let a = 1.0 - b - c |
| 749 | rp->a = 1.0 - rp->b - rp->c; |
| 750 | } |
| 751 | |
| 752 | /* |
| 753 | function SETZEROABC |
| 754 | |
| 755 | Convert formant frequencies and bandwidth into anti-resonator difference |
| 756 | equation constants. |
| 757 | */ |
| 758 | |
| 759 | static void setzeroabccxx . . $ setzeroabc(a0a3dbb240eaa8cd).(long int f, long int bw, resonator_ptr rp) |
| 760 | { |
| 761 | double r; |
| 762 | double arg; |
| 763 | |
| 764 | f = -f; |
| 765 | |
| 766 | // First compute ordinary resonator coefficients |
| 767 | // Let r = exp(-pi bw t) |
| 768 | arg = kt_globalscxx . . $ kt_globals..minus_pi_t * bw; |
| 769 | r = expcxx . . $ exp(fee4f1d22bc8e617).(arg); |
| 770 | |
| 771 | // Let c = -r**2 |
| 772 | rp->c = -(r * r); |
| 773 | |
| 774 | // Let b = r * 2*cos(2 pi f t) |
| 775 | arg = kt_globalscxx . . $ kt_globals..two_pi_t * f; |
| 776 | rp->b = r * coscxx . . $ cos(fee4f1d22bc8e617).(arg) * 2.; |
| 777 | |
| 778 | // Let a = 1.0 - b - c |
| 779 | rp->a = 1.0 - rp->b - rp->c; |
| 780 | |
| 781 | // Now convert to antiresonator coefficients (a'=1/a, b'=b/a, c'=c/a) |
| 782 | |
| 783 | // If f == 0 then rp->a gets set to 0 which makes a'=1/a set a', b' and c' to |
| 784 | // INF, causing an audible sound spike when triggered (e.g. apiration with the |
| 785 | // nasal register set to f=0, bw=0). |
| 786 | if (rp->a != 0) { |
| 787 | // Now convert to antiresonator coefficients (a'=1/a, b'=b/a, c'=c/a) |
| 788 | rp->a = 1.0 / rp->a; |
| 789 | rp->c *= -rp->a; |
| 790 | rp->b *= -rp->a; |
| 791 | } |
| 792 | } |
| 793 | |
| 794 | /* |
| 795 | function GEN_NOISE |
| 796 | |
| 797 | Random number generator (return a number between -8191 and +8191) |
| 798 | Noise spectrum is tilted down by soft low-pass filter having a pole near |
| 799 | the origin in the z-plane, i.e. output = input + (0.75 * lastoutput) |
| 800 | */ |
| 801 | |
| 802 | static double gen_noisecxx . . $ gen_noise(447c67c6676f75c3).(double noise) |
| 803 | { |
| 804 | long temp; |
| 805 | static double nlast; |
| 806 | |
| 807 | temp = (long)getrandomcxx . . $ `external/espeak/klatt.cpp:50:9`!(-8191, 8191); |
| 808 | kt_globalscxx . . $ kt_globals..nrand = (long)temp; |
| 809 | |
| 810 | noise = kt_globalscxx . . $ kt_globals..nrand + (0.75 * nlast); |
| 811 | nlast = noise; |
| 812 | |
| 813 | return noise; |
| 814 | } |
| 815 | |
| 816 | /* |
| 817 | function DBTOLIN |
| 818 | |
| 819 | Convert from decibels to a linear scale factor |
| 820 | |
| 821 | |
| 822 | Conversion table, db to linear, 87 dB --> 32767 |
| 823 | 86 dB --> 29491 (1 dB down = 0.5**1/6) |
| 824 | ... |
| 825 | 81 dB --> 16384 (6 dB down = 0.5) |
| 826 | ... |
| 827 | 0 dB --> 0 |
| 828 | |
| 829 | The just noticeable difference for a change in intensity of a vowel |
| 830 | is approximately 1 dB. Thus all amplitudes are quantized to 1 dB |
| 831 | steps. |
| 832 | */ |
| 833 | |
| 834 | static double DBtoLINcxx . . $ DBtoLIN(66f4a6ec74012662).(long dB) |
| 835 | { |
| 836 | static const short amptable[88] = { |
| 837 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7, |
| 838 | 8, 9, 10, 11, 13, 14, 16, 18, 20, 22, 25, 28, 32, |
| 839 | 35, 40, 45, 51, 57, 64, 71, 80, 90, 101, 114, 128, |
| 840 | 142, 159, 179, 202, 227, 256, 284, 318, 359, 405, |
| 841 | 455, 512, 568, 638, 719, 881, 911, 1024, 1137, 1276, |
| 842 | 1438, 1622, 1823, 2048, 2273, 2552, 2875, 3244, 3645, |
| 843 | 4096, 4547, 5104, 5751, 6488, 7291, 8192, 9093, 10207, |
| 844 | 11502, 12976, 14582, 16384, 18350, 20644, 23429, |
| 845 | 26214, 29491, 32767 |
| 846 | }; |
| 847 | |
| 848 | if ((dB < 0) || (dB > 87)) |
| 849 | return 0; |
| 850 | |
| 851 | return (double)(amptable[dB]) * 0.001; |
| 852 | } |
| 853 | |
| 854 | static klatt_peaks_t peakscxx . . $ peaks.[N_PEAKScxx . . $ `external/espeak/voice.h:35:9`!]; |
| 855 | static int end_wavecxx . . $ end_wave.; |
| 856 | static int klattpcxx . . $ klattp.[N_KLATTPcxx . . $ `external/espeak/synthesize.h:81:9`!]; |
| 857 | static double klattp1cxx . . $ klattp1.[N_KLATTPcxx . . $ `external/espeak/synthesize.h:81:9`!]; |
| 858 | static double klattp_inccxx . . $ klattp_inc.[N_KLATTPcxx . . $ `external/espeak/synthesize.h:81:9`!]; |
| 859 | |
| 860 | int Wavegen_Klattcxx . . $ Wavegen_Klatt(cca728f2211ced78).(int length, int resume, frame_t *fr1, frame_t *fr2, WGEN_DATA *wdata, voice_t *wvoice) |
| 861 | { |
| 862 | #if USE_SPEECHPLAYERcxx . . $ `external/espeak/espeak__config.h:15:9`! |
| 863 | if(wvoice->klattv[0] == 6) |
| 864 | return Wavegen_KlattSP(wdata, wvoice, length, resume, fr1, fr2); |
| 865 | #endif |
| 866 | |
| 867 | if (resume == 0) |
| 868 | SetSynth_Klattcxx . . $ SetSynth_Klatt(b51b8c334121c45d).(length, fr1, fr2, wvoice, 1); |
| 869 | |
| 870 | int pk; |
| 871 | int x; |
| 872 | int ix; |
| 873 | int fade; |
| 874 | |
| 875 | if (resume == 0) |
| 876 | sample_countcxx . . $ sample_count. = 0; |
| 877 | |
| 878 | while (sample_countcxx . . $ sample_count. < nsamplescxx . . $ nsamples.) { |
| 879 | kt_framecxx . . $ kt_frame..F0hz10 = (wdata->pitch * 10) / 4096; |
| 880 | |
| 881 | // formants F6,F7,F8 are fixed values for cascade resonators, set in KlattInit() |
| 882 | // but F6 is used for parallel resonator |
| 883 | // F0 is used for the nasal zero |
| 884 | for (ix = 0; ix < 6; ix++) { |
| 885 | kt_framecxx . . $ kt_frame..Fhz[ix] = peakscxx . . $ peaks.[ix].freq; |
| 886 | if (ix < 4) |
| 887 | kt_framecxx . . $ kt_frame..Bhz[ix] = peakscxx . . $ peaks.[ix].bw; |
| 888 | } |
| 889 | for (ix = 1; ix < 7; ix++) |
| 890 | kt_framecxx . . $ kt_frame..Ap[ix] = peakscxx . . $ peaks.[ix].ap; |
| 891 | |
| 892 | kt_framecxx . . $ kt_frame..AVdb = klattpcxx . . $ klattp.[KLATT_AVcxx . . $ `external/espeak/synthesize.h:84:9`!]; |
| 893 | kt_framecxx . . $ kt_frame..AVpdb = klattpcxx . . $ klattp.[KLATT_AVpcxx . . $ `external/espeak/synthesize.h:91:9`!]; |
| 894 | kt_framecxx . . $ kt_frame..AF = klattpcxx . . $ klattp.[KLATT_Friccxx . . $ `external/espeak/synthesize.h:92:9`!]; |
| 895 | kt_framecxx . . $ kt_frame..AB = klattpcxx . . $ klattp.[KLATT_FricBPcxx . . $ `external/espeak/synthesize.h:93:9`!]; |
| 896 | kt_framecxx . . $ kt_frame..ASP = klattpcxx . . $ klattp.[KLATT_Asprcxx . . $ `external/espeak/synthesize.h:87:9`!]; |
| 897 | kt_framecxx . . $ kt_frame..Aturb = klattpcxx . . $ klattp.[KLATT_Turbcxx . . $ `external/espeak/synthesize.h:94:9`!]; |
| 898 | kt_framecxx . . $ kt_frame..Kskew = klattpcxx . . $ klattp.[KLATT_Skewcxx . . $ `external/espeak/synthesize.h:88:9`!]; |
| 899 | kt_framecxx . . $ kt_frame..TLTdb = klattpcxx . . $ klattp.[KLATT_Tiltcxx . . $ `external/espeak/synthesize.h:86:9`!]; |
| 900 | kt_framecxx . . $ kt_frame..Kopen = klattpcxx . . $ klattp.[KLATT_Kopencxx . . $ `external/espeak/synthesize.h:90:9`!]; |
| 901 | |
| 902 | // advance formants |
| 903 | for (pk = 0; pk < N_PEAKScxx . . $ `external/espeak/voice.h:35:9`!; pk++) { |
| 904 | peakscxx . . $ peaks.[pk].freq1 += peakscxx . . $ peaks.[pk].freq_inc; |
| 905 | peakscxx . . $ peaks.[pk].freq = (int)peakscxx . . $ peaks.[pk].freq1; |
| 906 | peakscxx . . $ peaks.[pk].bw1 += peakscxx . . $ peaks.[pk].bw_inc; |
| 907 | peakscxx . . $ peaks.[pk].bw = (int)peakscxx . . $ peaks.[pk].bw1; |
| 908 | peakscxx . . $ peaks.[pk].bp1 += peakscxx . . $ peaks.[pk].bp_inc; |
| 909 | peakscxx . . $ peaks.[pk].bp = (int)peakscxx . . $ peaks.[pk].bp1; |
| 910 | peakscxx . . $ peaks.[pk].ap1 += peakscxx . . $ peaks.[pk].ap_inc; |
| 911 | peakscxx . . $ peaks.[pk].ap = (int)peakscxx . . $ peaks.[pk].ap1; |
| 912 | } |
| 913 | |
| 914 | // advance other parameters |
| 915 | for (ix = 0; ix < N_KLATTPcxx . . $ `external/espeak/synthesize.h:81:9`!; ix++) { |
| 916 | klattp1cxx . . $ klattp1.[ix] += klattp_inccxx . . $ klattp_inc.[ix]; |
| 917 | klattpcxx . . $ klattp.[ix] = (int)klattp1cxx . . $ klattp1.[ix]; |
| 918 | } |
| 919 | |
| 920 | for (ix = 0; ix <= 6; ix++) { |
| 921 | kt_framecxx . . $ kt_frame..Fhz_next[ix] = peakscxx . . $ peaks.[ix].freq; |
| 922 | if (ix < 4) |
| 923 | kt_framecxx . . $ kt_frame..Bhz_next[ix] = peakscxx . . $ peaks.[ix].bw; |
| 924 | } |
| 925 | |
| 926 | // advance the pitch |
| 927 | wdata->pitch_ix += wdata->pitch_inc; |
| 928 | if ((ix = wdata->pitch_ix>>8) > 127) ix = 127; |
| 929 | x = wdata->pitch_env[ix] * wdata->pitch_range; |
| 930 | wdata->pitch = (x>>8) + wdata->pitch_base; |
| 931 | |
| 932 | kt_globalscxx . . $ kt_globals..nspfr = (nsamplescxx . . $ nsamples. - sample_countcxx . . $ sample_count.); |
| 933 | if (kt_globalscxx . . $ kt_globals..nspfr > STEPSIZEcxx . . $ `external/espeak/synthesize.h:38:9`!) |
| 934 | kt_globalscxx . . $ kt_globals..nspfr = STEPSIZEcxx . . $ `external/espeak/synthesize.h:38:9`!; |
| 935 | |
| 936 | frame_initcxx . . $ frame_init(9c370aab8c75c9fc).(&kt_framecxx . . $ kt_frame.); // get parameters for next frame of speech |
| 937 | |
| 938 | if (parwavecxx . . $ parwave(552c95723cfdbe41).(&kt_framecxx . . $ kt_frame., wdata) == 1) |
| 939 | return 1; // output buffer is full |
| 940 | } |
| 941 | |
| 942 | if (end_wavecxx . . $ end_wave. > 0) { |
| 943 | fade = 64; // not followed by formant synthesis |
| 944 | |
| 945 | // fade out to avoid a click |
| 946 | kt_globalscxx . . $ kt_globals..fadeout = fade; |
| 947 | end_wavecxx . . $ end_wave. = 0; |
| 948 | sample_countcxx . . $ sample_count. -= fade; |
| 949 | kt_globalscxx . . $ kt_globals..nspfr = fade; |
| 950 | if (parwavecxx . . $ parwave(552c95723cfdbe41).(&kt_framecxx . . $ kt_frame., wdata) == 1) |
| 951 | return 1; // output buffer is full |
| 952 | } |
| 953 | |
| 954 | return 0; |
| 955 | } |
| 956 | |
| 957 | static void SetSynth_Klattcxx . . $ SetSynth_Klatt(b51b8c334121c45d).(int length, frame_t *fr1, frame_t *fr2, voice_t *wvoice, int control) |
| 958 | { |
| 959 | int ix; |
| 960 | double next; |
| 961 | int qix; |
| 962 | int cmd; |
| 963 | frame_t *fr3; |
| 964 | static frame_t prev_fr; |
| 965 | |
| 966 | if (wvoice != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 967 | if ((wvoice->klattv[0] > 0) && (wvoice->klattv[0] <= 5 )) { |
| 968 | kt_globalscxx . . $ kt_globals..glsource = wvoice->klattv[0]; |
| 969 | kt_globalscxx . . $ kt_globals..scale_wav = scale_wav_tabcxx . . $ scale_wav_tab.[kt_globalscxx . . $ kt_globals..glsource]; |
| 970 | } |
| 971 | kt_globalscxx . . $ kt_globals..f0_flutter = wvoice->flutter/32; |
| 972 | } |
| 973 | |
| 974 | end_wavecxx . . $ end_wave. = 0; |
| 975 | if (control & 2) |
| 976 | end_wavecxx . . $ end_wave. = 1; // fadeout at the end |
| 977 | if (control & 1) { |
| 978 | end_wavecxx . . $ end_wave. = 1; |
| 979 | for (qix = wcmdq_head+1;; qix++) { |
| 980 | if (qix >= N_WCMDQcxx . . $ `external/espeak/synthesize.h:415:9`!) qix = 0; |
| 981 | if (qix == wcmdq_tail) break; |
| 982 | |
| 983 | cmd = wcmdq[qix][0]; |
| 984 | if (cmd == WCMD_KLATTcxx . . $ `external/espeak/synthesize.h:398:9`!) { |
| 985 | end_wavecxx . . $ end_wave. = 0; // next wave generation is from another spectrum |
| 986 | |
| 987 | fr3 = (frame_t *)wcmdq[qix][2]; |
| 988 | for (ix = 1; ix < 6; ix++) { |
| 989 | if (fr3->ffreq[ix] != fr2->ffreq[ix]) { |
| 990 | // there is a discontinuity in formants |
| 991 | end_wavecxx . . $ end_wave. = 2; |
| 992 | break; |
| 993 | } |
| 994 | } |
| 995 | break; |
| 996 | } |
| 997 | if ((cmd == WCMD_WAVEcxx . . $ `external/espeak/synthesize.h:403:9`!) || (cmd == WCMD_PAUSEcxx . . $ `external/espeak/synthesize.h:402:9`!)) |
| 998 | break; // next is not from spectrum, so continue until end of wave cycle |
| 999 | } |
| 1000 | |
| 1001 | for (ix = 1; ix < 6; ix++) { |
| 1002 | if (prev_fr.ffreq[ix] != fr1->ffreq[ix]) { |
| 1003 | // Discontinuity in formants. |
| 1004 | // end_wave was set in SetSynth_Klatt() to fade out the previous frame |
| 1005 | KlattResetcxx . . $ KlattReset(d4f767463ce0a6b3).(0); |
| 1006 | break; |
| 1007 | } |
| 1008 | } |
| 1009 | memcpy(&prev_fr, fr2, sizeof(prev_fr)); |
| 1010 | } |
| 1011 | |
| 1012 | for (ix = 0; ix < N_KLATTPcxx . . $ `external/espeak/synthesize.h:81:9`!; ix++) { |
| 1013 | if ((ix >= 5) || ((fr1->frflags & FRFLAG_KLATTcxx . . $ `external/espeak/synthesize.h:41:9`!) == 0)) { |
| 1014 | klattp1cxx . . $ klattp1.[ix] = klattpcxx . . $ klattp.[ix] = 0; |
| 1015 | klattp_inccxx . . $ klattp_inc.[ix] = 0; |
| 1016 | } else { |
| 1017 | klattp1cxx . . $ klattp1.[ix] = klattpcxx . . $ klattp.[ix] = fr1->klattp[ix]; |
| 1018 | klattp_inccxx . . $ klattp_inc.[ix] = (double)((fr2->klattp[ix] - klattpcxx . . $ klattp.[ix]) * STEPSIZEcxx . . $ `external/espeak/synthesize.h:38:9`!)/length; |
| 1019 | } |
| 1020 | } |
| 1021 | |
| 1022 | nsamplescxx . . $ nsamples. = length; |
| 1023 | |
| 1024 | for (ix = 1; ix < 6; ix++) { |
| 1025 | peakscxx . . $ peaks.[ix].freq1 = (fr1->ffreq[ix] * wvoice->freq[ix] / 256.0) + wvoice->freqadd[ix]; |
| 1026 | peakscxx . . $ peaks.[ix].freq = (int)peakscxx . . $ peaks.[ix].freq1; |
| 1027 | next = (fr2->ffreq[ix] * wvoice->freq[ix] / 256.0) + wvoice->freqadd[ix]; |
| 1028 | peakscxx . . $ peaks.[ix].freq_inc = ((next - peakscxx . . $ peaks.[ix].freq1) * STEPSIZEcxx . . $ `external/espeak/synthesize.h:38:9`!) / length; |
| 1029 | |
| 1030 | if (ix < 4) { |
| 1031 | // klatt bandwidth for f1, f2, f3 (others are fixed) |
| 1032 | peakscxx . . $ peaks.[ix].bw1 = fr1->bw[ix] * 2 * (wvoice->width[ix] / 256.0); |
| 1033 | peakscxx . . $ peaks.[ix].bw = (int)peakscxx . . $ peaks.[ix].bw1; |
| 1034 | next = fr2->bw[ix] * 2; |
| 1035 | peakscxx . . $ peaks.[ix].bw_inc = ((next - peakscxx . . $ peaks.[ix].bw1) * STEPSIZEcxx . . $ `external/espeak/synthesize.h:38:9`!) / length; |
| 1036 | } |
| 1037 | } |
| 1038 | |
| 1039 | // nasal zero frequency |
| 1040 | peakscxx . . $ peaks.[0].freq1 = fr1->klattp[KLATT_FNZcxx . . $ `external/espeak/synthesize.h:85:9`!] * 2; |
| 1041 | if (peakscxx . . $ peaks.[0].freq1 == 0) |
| 1042 | peakscxx . . $ peaks.[0].freq1 = kt_framecxx . . $ kt_frame..Fhz[F_NPcxx . . $ `external/espeak/klatt.h:135:9`!]; // if no nasal zero, set it to same freq as nasal pole |
| 1043 | |
| 1044 | peakscxx . . $ peaks.[0].freq = (int)peakscxx . . $ peaks.[0].freq1; |
| 1045 | next = fr2->klattp[KLATT_FNZcxx . . $ `external/espeak/synthesize.h:85:9`!] * 2; |
| 1046 | if (next == 0) |
| 1047 | next = kt_framecxx . . $ kt_frame..Fhz[F_NPcxx . . $ `external/espeak/klatt.h:135:9`!]; |
| 1048 | |
| 1049 | peakscxx . . $ peaks.[0].freq_inc = ((next - peakscxx . . $ peaks.[0].freq1) * STEPSIZEcxx . . $ `external/espeak/synthesize.h:38:9`!) / length; |
| 1050 | |
| 1051 | peakscxx . . $ peaks.[0].bw1 = 89; |
| 1052 | peakscxx . . $ peaks.[0].bw = 89; |
| 1053 | peakscxx . . $ peaks.[0].bw_inc = 0; |
| 1054 | |
| 1055 | if (fr1->frflags & FRFLAG_KLATTcxx . . $ `external/espeak/synthesize.h:41:9`!) { |
| 1056 | // the frame contains additional parameters for parallel resonators |
| 1057 | for (ix = 1; ix < 7; ix++) { |
| 1058 | peakscxx . . $ peaks.[ix].bp1 = fr1->klatt_bp[ix] * 4; // parallel bandwidth |
| 1059 | peakscxx . . $ peaks.[ix].bp = (int)peakscxx . . $ peaks.[ix].bp1; |
| 1060 | next = fr2->klatt_bp[ix] * 4; |
| 1061 | peakscxx . . $ peaks.[ix].bp_inc = ((next - peakscxx . . $ peaks.[ix].bp1) * STEPSIZEcxx . . $ `external/espeak/synthesize.h:38:9`!) / length; |
| 1062 | |
| 1063 | peakscxx . . $ peaks.[ix].ap1 = fr1->klatt_ap[ix]; // parallal amplitude |
| 1064 | peakscxx . . $ peaks.[ix].ap = (int)peakscxx . . $ peaks.[ix].ap1; |
| 1065 | next = fr2->klatt_ap[ix]; |
| 1066 | peakscxx . . $ peaks.[ix].ap_inc = ((next - peakscxx . . $ peaks.[ix].ap1) * STEPSIZEcxx . . $ `external/espeak/synthesize.h:38:9`!) / length; |
| 1067 | } |
| 1068 | } |
| 1069 | } |
| 1070 | |
| 1071 | void KlattInitcxx . . $ KlattInit(49f6e7a06ebc5aa8).(void) |
| 1072 | { |
| 1073 | |
| 1074 | static const short formant_hz[10] = { 280, 688, 1064, 2806, 3260, 3700, 6500, 7000, 8000, 280 }; |
| 1075 | static const short bandwidth[10] = { 89, 160, 70, 160, 200, 200, 500, 500, 500, 89 }; |
| 1076 | static const short parallel_amp[10] = { 0, 59, 59, 59, 59, 59, 59, 0, 0, 0 }; |
| 1077 | static const short parallel_bw[10] = { 59, 59, 89, 149, 200, 200, 500, 0, 0, 0 }; |
| 1078 | |
| 1079 | int ix; |
| 1080 | |
| 1081 | #if USE_SPEECHPLAYERcxx . . $ `external/espeak/espeak__config.h:15:9`! |
| 1082 | KlattInitSP(); |
| 1083 | #endif |
| 1084 | |
| 1085 | sample_countcxx . . $ sample_count. = 0; |
| 1086 | |
| 1087 | kt_globalscxx . . $ kt_globals..synthesis_model = CASCADE_PARALLELcxx . . $ `external/espeak/klatt.h:35:9`!; |
| 1088 | kt_globalscxx . . $ kt_globals..samrate = 22050; |
| 1089 | |
| 1090 | kt_globalscxx . . $ kt_globals..glsource = IMPULSIVEcxx . . $ `external/espeak/klatt.h:38:9`!; |
| 1091 | kt_globalscxx . . $ kt_globals..scale_wav = scale_wav_tabcxx . . $ scale_wav_tab.[kt_globalscxx . . $ kt_globals..glsource]; |
| 1092 | kt_globalscxx . . $ kt_globals..natural_samples = natural_samplescxx . . $ natural_samples.; |
| 1093 | kt_globalscxx . . $ kt_globals..num_samples = NUMBER_OF_SAMPLEScxx . . $ `external/espeak/klatt.cpp:69:9`!; |
| 1094 | kt_globalscxx . . $ kt_globals..sample_factor = 3.0; |
| 1095 | kt_globalscxx . . $ kt_globals..nspfr = (kt_globalscxx . . $ kt_globals..samrate * 10) / 1000; |
| 1096 | kt_globalscxx . . $ kt_globals..outsl = 0; |
| 1097 | kt_globalscxx . . $ kt_globals..f0_flutter = 20; |
| 1098 | |
| 1099 | KlattResetcxx . . $ KlattReset(d4f767463ce0a6b3).(2); |
| 1100 | |
| 1101 | // set default values for frame parameters |
| 1102 | for (ix = 0; ix <= 9; ix++) { |
| 1103 | kt_framecxx . . $ kt_frame..Fhz[ix] = formant_hz[ix]; |
| 1104 | kt_framecxx . . $ kt_frame..Bhz[ix] = bandwidth[ix]; |
| 1105 | kt_framecxx . . $ kt_frame..Ap[ix] = parallel_amp[ix]; |
| 1106 | kt_framecxx . . $ kt_frame..Bphz[ix] = parallel_bw[ix]; |
| 1107 | } |
| 1108 | kt_framecxx . . $ kt_frame..Bhz_next[F_NZcxx . . $ `external/espeak/klatt.h:128:9`!] = bandwidth[F_NZcxx . . $ `external/espeak/klatt.h:128:9`!]; |
| 1109 | |
| 1110 | kt_framecxx . . $ kt_frame..F0hz10 = 1000; |
| 1111 | kt_framecxx . . $ kt_frame..AVdb = 59; |
| 1112 | kt_framecxx . . $ kt_frame..ASP = 0; |
| 1113 | kt_framecxx . . $ kt_frame..Kopen = 40; |
| 1114 | kt_framecxx . . $ kt_frame..Aturb = 0; |
| 1115 | kt_framecxx . . $ kt_frame..TLTdb = 0; |
| 1116 | kt_framecxx . . $ kt_frame..AF = 50; |
| 1117 | kt_framecxx . . $ kt_frame..Kskew = 0; |
| 1118 | kt_framecxx . . $ kt_frame..AB = 0; |
| 1119 | kt_framecxx . . $ kt_frame..AVpdb = 0; |
| 1120 | kt_framecxx . . $ kt_frame..Gain0 = 62; |
| 1121 | } |