~ubuntu-branches/ubuntu/oneiric/espeak/oneiric

« back to all changes in this revision

Viewing changes to src/wavegen.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2008-08-26 09:37:23 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20080826093723-lwblp0nwfd93sggb
Tags: 1.38-0ubuntu1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1594
1594
}
1595
1595
 
1596
1596
 
1597
 
void SetPitch(int length, unsigned char *env, int pitch1, int pitch2)
1598
 
{//==================================================================
1599
 
// length in samples
 
1597
void SetPitch2(voice_t *voice, int pitch1, int pitch2, int *pitch_base, int *pitch_range)
 
1598
{//======================================================================================
1600
1599
        int x;
1601
1600
        int base;
1602
1601
        int range;
1603
1602
        int pitch_value;
1604
1603
 
1605
 
#ifdef LOG_FRAMES
1606
 
if(option_log_frames)
1607
 
{
1608
 
        f_log=fopen("log-espeakedit","a");
1609
 
        if(f_log != NULL)
1610
 
        {
1611
 
                fprintf(f_log,"   pitch %3d %3d  %3dmS\n",pitch1,pitch2,(length*1000)/samplerate);
1612
 
                fclose(f_log);
1613
 
                f_log=NULL;
1614
 
        }
1615
 
}
1616
 
#endif
1617
 
        if((pitch_env = env)==NULL)
1618
 
                pitch_env = env_fall;  // default
1619
 
 
1620
 
        pitch_ix = 0;
1621
 
        if(length==0)
1622
 
                pitch_inc = 0;
1623
 
        else
1624
 
                pitch_inc = (256 * ENV_LEN * STEPSIZE)/length;
1625
 
 
1626
1604
        if(pitch1 > pitch2)
1627
1605
        {
1628
1606
                x = pitch1;   // swap values
1636
1614
        if(pitch_value < 0)
1637
1615
                pitch_value = 0;
1638
1616
 
1639
 
        base = (wvoice->pitch_base * pitch_adjust_tab[pitch_value])/128;
1640
 
        range =  (wvoice->pitch_range * embedded_value[EMBED_R])/50;
 
1617
        base = (voice->pitch_base * pitch_adjust_tab[pitch_value])/128;
 
1618
        range =  (voice->pitch_range * embedded_value[EMBED_R])/50;
1641
1619
 
1642
1620
        // compensate for change in pitch when the range is narrowed or widened
1643
 
        base -= (range - wvoice->pitch_range)*18;
1644
 
 
1645
 
        pitch_base = base + (pitch1 * range);
1646
 
        pitch_range = base + (pitch2 * range) - pitch_base;
1647
 
 
 
1621
        base -= (range - voice->pitch_range)*18;
 
1622
 
 
1623
        *pitch_base = base + (pitch1 * range);
 
1624
        *pitch_range = base + (pitch2 * range) - *pitch_base;
 
1625
}
 
1626
 
 
1627
 
 
1628
void SetPitch(int length, unsigned char *env, int pitch1, int pitch2)
 
1629
{//==================================================================
 
1630
// length in samples
 
1631
 
 
1632
#ifdef LOG_FRAMES
 
1633
if(option_log_frames)
 
1634
{
 
1635
        f_log=fopen("log-espeakedit","a");
 
1636
        if(f_log != NULL)
 
1637
        {
 
1638
                fprintf(f_log,"   pitch %3d %3d  %3dmS\n",pitch1,pitch2,(length*1000)/samplerate);
 
1639
                fclose(f_log);
 
1640
                f_log=NULL;
 
1641
        }
 
1642
}
 
1643
#endif
 
1644
        if((pitch_env = env)==NULL)
 
1645
                pitch_env = env_fall;  // default
 
1646
 
 
1647
        pitch_ix = 0;
 
1648
        if(length==0)
 
1649
                pitch_inc = 0;
 
1650
        else
 
1651
                pitch_inc = (256 * ENV_LEN * STEPSIZE)/length;
 
1652
 
 
1653
        SetPitch2(wvoice, pitch1, pitch2, &pitch_base, &pitch_range);
1648
1654
        // set initial pitch
1649
1655
        pitch = ((pitch_env[0]*pitch_range)>>8) + pitch_base;   // Hz << 12
1650
1656