Browse Source

code cleanup: next bunch of globals

master
Yury Popov 2 years ago
parent
commit
7485828984

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

@@ -320,7 +320,7 @@ char *DecodeRule(const char *group_chars, int group_length, char *rule, int cont
}
c = ' ';
} else if (rb == RULE_ENDING) {
static const char *flag_chars = "eipvdfq tba ";
static const char flag_chars[] = "eipvdfq tba ";
flags = ((rule[0] & 0x7f)<< 8) + (rule[1] & 0x7f);
suffix_char = 'S';
if (flags & (SUFX_P >> 8))

+ 14
- 13
src/libespeak-ng/dictionary.c View File

@@ -43,8 +43,8 @@
#include "synthesize.h" // for STRESS_IS_PRIMARY, phoneme...
#include "translate.h" // for Translator, utf8_in, LANGU...

static int LookupFlags(Translator *tr, const char *word, unsigned int **flags_out);
static void DollarRule(char *word[], char *word_start, int consumed, int group_length, char *word_buf, Translator *tr, unsigned int *flags, int command, int *failed, int *add_points);
static int LookupFlags(Translator *tr, const char *word, unsigned int flags_out[2]);
static void DollarRule(char *word[], char *word_start, int consumed, int group_length, char *word_buf, Translator *tr, int command, int *failed, int *add_points);

typedef struct {
int points;
@@ -63,7 +63,7 @@ static const unsigned short diereses_list[7] = { 0xe4, 0xeb, 0xef, 0xf6, 0xfc, 0
// convert characters to an approximate 7 bit ascii equivalent
// used for checking for vowels (up to 0x259=schwa)
#define N_REMOVE_ACCENT 0x25e
static unsigned char remove_accent[N_REMOVE_ACCENT] = {
static const unsigned char remove_accent[N_REMOVE_ACCENT] = {
'a', 'a', 'a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', // 0c0
'd', 'n', 'o', 'o', 'o', 'o', 'o', 0, 'o', 'u', 'u', 'u', 'u', 'y', 't', 's', // 0d0
'a', 'a', 'a', 'a', 'a', 'a', 'a', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', // 0e0
@@ -396,7 +396,7 @@ void DecodePhonemes(const char *inptr, char *outptr)
unsigned char c;
unsigned int mnem;
PHONEME_TAB *ph;
static const char *stress_chars = "==,,'* ";
static const char stress_chars[] = "==,,'* ";

sprintf(outptr, "* ");
while ((phcode = *inptr++) > 0) {
@@ -551,7 +551,7 @@ const char *GetTranslatedPhonemeString(int phoneme_mode)
char phon_buf2[30];
PHONEME_LIST *plist;

static const char *stress_chars = "==,,''";
static const char stress_chars[] = "==,,''";

if (phon_out_buf == NULL) {
phon_out_size = N_PHON_OUT;
@@ -1480,10 +1480,9 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
int n_bytes;
int add_points;
int command;
unsigned int *flags = NULL;

MatchRecord match;
static MatchRecord best;
MatchRecord best;

int total_consumed; // letters consumed for best match

@@ -1699,7 +1698,7 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
else
failed = 1;
} else if (((command & 0xf0) == 0x20) || (command == DOLLAR_LIST)) {
DollarRule(word, word_start, consumed, group_length, word_buf, tr, flags, command, &failed, &add_points);
DollarRule(word, word_start, consumed, group_length, word_buf, tr, command, &failed, &add_points);
}

break;
@@ -1888,7 +1887,7 @@ static void MatchRule(Translator *tr, char *word[], char *word_start, int group_
pre_ptr++;
command = *rule++;
if ((command == DOLLAR_LIST) || ((command & 0xf0) == 0x20)) {
DollarRule(word, word_start, consumed, group_length, word_buf, tr, flags, command, &failed, &add_points);
DollarRule(word, word_start, consumed, group_length, word_buf, tr, command, &failed, &add_points);
}
break;
case RULE_SYLLABLE:
@@ -2842,7 +2841,7 @@ int Lookup(Translator *tr, const char *word, char *ph_out)
return flags0;
}

static int LookupFlags(Translator *tr, const char *word, unsigned int **flags_out)
static int LookupFlags(Translator *tr, const char *word, unsigned int flags_out[2])
{
char buf[100];
static unsigned int flags[2];
@@ -2850,7 +2849,8 @@ static int LookupFlags(Translator *tr, const char *word, unsigned int **flags_ou

flags[0] = flags[1] = 0;
LookupDictList(tr, &word1, buf, flags, 0, NULL);
*flags_out = flags;
flags_out[0] = flags[0];
flags_out[1] = flags[1];
return flags[0];
}

@@ -2979,14 +2979,15 @@ int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy)
return end_flags;
}

static void DollarRule(char *word[], char *word_start, int consumed, int group_length, char *word_buf, Translator *tr, unsigned int *flags, int command, int *failed, int *add_points) {
static void DollarRule(char *word[], char *word_start, int consumed, int group_length, char *word_buf, Translator *tr, int command, int *failed, int *add_points) {
// $list or $p_alt
// make a copy of the word up to the post-match characters
int ix = *word - word_start + consumed + group_length + 1;
memcpy(word_buf, word_start-1, ix);
word_buf[ix] = ' ';
word_buf[ix+1] = 0;
LookupFlags(tr, &word_buf[1], &flags);
unsigned int flags[2];
LookupFlags(tr, &word_buf[1], flags);

if ((command == DOLLAR_LIST) && (flags[0] & FLAG_FOUND) && !(flags[1] & FLAG_ONLY))
*add_points = 23;

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

@@ -68,7 +68,7 @@ static klatt_global_t kt_globals;

#define NUMBER_OF_SAMPLES 100

static int scale_wav_tab[] = { 45, 38, 45, 45, 55, 45 }; // scale output from different voicing sources
static const int scale_wav_tab[] = { 45, 38, 45, 45, 55, 45 }; // scale output from different voicing sources

// For testing, this can be overwritten in KlattInit()
static const short natural_samples2[256] = {

+ 0
- 2
src/libespeak-ng/langopts.c View File

@@ -42,8 +42,6 @@
static int CheckTranslator(Translator *tr, const MNEM_TAB *keyword_tab, int key);
static int LookupTune(const char *name);

extern const MNEM_TAB langopts_tab[];

void LoadLanguageOptions(Translator *translator, int key, char *keyValue ) {
if (CheckTranslator(translator, langopts_tab, key) != 0) {
return;

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

@@ -553,7 +553,7 @@ void LookupLetter(Translator *tr, unsigned int letter, int next_byte, char *ph_b


// this list must be in ascending order
static unsigned short derived_letters[] = {
static const unsigned short derived_letters[] = {
0x00aa, 'a'+L_SUP,
0x00b2, '2'+L_SUP,
0x00b3, '3'+L_SUP,
@@ -769,7 +769,7 @@ int TranslateRoman(Translator *tr, char *word, char *ph_out, WORD_TAB *wtab)
char ph_roman[30];
char number_chars[N_WORD_BYTES];

static const char *roman_numbers = "ixcmvld";
static const char roman_numbers[] = "ixcmvld";
static const int roman_values[] = { 1, 10, 100, 1000, 5, 50, 500 };

acc = 0;

+ 3
- 3
src/libespeak-ng/setlengths.c View File

@@ -46,7 +46,7 @@ extern int saved_parameters[];

// convert from words-per-minute to internal speed factor
// Use this to calibrate speed for wpm 80-450 (espeakRATE_MINIMUM - espeakRATE_MAXIMUM)
static unsigned char speed_lookup[] = {
static const unsigned char speed_lookup[] = {
255, 255, 255, 255, 255, // 80
253, 249, 245, 242, 238, // 85
235, 232, 228, 225, 222, // 90
@@ -106,7 +106,7 @@ static unsigned char speed_lookup[] = {
};

// speed_factor1 adjustments for speeds 350 to 374: pauses
static unsigned char pause_factor_350[] = {
static const unsigned char pause_factor_350[] = {
22, 22, 22, 22, 22, 22, 22, 21, 21, 21, // 350
21, 20, 20, 19, 19, 18, 17, 16, 15, 15, // 360
15, 15, 15, 15, 15 // 370
@@ -114,7 +114,7 @@ static unsigned char pause_factor_350[] = {

// wav_factor adjustments for speeds 350 to 450
// Use this to calibrate speed for wpm 350-450
static unsigned char wav_factor_350[] = {
static const unsigned char wav_factor_350[] = {
120, 121, 120, 119, 119, // 350
118, 118, 117, 116, 116, // 355
115, 114, 113, 112, 112, // 360

+ 3
- 3
src/libespeak-ng/spect.c View File

@@ -38,11 +38,11 @@

static int frame_width;

static int default_freq[N_PEAKS] =
static const int default_freq[N_PEAKS] =
{ 200, 500, 1200, 3000, 3500, 4000, 6900, 7800, 9000 };
static int default_width[N_PEAKS] =
static const int default_width[N_PEAKS] =
{ 750, 500, 550, 550, 600, 700, 700, 700, 700 };
static int default_klt_bw[N_PEAKS] =
static const int default_klt_bw[N_PEAKS] =
{ 89, 90, 140, 260, 260, 260, 500, 500, 500 };

static double read_double(FILE *stream)

+ 3
- 3
src/libespeak-ng/speech.c View File

@@ -80,7 +80,7 @@ static void *my_user_data = NULL;
static espeak_ng_OUTPUT_MODE my_mode = ENOUTPUT_MODE_SYNCHRONOUS;
static int out_samplerate = 0;
static int voice_samplerate = 22050;
static int min_buffer_length = 60; // minimum buffer length in ms
static const int min_buffer_length = 60; // minimum buffer length in ms
static espeak_ng_STATUS err = ENS_OK;

static t_espeak_callback *synth_callback = NULL;
@@ -659,7 +659,7 @@ espeak_ng_Synthesize(const void *text, size_t size,
{
(void)size; // unused in non-async modes

static unsigned int temp_identifier;
unsigned int temp_identifier;

if (unique_identifier == NULL)
unique_identifier = &temp_identifier;
@@ -708,7 +708,7 @@ espeak_ng_SynthesizeMark(const void *text,
{
(void)size; // unused in non-async modes

static unsigned int temp_identifier;
unsigned int temp_identifier;

if (unique_identifier == NULL)
unique_identifier = &temp_identifier;

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

@@ -1342,7 +1342,7 @@ Translator *SelectTranslator(const char *name)
case L('s', 'k'): // Slovak
case L('c', 's'): // Czech
{
static const char *sk_voiced = "bdgjlmnrvwzaeiouy";
static const char sk_voiced[] = "bdgjlmnrvwzaeiouy";

SetupTranslator(tr, stress_lengths_sk, stress_amps_sk);
tr->encoding = ESPEAKNG_ENCODING_ISO_8859_2;

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

@@ -64,7 +64,7 @@ static const MNEM_TAB genders[] = {
int tone_points[12] = { 600, 170, 1200, 135, 2000, 110, 3000, 110, -1, 0 };

// limit the rate of change for each formant number
static int formant_rate_22050[9] = { 240, 170, 170, 170, 170, 170, 170, 170, 170 }; // values for 22kHz sample rate
static const int formant_rate_22050[9] = { 240, 170, 170, 170, 170, 170, 170, 170, 170 }; // values for 22kHz sample rate
int formant_rate[9]; // values adjusted for actual sample rate

#define DEFAULT_LANGUAGE_PRIORITY 5

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

@@ -119,7 +119,7 @@ int wcmdq_tail = 0;

// pitch,speed,
const int embedded_default[N_EMBEDDED_VALUES] = { 0, 50, espeakRATE_NORMAL, 100, 50, 0, 0, 0, espeakRATE_NORMAL, 0, 0, 0, 0, 0, 0 };
static int embedded_max[N_EMBEDDED_VALUES] = { 0, 0x7fff, 750, 300, 99, 99, 99, 0, 750, 0, 0, 0, 0, 4, 0 };
static const int embedded_max[N_EMBEDDED_VALUES] = { 0, 0x7fff, 750, 300, 99, 99, 99, 0, 750, 0, 0, 0, 0, 4, 0 };

#if USE_LIBSONIC
static sonicStream sonicSpeedupStream = NULL;
@@ -130,7 +130,7 @@ static double sonicSpeed = 1.0;
// 2nd index=modulation_type
// value: bits 0-3 amplitude (16ths), bits 4-7 every n cycles
#define N_ROUGHNESS 8
static unsigned char modulation_tab[N_ROUGHNESS][8] = {
static const unsigned char modulation_tab[N_ROUGHNESS][8] = {
{ 0, 0x00, 0x00, 0x00, 0, 0x46, 0xf2, 0x29 },
{ 0, 0x2f, 0x00, 0x2f, 0, 0x45, 0xf2, 0x29 },
{ 0, 0x2f, 0x00, 0x2e, 0, 0x45, 0xf2, 0x28 },

Loading…
Cancel
Save