From cbff131b8993cde28349a2249870bad0971053eb Mon Sep 17 00:00:00 2001 From: jonsd Date: Tue, 21 Aug 2007 14:44:24 +0000 Subject: [PATCH] [1.28.07] Changed the format of envelope files (phsource/envelope). These are not text files which contains coordinates which define the envelope. The compile_phoneme_data operation now produces an image file phsource/envelopes.png which shows the shape of the envelopes. git-svn-id: https://espeak.svn.sourceforge.net/svnroot/espeak/trunk@78 d46cf337-b52f-0410-862d-fd96e6ae7743 --- phsource/envelope/p_211 | Bin 140 -> 0 bytes phsource/envelope/p_214 | Bin 140 -> 0 bytes phsource/envelope/p_fall | Bin 140 -> 0 bytes phsource/envelope/p_fallrise | Bin 140 -> 0 bytes phsource/envelope/p_level | Bin 140 -> 0 bytes phsource/envelope/p_rise | Bin 140 -> 0 bytes phsource/envelope/vi_2 | Bin 140 -> 0 bytes phsource/envelope/vi_5 | Bin 140 -> 0 bytes phsource/envelope/vi_5amp | Bin 140 -> 0 bytes phsource/envelope/vi_6 | Bin 140 -> 0 bytes phsource/envelope/vi_6amp | Bin 140 -> 0 bytes platforms/windows/windows_cmd/espeak.dsp | 2 +- src/compiledata.cpp | 88 ++++++++++++++++++++++- src/synthdata.cpp | 2 +- src/vowelchart.cpp | 52 ++++++++++++++ src/wave.cpp | 11 ++- 16 files changed, 149 insertions(+), 6 deletions(-) delete mode 100644 phsource/envelope/p_211 delete mode 100644 phsource/envelope/p_214 delete mode 100644 phsource/envelope/p_fall delete mode 100644 phsource/envelope/p_fallrise delete mode 100644 phsource/envelope/p_level delete mode 100644 phsource/envelope/p_rise delete mode 100644 phsource/envelope/vi_2 delete mode 100644 phsource/envelope/vi_5 delete mode 100644 phsource/envelope/vi_5amp delete mode 100644 phsource/envelope/vi_6 delete mode 100644 phsource/envelope/vi_6amp diff --git a/phsource/envelope/p_211 b/phsource/envelope/p_211 deleted file mode 100644 index 1153e96b90efb9e126a9127ada58cb0e0459768a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 140 zcmWIW3~}~w^$QDNs9^a2`^T4$Z(luobpQ7C%jZuYKfHhU_RZ^8FJC-=*0f1|U2RRZ zm8FHbnW>4fQDH%T-tNv0HkM{a`Z}6w$_jGQ5@I5P{Jh+p>})K|Oblp%k%@(koeK=O SkpNJDlaqs;osAW!hYMgOHHmpuhlsKOb*T4>uQQM|)dqOLG$=13eurbya0Wc^N4Q zF%cm_eqL@a4t6#cW+p~P1{h#uVrF4w=j7%U5Ehk`QBcv)F*LJwbn^+0OvuPDZ)oZ4 kn>=Ig!ey)1Z`rZ;;IUKZE?v8I@8Q!Iuitw0C)iZ{{8&>`uX_x_Vx4f@$c^K>+0y|<>TVu-rd{T*VWU~ z(9X=t$i~CLzrDM;x3sdbuB@r2rK6ypoSB!El8}y!iHC)PfPQ;(K~_pkM39e%lbw~BiID*g7@1kwxp?@6#iiv{H1$lZ9NqoH q;?fIBtLj@i`zFtryJ-2EjoWtZKXT&i#cQ|jJ$m-)-KVcVeggm~xI2^p diff --git a/phsource/envelope/p_level b/phsource/envelope/p_level deleted file mode 100644 index f937f61e0340d2c19a8b898be26c427efbb56bfb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 140 zcmWIW3~}~w^$QDNs9<1VX6F$Qk&sbP(a<$CwX}0`^Y#x8k4Z?$%q=Xds%vWR?w>q; l&VnT?)@<0aW6yyjCr+QgeC^h~hfiO;e*fv~kKg|(1OTc|V{rfg diff --git a/phsource/envelope/p_rise b/phsource/envelope/p_rise deleted file mode 100644 index 120b21f756b454dc53d74b228f913b84aa5ce3e7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 140 zcmV;70CWFPNmN5fMNU>w0C)fZ0t5vI2@4Dk5D^j-6&4s78XFuP9v>hfA|oRtB_<~* zC@Cr{EG#W9FEBAOGc+|eH#s^xJw87{LqtYMN=r>pQdCx1TV7yeW@&71b9Q=tfrW{U ul9rpGqo=B_v9-Cpz{AGM&C%4?+TP*h=j!e7^7Qui`TG3*{{H{}|NsAw0C)iZ{QCI!_4D%Z@9ypF>+0#~=jZ0-<>ch!B$Fy}P)zvahVErlOvk umy(W(g@Ai@acgB@TUS$0OGiULJ2*5jEh#1=9~>DM6cG;%3J3=U0|EiX{8gj? diff --git a/phsource/envelope/vi_5 b/phsource/envelope/vi_5 deleted file mode 100644 index bad96f0781aaf4d7808d371c330e3453dc95b595..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 140 zcmV;70CWFPNmN5fMNU>w0C)fZ0RsgF2nq`g4-gU*6&D#A93CGbBP1p$DJv{4FflVV zHaI#vJwHG~L`6qQN=!~rQBze`SXx|NUtwcqW@u_`Zf|jOb$5AteSd+1gocQUjE<3$ um6w^Dou8qkrl_i{ud%bXxVpW+!NkVN%g)f#)!5tJ;N#`!>+SIK_WAtHm^;D% diff --git a/phsource/envelope/vi_5amp b/phsource/envelope/vi_5amp deleted file mode 100644 index 0ec02021baec2e7c9d6d3203cdbfbfbae98986c9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 140 zcmWIW3~}~w^$QDNs9^X{3i$Eq_0#(|FP}YeXz$J~8`i8`ws_%!dGqGZo3~)m(iLkq QZrgMC^p(5MKapZ209!kFu>b%7 diff --git a/phsource/envelope/vi_6 b/phsource/envelope/vi_6 deleted file mode 100644 index 5d29dcfe80dc6b65cc1fb05f25d3673170fb0888..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 140 zcmV;70CWFPNmN5fMNU>w0C)iZ{{8&>`uX|z_xASn^z`%c@$vBR@9ysH?Ck66>gnj{ z=jP?*N=HONJvuitFfA%3BOn|Z784H)2?hfIqE^@d diff --git a/phsource/envelope/vi_6amp b/phsource/envelope/vi_6amp deleted file mode 100644 index 086aac05f331155726711622a2708c3dc3b0271f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 140 zcmWIW3~}~w^$QDNs9^X{2Ka{o{{H>@=g*(tzkmJu_4CK~Z(lxt`tbhk>zB`;K6-HX k*7YkF&z(AUXy2}F8`msfG!mQ-zU~gwD0163pEdT%j diff --git a/platforms/windows/windows_cmd/espeak.dsp b/platforms/windows/windows_cmd/espeak.dsp index 381b02cf..99ff63ff 100755 --- a/platforms/windows/windows_cmd/espeak.dsp +++ b/platforms/windows/windows_cmd/espeak.dsp @@ -73,7 +73,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib winmm.lib user32.lib gdi32.lib winspool.lib comdlg32.lib PAStaticWMME.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF diff --git a/src/compiledata.cpp b/src/compiledata.cpp index ef90cb14..53174961 100755 --- a/src/compiledata.cpp +++ b/src/compiledata.cpp @@ -75,6 +75,7 @@ extern void Write4Bytes(FILE *f, int value); extern void MakeVowelLists(void); extern void FindPhonemesUsed(void); +extern void DrawEnvelopes(); extern int CompileDictionary(const char *dsource, const char *dict_name, FILE *log, char *fname); extern char voice_name[]; @@ -91,6 +92,14 @@ typedef struct { } REF_HASH_TAB; +#define N_ENVELOPES 30 +#define ENV_LEN 128 +int n_envelopes = 0; +char envelope_paths[N_ENVELOPES][80]; +unsigned char envelope_dat[N_ENVELOPES][ENV_LEN]; + + + class Compile {//========== public: @@ -119,6 +128,7 @@ private: int LoadSpect(const char *path, int control); int LoadWavefile(FILE *f, const char *fname); int LoadEnvelope(FILE *f, const char *fname); + int LoadEnvelope2(FILE *f, const char *fname); int LoadDataFile(const char *path, int control); int AddSpect(int phcode, int *list, int control); void AddSpectList(int *list, int control); @@ -879,6 +889,13 @@ int Compile::LoadEnvelope(FILE *f, const char *fname) fread(buf,1,128,f); fwrite(buf,1,128,f_phdata); + if(n_envelopes < N_ENVELOPES) + { + strncpy0(envelope_paths[n_envelopes],fname,sizeof(envelope_paths[0])); + memcpy(envelope_dat[n_envelopes],buf,sizeof(envelope_dat[0])); + n_envelopes++; + } + return(displ); } @@ -971,6 +988,12 @@ int Compile::LoadDataFile(const char *path, int control) type_code = 'E'; } else + if(id == 0x45564E45) + { + ix = LoadEnvelope2(f,path); + type_code = 'E'; + } + else { Error("File not SPEC or RIFF",path); ix = -1; @@ -979,7 +1002,6 @@ int Compile::LoadDataFile(const char *path, int control) if(ix > 0) { -// fprintf(f_phcontents,"%c %-15s %4d 0x%.5x %s\n",type_code,current_fname,linenum,ix & 0x7fffff,path); fprintf(f_phcontents,"%c 0x%.5x %s\n",type_code,ix & 0x7fffff,path); } @@ -1808,6 +1830,67 @@ void make_envs() } #endif +int Compile::LoadEnvelope2(FILE *f, const char *fname) +{//=================================================== + int ix; + int n; + int x, y; + int displ; + int n_points; + char line_buf[128]; + float env_x[20]; + float env_y[20]; + int env_lin[20]; + unsigned char env[ENV_LEN]; + + n_points = 0; + fgets(line_buf,sizeof(line_buf),f); // skip first line + while(!feof(f)) + { + if(fgets(line_buf,sizeof(line_buf),f) == NULL) + break; + + env_lin[n_points] = 0; + n = sscanf(line_buf,"%f %f %d",&env_x[n_points],&env_y[n_points],&env_lin[n_points]); + if(n >= 2) + { + env_x[n_points] *= 1.28; // convert range 0-100 to 0-128 + n_points++; + } + } + env_x[n_points] = env_x[n_points-1]; + env_y[n_points] = env_y[n_points-1]; + + ix = -1; + for(x=0; x env_x[ix+4]) + ix++; + + if(n_points > 3) + y = (int)(polint(&env_x[ix],&env_y[ix],4,x) * 2.55); // convert to range 0-255 + else + y = (int)(polint(&env_x[ix],&env_y[ix],3,x) * 2.55); + if(y < 0) y = 0; + if(y > 255) y = 255; + env[x] = y; + } + + + if(n_envelopes < N_ENVELOPES) + { + strncpy0(envelope_paths[n_envelopes],fname,sizeof(envelope_paths[0])); + memcpy(envelope_dat[n_envelopes],env,ENV_LEN); + n_envelopes++; + } + + displ = ftell(f_phdata); + fwrite(env,1,128,f_phdata); + + return(displ); +} + + static int ref_sorter(char **a, char **b) {//====================================== @@ -2081,6 +2164,7 @@ void Compile::CPhonemeTab(const char *source) make_envs(); #endif + n_envelopes = 0; error_count = 0; memset(markers_used,0,sizeof(markers_used)); @@ -2192,7 +2276,7 @@ fprintf(f_errors,"Refs %d, Reused %d\n",count_references,duplicate_references); LoadPhData(); LoadVoice(voice_name,0); Report(); - + DrawEnvelopes(); report_dict = CompileAllDictionaries(); diff --git a/src/synthdata.cpp b/src/synthdata.cpp index 0f7ca186..d8652ad0 100755 --- a/src/synthdata.cpp +++ b/src/synthdata.cpp @@ -35,7 +35,7 @@ #include "translate.h" #include "wave.h" -const char *version_string = "1.28.05 17.Aug.07"; +const char *version_string = "1.28.07 21.Aug.07"; const int version_phdata = 0x012801; int option_device_number = -1; diff --git a/src/vowelchart.cpp b/src/vowelchart.cpp index 39ee1e0b..2a7baf47 100644 --- a/src/vowelchart.cpp +++ b/src/vowelchart.cpp @@ -506,3 +506,55 @@ void MakeVowelLists(void) LoadVoice(voice_name,0); // reset the original phoneme table delete progress; } + + +extern int n_envelopes; +extern char envelope_paths[][80]; +extern unsigned char envelope_dat[][128]; + +#define HT_ENV 140 +#define WD_ENV 128*2 + +void DrawEnvelopes() +{//================ + int ix_env; + int y_base; + int x; + unsigned char *env; + char name[80]; + + wxBitmap bitmap(WD_ENV,HT_ENV*n_envelopes); + + // Create a memory DC + wxMemoryDC dc; + dc.SelectObject(bitmap); + dc.SetBrush(*wxWHITE_BRUSH); + dc.SetFont(*wxSWISS_FONT); + dc.Clear(); + + + for(ix_env=0; ix_env