summaryrefslogtreecommitdiff
path: root/navit/support/espeak/intonation.c
diff options
context:
space:
mode:
Diffstat (limited to 'navit/support/espeak/intonation.c')
-rw-r--r--[-rwxr-xr-x]navit/support/espeak/intonation.c521
1 files changed, 380 insertions, 141 deletions
diff --git a/navit/support/espeak/intonation.c b/navit/support/espeak/intonation.c
index 61b2ff282..04d72a9c8 100755..100644
--- a/navit/support/espeak/intonation.c
+++ b/navit/support/espeak/intonation.c
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
#include <wctype.h>
#include "speak_lib.h"
@@ -45,8 +46,8 @@ typedef struct {
char env;
char flags; //bit 0=pitch rising, bit1=emnphasized, bit2=end of clause
char nextph_type;
- short pitch1;
- short pitch2;
+ unsigned char pitch1;
+ unsigned char pitch2;
} SYLLABLE;
static SYLLABLE *syllable_tab;
@@ -61,10 +62,10 @@ static int tone_pitch_env; /* used to return pitch envelope */
#define PITCHfall 0
-#define PITCHrise 1
-#define PITCHfrise 2 // and 3 must be for the varient preceded by 'r'
-#define PITCHfrise2 4 // and 5 must be the 'r' variant
-#define PITCHrisefall 6
+#define PITCHrise 2
+#define PITCHfrise 4 // and 3 must be for the variant preceded by 'r'
+#define PITCHfrise2 6 // and 5 must be the 'r' variant
+#define PITCHrisefall 8
/* 0 fall */
unsigned char env_fall[128] = {
@@ -191,9 +192,9 @@ static unsigned char env_risefallrise[128] = {
-unsigned char *envelope_data[18] = {
- env_fall,
- env_rise,
+unsigned char *envelope_data[N_ENVELOPE_DATA] = {
+ env_fall, env_fall,
+ env_rise, env_rise,
env_frise, env_r_frise,
env_frise2, env_r_frise2,
env_risefall, env_risefall,
@@ -206,18 +207,17 @@ unsigned char *envelope_data[18] = {
};
-/* all pitches given in Hz above pitch_base */
+
+/* indexed by stress */
+static int min_drop[] = {6,7,9,9,20,20,20,25};
// pitch change during the main part of the clause
-static int drops_0[8] = {0x400,0x400,0x700,0x700,0x700,0xa00,0x1800,0x0e00};
-//static int drops_1[8] = {0x400,0x400,0x600,0x600,0xc00,0xc00,0x0e00,0x0e00};
-//static int drops_2[8] = {0x400,0x400,0x600,0x600,-0x800,0xc00,0x0e00,0x0e00};
+static int drops_0[8] = {9,9,16,16,16,23,55,32};
-static short oflow[] = {0, 20, 12, 4, 0};
-static short oflow_emf[] = {5, 24, 15, 10, 5};
-static short oflow_less[] = {3, 19, 12, 7, 2};
-// static short oflow_test2[] = {20, 0, 20, 0, 20};
-// static short back_emf[] = {35, 32, 0};
+// overflow table values are 64ths of the body pitch range (between body_start and body_end)
+static signed char oflow[] = {0, 40, 24, 8, 0};
+static signed char oflow_emf[] = {10, 52, 32, 20, 10};
+static signed char oflow_less[] = {6, 38, 24, 14, 4};
#define N_TONE_HEAD_TABLE 13
@@ -235,8 +235,8 @@ typedef struct {
unsigned char body_max_steps;
char body_lower_u;
- char n_overflow;
- short *overflow;
+ unsigned char n_overflow;
+ signed char *overflow;
} TONE_HEAD;
@@ -259,38 +259,38 @@ typedef struct {
#define T_EMPH 1
static TONE_HEAD tone_head_table[N_TONE_HEAD_TABLE] = {
- {20, 25, 34, 22, drops_0, 3, 3, 5, oflow}, // 0 statement
- {20, 25, 34, 20, drops_0, 3, 3, 5, oflow}, // 1 comma
- {20, 25, 34, 20, drops_0, 3, 3, 5, oflow}, // 2 question
- {20, 25, 36, 22, drops_0, 3, 4, 5, oflow_emf}, // 3 exclamation
- {20, 25, 34, 22, drops_0, 3, 3, 5, oflow}, // 4 statement, emphatic
- {20, 25, 32, 24, drops_0, 4, 3, 5, oflow_less}, // 5 statement, less intonation
- {20, 25, 32, 24, drops_0, 4, 3, 5, oflow_less}, // 6 comma, less intonation
- {20, 25, 32, 24, drops_0, 4, 3, 5, oflow_less}, // 7 comma, less intonation, less rise
- {20, 25, 34, 22, drops_0, 3, 3, 5, oflow}, // 8 pitch raises at end of sentence
- {20, 25, 34, 20, drops_0, 3, 3, 5, oflow}, // 9 comma
- {20, 25, 34, 22, drops_0, 3, 3, 5, oflow}, // 10 question
- {15, 18, 18, 14, drops_0, 3, 3, 5, oflow_less}, // 11 test
- {20, 25, 24, 22, drops_0, 3, 3, 5, oflow_less}, // 12 test
+ {46, 57, 78, 50, drops_0, 3, 7, 5, oflow}, // 0 statement
+ {46, 57, 78, 46, drops_0, 3, 7, 5, oflow}, // 1 comma
+ {46, 57, 78, 46, drops_0, 3, 7, 5, oflow}, // 2 question
+ {46, 57, 90, 50, drops_0, 3, 9, 5, oflow_emf}, // 3 exclamation
+ {46, 57, 78, 50, drops_0, 3, 7, 5, oflow}, // 4 statement, emphatic
+ {46, 57, 74, 55, drops_0, 4, 7, 5, oflow_less}, // 5 statement, less intonation
+ {46, 57, 74, 55, drops_0, 4, 7, 5, oflow_less}, // 6 comma, less intonation
+ {46, 57, 74, 55, drops_0, 4, 7, 5, oflow_less}, // 7 comma, less intonation, less rise
+ {46, 57, 78, 50, drops_0, 3, 7, 5, oflow}, // 8 pitch raises at end of sentence
+ {46, 57, 78, 46, drops_0, 3, 7, 5, oflow}, // 9 comma
+ {46, 57, 78, 50, drops_0, 3, 7, 5, oflow}, // 10 question
+ {34, 41, 41, 32, drops_0, 3, 7, 5, oflow_less}, // 11 test
+ {46, 57, 55, 50, drops_0, 3, 7, 5, oflow_less}, // 12 test
};
static TONE_NUCLEUS tone_nucleus_table[N_TONE_NUCLEUS_TABLE] = {
- {PITCHfall, 30, 5, PITCHfall, 32, 9, NULL, 12, 7, 0}, // 0 statement
- {PITCHfrise, 35, 8, PITCHfrise2, 35,10, NULL, 15, 23, 0}, // 1 comma
- {PITCHfrise, 39,10, PITCHfrise2, 36,10, NULL, 15, 28, 0}, // 2 question
-// {PITCHfall, 41, 4, PITCHfall, 41,27, NULL, 16, 4, T_EMPH}, // 3 exclamation
- {PITCHfall, 41, 4, PITCHfall, 41,35, NULL, 35, 4, T_EMPH}, // 3 exclamation
- {PITCHfall, 38, 2, PITCHfall, 42,30, NULL, 15, 5, 0}, // 4 statement, emphatic
- {PITCHfall, 28, 5, PITCHfall, 28, 9, NULL, 12, 7, 0}, // 5 statement, less intonation
- {PITCHfrise, 30, 8, PITCHfrise2, 30,10, NULL, 13, 20, 0}, // 6 comma, less intonation
- {PITCHfrise2, 28, 7, PITCHfall, 29,14, NULL, 14, 8, 0}, // 7 comma, less intonation, less rise
- {PITCHrise, 30,20, PITCHfall, 19,14, NULL, 20, 26, 0}, // 8 pitch raises at end of sentence
- {PITCHfrise, 35,11, PITCHfrise2, 32,10, NULL, 19, 24, 0}, // 9 comma
- {PITCHfrise, 39,15, PITCHfall, 28,14, NULL, 20, 36, 0}, // 10 question
- {PITCHfall, 28, 6, PITCHfall, 28,10, NULL, 12, 6, 0}, // 11 test
- {PITCHfall, 35, 9, PITCHfall, 35,12, NULL, 16, 10, 0}, // 12 test
+ {PITCHfall, 64, 8, PITCHfall, 70,18, NULL, 24, 12, 0}, // 0 statement
+ {PITCHfrise, 80,18, PITCHfrise2, 78,22, NULL, 34, 52, 0}, // 1 comma
+ {PITCHfrise, 88,22, PITCHfrise2, 82,22, NULL, 34, 64, 0}, // 2 question
+ {PITCHfall, 92, 8, PITCHfall, 92,80, NULL, 76, 8, T_EMPH}, // 3 exclamation
+
+ {PITCHfall, 86, 4, PITCHfall, 94,66, NULL, 34, 10, 0}, // 4 statement, emphatic
+ {PITCHfall, 62,10, PITCHfall, 62,20, NULL, 28, 16, 0}, // 5 statement, less intonation
+ {PITCHfrise, 68,18, PITCHfrise2, 68,22, NULL, 30, 44, 0}, // 6 comma, less intonation
+ {PITCHfrise2, 64,16, PITCHfall, 66,32, NULL, 32, 18, 0}, // 7 comma, less intonation, less rise
+ {PITCHrise, 68,46, PITCHfall, 42,32, NULL, 46, 58, 0}, // 8 pitch raises at end of sentence
+ {PITCHfrise, 78,24, PITCHfrise2, 72,22, NULL, 42, 52, 0}, // 9 comma
+ {PITCHfrise, 88,34, PITCHfall, 64,32, NULL, 46, 82, 0}, // 10 question
+ {PITCHfall, 56,12, PITCHfall, 56,20, NULL, 24, 12, 0}, // 11 test
+ {PITCHfall, 70,18, PITCHfall, 70,24, NULL, 32, 20, 0}, // 12 test
};
-
+
/* index by 0=. 1=, 2=?, 3=! 4=none, 5=emphasized */
@@ -306,11 +306,8 @@ unsigned char punctuation_to_tone[INTONATION_TYPES][PUNCT_INTONATIONS] = {
};
-
-/* indexed by stress */
-static int min_drop[] = {0x300,0x300,0x400,0x400,0x900,0x900,0x900,0xb00};
-
-
+int n_tunes = 0;
+TUNE *tunes = NULL;
#define SECONDARY 3
@@ -341,7 +338,7 @@ static void count_pitch_vowels(int start, int end, int clause_end)
number_body = 0;
number_tail = 0; /* number between tonic syllable and next primary */
last_primary = -1;
-
+
for(ix=start; ix<end; ix++)
{
stress = syllable_tab[ix].stress; /* marked stress level */
@@ -419,20 +416,17 @@ static int count_increments(int ix, int end_ix, int min_stress)
+
static void set_pitch(SYLLABLE *syl, int base, int drop)
/******************************************************/
-// Set the pitch of a vowel in syllable_tab. Base & drop are Hz * 256
+// Set the pitch of a vowel in syllable_tab
{
int pitch1, pitch2;
int flags = 0;
- /* adjust experimentally */
- int pitch_range2 = 148;
- int pitch_base2 = 72;
-
if(base < 0) base = 0;
- pitch2 = ((base * pitch_range2 ) >> 15) + pitch_base2;
+ pitch2 = base;
if(drop < 0)
{
@@ -440,10 +434,12 @@ static void set_pitch(SYLLABLE *syl, int base, int drop)
drop = -drop;
}
- pitch1 = pitch2 + ((drop * pitch_range2) >> 15);
+ pitch1 = pitch2 + drop;
+ if(pitch1 < 0)
+ pitch1 = 0;
- if(pitch1 > 511) pitch1 = 511;
- if(pitch2 > 511) pitch2 = 511;
+ if(pitch1 > 254) pitch1 = 254;
+ if(pitch2 > 254) pitch2 = 254;
syl->pitch1 = pitch1;
syl->pitch2 = pitch2;
@@ -451,6 +447,164 @@ static void set_pitch(SYLLABLE *syl, int base, int drop)
} /* end of set_pitch */
+static int CountUnstressed(int start, int end, int limit)
+{//======================================================
+ int ix;
+
+ for(ix=start; ix <= end; ix++)
+ {
+ if(syllable_tab[ix].stress >= limit)
+ break;
+ }
+ return(ix - start);
+}
+
+static int SetHeadIntonation(TUNE *tune, int syl_ix, int end_ix, int control)
+{//==========================================================================
+ int stress;
+ SYLLABLE *syl;
+ int ix;
+ int pitch=0;
+ int increment=0;
+ int n_steps=0;
+ int stage; // onset, head, last
+ int initial;
+ int overflow_ix=0;
+ int pitch_range;
+ int pitch_range_abs;
+ int *drops;
+ int n_unstressed=0;
+ int unstressed_ix=0;
+ int unstressed_inc;
+ int used_onset = 0;
+ int head_final = end_ix;
+int secondary=2; // 2
+
+ pitch_range = (tune->head_end - tune->head_start) << 8;
+ pitch_range_abs = abs(pitch_range);
+ drops = drops_0; // this should be controled by tune->head_drops
+ initial = 1;
+
+ stage = 0;
+ if(tune->onset == 255)
+ stage = 1; // no onset specified
+
+ if(tune->head_last != 255)
+ {
+ // find the last primary stress in the body
+ for(ix = end_ix-1; ix >= syl_ix; ix--)
+ {
+ if(syllable_tab[ix].stress >= 4)
+ {
+ head_final = ix;
+ break;
+ }
+ }
+ }
+
+ while(syl_ix < end_ix)
+ {
+ syl = &syllable_tab[syl_ix];
+ stress = syl->stress;
+
+ if(initial || (stress >= 4))
+ {
+ // a primary stress
+
+ if((initial) || (stress == 5))
+ {
+ initial = 0;
+ overflow_ix = 0;
+
+ if(tune->onset == 255)
+ {
+ n_steps = count_increments(syl_ix, head_final, 4);
+ pitch = tune->head_start << 8;
+ }
+ else
+ {
+ // a pitch has been specified for the onset syllable, don't include it in the pitch incrementing
+ n_steps = count_increments(syl_ix+1, head_final, 4);
+ pitch = tune->onset << 8;
+ used_onset = 1;
+ }
+
+ if(n_steps > tune->head_max_steps)
+ n_steps = tune->head_max_steps;
+
+ if(n_steps > 1)
+ {
+ increment = pitch_range / (n_steps -1);
+ }
+ else
+ increment = 0;
+
+ }
+ else
+ if(syl_ix == head_final)
+ {
+ // a pitch has been specified for the last primary stress before the nucleus
+ pitch = tune->head_last << 8;
+ stage = 2;
+ }
+ else
+ {
+ if(used_onset)
+ {
+ stage = 1;
+ used_onset = 0;
+ pitch = tune->head_start << 8;
+ n_steps++;
+ }
+ else
+ if(n_steps > 0)
+ pitch += increment;
+ else
+ {
+ pitch = (tune->head_end << 8) + (pitch_range_abs * tune->head_extend[overflow_ix++])/64;
+ if(overflow_ix >= tune->n_head_extend)
+ {
+ overflow_ix = 0;
+ }
+ }
+ }
+
+ n_steps--;
+ }
+
+ if(stress >= PRIMARY)
+ {
+ n_unstressed = CountUnstressed(syl_ix+1, end_ix, secondary);
+ unstressed_ix = 0;
+ syl->stress = PRIMARY_STRESSED;
+ syl->env = tune->stressed_env;
+ set_pitch(syl,(pitch >> 8), tune->stressed_drop);
+ }
+ else
+ if(stress >= secondary)
+ {
+ n_unstressed = CountUnstressed(syl_ix+1, end_ix, secondary);
+ unstressed_ix = 0;
+ set_pitch(syl,(pitch >> 8),drops[stress]);
+ }
+ else
+ {
+ if(n_unstressed > 1)
+ unstressed_inc = (tune->unstr_end[stage] - tune->unstr_start[stage]) / (n_unstressed - 1);
+ else
+ unstressed_inc = 0;
+
+ set_pitch(syl, (pitch >> 8) + tune->unstr_start[stage] + (unstressed_inc * unstressed_ix), drops[stress]);
+ unstressed_ix++;
+ }
+
+ syl_ix++;
+ }
+ return(syl_ix);
+
+} // end of SetBodyIntonation
+
+
static int calc_pitch_segment(int ix, int end_ix, TONE_HEAD *th, TONE_NUCLEUS *tn, int min_stress, int continuing)
/**********************************************************************************************/
@@ -466,13 +620,17 @@ static int calc_pitch_segment(int ix, int end_ix, TONE_HEAD *th, TONE_NUCLEUS *t
int initial;
int overflow=0;
int n_overflow;
+ int pitch_range;
+ int pitch_range_abs;
int *drops;
- short *overflow_tab;
+ signed char *overflow_tab;
SYLLABLE *syl;
- static short continue_tab[5] = {-13, 16, 10, 4, 0};
+ static signed char continue_tab[5] = {-26, 32, 20, 8, 0};
drops = th->body_drops;
+ pitch_range = (th->body_end - th->body_start) << 8;
+ pitch_range_abs = abs(pitch_range);
if(continuing)
{
@@ -480,8 +638,7 @@ static int calc_pitch_segment(int ix, int end_ix, TONE_HEAD *th, TONE_NUCLEUS *t
overflow = 0;
n_overflow = 5;
overflow_tab = continue_tab;
- increment = (th->body_end - th->body_start) << 8;
- increment = increment / (th->body_max_steps -1);
+ increment = pitch_range / (th->body_max_steps -1);
}
else
{
@@ -513,8 +670,7 @@ static int calc_pitch_segment(int ix, int end_ix, TONE_HEAD *th, TONE_NUCLEUS *t
if(n_steps > 1)
{
- increment = (th->body_end - th->body_start) << 8;
- increment = increment / (n_steps -1);
+ increment = pitch_range / (n_steps -1);
}
else
increment = 0;
@@ -527,7 +683,7 @@ static int calc_pitch_segment(int ix, int end_ix, TONE_HEAD *th, TONE_NUCLEUS *t
pitch += increment;
else
{
- pitch = (th->body_end << 8) - (increment * overflow_tab[overflow++])/16;
+ pitch = (th->body_end << 8) + (pitch_range_abs * overflow_tab[overflow++])/64;
if(overflow >= n_overflow)
{
overflow = 0;
@@ -541,27 +697,27 @@ static int calc_pitch_segment(int ix, int end_ix, TONE_HEAD *th, TONE_NUCLEUS *t
n_primary--;
if((tn->backwards) && (n_primary < 2))
{
- pitch = tn->backwards[n_primary] << 8;
+ pitch = tn->backwards[n_primary] << 8;
}
}
if(stress >= PRIMARY)
{
syl->stress = PRIMARY_STRESSED;
- set_pitch(syl,pitch,drops[stress]);
+ set_pitch(syl,(pitch >> 8),drops[stress]);
}
else
if(stress >= SECONDARY)
{
- set_pitch(syl,pitch,drops[stress]);
+ set_pitch(syl,(pitch >> 8),drops[stress]);
}
else
{
/* unstressed, drop pitch if preceded by PRIMARY */
if((syllable_tab[ix-1].stress & 0x3f) >= SECONDARY)
- set_pitch(syl,pitch - (th->body_lower_u << 8), drops[stress]);
+ set_pitch(syl,(pitch >> 8) - th->body_lower_u, drops[stress]);
else
- set_pitch(syl,pitch,drops[stress]);
+ set_pitch(syl,(pitch >> 8),drops[stress]);
}
ix++;
@@ -571,13 +727,12 @@ static int calc_pitch_segment(int ix, int end_ix, TONE_HEAD *th, TONE_NUCLEUS *t
+static void SetPitchGradient(int start_ix, int end_ix, int start_pitch, int end_pitch)
+{//====================================================================================
+// Set a linear pitch change over a number of syllables.
+// Used for pre-head, unstressed syllables in the body, and the tail
-
-static int calc_pitch_segment2(int ix, int end_ix, int start_p, int end_p, int min_stress)
-/****************************************************************************************/
-/* Linear pitch rise/fall, change pitch at min_stress or stronger
- Used for pre-head and tail */
-{
+ int ix;
int stress;
int pitch;
int increment;
@@ -585,54 +740,112 @@ static int calc_pitch_segment2(int ix, int end_ix, int start_p, int end_p, int m
int drop;
SYLLABLE *syl;
- if(ix >= end_ix)
- return(ix);
-
- n_increments = count_increments(ix,end_ix,min_stress);
- increment = (end_p - start_p) << 8;
-
+ increment = (end_pitch - start_pitch) << 8;
+ n_increments = end_ix - start_ix;
+
+ if(n_increments <= 0)
+ return;
+
if(n_increments > 1)
{
increment = increment / n_increments;
}
-
- pitch = start_p << 8;
- while(ix < end_ix)
+ pitch = start_pitch << 8;
+
+ for(ix=start_ix; ix < end_ix; ix++)
{
syl = &syllable_tab[ix];
stress = syl->stress;
if(increment > 0)
{
- set_pitch(syl,pitch,-increment);
+ set_pitch(syl,(pitch >> 8),-(increment >> 8));
pitch += increment;
}
else
{
- drop = -increment;
+ drop = -(increment >> 8);
if(drop < min_drop[stress])
drop = min_drop[stress];
pitch += increment;
- if(drop > 0x900)
- drop = 0x900;
- set_pitch(syl, pitch, drop);
+ if(drop > 18)
+ drop = 18;
+ set_pitch(syl, (pitch >> 8), drop);
}
-
- ix++;
}
- return(ix);
-} /* end of calc_pitch_segment2 */
+} // end of SetPitchGradient
+static int calc_pitches2(int start, int end, int tune_number)
+//============================================================
+// Calculate pitch values for the vowels in this tone group
+{
+ int ix;
+ TUNE *tune;
+ int drop;
+ tune = &tunes[tune_number];
+ ix = start;
+ /* vowels before the first primary stress */
+ /******************************************/
+
+ SetPitchGradient(ix, ix+number_pre, tune->prehead_start, tune->prehead_end);
+ ix += number_pre;
+
+ /* body of tonic segment */
+ /*************************/
-static int calc_pitches(int start, int end, int head_tone, int nucleus_tone)
-//===========================================================================
+ if(option_tone_flags & OPTION_EMPHASIZE_PENULTIMATE)
+ {
+ tone_posn = tone_posn2; // put tone on the penultimate stressed word
+ }
+ ix = SetHeadIntonation(tune, ix, tone_posn, 0);
+
+ if(no_tonic)
+ return(0);
+
+ /* tonic syllable */
+ /******************/
+
+// if(tn->flags & T_EMPH)
+// {
+// syllable_tab[ix].flags |= SYL_EMPHASIS;
+// }
+
+ if(number_tail == 0)
+ {
+ tone_pitch_env = tune->nucleus0_env;
+ drop = tune->nucleus0_max - tune->nucleus0_min;
+ set_pitch(&syllable_tab[ix++],tune->nucleus0_min, drop);
+ }
+ else
+ {
+ tone_pitch_env = tune->nucleus1_env;
+ drop = tune->nucleus1_max - tune->nucleus1_min;
+ set_pitch(&syllable_tab[ix++],tune->nucleus1_min, drop);
+ }
+
+ syllable_tab[tone_posn].env = tone_pitch_env;
+ if(syllable_tab[tone_posn].stress == PRIMARY)
+ syllable_tab[tone_posn].stress = PRIMARY_STRESSED;
+
+ /* tail, after the tonic syllable */
+ /**********************************/
+
+ SetPitchGradient(ix, end, tune->tail_start, tune->tail_end);
+
+ return(tone_pitch_env);
+} /* end of calc_pitches2 */
+
+
+
+static int calc_pitches(int control, int start, int end, int tune_number)
+//========================================================================
// Calculate pitch values for the vowels in this tone group
{
int ix;
@@ -641,36 +854,40 @@ static int calc_pitches(int start, int end, int head_tone, int nucleus_tone)
int drop;
int continuing = 0;
+ if(control == 0)
+ {
+ return(calc_pitches2(start, end, tune_number));
+ }
+
if(start > 0)
continuing = 1;
- th = &tone_head_table[head_tone];
- tn = &tone_nucleus_table[nucleus_tone];
+ th = &tone_head_table[tune_number];
+ tn = &tone_nucleus_table[tune_number];
ix = start;
/* vowels before the first primary stress */
/******************************************/
- if(number_pre > 0)
- {
- ix = calc_pitch_segment2(ix, ix+number_pre, th->pre_start, th->pre_end, 0);
- }
+ SetPitchGradient(ix, ix+number_pre, th->pre_start, th->pre_end);
+ ix += number_pre;
/* body of tonic segment */
/*************************/
if(option_tone_flags & OPTION_EMPHASIZE_PENULTIMATE)
{
- tone_posn = tone_posn2; // put tone on the penultimate stressed word
+ tone_posn = tone_posn2; // put tone on the penultimate stressed word
}
ix = calc_pitch_segment(ix,tone_posn, th, tn, PRIMARY, continuing);
-
+// ix = SetBodyIntonation(&tunes[0], ix, tone_posn, 0);
+
if(no_tonic)
return(0);
/* tonic syllable */
/******************/
-
+
if(tn->flags & T_EMPH)
{
syllable_tab[ix].flags |= SYL_EMPHASIS;
@@ -680,13 +897,13 @@ static int calc_pitches(int start, int end, int head_tone, int nucleus_tone)
{
tone_pitch_env = tn->pitch_env0;
drop = tn->tonic_max0 - tn->tonic_min0;
- set_pitch(&syllable_tab[ix++],tn->tonic_min0 << 8,drop << 8);
+ set_pitch(&syllable_tab[ix++],tn->tonic_min0, drop);
}
else
{
tone_pitch_env = tn->pitch_env1;
drop = tn->tonic_max1 - tn->tonic_min1;
- set_pitch(&syllable_tab[ix++],tn->tonic_min1 << 8,drop << 8);
+ set_pitch(&syllable_tab[ix++],tn->tonic_min1, drop);
}
syllable_tab[tone_posn].env = tone_pitch_env;
@@ -695,8 +912,8 @@ static int calc_pitches(int start, int end, int head_tone, int nucleus_tone)
/* tail, after the tonic syllable */
/**********************************/
-
- calc_pitch_segment2(ix, end, tn->tail_start, tn->tail_end, 0);
+
+ SetPitchGradient(ix, end, tn->tail_start, tn->tail_end);
return(tone_pitch_env);
} /* end of calc_pitches */
@@ -720,7 +937,7 @@ static void CalcPitches_Tone(Translator *tr, int clause_tone)
PHONEME_TAB *tph;
PHONEME_TAB *prev_tph; // forget across word boundary
PHONEME_TAB *prevw_tph; // remember across word boundary
- PHONEME_TAB *prev2_tph; // 2 tones previous
+// PHONEME_TAB *prev2_tph; // 2 tones previous
PHONEME_LIST *prev_p;
int pitch_adjust = 0; // pitch gradient through the clause - inital value
@@ -728,8 +945,6 @@ static void CalcPitches_Tone(Translator *tr, int clause_tone)
int pitch_low = 0; // until it drops to this
int pitch_high = 0; // then reset to this
- p = &phoneme_list[0];
-
// count number of stressed syllables
p = &phoneme_list[0];
for(ix=0; ix<n_phoneme_list; ix++, p++)
@@ -822,7 +1037,7 @@ static void CalcPitches_Tone(Translator *tr, int clause_tone)
if(tph->mnemonic == 0x343132) // [214]
prev_p->tone_ph = PhonemeCode2('3','5');
else
- prev_p->tone_ph = PhonemeCode2('2','1');
+ prev_p->tone_ph = PhonemeCode2('2','1');
}
if((prev_tph->mnemonic == 0x3135) && (tph->mnemonic == 0x3135)) // [51] + [51]
{
@@ -840,12 +1055,12 @@ static void CalcPitches_Tone(Translator *tr, int clause_tone)
p->tone_ph = PhonemeCode2('4','4');
// tone 5 is unstressed (shorter)
- p->stresslevel = 1; // diminished stress
+ p->stresslevel = 0; // diminished stress
}
}
prev_p = p;
- prev2_tph = prevw_tph;
+// prev2_tph = prevw_tph;
prevw_tph = prev_tph = tph;
pause = 0;
}
@@ -859,7 +1074,7 @@ static void CalcPitches_Tone(Translator *tr, int clause_tone)
{
tone_ph = p->tone_ph;
- if(p->stresslevel != 1) // TEST, consider all syllables as stressed
+ if(p->stresslevel != 0) // TEST, consider all syllables as stressed
{
if(ix == final_stressed)
{
@@ -900,7 +1115,9 @@ void CalcPitches(Translator *tr, int clause_type)
int n_st;
int option;
int group_tone;
+#ifdef deleted
int group_tone_emph;
+#endif
int group_tone_comma;
int ph_start=0;
int st_start;
@@ -951,11 +1168,24 @@ void CalcPitches(Translator *tr, int clause_type)
option = tr->langopts.intonation_group;
if(option >= INTONATION_TYPES)
- option = 0;
+ option = 1;
- group_tone = tr->punct_to_tone[option][clause_type];
- group_tone_emph = tr->punct_to_tone[option][5]; // emphatic form of statement
- group_tone_comma = tr->punct_to_tone[option][1]; // emphatic form of statement
+ if(option == 0)
+ {
+ group_tone = tr->langopts.tunes[clause_type];
+#ifdef deleted
+ group_tone_emph = tr->langopts.tunes[5];
+#endif
+ group_tone_comma = tr->langopts.tunes[1];
+ }
+ else
+ {
+ group_tone = tr->punct_to_tone[option][clause_type];
+#ifdef deleted
+ group_tone_emph = tr->punct_to_tone[option][5]; // emphatic form of statement
+#endif
+ group_tone_comma = tr->punct_to_tone[option][1]; // emphatic form of statement
+ }
if(clause_type == 4)
no_tonic = 1; /* incomplete clause, used for abbreviations such as Mr. Dr. Mrs. */
@@ -1023,9 +1253,23 @@ void CalcPitches(Translator *tr, int clause_type)
count_pitch_vowels(st_start, ix, n_st);
if((ix < n_st) || (clause_type == 0))
- calc_pitches(st_start, ix, group_tone_emph, group_tone_emph); // split into > 1 tone groups, use emphatic tone
+ {
+ calc_pitches(option, st_start, ix, group_tone); // split into > 1 tone groups
+
+ if((clause_type==1) || (clause_type==2))
+ group_tone = tr->langopts.tunes[1]; // , or ? remainder has comma-tone
+ else
+ group_tone = tr->langopts.tunes[0]; // . or ! remainder has statement tone
+ }
+ else
+ calc_pitches(option, st_start, ix, group_tone);
+
+#ifdef deleted
+ if((ix < n_st) || (clause_type == 0))
+ calc_pitches(option, st_start, ix, group_tone_emph); // split into > 1 tone groups, use emphatic tone
else
- calc_pitches(st_start, ix, group_tone, group_tone);
+ calc_pitches(option, st_start, ix, group_tone);
+#endif
st_start = ix;
}
@@ -1034,7 +1278,7 @@ void CalcPitches(Translator *tr, int clause_type)
// end of clause after this syllable, indicated by a phonPAUSE_CLAUSE phoneme
st_clause_end = st_ix+1;
count_pitch_vowels(st_start, st_clause_end, st_clause_end);
- calc_pitches(st_start, st_clause_end, group_tone_comma, group_tone_comma);
+ calc_pitches(option, st_start, st_clause_end, group_tone_comma);
st_start = st_clause_end;
}
}
@@ -1042,28 +1286,23 @@ void CalcPitches(Translator *tr, int clause_type)
if(st_start < st_ix)
{
count_pitch_vowels(st_start, st_ix, n_st);
- calc_pitches(st_start, st_ix, group_tone, group_tone);
+ calc_pitches(option, st_start, st_ix, group_tone);
}
-
+
// unpack pitch data
st_ix=0;
for(ix=ph_start; ix < ph_end; ix++)
{
p = &phoneme_list[ix];
p->stresslevel = syllable_tab[st_ix].stress;
-
+
if(p->synthflags & SFLAG_SYLLABLE)
{
syl = &syllable_tab[st_ix];
- x = syl->pitch1 - 72;
- if(x < 0) x = 0;
- p->pitch1 = x;
-
- x = syl->pitch2 - 72;
- if(x < 0) x = 0;
- p->pitch2 = x;
+ p->pitch1 = syl->pitch1;
+ p->pitch2 = syl->pitch2;
p->env = PITCHfall;
if(syl->flags & SYL_RISE)
@@ -1094,11 +1333,11 @@ if(p->tone_ph)
{
p->stresslevel |= 8; // emphasized
}
-
+
st_ix++;
}
}
-} // end of Translator::CalcPitches
+} // end of CalcPitches
+
-