[1.40.21]

Fix: -g command option not working on Windows.
Fix: Text position value in events was limited to 16 bits.

[1.40.15]
espeakedit:  Change formant dialog to include Klatt parameters.
espeakedit:  Change the format of formant data to include Klatt parameters.
espeakedit:  Fix the frequency of F7,F8 at 7800Hz,9000Hz.


git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@220 d46cf337-b52f-0410-862d-fd96e6ae7743
This commit is contained in:
jonsd
2009-05-29 11:48:39 +00:00
parent 206026b498
commit 0fc12016fa
52 changed files with 1147 additions and 791 deletions
+53 -30
View File
@@ -635,8 +635,15 @@ int Compile::LoadSpect(const char *path, int control)
}
spectseq->Load(stream);
if(spectseq->synthesizer_type == 1)
klatt_flag = FRFLAG_KLATT;
// do we need additional klatt data ?
for(frame=0; frame < spectseq->numframes; frame++)
{
for(ix=5; ix<N_KLATTP2; ix++)
{
if(spectseq->frames[frame]->klatt_param[ix] != 0)
klatt_flag = FRFLAG_KLATT;
}
}
displ = ftell(f_phdata);
@@ -716,53 +723,69 @@ for(ix=0; ix<8; ix++)
// write: peak data
count_frames++;
for(peak=0; peak<N_PEAKS; peak++)
for(peak=0; peak < 8; peak++)
{
fr_out->ffreq[peak] = fr->peaks[peak].pkfreq;
if(peak < 7)
fr_out->ffreq[peak] = fr->peaks[peak].pkfreq;
if(klatt_flag)
{
pkheight = fr->peaks[peak].pkheight / 128;
}
else
{
pkheight = spectseq->amplitude * fr->amp_adjust * fr->peaks[peak].pkheight;
pkheight = pkheight/640000;
if(pkheight > 255) pkheight = 255;
}
pkheight = spectseq->amplitude * fr->amp_adjust * fr->peaks[peak].pkheight;
pkheight = pkheight/640000;
if(pkheight > 255) pkheight = 255;
fr_out->fheight[peak] = int(pkheight);
if(peak < 6)
{
x = fr->peaks[peak].pkwidth/2;
x2 = fr->peaks[peak].pkright;
if(klatt_flag == 0)
{
x /= 2;
x2 /= 4;
}
x = fr->peaks[peak].pkwidth/4;
if(x > 255) x = 255;
fr_out->fwidth[peak] = x;
if(x2 > 255) x2 = 255;
fr_out->fright[peak] = x2;
if(peak < 3)
{
x2 = fr->peaks[peak].pkright/4;
if(x2 > 255) x2 = 255;
fr_out->fright[peak] = x2;
}
}
if(peak < 4)
{
x = fr->peaks[peak].klt_bw / 2;
if(x > 255) x = 255;
fr_out->bw[peak] = x;
}
}
for(ix=0; ix<5; ix++)
{
fr_out->klattp[ix] = fr->klatt_param[ix];
fr_out->klattp[KLATT_FNZ] = fr->klatt_param[KLATT_FNZ] / 2;
}
if(klatt_flag)
{
if(fr->klatt_param[KLATT_Kopen] == 0)
// additional klatt parameters
for(ix=0; ix<5; ix++)
{
Error("Klatt_Kopen has value 0");
fr_out->klattp2[ix] = fr->klatt_param[ix+5];
}
// additional fields
for(ix=0; ix<N_KLATTP; ix++)
for(peak=0; peak<7; peak++)
{
fr_out->klattp[ix] = fr->klatt_param[ix];
fr_out->klatt_ap[ix] = fr->peaks[peak].klt_ap;
x = fr->peaks[peak].klt_bp / 2;
if(x > 255) x = 255;
fr_out->klatt_bp[ix] = x;
}
fr_out->fwidth6 = fr->peaks[6].pkwidth/2;
fr_out->fright6 = fr->peaks[6].pkright;
}
if(fr_out->bw[1] == 0)
{
fr_out->bw[0] = 89 / 2;
fr_out->bw[1] = 90 / 2;
fr_out->bw[2] = 140 / 2;
fr_out->bw[3] = 260 / 2;
}
n_frames++;
+2 -2
View File
@@ -232,9 +232,9 @@ wxSashLayoutWindow *win;
// Another window to the left of the client window
win = new wxSashLayoutWindow(this, ID_WINDOW_LEFT2,
wxDefaultPosition, wxSize(200, 30),
wxDefaultPosition, wxSize(298, 30),
wxNO_BORDER | wxSW_3D | wxCLIP_CHILDREN);
win->SetDefaultSize(wxSize(212, 1000));
win->SetDefaultSize(wxSize(310, 1000));
win->SetOrientation(wxLAYOUT_VERTICAL);
win->SetAlignment(wxLAYOUT_LEFT);
// win->SetBackgroundColour(wxColour(0, 255, 255));
+154 -95
View File
@@ -102,57 +102,90 @@ FormantDlg::FormantDlg(wxWindow *parent) : wxPanel(parent,-1,wxDefaultPosition,w
xplace = 28;
id = 201;
new wxStaticText(this,-1,_T("Formants"),wxPoint(4,5));
t_lab[4] = new wxStaticText(this,-1,_T(" BW BWp Ap"),wxPoint(78,5),wxSize(300,20));
new wxStaticText(this,-1,_T(" Ht Width (Klatt)"),wxPoint(78,5),wxSize(300,20));
new wxStaticText(this,-1,_T("Bw Ap Bp"),wxPoint(188,29),wxSize(300,20));
for(ix=0; ix<N_PEAKS; ix++)
for(ix=0; ix < 8; ix++)
{
string.Printf(_T("%d"),ix);
t_labpk[ix] = new wxStaticText(this,id++,string,
wxPoint(xplace-22,y+1+24*ix));
t_pkfreq[ix] = new wxTextCtrl(this,id++,_T(""),
wxPoint(xplace,y+24*ix),wxSize(48,20),
wxTE_CENTRE+wxTE_READONLY);
if(ix < 7)
{
t_pkfreq[ix] = new wxTextCtrl(this,id++,_T(""),
wxPoint(xplace,y+24*ix),wxSize(44,20),
wxTE_CENTRE);
}
t_pkheight[ix] = new wxTextCtrl(this,id++,_T(""),
wxPoint(xplace+50,y+24*ix),wxSize(36,20),
wxTE_CENTRE+wxTE_READONLY);
t_pkwidth[ix] = new wxTextCtrl(this,id++,_T(""),
wxPoint(xplace+88,y+24*ix),wxSize(48,20),
wxTE_CENTRE+wxTE_READONLY);
t_pkright[ix] = new wxTextCtrl(this,id++,_T(""),
wxPoint(xplace+138,y+24*ix),wxSize(36,20),
wxTE_CENTRE+wxTE_READONLY);
if(ix>5) t_pkwidth[ix]->Hide();
wxPoint(xplace+46,y+24*ix),wxSize(36,20),
wxTE_CENTRE);
if(ix < 6)
{
t_pkwidth[ix] = new wxTextCtrl(this,id++,_T(""),
wxPoint(xplace+84,y+24*ix),wxSize(60,20),
wxTE_CENTRE);
}
if((ix == 0) || (ix > 6)) continue;
if(ix < 4)
{
t_klt_bw[ix] = new wxTextCtrl(this,id++,_T(""),
wxPoint(xplace+150,y+24*ix),wxSize(40,20),
wxTE_CENTRE);
}
t_klt_ap[ix] = new wxTextCtrl(this,id++,_T(""),
wxPoint(xplace+192,y+24*ix),wxSize(36,20),
wxTE_CENTRE);
t_klt_bp[ix] = new wxTextCtrl(this,id++,_T(""),
wxPoint(xplace+230,y+24*ix),wxSize(40,20),
wxTE_CENTRE);
}
y=240;
y=224;
t_timeframe = new wxSpinCtrl(this,T_TIMEFRAME,_T(""), wxPoint(6,y+0), wxSize(52,24), wxTE_CENTRE,0,500);
t_orig_frame = new wxStaticText(this,-1,_T("mS"),wxPoint(57,y+8));
t_ampframe = new wxSpinCtrl(this,T_AMPFRAME,_T(""), wxPoint(100,y+0), wxSize(52,24), wxTE_CENTRE,0,500);
t_lab[3] = new wxStaticText(this,-1,_T("% amp - Frame"),wxPoint(151,y+8));
t_orig_frame = new wxStaticText(this,-1,_T("mS"),wxPoint(61,y+8));
t_ampframe = new wxSpinCtrl(this,T_AMPFRAME,_T(""), wxPoint(104,y+0), wxSize(52,24), wxTE_CENTRE,0,500);
t_lab[3] = new wxStaticText(this,-1,_T("% amp - Frame"),wxPoint(159,y+8));
s_klatt[KLATT_AV] = new wxSpinCtrl(this,T_AV,_T(""), wxPoint(6,y+32), wxSize(52,24), wxTE_CENTRE,0,500);
t_klatt[KLATT_AV] = new wxStaticText(this,-1,_T("AV"),wxPoint(61,y+36));
s_klatt[KLATT_AVp] = new wxSpinCtrl(this,T_AVP,_T(""), wxPoint(100,y+32), wxSize(52,24), wxTE_CENTRE,0,500);
t_klatt[KLATT_AVp] = new wxStaticText(this,-1,_T("AVp"),wxPoint(155,y+36));
y += 40;
s_klatt[KLATT_AV] = new wxSpinCtrl(this,T_AV,_T(""), wxPoint(6,y), wxSize(52,24), wxTE_CENTRE,0,500);
t_klatt[KLATT_AV] = new wxStaticText(this,-1,_T("AV"),wxPoint(61,y+4));
s_klatt[KLATT_Fric] = new wxSpinCtrl(this,T_FRIC,_T(""), wxPoint(6,y+60), wxSize(52,24), wxTE_CENTRE,0,500);
t_klatt[KLATT_Fric] = new wxStaticText(this,-1,_T("Fric"),wxPoint(61,y+64));
s_klatt[KLATT_FricBP] = new wxSpinCtrl(this,T_FRICBP,_T(""), wxPoint(100,y+60), wxSize(52,24), wxTE_CENTRE,0,500);
t_klatt[KLATT_FricBP] = new wxStaticText(this,-1,_T("FricBP"),wxPoint(155,y+64));
s_klatt[KLATT_FNZ] = new wxSpinCtrl(this,T_FNZ,_T(""), wxPoint(104,y), wxSize(52,24), wxTE_CENTRE,0,500);
t_klatt[KLATT_FNZ] = new wxStaticText(this,-1,_T("FNZ"),wxPoint(159,y+4));
s_klatt[KLATT_Aspr] = new wxSpinCtrl(this,T_ASPR,_T(""), wxPoint(6,y+88), wxSize(52,24), wxTE_CENTRE,0,500);
t_klatt[KLATT_Aspr] = new wxStaticText(this,-1,_T("Aspr"),wxPoint(61,y+92));
s_klatt[KLATT_Turb] = new wxSpinCtrl(this,T_TURB,_T(""), wxPoint(100,y+88), wxSize(52,24), wxTE_CENTRE,0,500);
t_klatt[KLATT_Turb] = new wxStaticText(this,-1,_T("Turb"),wxPoint(155,y+92));
s_klatt[KLATT_Skew] = new wxSpinCtrl(this,T_SKEW,_T(""), wxPoint(6,y+116), wxSize(52,24), wxTE_CENTRE,0,500);
t_klatt[KLATT_Skew] = new wxStaticText(this,-1,_T("Skew"),wxPoint(61,y+120));
s_klatt[KLATT_Tilt] = new wxSpinCtrl(this,T_TILT,_T(""), wxPoint(100,y+116), wxSize(52,24), wxTE_CENTRE,0,500);
t_klatt[KLATT_Tilt] = new wxStaticText(this,-1,_T("Tilt"),wxPoint(155,y+120));
y += 28;
s_klatt[KLATT_Tilt] = new wxSpinCtrl(this,T_TILT,_T(""), wxPoint(6,y), wxSize(52,24), wxTE_CENTRE,0,500);
t_klatt[KLATT_Tilt] = new wxStaticText(this,-1,_T("Tilt"),wxPoint(61,y+4));
s_klatt[KLATT_Aspr] = new wxSpinCtrl(this,T_ASPR,_T(""), wxPoint(104,y), wxSize(52,24), wxTE_CENTRE,0,500);
t_klatt[KLATT_Aspr] = new wxStaticText(this,-1,_T("Aspr"),wxPoint(159,y+4));
s_klatt[KLATT_Skew] = new wxSpinCtrl(this,T_SKEW,_T(""), wxPoint(202,y), wxSize(52,24), wxTE_CENTRE,0,500);
t_klatt[KLATT_Skew] = new wxStaticText(this,-1,_T("Skew"),wxPoint(257,y+4));
y += 28;
s_klatt[KLATT_AVp] = new wxSpinCtrl(this,T_AVP,_T(""), wxPoint(6,y), wxSize(52,24), wxTE_CENTRE,0,500);
t_klatt[KLATT_AVp] = new wxStaticText(this,-1,_T("AVp"),wxPoint(61,y+4));
s_klatt[KLATT_Fric] = new wxSpinCtrl(this,T_FRIC,_T(""), wxPoint(104,y), wxSize(52,24), wxTE_CENTRE,0,500);
t_klatt[KLATT_Fric] = new wxStaticText(this,-1,_T("Fric"),wxPoint(159,y+4));
s_klatt[KLATT_FricBP] = new wxSpinCtrl(this,T_FRICBP,_T(""), wxPoint(202,y), wxSize(52,24), wxTE_CENTRE,0,500);
t_klatt[KLATT_FricBP] = new wxStaticText(this,-1,_T("FricBP"),wxPoint(257,y+4));
y += 28;
s_klatt[KLATT_Kopen] = new wxSpinCtrl(this,T_KOPEN,_T(""), wxPoint(6,y), wxSize(52,24), wxTE_CENTRE,0,500);
t_klatt[KLATT_Kopen] = new wxStaticText(this,-1,_T("kopen"),wxPoint(61,y+4));
s_klatt[KLATT_Turb] = new wxSpinCtrl(this,T_TURB,_T(""), wxPoint(104,y), wxSize(52,24), wxTE_CENTRE,0,500);
t_klatt[KLATT_Turb] = new wxStaticText(this,-1,_T("Turb"),wxPoint(159,y+4));
s_klatt[KLATT_Kopen] = new wxSpinCtrl(this,T_KOPEN,_T(""), wxPoint(6,y+144), wxSize(52,24), wxTE_CENTRE,0,500);
t_klatt[KLATT_Kopen] = new wxStaticText(this,-1,_T("kopen"),wxPoint(61,y+148));
t_zoomout = new wxButton(this,T_ZOOMOUT,_T("Zoom-"),wxPoint(16,420));
@@ -168,8 +201,6 @@ FormantDlg::FormantDlg(wxWindow *parent) : wxPanel(parent,-1,wxDefaultPosition,w
t_pitch = new wxStaticText(this,-1,_T(""),wxPoint(4,520),wxSize(192,24));
HideFields(0);
pitchgraph = new ByteGraph(this,wxPoint(0,538),wxSize(200,140));
pitchgraph->SetData(128,env_fall);
pitchgraph->ShowSpectrum(1);
@@ -177,62 +208,71 @@ FormantDlg::FormantDlg(wxWindow *parent) : wxPanel(parent,-1,wxDefaultPosition,w
}
void FormantDlg::HideFields(int synth_type)
{//=======================================
void FormantDlg::GetValues(SpectSeq *spectseq, int frame)
{//======================================================
int ix;
static int prev_synth_type = -1;
wxString value;
long num;
SpectFrame *sf;
if(synth_type == prev_synth_type)
return; // no change
if(spectseq->frames == NULL)
return;
sf = spectseq->frames[frame];
if(synth_type == 0)
for(ix=0; ix < 8; ix++)
{
for(ix=0; ix<9; ix++)
if(ix < 7)
{
s_klatt[ix]->Hide();
t_klatt[ix]->Hide();
num = 0;
value = t_pkfreq[ix]->GetValue();
value.ToLong(&num);
sf->peaks[ix].pkfreq = num;
}
for(ix=6; ix<9; ix++)
num = 0;
value = t_pkheight[ix]->GetValue();
value.ToLong(&num);
sf->peaks[ix].pkheight = num << 6;
if(ix < 6)
{
t_pkfreq[ix]->Show();
t_pkheight[ix]->Show();
t_pkwidth[ix]->Hide();
t_pkright[ix]->Hide();
num = 0;
value = t_pkwidth[ix]->GetValue();
value.ToLong(&num);
sf->peaks[ix].pkwidth = sf->peaks[ix].pkright = num*2;
if((ix < 3) && ((value = value.AfterFirst('/')) != wxEmptyString))
{
num = 0;
value.ToLong(&num);
sf->peaks[ix].pkright = num*2;
}
}
t_ampframe->Show();
t_amplitude->Show();
t_lab[2]->Show();
t_lab[3]->Show();
t_labpk[7]->Show();
t_labpk[8]->Show();
t_lab[4]->Hide();
}
else
for(ix=1; ix < 6; ix++)
{
for(ix=0; ix<9; ix++)
if(ix < 3)
{
s_klatt[ix]->Show();
t_klatt[ix]->Show();
num = 0;
value = t_klt_bw[ix]->GetValue();
value.ToLong(&num);
sf->peaks[ix].klt_bw = num;
}
for(ix=7; ix<9; ix++)
{
t_pkfreq[ix]->Hide();
t_pkheight[ix]->Hide();
t_pkwidth[ix]->Hide();
t_pkright[ix]->Hide();
}
t_pkwidth[6]->Show(1);
t_pkright[6]->Show(1);
t_ampframe->Hide();
t_amplitude->Hide();
t_lab[2]->Hide();
t_lab[3]->Hide();
t_labpk[7]->Hide();
t_labpk[8]->Hide();
t_lab[4]->Show();
num = 0;
value = t_klt_ap[ix]->GetValue();
value.ToLong(&num);
sf->peaks[ix].klt_ap = num;
num = 0;
value = t_klt_bp[ix]->GetValue();
value.ToLong(&num);
sf->peaks[ix].klt_bp = num;
}
prev_synth_type = synth_type;
}
} // end of FormantDlg::GetValues
void FormantDlg::ShowFrame(SpectSeq *spectseq, int frame, int pk, int field)
@@ -241,20 +281,19 @@ void FormantDlg::ShowFrame(SpectSeq *spectseq, int frame, int pk, int field)
SpectFrame *sf;
wxString value;
int original_mS;
peak_t *peak;
if(spectseq->frames == NULL)
return;
sf = spectseq->frames[frame];
HideFields(spectseq->synthesizer_type);
if(field == 0xff)
{
// indicate the selected peak
// t_select_peak[pk]->SetValue(TRUE);
}
for(ix=0; ix<N_PEAKS; ix++)
for(ix=0; ix < 8; ix++)
{
if(field != 0xff && pk!=ix)
continue;
@@ -268,7 +307,9 @@ void FormantDlg::ShowFrame(SpectSeq *spectseq, int frame, int pk, int field)
t_labpk[ix]->SetLabel(value);
}
if(field & 1)
peak = &(sf->peaks[ix]);
if((field & 1) && (ix < 7))
{
value.Printf(_T("%4d"),sf->peaks[ix].pkfreq);
t_pkfreq[ix]->SetValue(value);
@@ -278,12 +319,34 @@ void FormantDlg::ShowFrame(SpectSeq *spectseq, int frame, int pk, int field)
value.Printf(_T("%3d"),sf->peaks[ix].pkheight >> 6);
t_pkheight[ix]->SetValue(value);
}
if(field & 4)
if((field & 4) && (ix < 6))
{
value.Printf(_T("%3d"),sf->peaks[ix].pkwidth/2);
if(sf->peaks[ix].pkwidth == sf->peaks[ix].pkright)
value.Printf(_T("%3d"),sf->peaks[ix].pkwidth/2);
else
value.Printf(_T("%3d/%3d"),sf->peaks[ix].pkwidth/2, sf->peaks[ix].pkright/2);
t_pkwidth[ix]->SetValue(value);
value.Printf(_T("%3d"),sf->peaks[ix].pkright/2);
t_pkright[ix]->SetValue(value);
}
if((ix > 0) && (ix < 7))
{
if((field & 8) && (ix < 4))
{
value.Printf(_T("%3d"),peak->klt_bw);
t_klt_bw[ix]->SetValue(value);
}
if(field & 16)
{
value.Printf(_T("%3d"),peak->klt_ap);
t_klt_ap[ix]->SetValue(value);
}
if(field & 32)
{
value.Printf(_T("%3d"),peak->klt_bp);
t_klt_bp[ix]->SetValue(value);
}
}
}
@@ -294,15 +357,11 @@ void FormantDlg::ShowFrame(SpectSeq *spectseq, int frame, int pk, int field)
value.Printf(_T("%3d"),sf->amp_adjust);
t_ampframe->SetValue(value);
if(spectseq->synthesizer_type == 1)
for(ix=0; ix<N_KLATTP; ix++)
{
for(ix=0; ix<9; ix++)
{
SetSpinCtrl(s_klatt[ix], sf->klatt_param[ix]);
}
SetSpinCtrl(s_klatt[ix], sf->klatt_param[ix]);
}
} // end of FormantDlg::ShowFrame
+75 -54
View File
@@ -30,10 +30,10 @@
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include "klatt.h"
#include "speak_lib.h"
#include "speech.h"
#include "klatt.h"
#include "phoneme.h"
#include "synthesize.h"
#include "voice.h"
@@ -967,7 +967,7 @@ static double DBtoLIN(long dB)
extern voice_t *wvoice;
static wavegen_peaks_t peaks[N_PEAKS];
static klatt_peaks_t peaks[N_PEAKS];
static int end_wave;
static int klattp[N_KLATTP];
static double klattp1[N_KLATTP];
@@ -992,20 +992,20 @@ int Wavegen_Klatt(int resume)
{
kt_frame.F0hz10 = (wdata.pitch * 10) / 4096;
kt_frame.Fhz[F_NP] = peaks[0].freq;
kt_frame.Fhz[F_NZ] = peaks[0].left;
// formants F6,F7,F8 are fixed values for cascade resonators, set in KlattInit()
// but F6 is used for parallel resonator
for(ix=1; ix<=6; ix++)
// F0 is used for the nasal zero
for(ix=0; ix < 6; ix++)
{
if(ix < 6)
kt_frame.Fhz[ix] = peaks[ix].freq;
if(ix < 4)
{
kt_frame.Fhz[ix] = peaks[ix].freq;
kt_frame.Bhz[ix] = peaks[ix].height;
kt_frame.Bhz[ix] = peaks[ix].bw;
}
kt_frame.Bphz[ix] = peaks[ix].left;
kt_frame.Ap[ix] = peaks[ix].right;
}
for(ix=1; ix < 7; ix++)
{
kt_frame.Ap[ix] = 0;
}
kt_frame.AVdb = klattp[KLATT_AV];
@@ -1023,27 +1023,30 @@ int Wavegen_Klatt(int resume)
{
peaks[pk].freq1 += peaks[pk].freq_inc;
peaks[pk].freq = (int)peaks[pk].freq1;
peaks[pk].height1 += peaks[pk].height_inc;
peaks[pk].height = (int)peaks[pk].height1;
peaks[pk].left1 += peaks[pk].left_inc;
peaks[pk].left = (int)peaks[pk].left1;
peaks[pk].right1 += peaks[pk].right_inc;
peaks[pk].right = (int)peaks[pk].right1;
peaks[pk].bw1 += peaks[pk].bw_inc;
peaks[pk].bw = (int)peaks[pk].bw1;
peaks[pk].bp1 += peaks[pk].bp_inc;
peaks[pk].bp = (int)peaks[pk].bp1;
peaks[pk].ap1 += peaks[pk].ap_inc;
peaks[pk].ap = (int)peaks[pk].ap1;
}
for(ix=1; ix<=6; ix++)
{
kt_frame.Fhz_next[ix] = peaks[ix].freq;
kt_frame.Bhz_next[ix] = peaks[ix].height;
}
kt_frame.Fhz_next[F_NZ] = peaks[0].left;
// advance other parameters
for(ix=0; ix < N_KLATTP; ix++)
{
klattp1[ix] += klattp_inc[ix];
klattp[ix] = int(klattp1[ix]);
}
for(ix=0; ix<=6; ix++)
{
kt_frame.Fhz_next[ix] = peaks[ix].freq;
if(ix < 4)
{
kt_frame.Bhz_next[ix] = peaks[ix].bw;
}
}
// advance the pitch
wdata.pitch_ix += wdata.pitch_inc;
if((ix = wdata.pitch_ix>>8) > 127) ix = 127;
@@ -1163,48 +1166,66 @@ void SetSynth_Klatt(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v
for(ix=0; ix<N_KLATTP; ix++)
{
klattp1[ix] = klattp[ix] = fr1->klattp[ix];
klattp_inc[ix] = double((fr2->klattp[ix] - klattp[ix]) * STEPSIZE)/length;
if((ix >= 5) && ((fr1->frflags & FRFLAG_KLATT) == 0))
{
klattp1[ix] = klattp[ix] = 0;
klattp_inc[ix] = 0;
}
else
{
klattp1[ix] = klattp[ix] = fr1->klattp[ix];
klattp_inc[ix] = double((fr2->klattp[ix] - klattp[ix]) * STEPSIZE)/length;
}
if((ix>0) && (ix < KLATT_AVp))
klattp1[ix] = klattp[ix] = (klattp[ix] + wvoice->klattv[ix]);
// get klatt parameter adjustments for the voice
// if((ix>0) && (ix < KLATT_AVp))
// klattp1[ix] = klattp[ix] = (klattp[ix] + wvoice->klattv[ix]);
}
nsamples = length;
for(ix=0; ix<N_PEAKS; ix++)
for(ix=1; ix < 6; ix++)
{
peaks[ix].freq1 = (fr1->ffreq[ix] * v->freq[ix] / 256.0) + v->freqadd[ix];
peaks[ix].freq = int(peaks[ix].freq1);
next = (fr2->ffreq[ix] * v->freq[ix] / 256.0) + v->freqadd[ix];
peaks[ix].freq_inc = ((next - peaks[ix].freq1) * STEPSIZE) / length; // lower headroom for fixed point math
peaks[ix].freq_inc = ((next - peaks[ix].freq1) * STEPSIZE) / length;
peaks[ix].height1 = fr1->fheight[ix] * 2;
peaks[ix].height = int(peaks[ix].height1);
next = fr2->fheight[ix] * 2;
peaks[ix].height_inc = ((next - peaks[ix].height1) * STEPSIZE) / length;
if(ix < 6)
if(ix < 4)
{
peaks[ix].left1 = fr1->fwidth[ix] * 2;
peaks[ix].left = int(peaks[ix].left1);
next = fr2->fwidth[ix] * 2;
peaks[ix].left_inc = ((next - peaks[ix].left1) * STEPSIZE) / length;
peaks[ix].right1 = fr1->fright[ix];
peaks[ix].right = int(peaks[ix].right1);
next = fr2->fright[ix];
peaks[ix].right_inc = ((next - peaks[ix].right1) * STEPSIZE) / length;
// klatt bandwidth for f1, f2, f3 (others are fixed)
peaks[ix].bw1 = fr1->bw[ix] * 2;
peaks[ix].bw = int(peaks[ix].bw1);
next = fr2->bw[ix] * 2;
peaks[ix].bw_inc = ((next - peaks[ix].bw1) * STEPSIZE) / length;
}
peaks[6].left1 = fr1->fwidth6 * 2;
peaks[6].left = int(peaks[6].left1);
next = fr2->fwidth6 * 2;
peaks[6].left_inc = ((next - peaks[6].left1) * STEPSIZE) / length;
}
peaks[6].right1 = fr1->fright6;
peaks[6].right = int(peaks[6].right1);
next = fr2->fright6;
peaks[6].right_inc = ((next - peaks[6].right1) * STEPSIZE) / length;
// nasal zero frequency
peaks[0].freq1 = fr1->klattp[KLATT_FNZ] * 2;
peaks[0].freq = int(peaks[0].freq1);
next = fr2->klattp[KLATT_FNZ] * 2;
peaks[0].freq_inc = ((next - peaks[0].freq1) * STEPSIZE) / length;
peaks[0].bw1 = 89;
peaks[0].bw = 89;
peaks[0].bw_inc = 0;
if(fr1->frflags & FRFLAG_KLATT)
{
// the frame contains additional parameters for parallel resonators
for(ix=1; ix < 7; ix++)
{
peaks[ix].bp1 = fr1->klatt_bp[ix] * 4; // parallel bandwidth
peaks[ix].bp = int(peaks[ix].bp1);
next = fr2->klatt_bp[ix] * 2;
peaks[ix].bp_inc = ((next - peaks[ix].bp1) * STEPSIZE) / length;
peaks[ix].ap1 = fr1->klatt_ap[ix]; // parallal amplitude
peaks[ix].ap = int(peaks[ix].ap1);
next = fr2->klatt_ap[ix] * 2;
peaks[ix].ap_inc = ((next - peaks[ix].ap1) * STEPSIZE) / length;
}
}
} // end of SetSynth_Klatt
@@ -1276,7 +1297,7 @@ void KlattInit()
kt_frame.Kskew = 0;
kt_frame.AB = 0;
kt_frame.AVpdb = 0;
kt_frame.Gain0 = 62;
kt_frame.Gain0 = 60; // 62
} // end of KlattInit
#endif // INCLUDE_KLATT
+17 -2
View File
@@ -99,14 +99,14 @@ typedef struct
/* Structure for Klatt Parameters */
#define F_NP 0 // nasal zero formant
#define F_NZ 0 // nasal zero formant
#define F1 1
#define F2 2
#define F3 3
#define F4 4
#define F5 5
#define F6 6
#define F_NZ 9 // nasal pole formant
#define F_NP 9 // nasal pole formant
typedef struct
@@ -135,4 +135,19 @@ typedef struct
} klatt_frame_t, *klatt_frame_ptr;
typedef struct {
int freq; // Hz
int bw; // klatt bandwidth
int ap; // parallel amplitude
int bp; // parallel bandwidth
DOUBLEX freq1; // floating point versions of the above
DOUBLEX bw1;
DOUBLEX ap1;
DOUBLEX bp1;
DOUBLEX freq_inc; // increment by this every 64 samples
DOUBLEX bw_inc;
DOUBLEX ap_inc;
DOUBLEX bp_inc;
} klatt_peaks_t;
+1 -1
View File
@@ -1248,7 +1248,7 @@ static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned
value = this_value = atoi(word);
ph_ordinal2[0] = 0;
if((tr->langopts.numbers & 0x10000) && (word[ix] == '.'))
if((tr->langopts.numbers & 0x10000) && (word[ix] == '.') && !isdigit(word[ix+2]))
{
// ordinal number is indicated by dot after the number
ordinal = 2;
+2 -2
View File
@@ -445,7 +445,7 @@ static void StopSpeak(int unused)
};
int optind;
static int optional_argument;
static const char *arg_opts = "afklpsvw"; // which options have arguments
static const char *arg_opts = "abfgklpsvw"; // which options have arguments
static char *opt_string="";
#define no_argument 0
#define required_argument 1
@@ -568,7 +568,7 @@ int main (int argc, char **argv)
#else
while(true)
{
c = getopt_long (argc, argv, "a:b:f:g:hk:l:p:qs:v:w:xXmz",
c = getopt_long (argc, argv, "a:b:f:g:hk:l:p:qs:v:w:xXmz", // NOTE: also change arg_opts to indicate which commands have a numeric value
long_options, &option_index);
/* Detect the end of the options. */
+1 -1
View File
@@ -523,7 +523,7 @@ void MarkerEvent(int type, unsigned int char_position, int value, unsigned char
ep->type = (espeak_EVENT_TYPE)type;
ep->unique_identifier = my_unique_identifier;
ep->user_data = my_user_data;
ep->text_position = char_position & 0xffff;
ep->text_position = char_position & 0xffffff;
ep->length = char_position >> 24;
time = (double(count_samples + mbrola_delay + (out_ptr - out_start)/2)*1000.0)/samplerate;
+47 -26
View File
@@ -61,7 +61,8 @@ static int default_freq[N_PEAKS] =
{200,500,1200,3000,3500,4000,6900,7800,9000};
static int default_width[N_PEAKS] =
{750,500,550,550,600,700,700,700,700};
static int default_klt_bw[N_PEAKS] =
{89,90,140,260,260,260,500,500,500};
float SpectTilt(int value, int freq)
{//=================================
@@ -113,8 +114,15 @@ SpectFrame::SpectFrame(SpectFrame *copy)
peaks[ix].pkheight = 0;
peaks[ix].pkwidth = default_width[ix];
peaks[ix].pkright = default_width[ix];
peaks[ix].klt_bw = default_klt_bw[ix];
peaks[ix].klt_ap = 0;
peaks[ix].klt_bp = default_klt_bw[ix];
}
memset(klatt_param, 0, sizeof(klatt_param));
klatt_param[KLATT_AV] = 59;
klatt_param[KLATT_Kopen] = 40;
if(copy != NULL)
{
*this = *copy;
@@ -133,11 +141,11 @@ SpectFrame::~SpectFrame()
int SpectFrame::Import(wxInputStream& stream1)
{//==========================================
// Import Pratt analysis data
int ix;
double x;
unsigned short *spect_data;
synthesizer_type = 0;
wxTextInputStream stream(stream1);
stream >> time;
@@ -274,13 +282,13 @@ int SpectFrame::ImportSPC2(wxInputStream& stream, float &time_acc)
int SpectFrame::Load(wxInputStream& stream, int synth_type)
{//========================================================
int SpectFrame::Load(wxInputStream& stream, int file_format_type)
{//==============================================================
int ix;
int x;
unsigned short *spect_data;
synthesizer_type = synth_type;
file_format = file_format_type;
wxDataInputStream s(stream);
time = s.ReadDouble();
@@ -291,6 +299,12 @@ int SpectFrame::Load(wxInputStream& stream, int synth_type)
markers = s.Read16();
amp_adjust = s.Read16();
if(file_format == 2)
{
s.Read16(); // spare
s.Read16(); // spare
}
for(ix=0; ix<N_PEAKS; ix++)
{
formants[ix].freq = s.Read16();
@@ -300,11 +314,18 @@ int SpectFrame::Load(wxInputStream& stream, int synth_type)
keyframe = 1;
peaks[ix].pkwidth = s.Read16();
peaks[ix].pkright = s.Read16();
if(file_format == 2)
{
peaks[ix].klt_bw = s.Read16();
peaks[ix].klt_ap = s.Read16();
peaks[ix].klt_bp = s.Read16();
}
}
if(synthesizer_type == 1)
if(file_format > 0)
{
for(ix=0; ix<N_KLATTP; ix++)
for(ix=0; ix<N_KLATTP2; ix++)
{
klatt_param[ix] = s.Read16();
}
@@ -344,6 +365,12 @@ int SpectFrame::Save(wxOutputStream& stream)
s.Write16(markers);
s.Write16(amp_adjust);
if(file_format == 2)
{
s.Write16(0); // spare
s.Write16(0); // spare
}
for(ix=0; ix<N_PEAKS; ix++)
{
s.Write16(formants[ix].freq);
@@ -353,11 +380,18 @@ int SpectFrame::Save(wxOutputStream& stream)
s.Write16(keyframe ? peaks[ix].pkheight : 0);
s.Write16(peaks[ix].pkwidth);
s.Write16(peaks[ix].pkright);
if(file_format == 2)
{
s.Write16(peaks[ix].klt_bw);
s.Write16(peaks[ix].klt_ap);
s.Write16(peaks[ix].klt_bp);
}
}
if(synthesizer_type == 1)
if(file_format > 0)
{
for(ix=0; ix<N_KLATTP; ix++)
for(ix=0; ix<N_KLATTP2; ix++)
{
s.Write16(klatt_param[ix]);
}
@@ -481,20 +515,9 @@ void SpectFrame::DrawPeaks(wxDC *dc, int offy, int frame_width, int seq_amplitud
if((pk->pkfreq == 0) || (pk->pkheight==0)) continue;
if(synthesizer_type==1)
{
if(peak==0) continue;
height = pk->pkheight + (64 * 64);
height = (500000/height) * 100;
pkright = pkwidth = pk->pkheight / 16;
}
else
{
height = pk->pkheight;
pkright = pk->pkright;
pkwidth = pk->pkwidth;
}
height = pk->pkheight;
pkright = pk->pkright;
pkwidth = pk->pkwidth;
x1 = (int)(pk->pkfreq*scale_x);
x2 = (int)((pk->pkfreq + pkright)*scale_x);
@@ -678,8 +701,6 @@ void SpectFrame::KlattDefaults()
int bw;
int bw3;
synthesizer_type = 1;
klatt_param[KLATT_AV] = 59;
klatt_param[KLATT_AVp] = 0;
klatt_param[KLATT_Fric] = 0;
@@ -689,7 +710,7 @@ void SpectFrame::KlattDefaults()
klatt_param[KLATT_Skew] = 0;
klatt_param[KLATT_Tilt] = 0;
klatt_param[KLATT_Kopen] = 40;
klatt_param[KLATT_spare1] = 0;
klatt_param[KLATT_FNZ] = 280;
bw = 60;
if(peaks[1].pkfreq < 400)
+22 -8
View File
@@ -48,11 +48,13 @@
#define T_SKEW 318
#define T_TILT 319
#define T_KOPEN 320
#define T_FNZ 321
#define FILEID1_SPECTSEQ 0x43455053
#define FILEID2_SPECTSEQ 0x51455354 // for eSpeak sequence
#define FILEID2_SPECTSEK 0x4b455354 // for Klatt sequence
#define FILEID2_SPECTSQ2 0x32515354 // with Klatt data
#define FILEID1_SPC2 0x32435053 // an old format for spectrum files
@@ -72,10 +74,20 @@ typedef struct {
} PitchEnvelope;
typedef struct {
short freq;
short bandw;
short freq;
short bandw;
} formant_t;
typedef struct {
short pkfreq;
short pkheight;
short pkwidth;
short pkright;
short klt_bw;
short klt_ap;
short klt_bp;
} peak_t;
//===============================================================================================
// Old "SPC2" format
@@ -122,7 +134,7 @@ public:
~SpectFrame();
int Import(wxInputStream &stream);
int ImportSPC2(wxInputStream &stream, float &time_acc);
int Load(wxInputStream &stream, int synthesizer_type);
int Load(wxInputStream &stream, int file_format_type);
int Save(wxOutputStream &stream);
void Draw(wxDC &dc, int offy, int frame_width, double scalex, double scaley);
@@ -149,10 +161,10 @@ public:
int nx;
int markers;
int max_y;
int synthesizer_type; // 0=eSpeak, 1=Klatt
int file_format; // 0=eSpeak, 1=Klatt, 2=eSpeak+Klatt
USHORT *spect; // sqrt of harmonic amplitudes, 1-nx at 'pitch'
short klatt_param[N_KLATTP];
short klatt_param[N_KLATTP2];
formant_t formants[N_PEAKS]; // this is just the estimate given by Praat
peak_t peaks[N_PEAKS];
@@ -187,7 +199,6 @@ public:
float GetKeyedLength();
void SetFrameLengths();
void ConstructVowel(void);
void SetKlattDefaults(void);
int numframes;
int amplitude;
@@ -203,7 +214,7 @@ public:
int bass_reduction;
int max_x;
int max_y;
int synthesizer_type;
int file_format;
private:
@@ -281,6 +292,7 @@ class FormantDlg : public wxPanel
public:
FormantDlg(wxWindow *parent);
void ShowFrame(SpectSeq *spectseq, int frame, int pk, int field);
void GetValues(SpectSeq *spectseq, int frame);
void OnCommand(wxCommandEvent& event);
void OnSpin(wxSpinEvent& event);
void HideFields(int synth_type);
@@ -304,7 +316,9 @@ class FormantDlg : public wxPanel
wxTextCtrl *t_pkfreq[N_PEAKS];
wxTextCtrl *t_pkheight[N_PEAKS];
wxTextCtrl *t_pkwidth[N_PEAKS];
wxTextCtrl *t_pkright[N_PEAKS];
wxTextCtrl *t_klt_bw[N_PEAKS];
wxTextCtrl *t_klt_ap[N_PEAKS];
wxTextCtrl *t_klt_bp[N_PEAKS];
wxRadioButton *t_select_peak[N_PEAKS];
wxButton *t_zoomout;
+33 -33
View File
@@ -253,7 +253,7 @@ void SpectDisplay::RefreshDialogValues(int type)
sf->amp_adjust = formantdlg->t_ampframe->GetValue();
sf->length_adjust = formantdlg->t_timeframe->GetValue() - spectseq->GetFrameLength(sframe,0,NULL);
for(ix=0; ix<9; ix++)
for(ix=0; ix < N_KLATTP; ix++)
{
sf->klatt_param[ix] = formantdlg->s_klatt[ix]->GetValue();
}
@@ -550,6 +550,7 @@ void SpectDisplay::OnKey(wxKeyEvent& event)
case WXK_NEXT:
if(sframe < spectseq->numframes-1)
{
formantdlg->GetValues(spectseq, sframe);
spectseq->SelectAll(0);
sframe++;
spectseq->frames[sframe]->selected = 1;
@@ -560,6 +561,7 @@ void SpectDisplay::OnKey(wxKeyEvent& event)
case WXK_PRIOR:
if(sframe > 0)
{
formantdlg->GetValues(spectseq, sframe);
spectseq->SelectAll(0);
sframe--;
spectseq->frames[sframe]->selected = 1;
@@ -633,14 +635,15 @@ void SpectDisplay::OnKey(wxKeyEvent& event)
if(event.ControlDown())
{
// CTRL, rotate, make right slope steeper
if(spectseq->synthesizer_type==0)
if(pk_num < 3)
{
pk->pkright-= 5;
pk->pkwidth += 5;
pk->pkwidth += 5;
}
}
else
{
if(spectseq->synthesizer_type==0)
pk->pkright -= 10;
pk->pkright -= 10;
pk->pkwidth -= 10;
if(pk->pkright < 0)
pk->pkright = 0;
@@ -655,14 +658,15 @@ void SpectDisplay::OnKey(wxKeyEvent& event)
if(event.ControlDown())
{
// CTRL: rotate, make left slope steeper
if(spectseq->synthesizer_type==0)
if(pk_num < 3)
{
pk->pkright += 5;
pk->pkwidth -= 5;
pk->pkwidth -= 5;
}
}
else
{
if(spectseq->synthesizer_type==0)
pk->pkright += 10;
pk->pkright += 10;
pk->pkwidth += 10;
}
field = 4;
@@ -670,8 +674,7 @@ void SpectDisplay::OnKey(wxKeyEvent& event)
break;
case '<': // width--
if(spectseq->synthesizer_type==0)
pk->pkright -= 2;
pk->pkright -= 2;
pk->pkwidth -= 2;
if(pk->pkwidth < 0)
pk->pkwidth = 0;
@@ -680,8 +683,7 @@ void SpectDisplay::OnKey(wxKeyEvent& event)
break;
case '>': // width++
if(spectseq->synthesizer_type==0)
pk->pkright += 2;
pk->pkright += 2;
pk->pkwidth += 2;
display = 1;
field = 4;
@@ -744,8 +746,8 @@ void SpectDisplay::OnKey(wxKeyEvent& event)
break;
case 0x104b: // CTRL-K
spectseq->SetKlattDefaults();
display = 3;
// spectseq->SetKlattDefaults();
// display = 3;
break;
case 0x104d: // CTRL-M
@@ -865,28 +867,25 @@ void SpectDisplay::OnKey(wxKeyEvent& event)
sf = spectseq->frames[sframe];
pk = &sf->peaks[pk_num];
if(spectseq->synthesizer_type==0)
{
if(pk->pkwidth < 50) pk->pkwidth = 50; // min. width
if(pk->pkright < 50) pk->pkright = 50;
if(pk->pkwidth < 50) pk->pkwidth = 50; // min. width
if(pk->pkright < 50) pk->pkright = 50;
// ensure minimum separation between peaks & prevent crossover
if(direction > 0)
// ensure minimum separation between peaks & prevent crossover
if(direction > 0)
{
for(i=pk_num+1; i<N_PEAKS; i++)
{
for(i=pk_num+1; i<N_PEAKS; i++)
{
if(sf->peaks[i].pkfreq < sf->peaks[i-1].pkfreq + 100)
sf->peaks[i].pkfreq = sf->peaks[i-1].pkfreq + 100;
}
if(sf->peaks[i].pkfreq < sf->peaks[i-1].pkfreq + 100)
sf->peaks[i].pkfreq = sf->peaks[i-1].pkfreq + 100;
}
else
if(direction < 0)
}
else
if(direction < 0)
{
for(i=pk_num-1; i>=0; i--)
{
for(i=pk_num-1; i>=0; i--)
{
if(sf->peaks[i].pkfreq > sf->peaks[i+1].pkfreq - 100)
sf->peaks[i].pkfreq = sf->peaks[i+1].pkfreq - 100;
}
if(sf->peaks[i].pkfreq > sf->peaks[i+1].pkfreq - 100)
sf->peaks[i].pkfreq = sf->peaks[i+1].pkfreq - 100;
}
}
@@ -957,6 +956,7 @@ void SpectDisplay::OnMouse(wxMouseEvent& event)
if(frame < spectseq->numframes)
{
formantdlg->GetValues(spectseq,sframe);
if(sframe != frame)
formantdlg->ShowFrame(spectseq,frame,pk_num,0xff);
+31 -64
View File
@@ -147,7 +147,7 @@ SpectSeq::SpectSeq(int n)
max_x = 3000;
max_y = 1;
synthesizer_type = 0;
file_format = 0;
}
SpectSeq::~SpectSeq()
@@ -391,7 +391,7 @@ void SpectSeq::Load2(wxInputStream& stream, int import, int n)
}
else
{
if(frame->Load(stream, synthesizer_type) != 0) break;
if(frame->Load(stream, file_format) != 0) break;
}
frames[numframes++] = frame;
@@ -424,6 +424,7 @@ else
int SpectSeq::Import(wxInputStream& stream)
{//========================================
// Import data from Pratt analysis
int n = 0;
@@ -509,12 +510,17 @@ int SpectSeq::Load(wxInputStream & stream)
else
if((id1 == FILEID1_SPECTSEQ) && (id2 == FILEID2_SPECTSEQ))
{
synthesizer_type = 0; // eSpeak formants
file_format = 0; // eSpeak formants
}
else
if((id1 == FILEID1_SPECTSEQ) && (id2 == FILEID2_SPECTSEK))
{
synthesizer_type = 1; // formants for Klatt synthesizer
file_format = 1; // formants for Klatt synthesizer
}
else
if((id1 == FILEID1_SPECTSEQ) && (id2 == FILEID2_SPECTSQ2))
{
file_format = 2; // formants for Klatt synthesizer
}
else
{
@@ -554,7 +560,9 @@ int SpectSeq::Save(wxOutputStream &stream, int selection)
wxDataOutputStream s(stream);
s.Write32(FILEID1_SPECTSEQ);
if(synthesizer_type == 1)
if(file_format == 2)
s.Write32(FILEID2_SPECTSQ2);
if(file_format == 1)
s.Write32(FILEID2_SPECTSEK);
else
s.Write32(FILEID2_SPECTSEQ);
@@ -576,24 +584,6 @@ int SpectSeq::Save(wxOutputStream &stream, int selection)
void SpectSeq::SetKlattDefaults(void)
{//==================================
int ix;
synthesizer_type = 1;
for(ix=0; ix<numframes; ix++)
{
if(frames[ix]->keyframe)
{
frames[ix]->KlattDefaults();
}
frames[ix]->synthesizer_type = 1;
}
}
void SpectSeq::ConstructVowel(void)
{//================================
@@ -924,13 +914,10 @@ void SpectSeq::ApplyAmp_adjust(SpectFrame *sp, peak_t *peaks)
memcpy(peaks,sp->peaks,sizeof(*peaks)*N_PEAKS);
if(synthesizer_type == 0)
for(ix=0; ix<N_PEAKS; ix++)
{
for(ix=0; ix<N_PEAKS; ix++)
{
y = peaks[ix].pkheight * sp->amp_adjust * amplitude;
peaks[ix].pkheight = y / 10000;
}
y = peaks[ix].pkheight * sp->amp_adjust * amplitude;
peaks[ix].pkheight = y / 10000;
}
} // end of ApplyAmp_adjust
@@ -939,44 +926,26 @@ void SpectSeq::ApplyAmp_adjust(SpectFrame *sp, peak_t *peaks)
void PeaksToFrame(SpectFrame *sp1, peak_t *pks, frame_t *fr)
{//=========================================================
int ix;
int x, x2;
int x;
for(ix=0; ix<N_PEAKS; ix++)
for(ix=0; ix < 8; ix++)
{
fr->ffreq[ix] = pks[ix].pkfreq;
if(sp1->synthesizer_type==0)
{
x = pks[ix].pkheight >> 6;
}
else
{
x = pks[ix].pkheight >> 7;
fr->fwidth6 = pks[6].pkwidth >> 1;
fr->fright6 = pks[6].pkright;
}
if(x > 255)
x = 255;
fr->fheight[ix] = x;
if(ix < 7)
fr->ffreq[ix] = pks[ix].pkfreq;
fr->fheight[ix] = pks[ix].pkheight >> 6;
if(ix < 6)
{
x = pks[ix].pkwidth/2;
x2 = pks[ix].pkright;
if(sp1->synthesizer_type == 0)
{
x /= 2;
x2 /= 4;
}
if(x > 255)
if((x = (pks[ix].pkwidth >> 2)) > 255)
x = 255;
fr->fwidth[ix] = x;
if(x2 > 255)
x2 = 255;
fr->fright[ix] = x2;
if(ix < 3)
{
if((x = (pks[ix].pkright >> 2)) > 255)
x = 255;
fr->fright[ix] = x;
}
}
}
@@ -994,11 +963,7 @@ static void SetSynth_mS(int length_mS, SpectFrame *sp1, SpectFrame *sp2, peak_t
PeaksToFrame(sp2,pks2,&fr2);
#ifdef KLATT_TEST
if(sp1->synthesizer_type == 1)
{
SetSynth_Klatt((length_mS * samplerate) / 1000, 0, &fr1, &fr2, voice, control); // convert mS to samples
}
else
// SetSynth_Klatt((length_mS * samplerate) / 1000, 0, &fr1, &fr2, voice, control); // convert mS to samples
#endif
{
SetSynth((length_mS * samplerate) / 1000, 0, &fr1, &fr2, voice); // convert mS to samples
@@ -1025,6 +990,7 @@ void SpectSeq::MakeWave(int start, int end, PitchEnvelope &pitch)
peak_t peaks0[N_PEAKS];
peak_t peaks1[N_PEAKS];
peak_t peaks2[N_PEAKS];
int synthesizer_type = 0;
#ifdef KLATT_TEST
KlattInit();
@@ -1158,6 +1124,7 @@ void SpectFrame::MakeWaveF(int control, PitchEnvelope &pitche, int amplitude, in
int ipitch;
int pbase;
char *fname_speech;
int synthesizer_type = 0;
#ifdef KLATT_TEST
KlattInit();
+1 -1
View File
@@ -21,7 +21,7 @@
#include <sys/types.h>
// conditional compilation options
//#define INCLUDE_KLATT
#define INCLUDE_KLATT
#if defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN
#define ARCH_BIG
+2 -2
View File
@@ -35,8 +35,8 @@
#include "translate.h"
#include "wave.h"
const char *version_string = "1.40.13 5.Apr.09";
const int version_phdata = 0x014000;
const char *version_string = "1.40.21 29.May.09";
const int version_phdata = 0x014015;
int option_device_number = -1;
+11 -13
View File
@@ -353,7 +353,7 @@ static void set_frame_rms(frame_t *fr, int new_rms)
849,851,853,856,858,861,863,865,868,870,872,875,877,879,882,884,
886,889,891,893,896,898,900,902};
if(fr->frflags & FRFLAG_KLATT)
if(voice->klattv[0])
{
if(new_rms == -1)
{
@@ -368,7 +368,7 @@ static void set_frame_rms(frame_t *fr, int new_rms)
x = sqrt_tab[x]; // sqrt(new_rms/fr->rms)*0x200;
for(ix=0; ix<N_PEAKS; ix++)
for(ix=0; ix < 8; ix++)
{
h = fr->fheight[ix] * x;
fr->fheight[ix] = h/0x200;
@@ -383,10 +383,10 @@ static void formants_reduce_hf(frame_t *fr, int level)
int ix;
int x;
if(fr->frflags & FRFLAG_KLATT)
if(voice->klattv[0])
return;
for(ix=2; ix<N_PEAKS; ix++)
for(ix=2; ix < 8; ix++)
{
x = fr->fheight[ix] * level;
fr->fheight[ix] = x/100;
@@ -551,7 +551,7 @@ static short vcolouring[N_VCOLOUR][5] = {
next_rms = seq[1].frame->rms;
if(fr->frflags & FRFLAG_KLATT)
if(voice->klattv[0])
{
fr->klattp[KLATT_AV] = 53; // reduce the amplituide of the start of a vowel
}
@@ -676,9 +676,6 @@ static void SmoothSpect(void)
q = wcmdq[syllable_centre];
frame_centre = (frame_t *)q[2];
//if(frame_centre->frflags & FRFLAG_KLATT)
// return; // TESTING
// backwards
ix = syllable_centre -1;
frame = frame2 = frame_centre;
@@ -911,7 +908,7 @@ if(which==1)
frame1 = frames[0].frame;
frame1_length = frames[0].length;
if(frame1->frflags & FRFLAG_KLATT)
if(voice->klattv[0])
wcmd_spect = WCMD_KLATT;
if(wavefile_ix == 0)
@@ -920,14 +917,14 @@ if(which==1)
{
// cancel any wavefile that was playing previously
wcmd_spect = WCMD_SPECT2;
if(frame1->frflags & FRFLAG_KLATT)
if(voice->klattv[0])
wcmd_spect = WCMD_KLATT2;
wave_flag = 0;
}
else
{
wcmd_spect = WCMD_SPECT;
if(frame1->frflags & FRFLAG_KLATT)
if(voice->klattv[0])
wcmd_spect = WCMD_KLATT;
}
}
@@ -944,9 +941,10 @@ if(which==1)
{
// but flag indicates keep HF peaks in last segment
fr = CopyFrame(frame1,1);
for(ix=3; ix<N_PEAKS; ix++)
for(ix=3; ix < 8; ix++)
{
fr->ffreq[ix] = last_frame->ffreq[ix];
if(ix < 7)
fr->ffreq[ix] = last_frame->ffreq[ix];
fr->fheight[ix] = last_frame->fheight[ix];
}
wcmdq[last_wcmdq][3] = (long)fr;
+42 -27
View File
@@ -70,25 +70,52 @@ extern int embedded_default[N_EMBEDDED_VALUES];
#define N_PEAKS 9
#define N_MARKERS 8
typedef struct {
short pkfreq;
short pkheight;
short pkwidth;
short pkright;
} peak_t;
#define N_KLATTP 10 // this affects the phoneme data file format
#define N_KLATTP2 14 // used in vowel files, with extra parameters for future extensions
#define KLATT_AV 0
#define KLATT_Kopen 1
#define KLATT_Skew 2
#define KLATT_Tilt 3
#define KLATT_Turb 4
#define KLATT_Aspr 5
#define KLATT_AVp 6 // this is after the parameters which can be change by the Voice
#define KLATT_FNZ 1 // nasal zero freq
#define KLATT_Tilt 2
#define KLATT_Aspr 3
#define KLATT_Skew 4
#define KLATT_Kopen 5
#define KLATT_AVp 6
#define KLATT_Fric 7
#define KLATT_FricBP 8
#define KLATT_spare1 9
#define KLATT_Turb 9
typedef struct { // 44 bytes
short frflags;
short ffreq[7];
unsigned char length;
unsigned char rms;
unsigned char fheight[8];
unsigned char fwidth[6]; // width/4 f0-5
unsigned char fright[3]; // width/4 f0-2
unsigned char bw[4]; // Klatt bandwidth BNZ /2, f1,f2,f3
unsigned char klattp[5]; // AV, FNZ, Tilt, Aspr, Skew
unsigned char klattp2[5]; // continuation of klattp[], Avp, Fric, FricBP, Turb
unsigned char klatt_ap[7]; // Klatt parallel amplitude
unsigned char klatt_bp[7]; // Klatt parallel bandwidth /2
} frame_t; // with extra Klatt parameters for parallel resonators
typedef struct { // 44 bytes
short frflags;
short ffreq[7];
unsigned char length;
unsigned char rms;
unsigned char fheight[8];
unsigned char fwidth[6]; // width/4 f0-5
unsigned char fright[3]; // width/4 f0-2
unsigned char bw[4]; // Klatt bandwidth BNZ /2, f1,f2,f3
unsigned char klattp[5]; // AV, FNZ, Tilt, Aspr, Skew
} frame_t2; // TESTING
#ifdef deleted
typedef struct {
short frflags;
unsigned char length;
@@ -110,19 +137,7 @@ typedef struct { // 43 bytes
unsigned char fwidth[6]; // width/4
unsigned char fright[6]; // width/4
} frame_t2; // the original, without Klatt additions, used for file "phondata"
typedef struct { // 44 bytes
short frflags;
short ffreq[7];
unsigned char length;
unsigned char rms;
unsigned char fheight[8];
unsigned char fwidth[6]; // width/4 f0-5
unsigned char fright[3]; // width/4 f0-2
unsigned char bw[4]; // Klatt bandwidth BNZ, f1,f2,f3
unsigned char klattp[5]; // AV, FNZ, Tilt, spare, spare (Aspr, Skew ?)
} frame_t3; // TESTING
#endif
+10 -3
View File
@@ -39,6 +39,7 @@
#define L_qa 0x716100
#define L_grc 0x677263 // grc Ancient Greek
#define L_jbo 0x6a626f // jbo Lojban
#define L_pap 0x706170 // pap Papiamento
#define L_zhy 0x7a6879 // zhy
// start of unicode pages for character sets
@@ -318,7 +319,7 @@ Translator *SelectTranslator(const char *name)
tr->langopts.stress_rule = 0;
SetLetterVowel(tr,'y');
// tr->langopts.numbers = 0x11849;
tr->langopts.numbers = 0x10c59;
}
break;
@@ -415,6 +416,7 @@ Translator *SelectTranslator(const char *name)
case L('e','s'): // Spanish
case L('c','a'): // Catalan
case L_pap: // Papiamento
{
static const short stress_lengths_es[8] = {180, 210, 190, 190, 0, 0, 230, 260};
// static const short stress_lengths_es[8] = {170, 200, 180, 180, 0, 0, 220, 250};
@@ -440,6 +442,11 @@ Translator *SelectTranslator(const char *name)
tr->punct_within_word = ca_punct_within_word;
tr->langopts.stress_flags = 0x200 | 0x6 | 0x30; // stress last syllable unless word ends with a vowel
}
else
if(name2 == L_pap)
{
tr->langopts.stress_flags = 0x100 | 0x6 | 0x30; // stress last syllable unless word ends with a vowel
}
}
break;
@@ -467,9 +474,9 @@ Translator *SelectTranslator(const char *name)
tr->langopts.param[LOPT_IT_DOUBLING] = 1;
tr->langopts.long_stop = 130;
tr->langopts.numbers = 0x1809;
tr->langopts.numbers = 0x1009;
SetLetterVowel(tr,'y');
tr->langopts.max_initial_consonants = 2;
// tr->langopts.max_initial_consonants = 2; // BUT foreign words may have 3
tr->langopts.spelling_stress = 1;
tr->langopts.intonation_group = 3; // less intonation, don't raise pitch at comma
}
+2 -2
View File
@@ -278,9 +278,9 @@ TranslDlg::TranslDlg(wxWindow *parent) : wxPanel(parent)
{//=====================================================
t_source = new wxTextCtrl(this,T_SOURCE,_T(""),wxPoint(0,4),
wxSize(204,250),wxTE_MULTILINE);
wxSize(298,250),wxTE_MULTILINE);
t_phonetic = new wxTextCtrl(this,T_PHONETIC,_T(""),wxPoint(0,262),
wxSize(204,350),wxTE_MULTILINE);
wxSize(298,350),wxTE_MULTILINE);
t_translate = new wxButton(this,T_TRANSLATE,_T("Translate"),wxPoint(4,620));
t_translate = new wxButton(this,T_RULES,_T("Show Rules"),wxPoint(4,652));
+4 -3
View File
@@ -366,7 +366,7 @@ void VoiceReset(int tone_only)
// Set voice to the default values
int pk;
static unsigned char default_heights[N_PEAKS] = {255,255,240,240,220,220,255,255,255};
static unsigned char default_heights[N_PEAKS] = {128,128,120,120,110,110,128,128,128};
static unsigned char default_widths[N_PEAKS] = {128,128,128,160,171,171,128,128,128};
static int breath_widths[N_PEAKS] = {0,200,200,400,400,400,600,600,600};
@@ -400,7 +400,7 @@ void VoiceReset(int tone_only)
for(pk=0; pk<N_PEAKS; pk++)
{
voice->freq[pk] = 256;
voice->height[pk] = default_heights[pk];
voice->height[pk] = default_heights[pk]*2;
voice->width[pk] = default_widths[pk]*2;
voice->breath[pk] = 0;
voice->breathw[pk] = breath_widths[pk]; // default breath formant woidths
@@ -839,7 +839,7 @@ voice_t *LoadVoice(const char *vname, int control)
case V_TONE:
{
int tone_data[10];
int tone_data[12];
ReadTonePoints(p,tone_data);
SetToneAdjust(voice,tone_data);
}
@@ -880,6 +880,7 @@ voice_t *LoadVoice(const char *vname, int control)
break;
case V_KLATT:
voice->klattv[0] = 1; // default source: IMPULSIVE
Read8Numbers(p,voice->klattv);
voice->klattv[KLATT_Kopen] -= 40;
break;
+38 -14
View File
@@ -988,14 +988,24 @@ static void AdvanceParameters()
peaks[ix].height = 0;
peaks[ix].left1 += peaks[ix].left_inc;
peaks[ix].left = int(peaks[ix].left1);
peaks[ix].right1 += peaks[ix].right_inc;
peaks[ix].right = int(peaks[ix].right1);
if(ix < 3)
{
peaks[ix].right1 += peaks[ix].right_inc;
peaks[ix].right = int(peaks[ix].right1);
}
else
{
peaks[ix].right = peaks[ix].left;
}
}
for(;ix < N_PEAKS; ix++)
for(;ix < 8; ix++)
{
// formants 6,7,8 don't have a width parameter
peaks[ix].freq1 += peaks[ix].freq_inc;
peaks[ix].freq = int(peaks[ix].freq1);
if(ix < 7)
{
peaks[ix].freq1 += peaks[ix].freq_inc;
peaks[ix].freq = int(peaks[ix].freq1);
}
peaks[ix].height1 += peaks[ix].height_inc;
if((peaks[ix].height = int(peaks[ix].height1)) < 0)
peaks[ix].height = 0;
@@ -1732,12 +1742,19 @@ if(option_log_frames)
nsamples += length2;
length4 = length2/4;
for(ix=0; ix<N_PEAKS; ix++)
peaks[7].freq = (7800 * v->freq[7] + v->freqadd[7]*256) << 8;
peaks[8].freq = (9000 * v->freq[8] + v->freqadd[8]*256) << 8;
for(ix=0; ix < 8; ix++)
{
peaks[ix].freq1 = (fr1->ffreq[ix] * v->freq[ix] + v->freqadd[ix]*256) << 8;
peaks[ix].freq = int(peaks[ix].freq1);
next = (fr2->ffreq[ix] * v->freq[ix] + v->freqadd[ix]*256) << 8;
peaks[ix].freq_inc = ((next - peaks[ix].freq1) * (STEPSIZE/4)) / length4; // lower headroom for fixed point math
if(ix < 7)
{
peaks[ix].freq1 = (fr1->ffreq[ix] * v->freq[ix] + v->freqadd[ix]*256) << 8;
peaks[ix].freq = int(peaks[ix].freq1);
next = (fr2->ffreq[ix] * v->freq[ix] + v->freqadd[ix]*256) << 8;
peaks[ix].freq_inc = ((next - peaks[ix].freq1) * (STEPSIZE/4)) / length4; // lower headroom for fixed point math
}
peaks[ix].height1 = (fr1->fheight[ix] * v->height[ix]) << 6;
peaks[ix].height = int(peaks[ix].height1);
@@ -1751,10 +1768,17 @@ if(option_log_frames)
next = (fr2->fwidth[ix] * v->width[ix]) << 10;
peaks[ix].left_inc = ((next - peaks[ix].left1) * STEPSIZE) / length2;
peaks[ix].right1 = (fr1->fright[ix] * v->width[ix]) << 10;
peaks[ix].right = int(peaks[ix].right1);
next = (fr2->fright[ix] * v->width[ix]) << 10;
peaks[ix].right_inc = ((next - peaks[ix].right1) * STEPSIZE) / length2;
if(ix < 3)
{
peaks[ix].right1 = (fr1->fright[ix] * v->width[ix]) << 10;
peaks[ix].right = int(peaks[ix].right1);
next = (fr2->fright[ix] * v->width[ix]) << 10;
peaks[ix].right_inc = ((next - peaks[ix].right1) * STEPSIZE) / length2;
}
else
{
peaks[ix].right = peaks[ix].left;
}
}
}
} // end of SetSynth