Browse Source

maintainability: pass seq_len_adjust to LookupSpect() instead of using globals

master
Juho Hiltunen 7 years ago
parent
commit
d08b8e43ca
3 changed files with 10 additions and 10 deletions
  1. 6
    7
      src/libespeak-ng/synthdata.c
  2. 2
    1
      src/libespeak-ng/synthdata.h
  3. 2
    2
      src/libespeak-ng/synthesize.c

+ 6
- 7
src/libespeak-ng/synthdata.c View File

int wavefile_ix; // a wavefile to play along with the synthesis int wavefile_ix; // a wavefile to play along with the synthesis
int wavefile_amp; int wavefile_amp;


int seq_len_adjust;
int vowel_transition[4]; int vowel_transition[4];


static espeak_ng_STATUS ReadPhFile(void **ptr, const char *fname, int *size, espeak_ng_ERROR_CONTEXT *context) static espeak_ng_STATUS ReadPhFile(void **ptr, const char *fname, int *size, espeak_ng_ERROR_CONTEXT *context)
return PhonemeCode(mnem); return PhonemeCode(mnem);
} }


frameref_t *LookupSpect(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, int *n_frames, PHONEME_LIST *plist)
frameref_t *LookupSpect(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, int *n_frames, PHONEME_LIST *plist, int *seq_len_adjust)
{ {
int ix; int ix;
int nf; int nf;
if (nf >= N_SEQ_FRAMES) if (nf >= N_SEQ_FRAMES)
nf = N_SEQ_FRAMES - 1; nf = N_SEQ_FRAMES - 1;


seq_len_adjust = fmt_params->fmt2_lenadj + fmt_params->fmt_length;
*seq_len_adjust = fmt_params->fmt2_lenadj + fmt_params->fmt_length;
seq_break = 0; seq_break = 0;


for (ix = 0; ix < nf; ix++) { for (ix = 0; ix < nf; ix++) {


// do we need to modify a frame for blending with a consonant? // do we need to modify a frame for blending with a consonant?
if ((this_ph->type == phVOWEL) && (fmt_params->fmt2_addr == 0) && (fmt_params->use_vowelin)) if ((this_ph->type == phVOWEL) && (fmt_params->fmt2_addr == 0) && (fmt_params->use_vowelin))
seq_len_adjust += FormantTransition2(frames, &nf, fmt_params->transition0, fmt_params->transition1, NULL, which);
*seq_len_adjust += FormantTransition2(frames, &nf, fmt_params->transition0, fmt_params->transition1, NULL, which);


length1 = 0; length1 = 0;
nf1 = nf - 1; nf1 = nf - 1;
// adjust the length of the main part to match the standard length specified for the vowel // adjust the length of the main part to match the standard length specified for the vowel
// less the front part of the vowel and any added suffix // less the front part of the vowel and any added suffix


length_std = fmt_params->std_length + seq_len_adjust - 45;
length_std = fmt_params->std_length + (int) *seq_len_adjust - 45;
if (length_std < 10) if (length_std < 10)
length_std = 10; length_std = 10;
if (plist->synthflags & SFLAG_LENGTHEN) if (plist->synthflags & SFLAG_LENGTHEN)
} else { } else {
// not a vowel // not a vowel
if (fmt_params->std_length > 0) if (fmt_params->std_length > 0)
seq_len_adjust += (fmt_params->std_length - length1);
*seq_len_adjust += (fmt_params->std_length - length1);
} }


if (seq_len_adjust != 0) { if (seq_len_adjust != 0) {
length_factor = ((length1 + seq_len_adjust) * 256)/length1;
length_factor = ((length1 + (int) *seq_len_adjust) * 256)/length1;
for (ix = 0; ix < nf1; ix++) for (ix = 0; ix < nf1; ix++)
frames[ix].length = (frames[ix].length * length_factor)/256; frames[ix].length = (frames[ix].length * length_factor)/256;
} }

+ 2
- 1
src/libespeak-ng/synthdata.h View File

int which, int which,
FMT_PARAMS *fmt_params, FMT_PARAMS *fmt_params,
int *n_frames, int *n_frames,
PHONEME_LIST *plist);
PHONEME_LIST *plist,
int *seq_len_adjust);


int NumInstnWords(unsigned short *prog); int NumInstnWords(unsigned short *prog);
int PhonemeCode(unsigned int mnem); int PhonemeCode(unsigned int mnem);

+ 2
- 2
src/libespeak-ng/synthesize.c View File

} }
} }


extern int seq_len_adjust; // temporary fix to advance the start point for playing the wav sample
int seq_len_adjust; // temporary fix to advance the start point for playing the wav sample


static int DoSample2(int index, int which, int std_length, int control, int length_mod, int amp) static int DoSample2(int index, int which, int std_length, int control, int length_mod, int amp)
{ {
} }


modn_flags = 0; modn_flags = 0;
frames = LookupSpect(this_ph, which, fmt_params, &n_frames, plist);
frames = LookupSpect(this_ph, which, fmt_params, &n_frames, plist, &seq_len_adjust);
if (frames == NULL) if (frames == NULL)
return 0; // not found return 0; // not found



Loading…
Cancel
Save