1 2 3 #define CASCADE_PARALLEL 1 /* Type of synthesis model */ 4 #define ALL_PARALLEL 2 5 6 #define IMPULSIVE 1 /* Type of voicing source */ 7 #define NATURAL 2 8 #define SAMPLED 3 9 #define SAMPLED2 4 10 11 #define PI 3.1415927 12 13 14 /* typedef's that need to be exported */ 15 16 typedef long flag; 17 18 /* Resonator Structure */ 19 20 typedef struct 21 { 22 double a; 23 double b; 24 double c; 25 double p1; 26 double p2; 27 double a_inc; 28 double b_inc; 29 double c_inc; 30 } resonator_t, *resonator_ptr; 31 32 /* Structure for Klatt Globals */ 33 34 typedef struct 35 { 36 flag synthesis_model; /* cascade-parallel or all-parallel */ 37 flag outsl; /* Output waveform selector */ 38 long samrate; /* Number of output samples per second */ 39 long FLPhz ; /* Frequeny of glottal downsample low-pass filter */ 40 long BLPhz ; /* Bandwidth of glottal downsample low-pass filter */ 41 flag glsource; /* Type of glottal source */ 42 int f0_flutter; /* Percentage of f0 flutter 0-100 */ 43 long nspfr; /* number of samples per frame */ 44 long nper; /* Counter for number of samples in a pitch period */ 45 long ns; 46 long T0; /* Fundamental period in output samples times 4 */ 47 long nopen; /* Number of samples in open phase of period */ 48 long nmod; /* Position in period to begin noise amp. modul */ 49 long nrand; /* Varible used by random number generator */ 50 double pulse_shape_a; /* Makes waveshape of glottal pulse when open */ 51 double pulse_shape_b; /* Makes waveshape of glottal pulse when open */ 52 double minus_pi_t; 53 double two_pi_t; 54 double onemd; 55 double decay; 56 double amp_bypas; /* AB converted to linear gain */ 57 double amp_voice; /* AVdb converted to linear gain */ 58 double par_amp_voice; /* AVpdb converted to linear gain */ 59 double amp_aspir; /* AP converted to linear gain */ 60 double amp_frica; /* AF converted to linear gain */ 61 double amp_breth; /* ATURB converted to linear gain */ 62 double amp_gain0; /* G0 converted to linear gain */ 63 int num_samples; /* number of glottal samples */ 64 double sample_factor; /* multiplication factor for glottal samples */ 65 short *natural_samples; /* pointer to an array of glottal samples */ 66 long original_f0; /* original value of f0 not modified by flutter */ 67 68 int fadeout; // set to 64 to cause fadeout over 64 samples 69 int scale_wav; // depends on the voicing source 70 71 #define N_RSN 20 72 #define Rnz 0 // nasal zero, anti-resonator 73 #define R1c 1 74 #define R2c 2 75 #define R3c 3 76 #define R4c 4 77 #define R5c 5 78 #define R6c 6 79 #define R7c 7 80 #define R8c 8 81 #define Rnpc 9 // nasal pole 82 83 #define Rparallel 10 84 #define Rnpp 10 85 #define R1p 11 86 #define R2p 12 87 #define R3p 13 88 #define R4p 14 89 #define R5p 15 90 #define R6p 16 91 92 #define RGL 17 93 #define RLP 18 94 #define Rout 19 95 96 resonator_t rsn[N_RSN]; // internal storage for resonators 97 resonator_t rsn_next[N_RSN]; 98 99 } klatt_global_t, *klatt_global_ptr; 100 101 /* Structure for Klatt Parameters */ 102 103 #define F_NZ 0 // nasal zero formant 104 #define F1 1 105 #define F2 2 106 #define F3 3 107 #define F4 4 108 #define F5 5 109 #define F6 6 110 #define F_NP 9 // nasal pole formant 111 112 113 typedef struct 114 { 115 int F0hz10; /* Voicing fund freq in Hz */ 116 int AVdb; /* Amp of voicing in dB, 0 to 70 */ 117 int Fhz[10]; // formant Hz, F_NZ to F6 to F_NP 118 int Bhz[10]; 119 int Ap[10]; /* Amp of parallel formants in dB, 0 to 80 */ 120 int Bphz[10]; /* Parallel formants bw in Hz, 40 to 1000 */ 121 122 int ASP; /* Amp of aspiration in dB, 0 to 70 */ 123 int Kopen; /* # of samples in open period, 10 to 65 */ 124 int Aturb; /* Breathiness in voicing, 0 to 80 */ 125 int TLTdb; /* Voicing spectral tilt in dB, 0 to 24 */ 126 int AF; /* Amp of frication in dB, 0 to 80 */ 127 int Kskew; /* Skewness of alternate periods, 0 to 40 in sample#/2 */ 128 129 int AB; /* Amp of bypass fric. in dB, 0 to 80 */ 130 int AVpdb; /* Amp of voicing, par in dB, 0 to 70 */ 131 int Gain0; /* Overall gain, 60 dB is unity, 0 to 60 */ 132 133 int AVdb_tmp; //copy of AVdb, which is changed within parwave() 134 int Fhz_next[10]; // Fhz for the next chunk, so we can do interpolation of resonator (a,b,c) parameters 135 int Bhz_next[10]; 136 } klatt_frame_t, *klatt_frame_ptr; 137 138 139 typedef struct { 140 int freq; // Hz 141 int bw; // klatt bandwidth 142 int ap; // parallel amplitude 143 int bp; // parallel bandwidth 144 DOUBLEX freq1; // floating point versions of the above 145 DOUBLEX bw1; 146 DOUBLEX ap1; 147 DOUBLEX bp1; 148 DOUBLEX freq_inc; // increment by this every 64 samples 149 DOUBLEX bw_inc; 150 DOUBLEX ap_inc; 151 DOUBLEX bp_inc; 152 } klatt_peaks_t; 153 154 155