From f00ff91fe41bb5b9ebfecfb74ec9279acc491880 Mon Sep 17 00:00:00 2001 From: Juho Hiltunen Date: Sat, 10 Mar 2018 14:07:44 +0200 Subject: [PATCH] headers: add new file wavegen.h with declarations of functions in wavegen.c --- src/libespeak-ng/compiledata.c | 1 + src/libespeak-ng/setlengths.c | 1 + src/libespeak-ng/spect.h | 3 ++ src/libespeak-ng/speech.c | 1 + src/libespeak-ng/synth_mbrola.c | 1 + src/libespeak-ng/synthesize.c | 1 + src/libespeak-ng/synthesize.h | 29 ------------- src/libespeak-ng/voices.c | 1 + src/libespeak-ng/wavegen.c | 5 ++- src/libespeak-ng/wavegen.h | 76 +++++++++++++++++++++++++++++++++ 10 files changed, 89 insertions(+), 30 deletions(-) create mode 100644 src/libespeak-ng/wavegen.h diff --git a/src/libespeak-ng/compiledata.c b/src/libespeak-ng/compiledata.c index 8510395b..e149eec4 100644 --- a/src/libespeak-ng/compiledata.c +++ b/src/libespeak-ng/compiledata.c @@ -37,6 +37,7 @@ #include "readclause.h" #include "synthdata.h" +#include "wavegen.h" #include "error.h" #include "phoneme.h" diff --git a/src/libespeak-ng/setlengths.c b/src/libespeak-ng/setlengths.c index 0affb765..3149e947 100644 --- a/src/libespeak-ng/setlengths.c +++ b/src/libespeak-ng/setlengths.c @@ -31,6 +31,7 @@ #include "readclause.h" #include "setlengths.h" #include "synthdata.h" +#include "wavegen.h" #include "phoneme.h" #include "voice.h" diff --git a/src/libespeak-ng/spect.h b/src/libespeak-ng/spect.h index d04b206b..64ca61a8 100644 --- a/src/libespeak-ng/spect.h +++ b/src/libespeak-ng/spect.h @@ -21,6 +21,9 @@ #define ESPEAK_NG_SPECT_H #include + +#include "wavegen.h" + #include "synthesize.h" #include "speech.h" diff --git a/src/libespeak-ng/speech.c b/src/libespeak-ng/speech.c index 858bf4ec..f787a4a2 100644 --- a/src/libespeak-ng/speech.c +++ b/src/libespeak-ng/speech.c @@ -51,6 +51,7 @@ #include "dictionary.h" #include "readclause.h" #include "synthdata.h" +#include "wavegen.h" #include "speech.h" #include "phoneme.h" diff --git a/src/libespeak-ng/synth_mbrola.c b/src/libespeak-ng/synth_mbrola.c index 4bab2160..a9c914e6 100644 --- a/src/libespeak-ng/synth_mbrola.c +++ b/src/libespeak-ng/synth_mbrola.c @@ -35,6 +35,7 @@ #include "dictionary.h" #include "readclause.h" #include "synthdata.h" +#include "wavegen.h" #include "speech.h" #include "phoneme.h" diff --git a/src/libespeak-ng/synthesize.c b/src/libespeak-ng/synthesize.c index 01755b36..7dc938ad 100644 --- a/src/libespeak-ng/synthesize.c +++ b/src/libespeak-ng/synthesize.c @@ -36,6 +36,7 @@ #include "intonation.h" #include "setlengths.h" #include "synthdata.h" +#include "wavegen.h" #include "phoneme.h" #include "voice.h" diff --git a/src/libespeak-ng/synthesize.h b/src/libespeak-ng/synthesize.h index 825dfc72..843471c2 100644 --- a/src/libespeak-ng/synthesize.h +++ b/src/libespeak-ng/synthesize.h @@ -35,7 +35,6 @@ extern "C" #define N_PHONEME_LIST 1000 // enough for source[N_TR_SOURCE] full of text, else it will truncate -#define MAX_HARMONIC 400 // 400 * 50Hz = 20 kHz, more than enough #define N_SEQ_FRAMES 25 // max frames in a spectrum sequence (real max is ablut 8) #define STEPSIZE 64 // 2.9mS at 22 kHz sample rate @@ -129,22 +128,6 @@ typedef struct { // 44 bytes unsigned char klattp[5]; // AV, FNZ, Tilt, Aspr, Skew } frame_t2; // without the extra Klatt parameters -// formant data used by wavegen -typedef struct { - int freq; // Hz<<16 - int height; // height<<15 - int left; // Hz<<16 - int right; // Hz<<16 - double freq1; // floating point versions of the above - double height1; - double left1; - double right1; - double freq_inc; // increment by this every 64 samples - double height_inc; - double left_inc; - double right_inc; -} wavegen_peaks_t; - typedef struct { unsigned char *pitch_env; int pitch; // pitch Hz*256 @@ -462,17 +445,7 @@ extern intptr_t wcmdq[N_WCMDQ][4]; extern int wcmdq_head; extern int wcmdq_tail; -// from Wavegen file -int WcmdqFree(void); -void WcmdqStop(void); -int WcmdqUsed(void); -void WcmdqInc(void); -void WavegenInit(int rate, int wavemult_fact); -int WavegenFill(void); void MarkerEvent(int type, unsigned int char_position, int value, int value2, unsigned char *out_ptr); -int GetAmplitude(void); -void SetPitch2(voice_t *voice, int pitch1, int pitch2, int *pitch_base, int *pitch_range); -int PeaksToHarmspect(wavegen_peaks_t *peaks, int pitch, int *htab, int control); extern unsigned char *wavefile_data; extern int samplerate; @@ -546,8 +519,6 @@ int DoSample3(PHONEME_DATA *phdata, int length_mod, int amp); int DoSpect2(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, PHONEME_LIST *plist, int modulation); int PauseLength(int pause, int control); -void InitBreath(void); - #ifdef __cplusplus } #endif diff --git a/src/libespeak-ng/voices.c b/src/libespeak-ng/voices.c index 4cd245c6..3d4b27a6 100644 --- a/src/libespeak-ng/voices.c +++ b/src/libespeak-ng/voices.c @@ -41,6 +41,7 @@ #include "dictionary.h" #include "readclause.h" #include "synthdata.h" +#include "wavegen.h" #include "speech.h" #include "phoneme.h" diff --git a/src/libespeak-ng/wavegen.c b/src/libespeak-ng/wavegen.c index ab833cf8..f584ad04 100644 --- a/src/libespeak-ng/wavegen.c +++ b/src/libespeak-ng/wavegen.c @@ -32,6 +32,8 @@ #include #include +#include "wavegen.h" + #include "synthesize.h" #include "speech.h" #include "phoneme.h" @@ -80,6 +82,7 @@ static RESONATOR rbreath[N_PEAKS]; static int harm_sqrt_n = 0; #define N_LOWHARM 30 +#define MAX_HARMONIC 400 // 400 * 50Hz = 20 kHz, more than enough static int harm_inc[N_LOWHARM]; // only for these harmonics do we interpolate amplitude between steps static int *harmspect; static int hswitch = 0; @@ -1393,7 +1396,7 @@ static int SpeedUp(short *outbuf, int length_in, int length_out, int end_of_text #endif // Call WavegenFill2, and then speed up the output samples. -int WavegenFill() +int WavegenFill(void) { int finished; unsigned char *p_start; diff --git a/src/libespeak-ng/wavegen.h b/src/libespeak-ng/wavegen.h new file mode 100644 index 00000000..75d2a836 --- /dev/null +++ b/src/libespeak-ng/wavegen.h @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2005 to 2015 by Jonathan Duddington + * email: jonsd@users.sourceforge.net + * Copyright (C) 2015-2018 Reece H. Dunn + * Copyright (C) 2018 Juho Hiltunen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see: . + */ + +#ifndef ESPEAK_NG_WAVEGEN_H +#define ESPEAK_NG_WAVEGEN_H + +#include "voice.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef struct { + int freq; // Hz<<16 + int height; // height<<15 + int left; // Hz<<16 + int right; // Hz<<16 + double freq1; // floating point versions of the above + double height1; + double left1; + double right1; + double freq_inc; // increment by this every 64 samples + double height_inc; + double left_inc; + double right_inc; +} wavegen_peaks_t; + + +int GetAmplitude(void); +void InitBreath(void); +int PeaksToHarmspect(wavegen_peaks_t *peaks, + int pitch, + int *htab, + int control); + +void SetPitch2(voice_t *voice, + int pitch1, + int pitch2, + int *pitch_base, + int *pitch_range); + +void WavegenInit(int rate, + int wavemult_fact); + + +int WavegenFill(void); +void WavegenSetVoice(voice_t *v); +int WcmdqFree(void); +void WcmdqStop(void); +int WcmdqUsed(void); +void WcmdqInc(void); + +#ifdef __cplusplus +} +#endif + +#endif +