From d1fd650219c27b4af323a424cd83573396af102f Mon Sep 17 00:00:00 2001 From: Juho Hiltunen Date: Fri, 9 Mar 2018 17:36:15 +0200 Subject: [PATCH] Replace references to USHORT, DOUBLEX and UCHAR with unsigned short, double and unsigned char. This makes the codebase more consistent. Including speech.h is not necessary anymore in some files. Includes have been removed. --- src/libespeak-ng/compiledata.c | 26 +++++++++++++------------- src/libespeak-ng/klatt.c | 3 +-- src/libespeak-ng/klatt.h | 16 ++++++++-------- src/libespeak-ng/spect.c | 3 +-- src/libespeak-ng/spect.h | 2 +- src/libespeak-ng/speech.h | 4 ---- src/libespeak-ng/synthdata.c | 16 ++++++++-------- src/libespeak-ng/synthesize.c | 1 - src/libespeak-ng/synthesize.h | 18 +++++++++--------- src/libespeak-ng/voice.h | 4 +--- src/libespeak-ng/wavegen.c | 2 +- 11 files changed, 43 insertions(+), 52 deletions(-) diff --git a/src/libespeak-ng/compiledata.c b/src/libespeak-ng/compiledata.c index 6ab43b0f..937b090a 100644 --- a/src/libespeak-ng/compiledata.c +++ b/src/libespeak-ng/compiledata.c @@ -323,9 +323,9 @@ int proc_addr[N_PROCS]; char proc_names[N_ITEM_STRING+1][N_PROCS]; #define MAX_PROG_BUF 2000 -USHORT *prog_out; -USHORT *prog_out_max; -USHORT prog_buf[MAX_PROG_BUF+20]; +unsigned short *prog_out; +unsigned short *prog_out_max; +unsigned short prog_buf[MAX_PROG_BUF+20]; static espeak_ng_STATUS ReadPhondataManifest(espeak_ng_ERROR_CONTEXT *context) { @@ -442,8 +442,8 @@ STACK stack[N_STACK]; #define N_IF_STACK 12 int if_level; typedef struct { - USHORT *p_then; - USHORT *p_else; + unsigned short *p_then; + unsigned short *p_else; bool returned; } IF_STACK; IF_STACK if_stack[N_IF_STACK]; @@ -1626,7 +1626,7 @@ static int CompileIf(int elif) int bitmap; int brackets; bool not_flag; - USHORT *prog_last_if = NULL; + unsigned short *prog_last_if = NULL; then_count = 2; after_if = true; @@ -1727,7 +1727,7 @@ static int CompileIf(int elif) static void FillThen(int add) { - USHORT *p; + unsigned short *p; int offset; p = if_stack[if_level].p_then; @@ -1755,8 +1755,8 @@ static void FillThen(int add) static int CompileElse(void) { - USHORT *ref; - USHORT *p; + unsigned short *ref; + unsigned short *p; if (if_level < 1) { error("ELSE not expected"); @@ -1794,7 +1794,7 @@ static int CompileElif(void) static int CompileEndif(void) { - USHORT *p; + unsigned short *p; int chain; int offset; @@ -2293,7 +2293,7 @@ static int CompilePhoneme(int compile_phoneme) if (prog_out > prog_buf) { // write out the program for this phoneme fflush(f_phindex); - phoneme_out->program = ftell(f_phindex) / sizeof(USHORT); + phoneme_out->program = ftell(f_phindex) / sizeof(unsigned short); if (f_prog_log != NULL) { phoneme_prog_log.addr = phoneme_out->program; @@ -2302,8 +2302,8 @@ static int CompilePhoneme(int compile_phoneme) } if (compile_phoneme == 0) - proc_addr[n_procs++] = ftell(f_phindex) / sizeof(USHORT); - fwrite(prog_buf, sizeof(USHORT), prog_out - prog_buf, f_phindex); + proc_addr[n_procs++] = ftell(f_phindex) / sizeof(unsigned short); + fwrite(prog_buf, sizeof(unsigned short), prog_out - prog_buf, f_phindex); } return 0; diff --git a/src/libespeak-ng/klatt.c b/src/libespeak-ng/klatt.c index 8b754307..99a82526 100644 --- a/src/libespeak-ng/klatt.c +++ b/src/libespeak-ng/klatt.c @@ -34,7 +34,6 @@ #include #include -#include "speech.h" #include "phoneme.h" #include "voice.h" #include "synthesize.h" @@ -938,7 +937,7 @@ static int Wavegen_Klatt(int resume) static void SetSynth_Klatt(int length, frame_t *fr1, frame_t *fr2, voice_t *v, int control) { int ix; - DOUBLEX next; + double next; int qix; int cmd; frame_t *fr3; diff --git a/src/libespeak-ng/klatt.h b/src/libespeak-ng/klatt.h index fe2625c8..f8acdb84 100644 --- a/src/libespeak-ng/klatt.h +++ b/src/libespeak-ng/klatt.h @@ -167,14 +167,14 @@ typedef struct { int bw; // klatt bandwidth int ap; // parallel amplitude int bp; // parallel bandwidth - DOUBLEX freq1; // floating point versions of the above - DOUBLEX bw1; - DOUBLEX ap1; - DOUBLEX bp1; - DOUBLEX freq_inc; // increment by this every 64 samples - DOUBLEX bw_inc; - DOUBLEX ap_inc; - DOUBLEX bp_inc; + double freq1; // floating point versions of the above + double bw1; + double ap1; + double bp1; + double freq_inc; // increment by this every 64 samples + double bw_inc; + double ap_inc; + double bp_inc; } klatt_peaks_t; void KlattInit(void); diff --git a/src/libespeak-ng/spect.c b/src/libespeak-ng/spect.c index e468dfd6..dc027df5 100644 --- a/src/libespeak-ng/spect.c +++ b/src/libespeak-ng/spect.c @@ -30,7 +30,6 @@ #include #include -#include "speech.h" #include "phoneme.h" #include "voice.h" #include "synthesize.h" @@ -193,7 +192,7 @@ static espeak_ng_STATUS LoadFrame(SpectFrame *frame, FILE *stream, int file_form } } - spect_data = malloc(sizeof(USHORT) * frame->nx); + spect_data = malloc(sizeof(unsigned short) * frame->nx); if (spect_data == NULL) return ENOMEM; diff --git a/src/libespeak-ng/spect.h b/src/libespeak-ng/spect.h index 398f01cf..d04b206b 100644 --- a/src/libespeak-ng/spect.h +++ b/src/libespeak-ng/spect.h @@ -105,7 +105,7 @@ typedef struct { unsigned short nx; short markers; int max_y; - USHORT *spect; // sqrt of harmonic amplitudes, 1-nx at 'pitch' + unsigned short *spect; // sqrt of harmonic amplitudes, 1-nx at 'pitch' short klatt_param[N_KLATTP2]; diff --git a/src/libespeak-ng/speech.h b/src/libespeak-ng/speech.h index 36159e7c..fd3d3e75 100644 --- a/src/libespeak-ng/speech.h +++ b/src/libespeak-ng/speech.h @@ -57,10 +57,6 @@ extern "C" #define PATH_ESPEAK_DATA "/usr/share/espeak-ng-data" #endif -typedef unsigned short USHORT; -typedef unsigned char UCHAR; -typedef double DOUBLEX; - typedef struct { const char *mnem; int value; diff --git a/src/libespeak-ng/synthdata.c b/src/libespeak-ng/synthdata.c index 09d1def6..81ce99d4 100644 --- a/src/libespeak-ng/synthdata.c +++ b/src/libespeak-ng/synthdata.c @@ -47,7 +47,7 @@ int current_phoneme_table; PHONEME_TAB *phoneme_tab[N_PHONEME_TAB]; unsigned char phoneme_tab_flags[N_PHONEME_TAB]; // bit 0: not inherited -USHORT *phoneme_index = NULL; +unsigned short *phoneme_index = NULL; char *phondata_ptr = NULL; unsigned char *wavefile_data = NULL; static unsigned char *phoneme_tab_data = NULL; @@ -498,7 +498,7 @@ static int CountVowelPosition(PHONEME_LIST *plist) return count; } -static bool InterpretCondition(Translator *tr, int control, PHONEME_LIST *plist, USHORT *p_prog, WORD_PH_DATA *worddata) +static bool InterpretCondition(Translator *tr, int control, PHONEME_LIST *plist, unsigned short *p_prog, WORD_PH_DATA *worddata) { int which; int ix; @@ -693,9 +693,9 @@ static bool InterpretCondition(Translator *tr, int control, PHONEME_LIST *plist, return false; } -static void SwitchOnVowelType(PHONEME_LIST *plist, PHONEME_DATA *phdata, USHORT **p_prog, int instn_type) +static void SwitchOnVowelType(PHONEME_LIST *plist, PHONEME_DATA *phdata, unsigned short **p_prog, int instn_type) { - USHORT *prog; + unsigned short *prog; int voweltype; signed char x; @@ -716,7 +716,7 @@ static void SwitchOnVowelType(PHONEME_LIST *plist, PHONEME_DATA *phdata, USHORT *p_prog += 12; } -int NumInstnWords(USHORT *prog) +int NumInstnWords(unsigned short *prog) { int instn; int instn2; @@ -769,8 +769,8 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_ // bit 8: change phonemes PHONEME_TAB *ph; - USHORT *prog; - USHORT instn; + unsigned short *prog; + unsigned short instn; int instn2; int or_flag; bool truth; @@ -782,7 +782,7 @@ void InterpretPhoneme(Translator *tr, int control, PHONEME_LIST *plist, PHONEME_ #define N_RETURN 10 int n_return = 0; - USHORT *return_addr[N_RETURN]; // return address stack + unsigned short *return_addr[N_RETURN]; // return address stack ph = plist->ph; diff --git a/src/libespeak-ng/synthesize.c b/src/libespeak-ng/synthesize.c index 0ce0dfa2..194d5343 100644 --- a/src/libespeak-ng/synthesize.c +++ b/src/libespeak-ng/synthesize.c @@ -32,7 +32,6 @@ #include #include -#include "speech.h" #include "phoneme.h" #include "voice.h" #include "synthesize.h" diff --git a/src/libespeak-ng/synthesize.h b/src/libespeak-ng/synthesize.h index 731c1a26..fcd4229f 100644 --- a/src/libespeak-ng/synthesize.h +++ b/src/libespeak-ng/synthesize.h @@ -137,14 +137,14 @@ typedef struct { int height; // height<<15 int left; // Hz<<16 int right; // Hz<<16 - DOUBLEX freq1; // floating point versions of the above - DOUBLEX height1; - DOUBLEX left1; - DOUBLEX right1; - DOUBLEX freq_inc; // increment by this every 64 samples - DOUBLEX height_inc; - DOUBLEX left_inc; - DOUBLEX right_inc; + 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 { @@ -561,7 +561,7 @@ int DoSpect2(PHONEME_TAB *this_ph, int which, FMT_PARAMS *fmt_params, PHONEME_L int PauseLength(int pause, int control); int LookupPhonemeTable(const char *name); unsigned char *GetEnvelope(int index); -int NumInstnWords(USHORT *prog); +int NumInstnWords(unsigned short *prog); void InitBreath(void); diff --git a/src/libespeak-ng/voice.h b/src/libespeak-ng/voice.h index 8be96d8a..d33c8ca7 100644 --- a/src/libespeak-ng/voice.h +++ b/src/libespeak-ng/voice.h @@ -22,8 +22,6 @@ #include -#include "speech.h" - #ifdef __cplusplus extern "C" { @@ -80,7 +78,7 @@ typedef struct { } voice_t; // percentages shown to user, ix=N_PEAKS means ALL peaks -extern USHORT voice_pcnt[N_PEAKS+1][3]; +extern unsigned short voice_pcnt[N_PEAKS+1][3]; extern espeak_VOICE current_voice_selected; diff --git a/src/libespeak-ng/wavegen.c b/src/libespeak-ng/wavegen.c index 68f8a0f6..ab833cf8 100644 --- a/src/libespeak-ng/wavegen.c +++ b/src/libespeak-ng/wavegen.c @@ -1151,7 +1151,7 @@ static void SetSynth(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t * return; int ix; - DOUBLEX next; + double next; int length2; int length4; int qix;