Navit SVN

/work/compile/navit/src/navit/support/espeak/klatt.h

00001 
00002 
00003 #define CASCADE_PARALLEL 1         /* Type of synthesis model */
00004 #define ALL_PARALLEL     2 
00005 
00006 #define IMPULSIVE        1         /* Type of voicing source */
00007 #define NATURAL          2
00008 #define SAMPLED          3
00009 
00010 #define PI               3.1415927
00011 
00012 
00013 /* typedef's that need to be exported */
00014 
00015 typedef long flag;
00016 
00017 /* Resonator Structure */
00018 
00019 typedef struct
00020 {
00021         double a;
00022         double b;
00023         double c;
00024         double p1;
00025         double p2;
00026         double a_inc;
00027         double b_inc;
00028         double c_inc;
00029 } resonator_t, *resonator_ptr;
00030 
00031 /* Structure for Klatt Globals */
00032 
00033 typedef struct
00034 {
00035   flag synthesis_model; /* cascade-parallel or all-parallel */
00036   flag outsl;       /* Output waveform selector                      */
00037   long samrate;     /* Number of output samples per second           */
00038   long FLPhz ;      /* Frequeny of glottal downsample low-pass filter */
00039   long BLPhz ;      /* Bandwidth of glottal downsample low-pass filter */
00040   flag glsource;    /* Type of glottal source */
00041   int f0_flutter;   /* Percentage of f0 flutter 0-100 */
00042   long nspfr;       /* number of samples per frame */
00043   long nper;        /* Counter for number of samples in a pitch period */
00044   long ns;
00045   long T0;          /* Fundamental period in output samples times 4 */
00046   long nopen;       /* Number of samples in open phase of period    */
00047   long nmod;        /* Position in period to begin noise amp. modul */
00048   long nrand;       /* Varible used by random number generator      */
00049   double pulse_shape_a;  /* Makes waveshape of glottal pulse when open   */
00050   double pulse_shape_b;  /* Makes waveshape of glottal pulse when open   */
00051   double minus_pi_t;
00052   double two_pi_t;
00053   double onemd;
00054   double decay;
00055   double amp_bypas; /* AB converted to linear gain              */
00056   double amp_voice; /* AVdb converted to linear gain            */
00057   double par_amp_voice; /* AVpdb converted to linear gain       */
00058   double amp_aspir; /* AP converted to linear gain              */
00059   double amp_frica; /* AF converted to linear gain              */
00060   double amp_breth; /* ATURB converted to linear gain           */
00061   double amp_gain0; /* G0 converted to linear gain              */
00062   int num_samples; /* number of glottal samples */
00063   double sample_factor; /* multiplication factor for glottal samples */
00064   short *natural_samples; /* pointer to an array of glottal samples */
00065   long original_f0; /* original value of f0 not modified by flutter */
00066 
00067         int fadeout;       // set to 64 to cause fadeout over 64 samples
00068         int scale_wav;     // depends on the voicing source
00069 
00070 #define N_RSN 20
00071 #define Rnpc 0
00072 #define R1c  1
00073 #define R2c  2
00074 #define R3c  3
00075 #define R4c  4
00076 #define R5c  5
00077 #define R6c  6
00078 #define R7c  7
00079 #define R8c  8
00080 #define Rnz  9
00081 
00082 #define Rparallel 10
00083 #define Rnpp 10
00084 #define R1p  11
00085 #define R2p  12
00086 #define R3p  13
00087 #define R4p  14
00088 #define R5p  15
00089 #define R6p  16
00090 
00091 #define RGL  17
00092 #define RLP  18
00093 #define Rout 19
00094 
00095   resonator_t rsn[N_RSN];        // internal storage for resonators
00096   resonator_t rsn_next[N_RSN];
00097 
00098 } klatt_global_t, *klatt_global_ptr;
00099   
00100 /* Structure for Klatt Parameters */
00101 
00102 #define F_NZ   0  // nasal zero formant
00103 #define F1     1
00104 #define F2     2
00105 #define F3     3
00106 #define F4     4
00107 #define F5     5
00108 #define F6     6
00109 #define F_NP   9  // nasal pole formant
00110 
00111 
00112 typedef struct
00113 {
00114         long F0hz10; /* Voicing fund freq in Hz                          */
00115         long AVdb;   /* Amp of voicing in dB,            0 to   70       */
00116         int Fhz[10];  // formant Hz, F_NZ to F6 to F_NP
00117         int Bhz[10];
00118         int Ap[10];   /* Amp of parallel formants in dB,    0 to   80       */
00119         int Bphz[10]; /* Parallel formants bw in Hz,       40 to 1000      */
00120 
00121         long ASP;    /* Amp of aspiration in dB,         0 to   70       */
00122         long Kopen;  /* # of samples in open period,     10 to   65      */
00123         long Aturb;  /* Breathiness in voicing,          0 to   80       */
00124         long TLTdb;  /* Voicing spectral tilt in dB,     0 to   24       */
00125         long AF;     /* Amp of frication in dB,          0 to   80       */
00126         long Kskew;  /* Skewness of alternate periods,   0 to   40 in sample#/2  */
00127 
00128         long AB;     /* Amp of bypass fric. in dB,       0 to   80       */
00129         long AVpdb;  /* Amp of voicing,  par in dB,      0 to   70       */
00130         long Gain0;  /* Overall gain, 60 dB is unity,    0 to   60       */
00131 
00132         long AVdb_tmp;      //copy of AVdb, which is changed within parwave()
00133         int Fhz_next[10];    // Fhz for the next chunk, so we can do interpolation of resonator (a,b,c) parameters
00134         int Bhz_next[10];
00135  } klatt_frame_t, *klatt_frame_ptr;
00136 
00137 
00138 typedef struct {
00139         int freq;     // Hz
00140         int bw;   // klatt bandwidth
00141         int ap;   // parallel amplitude
00142         int bp;   // parallel bandwidth
00143         DOUBLEX freq1; // floating point versions of the above
00144         DOUBLEX bw1;
00145         DOUBLEX ap1;
00146         DOUBLEX bp1;
00147         DOUBLEX freq_inc;    // increment by this every 64 samples
00148         DOUBLEX bw_inc;
00149         DOUBLEX ap_inc;
00150         DOUBLEX bp_inc;
00151 }  klatt_peaks_t;
00152 
00153