This is from the old espeak RiscOS port that has been removed. If/when the espeak-ng program is ported to RiscOS, this will be done in a different, more maintainable way.master
} | } | ||||
if ((tail[0] == 's') && (tail[1] == 't')) { | if ((tail[0] == 's') && (tail[1] == 't')) { | ||||
#ifdef PLATFORM_RISCOS | |||||
*value_out = 100; | |||||
#else | |||||
double x; | double x; | ||||
// convert from semitones to a frequency percentage | // convert from semitones to a frequency percentage | ||||
x = pow((double)2.0, (double)((value*sign)/12)) * 100; | x = pow((double)2.0, (double)((value*sign)/12)) * 100; | ||||
*value_out = (int)x; | *value_out = (int)x; | ||||
#endif | |||||
return 2; // percentage | return 2; // percentage | ||||
} | } | ||||
// It seems that the wctype functions don't work until the locale has been set | // It seems that the wctype functions don't work until the locale has been set | ||||
// to something other than the default "C". Then, not only Latin1 but also the | // to something other than the default "C". Then, not only Latin1 but also the | ||||
// other characters give the correct results with iswalpha() etc. | // other characters give the correct results with iswalpha() etc. | ||||
#ifdef PLATFORM_RISCOS | |||||
setlocale(LC_CTYPE, "ISO8859-1"); | |||||
#else | |||||
if (setlocale(LC_CTYPE, "C.UTF-8") == NULL) { | if (setlocale(LC_CTYPE, "C.UTF-8") == NULL) { | ||||
if (setlocale(LC_CTYPE, "UTF-8") == NULL) | if (setlocale(LC_CTYPE, "UTF-8") == NULL) | ||||
if (setlocale(LC_CTYPE, "en_US.UTF-8") == NULL) | if (setlocale(LC_CTYPE, "en_US.UTF-8") == NULL) | ||||
setlocale(LC_CTYPE, ""); | setlocale(LC_CTYPE, ""); | ||||
} | } | ||||
#endif | |||||
init_path(path); | init_path(path); | ||||
if (options & espeakINITIALIZE_PATH_ONLY) | if (options & espeakINITIALIZE_PATH_ONLY) |
#ifdef PLATFORM_WINDOWS | #ifdef PLATFORM_WINDOWS | ||||
#include "windows.h" | #include "windows.h" | ||||
#else | #else | ||||
#ifdef PLATFORM_RISCOS | |||||
#include "kernel.h" | |||||
#else | |||||
#include "dirent.h" | #include "dirent.h" | ||||
#endif | #endif | ||||
#endif | |||||
#include "speak_lib.h" | #include "speak_lib.h" | ||||
#include "phoneme.h" | #include "phoneme.h" | ||||
speed.fast_settings[1] = 800; | speed.fast_settings[1] = 800; | ||||
speed.fast_settings[2] = 175; | speed.fast_settings[2] = 175; | ||||
#ifdef PLATFORM_RISCOS | |||||
voice->roughness = 1; | |||||
#else | |||||
voice->roughness = 2; | voice->roughness = 2; | ||||
#endif | |||||
InitBreath(); | InitBreath(); | ||||
for (pk = 0; pk < N_PEAKS; pk++) { | for (pk = 0; pk < N_PEAKS; pk++) { | ||||
int ftype; | int ftype; | ||||
char fname[sizeof(path_home)+100]; | char fname[sizeof(path_home)+100]; | ||||
#ifdef PLATFORM_RISCOS | |||||
int len; | |||||
int *type; | |||||
char *p; | |||||
_kernel_swi_regs regs; | |||||
_kernel_oserror *error; | |||||
char buf[80]; | |||||
char directory2[sizeof(path_home)+100]; | |||||
regs.r[0] = 10; | |||||
regs.r[1] = (int)path; | |||||
regs.r[2] = (int)buf; | |||||
regs.r[3] = 1; | |||||
regs.r[4] = 0; | |||||
regs.r[5] = sizeof(buf); | |||||
regs.r[6] = 0; | |||||
while (regs.r[3] > 0) { | |||||
error = _kernel_swi(0x0c+0x20000, ®s, ®s); // OS_GBPB 10, read directory entries | |||||
if ((error != NULL) || (regs.r[3] == 0)) | |||||
break; | |||||
type = (int *)(&buf[16]); | |||||
len = strlen(&buf[20]); | |||||
sprintf(fname, "%s.%s", path, &buf[20]); | |||||
if (*type == 2) { | |||||
// a sub-directory | |||||
GetVoices(fname); | |||||
} else { | |||||
// a regular line, add it to the voices list | |||||
if ((f_voice = fopen(fname, "r")) == NULL) | |||||
continue; | |||||
// pass voice file name within the voices directory | |||||
voice_data = ReadVoiceFile(f_voice, fname+len_path_voices, &buf[20]); | |||||
fclose(f_voice); | |||||
if (voice_data != NULL) | |||||
voices_list[n_voices_list++] = voice_data; | |||||
} | |||||
} | |||||
#else | |||||
#ifdef PLATFORM_WINDOWS | #ifdef PLATFORM_WINDOWS | ||||
WIN32_FIND_DATAA FindFileData; | WIN32_FIND_DATAA FindFileData; | ||||
HANDLE hFind = INVALID_HANDLE_VALUE; | HANDLE hFind = INVALID_HANDLE_VALUE; | ||||
} | } | ||||
closedir(dir); | closedir(dir); | ||||
#endif | #endif | ||||
#endif | |||||
} | } | ||||
espeak_ERROR SetVoiceByName(const char *name) | espeak_ERROR SetVoiceByName(const char *name) | ||||
{ | { | ||||
char path_voices[sizeof(path_home)+12]; | char path_voices[sizeof(path_home)+12]; | ||||
#ifdef PLATFORM_RISCOS | |||||
if (n_voices_list == 0) { | |||||
sprintf(path_voices, "%s%cvoices", path_home, PATHSEP); | |||||
len_path_voices = strlen(path_voices)+1; | |||||
GetVoices(path_voices); | |||||
voices_list[n_voices_list] = NULL; // voices list terminator | |||||
} | |||||
return (const espeak_VOICE **)voices_list; | |||||
#else | |||||
int ix; | int ix; | ||||
int j; | int j; | ||||
espeak_VOICE *v; | espeak_VOICE *v; | ||||
voices[j] = NULL; | voices[j] = NULL; | ||||
} | } | ||||
return (const espeak_VOICE **)voices; | return (const espeak_VOICE **)voices; | ||||
#endif | |||||
} | } | ||||
ESPEAK_API espeak_VOICE *espeak_GetCurrentVoice(void) | ESPEAK_API espeak_VOICE *espeak_GetCurrentVoice(void) |
} | } | ||||
} | } | ||||
#ifndef PLATFORM_RISCOS | |||||
static double resonator(RESONATOR *r, double input) | static double resonator(RESONATOR *r, double input) | ||||
{ | { | ||||
double x; | double x; | ||||
rp->a = 1.0 - rp->b - rp->c; | rp->a = 1.0 - rp->b - rp->c; | ||||
} | } | ||||
#endif | |||||
void InitBreath(void) | void InitBreath(void) | ||||
{ | { | ||||
#ifndef PLATFORM_RISCOS | |||||
int ix; | int ix; | ||||
minus_pi_t = -PI / samplerate; | minus_pi_t = -PI / samplerate; | ||||
for (ix = 0; ix < N_PEAKS; ix++) | for (ix = 0; ix < N_PEAKS; ix++) | ||||
setresonator(&rbreath[ix], 2000, 200, 1); | setresonator(&rbreath[ix], 2000, 200, 1); | ||||
#endif | |||||
} | } | ||||
static void SetBreath() | static void SetBreath() | ||||
{ | { | ||||
#ifndef PLATFORM_RISCOS | |||||
int pk; | int pk; | ||||
if (wvoice->breath[0] == 0) | if (wvoice->breath[0] == 0) | ||||
setresonator(&rbreath[pk], peaks[pk].freq >> 16, wvoice->breathw[pk], 0); | setresonator(&rbreath[pk], peaks[pk].freq >> 16, wvoice->breathw[pk], 0); | ||||
} | } | ||||
} | } | ||||
#endif | |||||
} | } | ||||
static int ApplyBreath(void) | static int ApplyBreath(void) | ||||
{ | { | ||||
int value = 0; | int value = 0; | ||||
#ifndef PLATFORM_RISCOS | |||||
int noise; | int noise; | ||||
int ix; | int ix; | ||||
int amp; | int amp; | ||||
value += (int)resonator(&rbreath[ix], noise) * amp; | value += (int)resonator(&rbreath[ix], noise) * amp; | ||||
} | } | ||||
} | } | ||||
#endif | |||||
return value; | return value; | ||||
} | } | ||||
if (voicing != 64) | if (voicing != 64) | ||||
total = (total >> 6) * voicing; | total = (total >> 6) * voicing; | ||||
#ifndef PLATFORM_RISCOS | |||||
if (wvoice->breath[0]) | if (wvoice->breath[0]) | ||||
total += ApplyBreath(); | total += ApplyBreath(); | ||||
#endif | |||||
// mix with sampled wave if required | // mix with sampled wave if required | ||||
z2 = 0; | z2 = 0; |
// It seems that the wctype functions don't work until the locale has been set | // It seems that the wctype functions don't work until the locale has been set | ||||
// to something other than the default "C". Then, not only Latin1 but also the | // to something other than the default "C". Then, not only Latin1 but also the | ||||
// other characters give the correct results with iswalpha() etc. | // other characters give the correct results with iswalpha() etc. | ||||
#ifdef PLATFORM_RISCOS | |||||
setlocale(LC_CTYPE, "ISO8859-1"); | |||||
#else | |||||
if (setlocale(LC_CTYPE, "en_US.UTF-8") == NULL) { | if (setlocale(LC_CTYPE, "en_US.UTF-8") == NULL) { | ||||
if (setlocale(LC_CTYPE, "UTF-8") == NULL) | if (setlocale(LC_CTYPE, "UTF-8") == NULL) | ||||
setlocale(LC_CTYPE, ""); | setlocale(LC_CTYPE, ""); | ||||
} | } | ||||
#endif | |||||
if ((result = LoadPhData(&srate)) != 1) { | if ((result = LoadPhData(&srate)) != 1) { | ||||
if (result == -1) { | if (result == -1) { |