eSpeak NG is an open source speech synthesizer that supports more than hundred languages and accents.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

vowelchart.cpp 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  1. /***************************************************************************
  2. * Copyright (C) 2005 to 2013 by Jonathan Duddington *
  3. * email: [email protected] *
  4. * Copyright (C) 2013 Reece H. Dunn *
  5. * *
  6. * This program is free software; you can redistribute it and/or modify *
  7. * it under the terms of the GNU General Public License as published by *
  8. * the Free Software Foundation; either version 3 of the License, or *
  9. * (at your option) any later version. *
  10. * *
  11. * This program is distributed in the hope that it will be useful, *
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  14. * GNU General Public License for more details. *
  15. * *
  16. * You should have received a copy of the GNU General Public License *
  17. * along with this program; if not, write see: *
  18. * <http://www.gnu.org/licenses/>. *
  19. ***************************************************************************/
  20. #include <math.h>
  21. #include "wx/wx.h"
  22. #include <wx/dcmemory.h>
  23. #include <wx/dc.h>
  24. #include <wx/bitmap.h>
  25. #include <wx/dirdlg.h>
  26. #include "wx/filename.h"
  27. #include "wx/wfstream.h"
  28. #include "speak_lib.h"
  29. #include "main.h"
  30. #include "speech.h"
  31. #include "phoneme.h"
  32. #include "synthesize.h"
  33. #include "voice.h"
  34. #include "spect.h"
  35. #include "translate.h"
  36. #include "options.h"
  37. /* Read a file of vowel symbols and f1,f2 formants, and produce a vowel diagram
  38. */
  39. extern wxString path_phsource;
  40. extern char *phondata_ptr;
  41. extern USHORT *phoneme_index;
  42. extern int n_phoneme_tables;
  43. // size of the vowelchart png
  44. #define WIDTH 1580
  45. #define HEIGHT 800
  46. #define ROUND(x) ((int) ((x) + 0.5))
  47. static int HslValue (double n1, double n2, double hue)
  48. {//===================================================
  49. double value;
  50. if (hue > 255)
  51. hue -= 255;
  52. else if (hue < 0)
  53. hue += 255;
  54. if (hue < 42.5)
  55. value = n1 + (n2 - n1) * (hue / 42.5);
  56. else if (hue < 127.5)
  57. value = n2;
  58. else if (hue < 170)
  59. value = n1 + (n2 - n1) * ((170 - hue) / 42.5);
  60. else
  61. value = n1;
  62. return ROUND (value * 255.0);
  63. }
  64. /**
  65. * @hue: Hue channel, returns Red channel
  66. * @saturation: Saturation channel, returns Green channel
  67. * @lightness: Lightness channel, returns Blue channel
  68. *
  69. * The arguments are pointers to int, with the values pointed to in the
  70. * following ranges: H [0, 360], L [0, 255], S [0, 255].
  71. *
  72. * The function changes the arguments to point to the RGB value
  73. * corresponding, with the returned values all in the range [0, 255].
  74. **/
  75. void HslToRgb (int *hue, int *saturation, int *lightness)
  76. {//======================================================
  77. double h, s, l;
  78. h = (*hue * 256)/360;
  79. s = *saturation;
  80. l = *lightness;
  81. if (s == 0)
  82. {
  83. /* achromatic case */
  84. *hue = (int)l;
  85. *lightness = (int)l;
  86. *saturation = (int)l;
  87. }
  88. else
  89. {
  90. double m1, m2;
  91. if (l < 128)
  92. m2 = (l * (255 + s)) / 65025.0;
  93. else
  94. m2 = (l + s - (l * s) / 255.0) / 255.0;
  95. m1 = (l / 127.5) - m2;
  96. /* chromatic case */
  97. *hue = HslValue (m1, m2, h + 85);
  98. *saturation = HslValue (m1, m2, h);
  99. *lightness = HslValue (m1, m2, h - 85);
  100. }
  101. }
  102. static int vowel_posn[N_PHONEME_TAB];
  103. static int vowel_posn_ix;
  104. static double log2a(double x)
  105. {//========================
  106. // log2(x) = log(x) / log(2)
  107. return(log(x) / 0.693147);
  108. }
  109. static int VowelX(int f2)
  110. {//======================
  111. return(WIDTH - int((log2a(f2) - 9.40)*WIDTH/1.9));
  112. // return(WIDTH - int((log2a(f2) - 9.49)*WIDTH/1.8));
  113. }
  114. static int VowelY(int f1)
  115. {//======================
  116. return(int((log2a(f1) - 7.85)*HEIGHT/2.15));
  117. }
  118. static int VowelZ(int f3)
  119. {//======================
  120. int z;
  121. // range 2000-3000Hz, log2= 10.96 to 11.55
  122. z = int((log2a(f3) - 11.05)*256/0.50);
  123. if(z < 0) z = 0;
  124. if(z > 255) z = 255;
  125. return(z);
  126. }
  127. static void DrawVowel(wxDC *dc, wxString name, int f1, int f2, int f3, int g1, int g2)
  128. {//==================================================================================
  129. int ix;
  130. int posn;
  131. int collisions;
  132. int x,y,z,x2,y2;
  133. int r,g,b;
  134. wxBrush brush;
  135. y = VowelY(f1);
  136. x = VowelX(f2);
  137. z = VowelZ(f3);
  138. if(y < 0) y = 0;
  139. if(y > (HEIGHT-4)) y= (HEIGHT-4);
  140. if(x < 0) x = 0;
  141. if(x > (WIDTH-12)) x = (WIDTH-12);
  142. r = z;
  143. g = 255;
  144. b = 100 + z/2;
  145. HslToRgb(&r,&g,&b);
  146. brush.SetColour(r,g,b);
  147. dc->SetBrush(brush);
  148. dc->DrawCircle(x,y,4);
  149. // check for a label already at this position
  150. collisions = 0;
  151. posn = (x/8)*WIDTH + (y/8);
  152. for(ix=0; ix<vowel_posn_ix; ix++)
  153. {
  154. if(posn == vowel_posn[ix])
  155. collisions++;
  156. }
  157. vowel_posn[vowel_posn_ix++] = posn;
  158. dc->DrawText(name,x+4,y+(collisions*10));
  159. if(g2 != 0xffff)
  160. {
  161. y2 = VowelY(g1);
  162. x2 = VowelX(g2);
  163. dc->DrawLine(x,y,x2,y2);
  164. }
  165. }
  166. static int VowelChartDir(wxDC *dc, wxBitmap *bitmap)
  167. {//=================================================
  168. int ix;
  169. int nf;
  170. int count = 0;
  171. SpectSeq *spectseq;
  172. SpectFrame *frame1;
  173. SpectFrame *frame2=NULL;
  174. wxFileName filename;
  175. wxString dir = wxDirSelector(_T("Directory of vowel files"),path_phsource);
  176. if(dir.IsEmpty()) return(0);
  177. wxString path = wxFindFirstFile(dir+_T("/*"),wxFILE);
  178. while (!path.empty())
  179. {
  180. if((spectseq = new SpectSeq) == NULL) break;
  181. filename = wxFileName(path);
  182. wxFileInputStream stream(path);
  183. if(stream.Ok() == FALSE)
  184. {
  185. path = wxFindNextFile();
  186. continue;
  187. }
  188. spectseq->Load(stream);
  189. nf = 0;
  190. frame1 = NULL;
  191. if(spectseq->numframes > 0)
  192. {
  193. frame2 = spectseq->frames[0];
  194. }
  195. for(ix=0; ix<spectseq->numframes; ix++)
  196. {
  197. if(spectseq->frames[ix]->keyframe)
  198. {
  199. nf++;
  200. frame2 = spectseq->frames[ix];
  201. if(frame2->markers & FRFLAG_VOWEL_CENTRE)
  202. frame1 = frame2;
  203. }
  204. }
  205. if((nf >= 3) && (frame1 != NULL))
  206. {
  207. DrawVowel(dc,wxString(filename.GetName()),
  208. frame1->peaks[1].pkfreq, frame1->peaks[2].pkfreq, frame1->peaks[3].pkfreq,
  209. frame2->peaks[1].pkfreq, frame2->peaks[2].pkfreq);
  210. count++;
  211. }
  212. delete spectseq;
  213. path = wxFindNextFile();
  214. }
  215. filename.SetPath(dir);
  216. filename.SetFullName(_T("vowelchart.png"));
  217. bitmap->SaveFile(filename.GetFullPath(),wxBITMAP_TYPE_PNG);
  218. return(count);
  219. }
  220. static int VowelChartList(wxDC *dc, wxBitmap *bitmap, char *fname)
  221. {//===============================================================
  222. // Plot a graph of vowel formants.
  223. // y-axis is decreasing f1 (closeness)
  224. // x-axis is decreasing f2 (backness)
  225. FILE *f_in;
  226. int ix;
  227. int f1,f2,f3,g1,g2;
  228. int colour;
  229. int count=0;
  230. wxFileName filename;
  231. char name[40];
  232. char buf[200];
  233. wxString path;
  234. if(fname != NULL)
  235. {
  236. path = wxString(fname,wxConvLocal);
  237. }
  238. else
  239. {
  240. path = wxFileSelector(_T("Read file of vowel formants"),path_phsource,
  241. _T(""),_T(""),_T("*"),wxOPEN);
  242. }
  243. if(path.IsEmpty())
  244. {
  245. return(0);
  246. }
  247. filename = wxFileName(path);
  248. strcpy(buf,path.mb_str(wxConvLocal));
  249. f_in = fopen(buf,"r");
  250. if(f_in == NULL)
  251. {
  252. wxLogError(_T("Can't read file: %s"),buf);
  253. return(0);
  254. }
  255. while(fgets(buf,sizeof(buf),f_in) != NULL)
  256. {
  257. g2 = 0xffff;
  258. ix = sscanf(buf,"%s %d %d %d %d %d %d",name,&colour,&f1,&f2,&f3,&g1,&g2);
  259. if(ix >= 4)
  260. {
  261. if(colour == 1)
  262. {
  263. dc->SetPen(*wxMEDIUM_GREY_PEN);
  264. dc->SetTextForeground(wxColour(100,100,128));
  265. }
  266. else
  267. {
  268. dc->SetPen(*wxBLACK_PEN);
  269. dc->SetTextForeground(*wxBLACK);
  270. }
  271. DrawVowel(dc,wxString(name,wxConvLocal),
  272. f1,f2,f3,g1,g2);
  273. count++;
  274. }
  275. }
  276. filename.SetExt(_T("png"));
  277. bitmap->SaveFile(filename.GetFullPath(),wxBITMAP_TYPE_PNG);
  278. return(count);
  279. }
  280. void VowelChart(int control, char *fname)
  281. {//======================================
  282. // Plot a graph of vowel formants.
  283. // y-axis is decreasing f1 (closeness)
  284. // x-axis is decreasing f2 (backness)
  285. // control=1 from directory of lists
  286. // control=2 from single list
  287. // control=3 from directory of phoneme source data files
  288. int ix;
  289. int x,y;
  290. int count;
  291. wxFileName filename;
  292. wxBitmap bitmap(WIDTH,HEIGHT);
  293. // Create a memory DC
  294. wxMemoryDC dc;
  295. dc.SelectObject(bitmap);
  296. dc.SetBrush(*wxWHITE_BRUSH);
  297. dc.SetFont(*wxSWISS_FONT);
  298. dc.Clear();
  299. // draw grid
  300. dc.SetPen(*wxLIGHT_GREY_PEN);
  301. for(ix=200; ix<=1000; ix+=50)
  302. {
  303. y = VowelY(ix);
  304. dc.DrawLine(0,y,WIDTH,y);
  305. if((ix % 100) == 0)
  306. dc.DrawText(wxString::Format(_T("%d"),ix),1,y);
  307. }
  308. for(ix=700; ix<=2400; ix+=100)
  309. {
  310. x = VowelX(ix);
  311. dc.DrawLine(x,0,x,HEIGHT);
  312. if((ix % 200)==0)
  313. dc.DrawText(wxString::Format(_T("%d"),ix),x+1,0);
  314. }
  315. dc.SetPen(*wxBLACK_PEN);
  316. vowel_posn_ix = 0;
  317. if(control==3)
  318. count = VowelChartDir(&dc, &bitmap);
  319. else
  320. count = VowelChartList(&dc, &bitmap, fname);
  321. dc.SetTextForeground(*wxBLACK);
  322. if(control != 1)
  323. wxLogStatus(_T("Plotted %d vowels"),count);
  324. }
  325. void FindPhonemesUsed(void)
  326. {//========================
  327. int hash;
  328. char *p;
  329. unsigned int *pw;
  330. char *next;
  331. unsigned char c;
  332. int count = 0;
  333. int ignore;
  334. char phonetic[N_WORD_PHONEMES];
  335. // look through all the phoneme strings in the **_rules data
  336. // and mark these phoneme codes as used.
  337. p = translator->data_dictrules;
  338. while(*p != 0)
  339. {
  340. if(*p == RULE_CONDITION)
  341. p+=2;
  342. if(*p == RULE_LINENUM)
  343. p+=3;
  344. if(*p == RULE_GROUP_END)
  345. {
  346. p++;
  347. if(*p == 0) break;
  348. }
  349. if(*p == RULE_GROUP_START)
  350. {
  351. if(p[1] == RULE_REPLACEMENTS)
  352. {
  353. p++;
  354. pw = (unsigned int *)(((long)p+4) & ~3); // advance to next word boundary
  355. while(pw[0] != 0)
  356. {
  357. pw += 2; // find the end of the replacement list, each entry is 2 words.
  358. }
  359. p = (char *)(pw+1);
  360. continue;
  361. }
  362. if(p[1] == RULE_LETTERGP2)
  363. {
  364. while(*p != RULE_GROUP_END) p++;
  365. continue;
  366. }
  367. p += (strlen(p)+1);
  368. }
  369. while((c = *p) != 0)
  370. {
  371. if(c == RULE_CONDITION)
  372. p++; // next byte is the condition number, which may be 3 (= RULE_PHONEMES)
  373. if(c == RULE_PHONEMES)
  374. break;
  375. p++;
  376. }
  377. count++;
  378. if(c == RULE_PHONEMES)
  379. {
  380. ignore = 0;
  381. p++;
  382. while((c = *p) != 0)
  383. {
  384. if(c == phonSWITCH)
  385. ignore = 1;
  386. if(ignore == 0)
  387. phoneme_tab_flags[c] |= 2;
  388. p++;
  389. }
  390. }
  391. p++;
  392. }
  393. // NOTE, we should recognise langopts.textmode and ignore the *_list file (lang=zh)
  394. for(hash=0; hash<N_HASH_DICT; hash++)
  395. {
  396. p = translator->dict_hashtab[hash];
  397. if(p == NULL)
  398. continue;
  399. while(*p != 0)
  400. {
  401. next = p + p[0];
  402. if((p[1] & 0x80) == 0)
  403. {
  404. p += ((p[1] & 0x3f) + 2);
  405. strcpy(phonetic,p);
  406. p += strlen(phonetic) +1;
  407. // examine flags
  408. ignore = 0;
  409. while(p < next)
  410. {
  411. if(*p == BITNUM_FLAG_TEXTMODE)
  412. {
  413. ignore = 1;
  414. break;
  415. }
  416. p++;
  417. }
  418. if(ignore == 0)
  419. {
  420. p = phonetic;
  421. while((c = *p) != 0)
  422. {
  423. if(c == phonSWITCH)
  424. break;
  425. phoneme_tab_flags[c] |= 2;
  426. p++;
  427. }
  428. }
  429. }
  430. p = next;
  431. }
  432. }
  433. } // end of FindPhonemesUsed
  434. #define N_VOWELFMT_ADDR 20
  435. int n_vowelfmt_addr;
  436. int vowelfmt_addr[N_VOWELFMT_ADDR]; // FMT() statements found in a phoneme definition
  437. static void FindVowelFmt(int prog_start, int length)
  438. {//=================================================
  439. USHORT *prog;
  440. USHORT instn;
  441. int prog_end;
  442. prog_end = prog_start + length;
  443. n_vowelfmt_addr = 0;
  444. for(prog = &phoneme_index[prog_start]; prog < &phoneme_index[prog_end]; prog += NumInstnWords(prog))
  445. {
  446. instn = *prog;
  447. if((instn >> 12) == 11)
  448. {
  449. // FMT instruction
  450. if(n_vowelfmt_addr < N_VOWELFMT_ADDR)
  451. {
  452. vowelfmt_addr[n_vowelfmt_addr++] = ((instn & 0xf) << 18) + (prog[1] << 2);
  453. }
  454. }
  455. }
  456. } // end of FindVowelFmt
  457. static int prog_log_sorter(PHONEME_PROG_LOG *p1, PHONEME_PROG_LOG *p2)
  458. {//===================================================================
  459. return(p1->addr - p2->addr);
  460. }
  461. void MakeVowelLists(void)
  462. {//======================
  463. // For each phoneme table, make a list of its vowels and their
  464. // formant frequencies (f1,f2,f3) for use by VowelChart()
  465. int table;
  466. int ix;
  467. int phcode;
  468. PHONEME_TAB *ph;
  469. FILE *f;
  470. FILE *f_prog_log;
  471. SPECT_SEQ *seq;
  472. SPECT_SEQK *seqk;
  473. frame_t *frame;
  474. int n_prog_log;
  475. int vowelfmt_ix;
  476. int colour;
  477. int voice_found;
  478. PHONEME_PROG_LOG *prog_log_table;
  479. PHONEME_PROG_LOG *found_prog;
  480. PHONEME_PROG_LOG this_prog;
  481. char dirname[sizeof(path_source)+20];
  482. char fname[sizeof(dirname)+40];
  483. char save_voice_name[80];
  484. strcpy(save_voice_name,voice_name2);
  485. sprintf(fname,"%s%s",path_source,"compile_prog_log");
  486. if((f_prog_log = fopen(fname,"rb")) == NULL)
  487. {
  488. wxLogError(_T("Can't read 'compile_prog_log;"));
  489. return;
  490. }
  491. ix = GetFileLength(fname);
  492. prog_log_table = (PHONEME_PROG_LOG *)malloc(ix);
  493. if(prog_log_table == NULL)
  494. return;
  495. ix = fread(prog_log_table, 1, ix, f_prog_log);
  496. fclose(f_prog_log);
  497. n_prog_log = ix / sizeof(PHONEME_PROG_LOG);
  498. progress = new wxProgressDialog(_T("Vowel charts"),_T(""),n_phoneme_tables);
  499. sprintf(dirname,"%s%s",path_source,"vowelcharts");
  500. mkdir(dirname,S_IRWXU | S_IRGRP | S_IROTH);
  501. sprintf(fname,"%s/vowel_log",dirname);
  502. for(table=0; table<n_phoneme_tables; table++)
  503. {
  504. sprintf(fname,"%s/%s",dirname,phoneme_tab_list[table].name);
  505. if((f = fopen(fname,"w"))==NULL) continue;
  506. progress->Update(table);
  507. // select the phoneme table by name
  508. // if(SetVoiceByName(phoneme_tab_list[table].name) != 0) continue;
  509. if(SelectPhonemeTableName(phoneme_tab_list[table].name) < 0) continue;
  510. voice_found = 0;
  511. if((LoadVoice(phoneme_tab_list[table].name, 0) != NULL) && (translator->data_dictrules != NULL))
  512. {
  513. voice_found = 1;
  514. FindPhonemesUsed();
  515. }
  516. // phoneme table is terminated by a phoneme with no name (=0)
  517. for(phcode=1; phcode < n_phoneme_tab; phcode++)
  518. {
  519. ph = phoneme_tab[phcode];
  520. if((ph==NULL) || (ph->type != phVOWEL) || (ph->program == 0))
  521. continue;
  522. if(voice_found && (phoneme_tab_flags[phcode] & 3) == 0)
  523. {
  524. continue; // inherited, and not used
  525. }
  526. // find the size of this program
  527. this_prog.addr = ph->program;
  528. found_prog = (PHONEME_PROG_LOG *)bsearch((void *)&this_prog, (void *)prog_log_table, n_prog_log, sizeof(PHONEME_PROG_LOG), (int(*)(const void *,const void *))prog_log_sorter);
  529. FindVowelFmt(ph->program, found_prog->length);
  530. for(vowelfmt_ix=0; vowelfmt_ix < n_vowelfmt_addr; vowelfmt_ix++)
  531. {
  532. ix = vowelfmt_addr[vowelfmt_ix];
  533. seq = (SPECT_SEQ *)(&phondata_ptr[ix]);
  534. seqk = (SPECT_SEQK *)seq;
  535. if(seq->frame[0].frflags & FRFLAG_KLATT)
  536. frame = &seqk->frame[1];
  537. else
  538. frame = (frame_t *)&seq->frame[1];
  539. if((n_vowelfmt_addr - vowelfmt_ix) == 1)
  540. colour = 0;
  541. else
  542. colour = 1;
  543. fprintf(f,"%s\t %d %3d %4d %4d",WordToString(ph->mnemonic), colour,
  544. frame->ffreq[1],frame->ffreq[2],frame->ffreq[3]);
  545. if(seq->frame[0].frflags & FRFLAG_KLATT)
  546. frame = &seqk->frame[seqk->n_frames-1];
  547. else
  548. frame = (frame_t *)&seq->frame[seq->n_frames-1];
  549. fprintf(f," %3d %4d %4d\n",frame->ffreq[1],frame->ffreq[2],frame->ffreq[3]);
  550. }
  551. }
  552. fclose(f);
  553. VowelChart(1,fname); // draw the vowel chart
  554. }
  555. free(prog_log_table);
  556. LoadVoice(voice_name2,0); // reset the original phoneme table
  557. delete progress;
  558. LoadVoiceVariant(save_voice_name,0);
  559. }
  560. #define N_ENVELOPES 30
  561. extern int n_envelopes;
  562. extern char envelope_paths[N_ENVELOPES][80];
  563. extern unsigned char envelope_dat[N_ENVELOPES][ENV_LEN];
  564. #define HT_ENV 140
  565. #define WD_ENV 128*2
  566. void DrawEnvelopes()
  567. {//================
  568. int ix_env;
  569. int y_base;
  570. int x;
  571. FILE *f_txt=NULL;
  572. unsigned char *env;
  573. char name[200];
  574. wxBitmap bitmap(WD_ENV,HT_ENV*n_envelopes);
  575. // Create a memory DC
  576. wxMemoryDC dc;
  577. dc.SelectObject(bitmap);
  578. dc.SetBrush(*wxWHITE_BRUSH);
  579. dc.SetFont(*wxSWISS_FONT);
  580. dc.Clear();
  581. sprintf(name,"%s%s",path_source,"envelopes.txt");
  582. // f_txt = fopen(name,"w");
  583. for(ix_env=0; ix_env<n_envelopes; ix_env++)
  584. {
  585. y_base = HT_ENV * ix_env;
  586. dc.SetPen(*wxLIGHT_GREY_PEN);
  587. dc.DrawLine(0,y_base+0,256,y_base+0);
  588. dc.DrawLine(0,y_base+64,256,y_base+64);
  589. dc.DrawLine(0,y_base+128,256,y_base+128);
  590. dc.DrawLine(128,y_base+0,128,y_base+128);
  591. dc.SetPen(*wxBLACK_PEN);
  592. strncpy0(name,envelope_paths[ix_env],sizeof(name));
  593. dc.DrawText(wxString(name,wxConvLocal),1,y_base);
  594. env = envelope_dat[ix_env];
  595. y_base = y_base+128;
  596. for(x=0; x<127; x++)
  597. {
  598. dc.DrawLine(x*2, y_base-env[x]/2, (x+1)*2, y_base-env[x+1]/2);
  599. }
  600. if(f_txt != NULL)
  601. {
  602. fprintf(f_txt,"%s\n",name);
  603. for(x=0; x<128; x++)
  604. {
  605. fprintf(f_txt," 0x%.2x,",env[x]);
  606. if((x & 0xf) == 0xf)
  607. fputc('\n',f_txt);
  608. }
  609. fputc('\n',f_txt);
  610. }
  611. }
  612. bitmap.SaveFile(path_phsource+_T("/envelopes.png"),wxBITMAP_TYPE_PNG);
  613. if(f_txt != NULL)
  614. fclose(f_txt);
  615. }