Browse Source

code cleanup: pass voice_t wvoice as a parameter instead of using a global

SetSynth_Klatt() was using wvoice in two ways:
1) global wvoice was used directly
2) global wvoice was also passed in Wavegen_Klatt() as an argument "v"

Now the code only uses the function argument wvoice

Contributes to #68.
master
Juho Hiltunen 5 years ago
parent
commit
388be80da7
3 changed files with 6 additions and 7 deletions
  1. 4
    5
      src/libespeak-ng/klatt.c
  2. 1
    1
      src/libespeak-ng/klatt.h
  3. 1
    1
      src/libespeak-ng/wavegen.c

+ 4
- 5
src/libespeak-ng/klatt.c View File

return (double)(amptable[dB]) * 0.001; return (double)(amptable[dB]) * 0.001;
} }


extern voice_t *wvoice;
static klatt_peaks_t peaks[N_PEAKS]; static klatt_peaks_t peaks[N_PEAKS];
static int end_wave; static int end_wave;
static int klattp[N_KLATTP]; static int klattp[N_KLATTP];
static double klattp1[N_KLATTP]; static double klattp1[N_KLATTP];
static double klattp_inc[N_KLATTP]; static double klattp_inc[N_KLATTP];


int Wavegen_Klatt(int length, int resume, frame_t *fr1, frame_t *fr2, WGEN_DATA *wdata) int Wavegen_Klatt(int length, int resume, frame_t *fr1, frame_t *fr2, WGEN_DATA *wdata, voice_t *wvoice)
{ {
if (resume == 0) if (resume == 0)
SetSynth_Klatt(length, fr1, fr2, wvoice, 1); SetSynth_Klatt(length, fr1, fr2, wvoice, 1);
return 0; return 0;
} }


static void SetSynth_Klatt(int length, frame_t *fr1, frame_t *fr2, voice_t *v, int control) static void SetSynth_Klatt(int length, frame_t *fr1, frame_t *fr2, voice_t *wvoice, int control)
{ {
int ix; int ix;
double next; double next;
nsamples = length; nsamples = length;


for (ix = 1; ix < 6; ix++) { for (ix = 1; ix < 6; ix++) {
peaks[ix].freq1 = (fr1->ffreq[ix] * v->freq[ix] / 256.0) + v->freqadd[ix]; peaks[ix].freq1 = (fr1->ffreq[ix] * wvoice->freq[ix] / 256.0) + wvoice->freqadd[ix];
peaks[ix].freq = (int)peaks[ix].freq1; peaks[ix].freq = (int)peaks[ix].freq1;
next = (fr2->ffreq[ix] * v->freq[ix] / 256.0) + v->freqadd[ix]; next = (fr2->ffreq[ix] * wvoice->freq[ix] / 256.0) + wvoice->freqadd[ix];
peaks[ix].freq_inc = ((next - peaks[ix].freq1) * STEPSIZE) / length; peaks[ix].freq_inc = ((next - peaks[ix].freq1) * STEPSIZE) / length;


if (ix < 4) { if (ix < 4) {

+ 1
- 1
src/libespeak-ng/klatt.h View File



void KlattInit(void); void KlattInit(void);
void KlattReset(int control); void KlattReset(int control);
int Wavegen_Klatt(int length, int resume, frame_t *fr1, frame_t *fr2, WGEN_DATA *wdata); int Wavegen_Klatt(int length, int resume, frame_t *fr1, frame_t *fr2, WGEN_DATA *wdata, voice_t *wvoice);


#ifdef __cplusplus #ifdef __cplusplus
} }

+ 1
- 1
src/libespeak-ng/wavegen.c View File

wdata.n_mix_wavefile = 0; // ... and drop through to WCMD_SPECT case wdata.n_mix_wavefile = 0; // ... and drop through to WCMD_SPECT case
case WCMD_KLATT: case WCMD_KLATT:
echo_complete = echo_length; echo_complete = echo_length;
result = Wavegen_Klatt(length & 0xffff, resume, (frame_t *)q[2], (frame_t *)q[3], &wdata); result = Wavegen_Klatt(length & 0xffff, resume, (frame_t *)q[2], (frame_t *)q[3], &wdata, wvoice);
break; break;
#endif #endif
case WCMD_MARKER: case WCMD_MARKER:

Loading…
Cancel
Save