git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@234 d46cf337-b52f-0410-862d-fd96e6ae7743master
c2 = c3 << 24; | c2 = c3 << 24; | ||||
c2 = c2 >> 16; // sign extend | c2 = c2 >> 16; // sign extend | ||||
sample = (c1 & 0xff) + c2;; | |||||
sample = (c1 & 0xff) + c2; | |||||
if(sample > max) | if(sample > max) | ||||
max = sample; | max = sample; | ||||
if(f_phused != NULL) | if(f_phused != NULL) | ||||
fclose(f_phused); | fclose(f_phused); | ||||
LoadVoice(save_voice_name,1); | |||||
LoadVoiceVariant(save_voice_name,0); | |||||
if(errors == 0) | if(errors == 0) | ||||
return(wxString::Format(_T(" Compiled %d dictionaries"),dict_count)); | return(wxString::Format(_T(" Compiled %d dictionaries"),dict_count)); |
} | } | ||||
} | } | ||||
for(ix=1; ix < 6; ix++) | |||||
for(ix=1; ix < 7; ix++) | |||||
{ | { | ||||
if(ix < 3) | |||||
if(ix < 4) | |||||
{ | { | ||||
num = 0; | num = 0; | ||||
value = t_klt_bw[ix]->GetValue(); | value = t_klt_bw[ix]->GetValue(); |
flutter(frame); /* add f0 flutter */ | flutter(frame); /* add f0 flutter */ | ||||
#ifdef deleted | |||||
#ifdef LOG_FRAMES | |||||
if(option_log_frames) | |||||
{ | { | ||||
FILE *f; | FILE *f; | ||||
f=fopen("klatt_log","a"); | |||||
fprintf(f,"%4dhz %2dAV %4d %3d, %4d %3d, %4d %3d, %4d %3d, %4d, %3d, %4d %3d TLT=%2d\n",frame->F0hz10,frame->AVdb, | |||||
frame->F1hz,frame->B1hz,frame->F2hz,frame->B2hz,frame->F3hz,frame->B3hz,frame->F4hz,frame->B4hz,frame->F5hz,frame->B5hz,frame->F6hz,frame->B6hz,frame->TLTdb); | |||||
f=fopen("log-klatt","a"); | |||||
fprintf(f,"%4dhz %2dAV %4d %3d, %4d %3d, %4d %3d, %4d %3d, %4d, %3d, FNZ=%3d TLT=%2d\n",frame->F0hz10,frame->AVdb, | |||||
frame->Fhz[1],frame->Bhz[1],frame->Fhz[2],frame->Bhz[2],frame->Fhz[3],frame->Bhz[3],frame->Fhz[4],frame->Bhz[4],frame->Fhz[5],frame->Bhz[5],frame->Fhz[0],frame->TLTdb); | |||||
fclose(f); | fclose(f); | ||||
} | } | ||||
#endif | #endif | ||||
temp = 32767.0; | temp = 32767.0; | ||||
} | } | ||||
*out_ptr++ = int(temp); // **JSD | |||||
*out_ptr++ = int(temp); | |||||
*out_ptr++ = int(temp) >> 8; | *out_ptr++ = int(temp) >> 8; | ||||
sample_count++; | sample_count++; | ||||
if(out_ptr >= out_end) | if(out_ptr >= out_end) | ||||
static void reset_resonators() | static void reset_resonators() | ||||
{ | { | ||||
int r_ix; | int r_ix; | ||||
#ifdef LOG_FRAMES | |||||
if(option_log_frames) | |||||
{ | |||||
FILE *f_log; | |||||
f_log=fopen("log-klatt","a"); | |||||
if(f_log != NULL) | |||||
{ | |||||
fprintf(f_log,"Reset\n"); | |||||
fclose(f_log); | |||||
} | |||||
} | |||||
#endif | |||||
for(r_ix=0; r_ix < N_RSN; r_ix++) | |||||
for(r_ix=0; r_ix <= R6p; r_ix++) | |||||
{ | { | ||||
kt_globals.rsn[r_ix].p1 = 0; | kt_globals.rsn[r_ix].p1 = 0; | ||||
kt_globals.rsn[r_ix].p2 = 0; | kt_globals.rsn[r_ix].p2 = 0; | ||||
} | } | ||||
} | } | ||||
static void parwave_init() | |||||
void KlattReset() | |||||
{ | { | ||||
kt_globals.FLPhz = (950 * kt_globals.samrate) / 10000; | kt_globals.FLPhz = (950 * kt_globals.samrate) / 10000; | ||||
kt_globals.BLPhz = (630 * kt_globals.samrate) / 10000; | kt_globals.BLPhz = (630 * kt_globals.samrate) / 10000; | ||||
kt_globals.amp_gain0 = DBtoLIN(Gain0_tmp) / kt_globals.scale_wav; | kt_globals.amp_gain0 = DBtoLIN(Gain0_tmp) / kt_globals.scale_wav; | ||||
/* Set coefficients of variable cascade resonators */ | /* Set coefficients of variable cascade resonators */ | ||||
for(ix=0; ix<=8; ix++) | |||||
for(ix=1; ix<=9; ix++) | |||||
{ | { | ||||
// formants 1 to 8, plus nasal pole | // formants 1 to 8, plus nasal pole | ||||
setabc(frame->Fhz[ix],frame->Bhz[ix],&(kt_globals.rsn[ix])); | setabc(frame->Fhz[ix],frame->Bhz[ix],&(kt_globals.rsn[ix])); | ||||
} | } | ||||
} | } | ||||
#ifdef LOG_FRAMES | |||||
if(option_log_frames) | |||||
{ | { | ||||
//FILE *f; | |||||
//f=fopen("klatt_log","a"); | |||||
//fprintf(f,"len %4d (%3d %4d %4d) (%3d %4d %4d)\n",length,fr1->ffreq[1],fr1->ffreq[2],fr1->ffreq[3],fr2->ffreq[1],fr2->ffreq[2],fr2->ffreq[3]); | |||||
//fclose(f); | |||||
FILE *f_log; | |||||
f_log=fopen("log-espeakedit","a"); | |||||
if(f_log != NULL) | |||||
{ | |||||
fprintf(f_log,"K %3dmS %3d %3d %4d %4d %4d %4d (%2d) to %3d %3d %4d %4d %4d %4d (%2d)\n",length*1000/samplerate, | |||||
fr1->klattp[KLATT_FNZ]*2,fr1->ffreq[1],fr1->ffreq[2],fr1->ffreq[3],fr1->ffreq[4],fr1->ffreq[5], fr1->klattp[KLATT_AV], | |||||
fr2->klattp[KLATT_FNZ]*2,fr2->ffreq[1],fr2->ffreq[2],fr2->ffreq[3],fr1->ffreq[4],fr1->ffreq[5], fr2->klattp[KLATT_AV] ); | |||||
fclose(f_log); | |||||
} | |||||
f_log=fopen("log-klatt","a"); | |||||
if(f_log != NULL) | |||||
{ | |||||
fprintf(f_log,"K %3dmS %3d %3d %4d %4d (%2d) to %3d %3d %4d %4d (%2d)\n",length*1000/samplerate, | |||||
fr1->klattp[KLATT_FNZ]*2,fr1->ffreq[1],fr1->ffreq[2],fr1->ffreq[3], fr1->klattp[KLATT_AV], | |||||
fr2->klattp[KLATT_FNZ]*2,fr2->ffreq[1],fr2->ffreq[2],fr2->ffreq[3], fr2->klattp[KLATT_AV] ); | |||||
fclose(f_log); | |||||
} | |||||
} | } | ||||
#endif | |||||
if(control & 1) | if(control & 1) | ||||
{ | { | ||||
{ | { | ||||
// A break, not following on from another synthesized sound. | // A break, not following on from another synthesized sound. | ||||
// Reset the synthesizer | // Reset the synthesizer | ||||
//reset_resonators(&kt_globals); | |||||
parwave_init(); | |||||
KlattReset(); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
if((prev_fr.ffreq[1] != fr1->ffreq[1]) || (prev_fr.ffreq[2] != fr1->ffreq[2])) | |||||
for(ix=1; ix<6; ix++) | |||||
{ | { | ||||
// fade out to avoid a click, but only up to the end of output buffer | |||||
ix = (out_end - out_ptr)/2; | |||||
if(ix > 64) | |||||
ix = 64; | |||||
kt_globals.fadeout = ix; | |||||
kt_globals.nspfr = ix; | |||||
parwave(&kt_frame); | |||||
//reset_resonators(&kt_globals); | |||||
parwave_init(); | |||||
if(prev_fr.ffreq[ix] != fr1->ffreq[ix]) | |||||
{ | |||||
// Discontinuity in formants. | |||||
// fade out to avoid a click, but only up to the end of output buffer | |||||
ix = (out_end - out_ptr)/2; | |||||
if(ix > 64) | |||||
ix = 64; | |||||
kt_globals.fadeout = ix; | |||||
kt_globals.nspfr = ix; | |||||
parwave(&kt_frame); | |||||
reset_resonators(); | |||||
break; | |||||
} | |||||
} | } | ||||
} | } | ||||
wdata.prev_was_synth = 1; | wdata.prev_was_synth = 1; | ||||
// nasal zero frequency | // nasal zero frequency | ||||
peaks[0].freq1 = fr1->klattp[KLATT_FNZ] * 2; | peaks[0].freq1 = fr1->klattp[KLATT_FNZ] * 2; | ||||
if(peaks[0].freq1 == 0) | |||||
peaks[0].freq1 = kt_frame.Fhz[F_NP]; // if no nasal zero, set it to same freq as nasal pole | |||||
peaks[0].freq = int(peaks[0].freq1); | peaks[0].freq = int(peaks[0].freq1); | ||||
next = fr2->klattp[KLATT_FNZ] * 2; | next = fr2->klattp[KLATT_FNZ] * 2; | ||||
if(next == 0) | |||||
next = kt_frame.Fhz[F_NP]; | |||||
peaks[0].freq_inc = ((next - peaks[0].freq1) * STEPSIZE) / length; | peaks[0].freq_inc = ((next - peaks[0].freq1) * STEPSIZE) / length; | ||||
peaks[0].bw1 = 89; | peaks[0].bw1 = 89; | ||||
kt_globals.outsl = 0; | kt_globals.outsl = 0; | ||||
kt_globals.f0_flutter = 20; | kt_globals.f0_flutter = 20; | ||||
parwave_init(); | |||||
KlattReset(); | |||||
// set default values for frame parameters | // set default values for frame parameters | ||||
for(ix=0; ix<=9; ix++) | for(ix=0; ix<=9; ix++) | ||||
kt_frame.Kskew = 0; | kt_frame.Kskew = 0; | ||||
kt_frame.AB = 0; | kt_frame.AB = 0; | ||||
kt_frame.AVpdb = 0; | kt_frame.AVpdb = 0; | ||||
kt_frame.Gain0 = 60; // 62 | |||||
kt_frame.Gain0 = 62; // 60 | |||||
} // end of KlattInit | } // end of KlattInit | ||||
#endif // INCLUDE_KLATT | #endif // INCLUDE_KLATT |
int scale_wav; // depends on the voicing source | int scale_wav; // depends on the voicing source | ||||
#define N_RSN 20 | #define N_RSN 20 | ||||
#define Rnpc 0 | |||||
#define Rnz 0 // nasal zero, anti-resonator | |||||
#define R1c 1 | #define R1c 1 | ||||
#define R2c 2 | #define R2c 2 | ||||
#define R3c 3 | #define R3c 3 | ||||
#define R6c 6 | #define R6c 6 | ||||
#define R7c 7 | #define R7c 7 | ||||
#define R8c 8 | #define R8c 8 | ||||
#define Rnz 9 | |||||
#define Rnpc 9 // nasal pole | |||||
#define Rparallel 10 | #define Rparallel 10 | ||||
#define Rnpp 10 | #define Rnpp 10 | ||||
typedef struct | typedef struct | ||||
{ | { | ||||
long F0hz10; /* Voicing fund freq in Hz */ | |||||
long AVdb; /* Amp of voicing in dB, 0 to 70 */ | |||||
int F0hz10; /* Voicing fund freq in Hz */ | |||||
int AVdb; /* Amp of voicing in dB, 0 to 70 */ | |||||
int Fhz[10]; // formant Hz, F_NZ to F6 to F_NP | int Fhz[10]; // formant Hz, F_NZ to F6 to F_NP | ||||
int Bhz[10]; | int Bhz[10]; | ||||
int Ap[10]; /* Amp of parallel formants in dB, 0 to 80 */ | int Ap[10]; /* Amp of parallel formants in dB, 0 to 80 */ | ||||
int Bphz[10]; /* Parallel formants bw in Hz, 40 to 1000 */ | int Bphz[10]; /* Parallel formants bw in Hz, 40 to 1000 */ | ||||
long ASP; /* Amp of aspiration in dB, 0 to 70 */ | |||||
long Kopen; /* # of samples in open period, 10 to 65 */ | |||||
long Aturb; /* Breathiness in voicing, 0 to 80 */ | |||||
long TLTdb; /* Voicing spectral tilt in dB, 0 to 24 */ | |||||
long AF; /* Amp of frication in dB, 0 to 80 */ | |||||
long Kskew; /* Skewness of alternate periods, 0 to 40 in sample#/2 */ | |||||
int ASP; /* Amp of aspiration in dB, 0 to 70 */ | |||||
int Kopen; /* # of samples in open period, 10 to 65 */ | |||||
int Aturb; /* Breathiness in voicing, 0 to 80 */ | |||||
int TLTdb; /* Voicing spectral tilt in dB, 0 to 24 */ | |||||
int AF; /* Amp of frication in dB, 0 to 80 */ | |||||
int Kskew; /* Skewness of alternate periods, 0 to 40 in sample#/2 */ | |||||
long AB; /* Amp of bypass fric. in dB, 0 to 80 */ | |||||
long AVpdb; /* Amp of voicing, par in dB, 0 to 70 */ | |||||
long Gain0; /* Overall gain, 60 dB is unity, 0 to 60 */ | |||||
int AB; /* Amp of bypass fric. in dB, 0 to 80 */ | |||||
int AVpdb; /* Amp of voicing, par in dB, 0 to 70 */ | |||||
int Gain0; /* Overall gain, 60 dB is unity, 0 to 60 */ | |||||
long AVdb_tmp; //copy of AVdb, which is changed within parwave() | |||||
int AVdb_tmp; //copy of AVdb, which is changed within parwave() | |||||
int Fhz_next[10]; // Fhz for the next chunk, so we can do interpolation of resonator (a,b,c) parameters | int Fhz_next[10]; // Fhz for the next chunk, so we can do interpolation of resonator (a,b,c) parameters | ||||
int Bhz_next[10]; | int Bhz_next[10]; | ||||
} klatt_frame_t, *klatt_frame_ptr; | } klatt_frame_t, *klatt_frame_ptr; |
int x; | int x; | ||||
unsigned short *spect_data; | unsigned short *spect_data; | ||||
file_format = file_format_type; | |||||
wxDataInputStream s(stream); | wxDataInputStream s(stream); | ||||
time = s.ReadDouble(); | time = s.ReadDouble(); | ||||
markers = s.Read16(); | markers = s.Read16(); | ||||
amp_adjust = s.Read16(); | amp_adjust = s.Read16(); | ||||
if(file_format == 2) | |||||
if(file_format_type == 2) | |||||
{ | { | ||||
s.Read16(); // spare | |||||
s.Read16(); // spare | |||||
ix = s.Read16(); // spare | |||||
ix = s.Read16(); // spare | |||||
} | } | ||||
for(ix=0; ix<N_PEAKS; ix++) | for(ix=0; ix<N_PEAKS; ix++) | ||||
peaks[ix].pkwidth = s.Read16(); | peaks[ix].pkwidth = s.Read16(); | ||||
peaks[ix].pkright = s.Read16(); | peaks[ix].pkright = s.Read16(); | ||||
if(file_format == 2) | |||||
if(file_format_type == 2) | |||||
{ | { | ||||
peaks[ix].klt_bw = s.Read16(); | peaks[ix].klt_bw = s.Read16(); | ||||
peaks[ix].klt_ap = s.Read16(); | peaks[ix].klt_ap = s.Read16(); | ||||
} | } | ||||
} | } | ||||
if(file_format > 0) | |||||
if(file_format_type > 0) | |||||
{ | { | ||||
for(ix=0; ix<N_KLATTP2; ix++) | for(ix=0; ix<N_KLATTP2; ix++) | ||||
{ | { | ||||
} // End of SpectFrame::Load | } // End of SpectFrame::Load | ||||
int SpectFrame::Save(wxOutputStream& stream) | |||||
{//========================================= | |||||
int SpectFrame::Save(wxOutputStream& stream, int file_format_type) | |||||
{//=============================================================== | |||||
int ix; | int ix; | ||||
wxDataOutputStream s(stream); | wxDataOutputStream s(stream); | ||||
s.Write16(markers); | s.Write16(markers); | ||||
s.Write16(amp_adjust); | s.Write16(amp_adjust); | ||||
if(file_format == 2) | |||||
if(file_format_type == 2) | |||||
{ | { | ||||
s.Write16(0); // spare | s.Write16(0); // spare | ||||
s.Write16(0); // spare | s.Write16(0); // spare | ||||
s.Write16(peaks[ix].pkwidth); | s.Write16(peaks[ix].pkwidth); | ||||
s.Write16(peaks[ix].pkright); | s.Write16(peaks[ix].pkright); | ||||
if(file_format == 2) | |||||
if(file_format_type == 2) | |||||
{ | { | ||||
s.Write16(peaks[ix].klt_bw); | s.Write16(peaks[ix].klt_bw); | ||||
s.Write16(peaks[ix].klt_ap); | s.Write16(peaks[ix].klt_ap); | ||||
} | } | ||||
} | } | ||||
if(file_format > 0) | |||||
if(file_format_type > 0) | |||||
{ | { | ||||
for(ix=0; ix<N_KLATTP2; ix++) | for(ix=0; ix<N_KLATTP2; ix++) | ||||
{ | { |
int Import(wxInputStream &stream); | int Import(wxInputStream &stream); | ||||
int ImportSPC2(wxInputStream &stream, float &time_acc); | int ImportSPC2(wxInputStream &stream, float &time_acc); | ||||
int Load(wxInputStream &stream, int file_format_type); | int Load(wxInputStream &stream, int file_format_type); | ||||
int Save(wxOutputStream &stream); | |||||
int Save(wxOutputStream &stream, int file_format_type); | |||||
void Draw(wxDC &dc, int offy, int frame_width, double scalex, double scaley); | void Draw(wxDC &dc, int offy, int frame_width, double scalex, double scaley); | ||||
void ZeroPeaks(); | void ZeroPeaks(); | ||||
int nx; | int nx; | ||||
int markers; | int markers; | ||||
int max_y; | int max_y; | ||||
int file_format; // 0=eSpeak, 1=Klatt, 2=eSpeak+Klatt | |||||
USHORT *spect; // sqrt of harmonic amplitudes, 1-nx at 'pitch' | USHORT *spect; // sqrt of harmonic amplitudes, 1-nx at 'pitch' | ||||
short klatt_param[N_KLATTP2]; | short klatt_param[N_KLATTP2]; |
extern void SetSynth(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v); | extern void SetSynth(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v); | ||||
extern int Wavegen(); | extern int Wavegen(); | ||||
extern void CloseWaveFile2(); | extern void CloseWaveFile2(); | ||||
extern void KlattReset(); | |||||
extern FILE *f_wave; | extern FILE *f_wave; | ||||
static int frame_width; | static int frame_width; | ||||
out_ptr = out_start = wav_outbuf; | out_ptr = out_start = wav_outbuf; | ||||
out_end = &wav_outbuf[sizeof(wav_outbuf)]; | out_end = &wav_outbuf[sizeof(wav_outbuf)]; | ||||
#ifdef KLATT_TEST | |||||
if(synthesis_method == 1) | if(synthesis_method == 1) | ||||
result = Wavegen_Klatt(resume); | result = Wavegen_Klatt(resume); | ||||
else | else | ||||
#endif | |||||
result = Wavegen(); | result = Wavegen(); | ||||
if(f_wave != NULL) | if(f_wave != NULL) | ||||
wxDataOutputStream s(stream); | wxDataOutputStream s(stream); | ||||
file_format = 2; // inclue Klatt data in new saves | |||||
s.Write32(FILEID1_SPECTSEQ); | s.Write32(FILEID1_SPECTSEQ); | ||||
if(file_format == 2) | if(file_format == 2) | ||||
s.Write32(FILEID2_SPECTSQ2); | s.Write32(FILEID2_SPECTSQ2); | ||||
else | |||||
if(file_format == 1) | if(file_format == 1) | ||||
s.Write32(FILEID2_SPECTSEK); | s.Write32(FILEID2_SPECTSEK); | ||||
else | else | ||||
{ | { | ||||
if((selection==0) || frames[ix]->selected) | if((selection==0) || frames[ix]->selected) | ||||
{ | { | ||||
if(frames[ix]->Save(stream) != 0) return(1); | |||||
if(frames[ix]->Save(stream, file_format) != 0) return(1); | |||||
} | } | ||||
} | } | ||||
return(0); | return(0); | ||||
{//============================================== | {//============================================== | ||||
// Copy peaks down from next earlier/later keyframe | // Copy peaks down from next earlier/later keyframe | ||||
int f1; | int f1; | ||||
int pk; | |||||
for(f1=frame+direction; f1>=0 && f1<numframes; f1 += direction) | for(f1=frame+direction; f1>=0 && f1<numframes; f1 += direction) | ||||
{ | { | ||||
if(frames[f1]->keyframe) | if(frames[f1]->keyframe) | ||||
{ | { | ||||
for(pk=0; pk<N_PEAKS; pk++) | |||||
{ | |||||
frames[frame]->peaks[pk].pkfreq = frames[f1]->peaks[pk].pkfreq; | |||||
frames[frame]->peaks[pk].pkheight = frames[f1]->peaks[pk].pkheight; | |||||
frames[frame]->peaks[pk].pkwidth = frames[f1]->peaks[pk].pkwidth; | |||||
frames[frame]->peaks[pk].pkright = frames[f1]->peaks[pk].pkright; | |||||
} | |||||
memcpy(frames[frame]->peaks, frames[f1]->peaks, sizeof(frames[frame]->peaks)); | |||||
memcpy(frames[frame]->klatt_param, frames[f1]->klatt_param, sizeof(frames[frame]->klatt_param)); | memcpy(frames[frame]->klatt_param, frames[f1]->klatt_param, sizeof(frames[frame]->klatt_param)); | ||||
break; | break; | ||||
} | } | ||||
int ix; | int ix; | ||||
int x; | int x; | ||||
fr->frflags = FRFLAG_KLATT; | |||||
for(ix=0; ix < 8; ix++) | for(ix=0; ix < 8; ix++) | ||||
{ | { | ||||
if(ix < 7) | if(ix < 7) | ||||
{ | |||||
fr->ffreq[ix] = pks[ix].pkfreq; | fr->ffreq[ix] = pks[ix].pkfreq; | ||||
fr->klatt_ap[ix] = pks[ix].klt_ap; | |||||
fr->klatt_bp[ix] = pks[ix].klt_bp/2; | |||||
} | |||||
if(ix < 4) | |||||
fr->bw[ix] = pks[ix].klt_bw/2; | |||||
fr->fheight[ix] = pks[ix].pkheight >> 6; | fr->fheight[ix] = pks[ix].pkheight >> 6; | ||||
if(ix < 6) | if(ix < 6) | ||||
{ | { | ||||
fr->klattp[ix] = sp1->klatt_param[ix]; | fr->klattp[ix] = sp1->klatt_param[ix]; | ||||
} | } | ||||
fr->klattp[KLATT_FNZ] = sp1->klatt_param[KLATT_FNZ]/2; | |||||
if(fr->fheight[1] == 0) | |||||
{ | |||||
fr->klattp[KLATT_AV] -= 10; // fade in/out | |||||
} | |||||
} | } | ||||
static void SetSynth_mS(int length_mS, SpectFrame *sp1, SpectFrame *sp2, peak_t *pks1, peak_t *pks2, int control) | static void SetSynth_mS(int length_mS, SpectFrame *sp1, SpectFrame *sp2, peak_t *pks1, peak_t *pks2, int control) | ||||
PeaksToFrame(sp1,pks1,&fr1); | PeaksToFrame(sp1,pks1,&fr1); | ||||
PeaksToFrame(sp2,pks2,&fr2); | PeaksToFrame(sp2,pks2,&fr2); | ||||
#ifdef KLATT_TEST | |||||
// SetSynth_Klatt((length_mS * samplerate) / 1000, 0, &fr1, &fr2, voice, control); // convert mS to samples | |||||
#endif | |||||
if(voice->klattv[0]) | |||||
{ | |||||
SetSynth_Klatt((length_mS * samplerate) / 1000, 0, &fr1, &fr2, voice, control); // convert mS to samples | |||||
} | |||||
else | |||||
{ | { | ||||
SetSynth((length_mS * samplerate) / 1000, 0, &fr1, &fr2, voice); // convert mS to samples | SetSynth((length_mS * samplerate) / 1000, 0, &fr1, &fr2, voice); // convert mS to samples | ||||
} | } | ||||
peak_t peaks2[N_PEAKS]; | peak_t peaks2[N_PEAKS]; | ||||
int synthesizer_type = 0; | int synthesizer_type = 0; | ||||
#ifdef KLATT_TEST | |||||
KlattInit(); | |||||
#endif | |||||
if(voice->klattv[0]) | |||||
{ | |||||
synthesizer_type = 1; | |||||
KlattReset(); | |||||
} | |||||
SpeakNextClause(NULL,NULL,2); // stop speaking file | SpeakNextClause(NULL,NULL,2); // stop speaking file | ||||
if(numframes==0) return; | if(numframes==0) return; | ||||
lfactor = 1; | lfactor = 1; | ||||
} | } | ||||
// if((start==end) || (total_length == 0)) | |||||
// { | |||||
// sp1->MakeWaveF(1, pitch, amplitude, duration); | |||||
// return; | |||||
// } | |||||
len_samples = int(((total_length * lfactor + 50) * samplerate) / 1000); | len_samples = int(((total_length * lfactor + 50) * samplerate) / 1000); | ||||
SetPitch(len_samples,pitch.env,9,44); | SetPitch(len_samples,pitch.env,9,44); | ||||
if(first) | if(first) | ||||
{ | { | ||||
if(synthesizer_type == 1) | |||||
{ | |||||
memcpy(peaks0,peaks1,sizeof(peaks0)); | |||||
} | |||||
else | |||||
{ | |||||
PeaksZero(peaks1,peaks0); // fade in | |||||
} | |||||
PeaksZero(peaks1,peaks0); // fade in | |||||
SetSynth_mS(20,sp1,sp1,peaks0,peaks1,0); | SetSynth_mS(20,sp1,sp1,peaks0,peaks1,0); | ||||
MakeWaveFile(synthesizer_type); | MakeWaveFile(synthesizer_type); | ||||
first=0; | first=0; | ||||
} | } | ||||
} | } | ||||
if(synthesizer_type == 1) | |||||
{ | |||||
memcpy(peaks0,peaks2,sizeof(peaks0)); | |||||
} | |||||
else | |||||
{ | |||||
PeaksZero(peaks2,peaks0); // fade out | |||||
} | |||||
PeaksZero(peaks2,peaks0); // fade out | |||||
SetSynth_mS(30,sp2,sp2,peaks2,peaks0,2); | SetSynth_mS(30,sp2,sp2,peaks2,peaks0,2); | ||||
MakeWaveFile(synthesizer_type); | MakeWaveFile(synthesizer_type); | ||||
char *fname_speech; | char *fname_speech; | ||||
int synthesizer_type = 0; | int synthesizer_type = 0; | ||||
#ifdef KLATT_TEST | |||||
KlattInit(); | |||||
#endif | |||||
if(voice->klattv[0]) | |||||
{ | |||||
synthesizer_type = 1; | |||||
KlattReset(); | |||||
} | |||||
SpeakNextClause(NULL,NULL,2); // stop speaking file | SpeakNextClause(NULL,NULL,2); // stop speaking file | ||||
length = duration; | length = duration; | ||||
{ | { | ||||
memcpy(peaks1,peaks,sizeof(peaks1)); | memcpy(peaks1,peaks,sizeof(peaks1)); | ||||
if(synthesizer_type == 0) | |||||
{ | |||||
for(ix=0; ix<N_PEAKS; ix++) | |||||
{ | |||||
y = peaks1[ix].pkheight * amp_adjust * amplitude; | |||||
peaks1[ix].pkheight = y/10000; | |||||
} | |||||
PeaksZero(peaks1,peaks0); | |||||
} | |||||
else | |||||
for(ix=0; ix<N_PEAKS; ix++) | |||||
{ | { | ||||
memcpy(peaks0,peaks1,sizeof(peaks0)); | |||||
y = peaks1[ix].pkheight * amp_adjust * amplitude; | |||||
peaks1[ix].pkheight = y/10000; | |||||
} | } | ||||
PeaksZero(peaks1,peaks0); | |||||
SetSynth_mS(20,this,this,peaks0,peaks1,0); | SetSynth_mS(20,this,this,peaks0,peaks1,0); | ||||
MakeWaveFile(synthesizer_type); | MakeWaveFile(synthesizer_type); |
#include "translate.h" | #include "translate.h" | ||||
#include "wave.h" | #include "wave.h" | ||||
const char *version_string = "1.42.04 09.Dec.09"; | |||||
const char *version_string = "1.42.09 13.Dec.09"; | |||||
const int version_phdata = 0x014200; | const int version_phdata = 0x014200; | ||||
int option_device_number = -1; | int option_device_number = -1; |
if(voice->klattv[0]) | if(voice->klattv[0]) | ||||
{ | { | ||||
fr->klattp[KLATT_AV] = 53; // reduce the amplituide of the start of a vowel | |||||
// fr->klattp[KLATT_AV] = 53; // reduce the amplituide of the start of a vowel | |||||
fr->klattp[KLATT_AV] = seq[1].frame->klattp[KLATT_AV] - 6; | |||||
} | } | ||||
if(f2 != 0) | if(f2 != 0) | ||||
{ | { |
#ifdef LOG_FRAMES | #ifdef LOG_FRAMES | ||||
remove("log-espeakedit"); | remove("log-espeakedit"); | ||||
remove("log-klatt"); | |||||
#endif | #endif | ||||
} // end of WavegenInit | } // end of WavegenInit | ||||