| int head_final = end_ix; | int head_final = end_ix; | ||||
| int secondary = 2; | int secondary = 2; | ||||
| pitch_range = (tune->head_end - tune->head_start) << 8; | |||||
| pitch_range = (tune->head_end - tune->head_start) * 256; | |||||
| pitch_range_abs = abs(pitch_range); | pitch_range_abs = abs(pitch_range); | ||||
| drops = drops_0; // this should be controlled by tune->head_drops | drops = drops_0; // this should be controlled by tune->head_drops | ||||
| initial = true; | initial = true; | ||||
| if (tune->onset == 255) { | if (tune->onset == 255) { | ||||
| n_steps = count_increments(syllable_tab, syl_ix, head_final, 4); | n_steps = count_increments(syllable_tab, syl_ix, head_final, 4); | ||||
| pitch = tune->head_start << 8; | |||||
| pitch = tune->head_start * 256; | |||||
| } else { | } else { | ||||
| // a pitch has been specified for the onset syllable, don't include it in the pitch incrementing | // a pitch has been specified for the onset syllable, don't include it in the pitch incrementing | ||||
| n_steps = count_increments(syllable_tab, syl_ix+1, head_final, 4); | n_steps = count_increments(syllable_tab, syl_ix+1, head_final, 4); | ||||
| pitch = tune->onset << 8; | |||||
| pitch = tune->onset * 256; | |||||
| used_onset = true; | used_onset = true; | ||||
| } | } | ||||
| increment = 0; | increment = 0; | ||||
| } else if (syl_ix == head_final) { | } else if (syl_ix == head_final) { | ||||
| // a pitch has been specified for the last primary stress before the nucleus | // a pitch has been specified for the last primary stress before the nucleus | ||||
| pitch = tune->head_last << 8; | |||||
| pitch = tune->head_last * 256; | |||||
| stage = 2; | stage = 2; | ||||
| } else { | } else { | ||||
| if (used_onset) { | if (used_onset) { | ||||
| stage = 1; | stage = 1; | ||||
| used_onset = false; | used_onset = false; | ||||
| pitch = tune->head_start << 8; | |||||
| pitch = tune->head_start * 256; | |||||
| n_steps++; | n_steps++; | ||||
| } else if (n_steps > 0) | } else if (n_steps > 0) | ||||
| pitch += increment; | pitch += increment; | ||||
| else { | else { | ||||
| pitch = (tune->head_end << 8) + (pitch_range_abs * tune->head_extend[overflow_ix++])/64; | |||||
| pitch = (tune->head_end * 256) + (pitch_range_abs * tune->head_extend[overflow_ix++])/64; | |||||
| if (overflow_ix >= tune->n_head_extend) | if (overflow_ix >= tune->n_head_extend) | ||||
| overflow_ix = 0; | overflow_ix = 0; | ||||
| } | } | ||||
| unstressed_ix = 0; | unstressed_ix = 0; | ||||
| syl->stress = PRIMARY_STRESSED; | syl->stress = PRIMARY_STRESSED; | ||||
| syl->env = tune->stressed_env; | syl->env = tune->stressed_env; | ||||
| set_pitch(syl, (pitch >> 8), tune->stressed_drop); | |||||
| set_pitch(syl, (pitch / 256), tune->stressed_drop); | |||||
| } else if (stress >= secondary) { | } else if (stress >= secondary) { | ||||
| n_unstressed = CountUnstressed(syllable_tab, syl_ix+1, end_ix, secondary); | n_unstressed = CountUnstressed(syllable_tab, syl_ix+1, end_ix, secondary); | ||||
| unstressed_ix = 0; | unstressed_ix = 0; | ||||
| set_pitch(syl, (pitch >> 8), drops[stress]); | |||||
| set_pitch(syl, (pitch / 256), drops[stress]); | |||||
| } else { | } else { | ||||
| if (n_unstressed > 1) | if (n_unstressed > 1) | ||||
| unstressed_inc = (tune->unstr_end[stage] - tune->unstr_start[stage]) / (n_unstressed - 1); | unstressed_inc = (tune->unstr_end[stage] - tune->unstr_start[stage]) / (n_unstressed - 1); | ||||
| else | else | ||||
| unstressed_inc = 0; | unstressed_inc = 0; | ||||
| set_pitch(syl, (pitch >> 8) + tune->unstr_start[stage] + (unstressed_inc * unstressed_ix), drops[stress]); | |||||
| set_pitch(syl, (pitch / 256) + tune->unstr_start[stage] + (unstressed_inc * unstressed_ix), drops[stress]); | |||||
| unstressed_ix++; | unstressed_ix++; | ||||
| } | } | ||||
| static signed char continue_tab[5] = { -26, 32, 20, 8, 0 }; | static signed char continue_tab[5] = { -26, 32, 20, 8, 0 }; | ||||
| drops = th->body_drops; | drops = th->body_drops; | ||||
| pitch_range = (th->body_end - th->body_start) << 8; | |||||
| pitch_range = (th->body_end - th->body_start) * 256; | |||||
| pitch_range_abs = abs(pitch_range); | pitch_range_abs = abs(pitch_range); | ||||
| if (continuing) { | if (continuing) { | ||||
| else | else | ||||
| increment = 0; | increment = 0; | ||||
| pitch = th->body_start << 8; | |||||
| pitch = th->body_start * 256; | |||||
| } else { | } else { | ||||
| if (n_steps > 0) | if (n_steps > 0) | ||||
| pitch += increment; | pitch += increment; | ||||
| else { | else { | ||||
| pitch = (th->body_end << 8) + (pitch_range_abs * overflow_tab[overflow++])/64; | |||||
| pitch = (th->body_end * 256) + (pitch_range_abs * overflow_tab[overflow++])/64; | |||||
| if (overflow >= n_overflow) { | if (overflow >= n_overflow) { | ||||
| overflow = 0; | overflow = 0; | ||||
| overflow_tab = th->overflow; | overflow_tab = th->overflow; | ||||
| n_primary--; | n_primary--; | ||||
| if ((tn->backwards) && (n_primary < 2)) | if ((tn->backwards) && (n_primary < 2)) | ||||
| pitch = tn->backwards[n_primary] << 8; | |||||
| pitch = tn->backwards[n_primary] * 256; | |||||
| } | } | ||||
| if (stress >= PRIMARY) { | if (stress >= PRIMARY) { | ||||
| syl->stress = PRIMARY_STRESSED; | syl->stress = PRIMARY_STRESSED; | ||||
| set_pitch(syl, (pitch >> 8), drops[stress]); | |||||
| set_pitch(syl, (pitch / 256), drops[stress]); | |||||
| } else if (stress >= SECONDARY) | } else if (stress >= SECONDARY) | ||||
| set_pitch(syl, (pitch >> 8), drops[stress]); | |||||
| set_pitch(syl, (pitch / 256), drops[stress]); | |||||
| else { | else { | ||||
| // unstressed, drop pitch if preceded by PRIMARY | // unstressed, drop pitch if preceded by PRIMARY | ||||
| if ((syllable_tab[ix-1].stress & 0x3f) >= SECONDARY) | if ((syllable_tab[ix-1].stress & 0x3f) >= SECONDARY) | ||||
| set_pitch(syl, (pitch >> 8) - th->body_lower_u, drops[stress]); | |||||
| set_pitch(syl, (pitch / 256) - th->body_lower_u, drops[stress]); | |||||
| else | else | ||||
| set_pitch(syl, (pitch >> 8), drops[stress]); | |||||
| set_pitch(syl, (pitch / 256), drops[stress]); | |||||
| } | } | ||||
| ix++; | ix++; | ||||
| int drop; | int drop; | ||||
| SYLLABLE *syl; | SYLLABLE *syl; | ||||
| increment = (end_pitch - start_pitch) << 8; | |||||
| increment = (end_pitch - start_pitch) * 256; | |||||
| n_increments = end_ix - start_ix; | n_increments = end_ix - start_ix; | ||||
| if (n_increments <= 0) | if (n_increments <= 0) | ||||
| if (n_increments > 1) | if (n_increments > 1) | ||||
| increment = increment / n_increments; | increment = increment / n_increments; | ||||
| pitch = start_pitch << 8; | |||||
| pitch = start_pitch * 256; | |||||
| for (ix = start_ix; ix < end_ix; ix++) { | for (ix = start_ix; ix < end_ix; ix++) { | ||||
| syl = &syllable_tab[ix]; | syl = &syllable_tab[ix]; | ||||
| stress = syl->stress; | stress = syl->stress; | ||||
| if (increment > 0) { | if (increment > 0) { | ||||
| set_pitch(syl, (pitch >> 8), -(increment >> 8)); | |||||
| set_pitch(syl, (pitch / 256), -(increment / 256)); | |||||
| pitch += increment; | pitch += increment; | ||||
| } else { | } else { | ||||
| drop = -(increment >> 8); | |||||
| drop = -(increment / 256); | |||||
| if (drop < min_drop[stress]) | if (drop < min_drop[stress]) | ||||
| drop = min_drop[stress]; | drop = min_drop[stress]; | ||||
| if (drop > 18) | if (drop > 18) | ||||
| drop = 18; | drop = 18; | ||||
| set_pitch(syl, (pitch >> 8), drop); | |||||
| set_pitch(syl, (pitch / 256), drop); | |||||
| } | } | ||||
| } | } | ||||
| } | } |