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.

967 lines
30KB

  1. # data file for the Fltk User Interface Designer (fluid)
  2. version 1.0110
  3. header_name {.h}
  4. code_name {.cxx}
  5. decl {//Copyright (c) Nasca Octavian Paul. Released under GNU General Public License version 2} {public
  6. }
  7. decl {\#include <FL/Fl_File_Chooser.H>} {}
  8. decl {\#include <FL/Fl_Box.H>} {public
  9. }
  10. decl {\#include <FL/Fl_Group.H>} {public
  11. }
  12. decl {\#include <FL/Fl_Box.H>} {public
  13. }
  14. decl {\#include <FL/fl_draw.H>} {public
  15. }
  16. decl {\#include <FL/Fl_Value_Input.H>} {public
  17. }
  18. decl {\#include <FL/fl_ask.H>} {public
  19. }
  20. decl {\#include<sys/stat.h>} {}
  21. decl {\#include <stdio.h>} {}
  22. decl {\#include <string>} {}
  23. decl {\#include <math.h>} {}
  24. decl {\#include "Control.h"} {public
  25. }
  26. decl {\#include "FreeEditUI.h"} {public
  27. }
  28. decl {\#include "version.h"} {public
  29. }
  30. Function {hex4n(char c)} {return_type int
  31. } {
  32. code {if (c>96) c-=32;
  33. if ((c>='0')||(c<='9')) return (c-'0');
  34. if ((c>='A')||(c<='F')) return (c-'A')+10;
  35. return 0;} {}
  36. }
  37. Function {unescape(std::string s)} {return_type {std::string}
  38. } {
  39. code {std::string result;
  40. int slen=s.size();
  41. s+=" ";
  42. int sk=0;
  43. while (sk<slen){
  44. char c=s[sk];
  45. if (c=='%'){
  46. char c1=s[++sk];
  47. char c2=s[++sk];
  48. result+=(char)(16*hex4n(c1)+hex4n(c2));
  49. sk++;
  50. }else{
  51. result+=c;
  52. sk++;
  53. };
  54. };
  55. //printf("%s\\n%s\\n",s.c_str(),result.c_str());
  56. return result;} {}
  57. }
  58. class DDBox {: {public Fl_Box}
  59. } {
  60. Function {DDBox(int x, int y, int w, int h, const char *label = 0):Fl_Box(x,y,w,h,label)} {open
  61. } {
  62. code {new_drag_file=false;} {}
  63. }
  64. Function {handle(int event)} {open return_type int
  65. } {
  66. code {if ((event==FL_DND_ENTER)||(event==FL_DND_DRAG)||(event==FL_DND_RELEASE)) return 1;
  67. if (event==FL_PASTE){
  68. const char *url=Fl::event_text();
  69. if (strstr(url,"file://")!=url) return 0;//is not a file
  70. std::string filename=url+7;
  71. for (int i=0;i<filename.size();i++) if (filename[i]<32) filename[i]=0;
  72. drag_file=unescape(filename);
  73. new_drag_file=true;
  74. return 1;
  75. };
  76. return Fl_Box::handle(event);} {}
  77. }
  78. decl {std::string drag_file;} {public
  79. }
  80. decl {bool new_drag_file;} {public
  81. }
  82. }
  83. class GUI {open
  84. } {
  85. decl {enum Mode {STOP,PLAY,PAUSE,FREEZE};} {}
  86. Function {GUI()} {} {
  87. code {playing_for_button=false;
  88. eof_for_button=false;
  89. rendering=false;
  90. make_window();
  91. tick(this);
  92. refresh();
  93. set_mode(STOP);} {}
  94. }
  95. Function {~GUI()} {} {
  96. code {Fl::remove_timeout(tick,this);} {}
  97. }
  98. Function {open_input_file(const char *filename)} {open
  99. } {
  100. code {const char *ext=fl_filename_ext(filename);
  101. FILE_TYPE intype=FILE_WAV;
  102. if ((strcmp(ext,".ogg")==0)||(strcmp(ext,".OGG")==0)||(strcmp(ext,".Ogg")==0)) intype=FILE_VORBIS;
  103. if ((strcmp(ext,".mp3")==0)||(strcmp(ext,".MP3")==0)||(strcmp(ext,".Mp3")==0)) intype=FILE_MP3;
  104. bool result=control.set_input_filename(filename,intype);
  105. if (result) {
  106. infilename_output->copy_label(control.get_input_filename_and_info().c_str());
  107. } else {
  108. infilename_output->copy_label("");
  109. fl_alert("Error: Could not open audio file:\\n%s",filename);
  110. };
  111. refresh();} {}
  112. }
  113. Function {render()} {open
  114. } {
  115. code {render_button->deactivate();
  116. rendering=true;
  117. render_percent_slider->value(0);
  118. render_percent_slider->activate();
  119. cancel_render_button->activate();
  120. //char defaultfile[FL_PATH_MAX];
  121. //fl_filename_absolute(defaultfile,control.get_recommanded_output_filename().c_str());
  122. Fl_File_Chooser *fc=new Fl_File_Chooser(NULL,"Wave files (*.wav)\\tOgg Vorbis (*.ogg)",Fl_File_Chooser::CREATE,"Render to audio file...");
  123. fc->preview(0);
  124. fc->filter_value(0);
  125. fc->ok_label("Render");
  126. fc->show();
  127. while (fc->visible()){
  128. Fl::wait();
  129. };
  130. const char *newfile = fc->value();
  131. if (newfile != NULL) {
  132. if (file_exists(newfile)){
  133. if (!fl_choice("The file exists. \\nOverwrite it?","No","Yes",NULL)) return;
  134. };
  135. FILE_TYPE type=FILE_WAV;
  136. if (fc->filter_value()==1) type=FILE_VORBIS;
  137. const char *ext=fl_filename_ext(newfile);
  138. std::string outfilename=newfile;
  139. if (strlen(ext)==0){
  140. if (type==FILE_VORBIS) outfilename+=".ogg";
  141. else outfilename+=".wav";
  142. };
  143. render_percent_slider->copy_label(outfilename.c_str());
  144. FILE_TYPE intype=FILE_WAV;
  145. {
  146. const char *ext=fl_filename_ext(control.get_input_filename().c_str());
  147. if ((strcmp(ext,".ogg")==0)||(strcmp(ext,".OGG")==0)||(strcmp(ext,".Ogg")==0)) intype=FILE_VORBIS;
  148. if ((strcmp(ext,".MP3")==0)||(strcmp(ext,".mp3")==0)||(strcmp(ext,".Mp3")==0)) intype=FILE_MP3;
  149. };
  150. const char *outstr=control.Render(control.get_input_filename(),outfilename,type,intype,
  151. selection_pos1->value()/100.0,selection_pos2->value()/100.0).c_str();
  152. if (strlen(outstr)!=0) fl_alert("%s",outstr);
  153. };
  154. delete fc;
  155. render_button->activate();
  156. render_percent_slider->value(0);
  157. render_percent_slider->deactivate();
  158. render_percent_slider->label("");
  159. cancel_render_button->deactivate();
  160. rendering=false;} {}
  161. }
  162. Function {make_window()} {open private
  163. } {
  164. Fl_Window window {
  165. label {Paul's Extreme Sound Stretch} open
  166. xywh {192 131 995 550} type Double resizable
  167. code0 {if(strlen(VERSION)<2) {o->color(FL_BLUE); o->label("VERSION NOT SET!!!!!!!!!!!!");};} visible
  168. } {
  169. Fl_Menu_Bar {} {open
  170. xywh {0 0 1015 20}
  171. } {
  172. Submenu {} {
  173. label File open
  174. xywh {0 0 63 20}
  175. } {
  176. MenuItem {} {
  177. label {Open audio file...}
  178. callback {char *newfile = fl_file_chooser("Open Audio(ogg,wav,mp3) File?", NULL, NULL);
  179. if (newfile != NULL) {
  180. open_input_file(newfile);
  181. };
  182. selection_pos1->value(0.0);
  183. selection_pos2->value(100.0);
  184. refresh();}
  185. xywh {0 0 30 20}
  186. }
  187. MenuItem render_menu {
  188. label {Render and save audio file...}
  189. callback {selection_pos1->value(0.0);
  190. selection_pos2->value(100.0);
  191. tabs_widget->value(write_to_file_group);
  192. render();}
  193. xywh {10 10 30 20} deactivate divider
  194. }
  195. MenuItem {} {
  196. label {Open Parameters...}
  197. callback {char *newfile = fl_file_chooser("Open Parameter File?", "PaulStretch XML (*.psx)\\tAll Files (*)", NULL);
  198. if (newfile != NULL) {
  199. set_mode(STOP);
  200. control.stopplay();
  201. if (!control.load_parameters(newfile)){
  202. fl_alert("Error: Could not load parameter file:\\n%s",newfile);
  203. };
  204. };
  205. refreshgui();
  206. refresh();}
  207. xywh {10 10 30 20}
  208. }
  209. MenuItem {} {
  210. label {Save Parameters...}
  211. callback {char *newfile = fl_file_chooser("Save Parameters(paulstretch) File?", "PaulStretch XML (*.psx)\\tAll Files (*)", NULL);
  212. if (newfile != NULL) {
  213. if (file_exists(newfile)){
  214. if (!fl_choice("The file exists. \\nOverwrite it?","No","Yes",NULL)) return;
  215. };
  216. control.save_parameters(newfile);
  217. };
  218. refresh();}
  219. xywh {20 20 30 20} divider
  220. }
  221. MenuItem {} {
  222. label Exit
  223. callback {window->hide();}
  224. xywh {0 0 30 20}
  225. }
  226. }
  227. Submenu {} {
  228. label About
  229. xywh {15 15 63 20}
  230. } {
  231. MenuItem {} {
  232. label {About...}
  233. callback {aboutwindow->show();}
  234. xywh {15 15 30 20}
  235. }
  236. }
  237. }
  238. Fl_Tabs tabs_widget {open
  239. xywh {5 50 985 420} box BORDER_BOX
  240. } {
  241. Fl_Group {} {
  242. label Parameters open
  243. xywh {5 70 985 400}
  244. } {
  245. Fl_Slider stretch_slider {
  246. label {Stretch:}
  247. callback {refresh();
  248. control.update_player_stretch();}
  249. xywh {10 89 975 15} type {Horz Knob} box FLAT_BOX align 6 value 0.29
  250. }
  251. Fl_Slider fftsize_slider {
  252. label {Window Size:}
  253. callback {refresh();
  254. o->labelcolor(FL_BLUE);}
  255. xywh {10 155 975 15} type {Horz Knob} box FLAT_BOX align 6 value 0.47
  256. }
  257. Fl_Choice mode_choice {
  258. label {Mode:}
  259. callback {refresh();}
  260. xywh {850 110 135 20} down_box BORDER_BOX
  261. } {
  262. MenuItem {} {
  263. label Stretch
  264. xywh {10 10 30 20}
  265. }
  266. MenuItem {} {
  267. label HyperStretch
  268. xywh {20 20 30 20}
  269. }
  270. MenuItem {} {
  271. label Shorten
  272. xywh {0 0 30 20}
  273. }
  274. }
  275. Fl_Choice window_choice {
  276. label {Type:}
  277. callback {FFTWindow w=W_RECTANGULAR;
  278. switch(o->value()){
  279. case 0:
  280. w=W_RECTANGULAR;
  281. break;
  282. case 1:
  283. w=W_HAMMING;
  284. break;
  285. case 2:
  286. w=W_HANN;
  287. break;
  288. case 3:
  289. w=W_BLACKMAN;
  290. break;
  291. case 4:
  292. w=W_BLACKMAN_HARRIS;
  293. break;
  294. };
  295. control.set_window_type(w);
  296. refresh();}
  297. xywh {850 185 135 20} down_box BORDER_BOX when 1
  298. code0 {o->value(2);}
  299. } {
  300. MenuItem {} {
  301. label Rectangular
  302. xywh {40 40 30 20}
  303. }
  304. MenuItem {} {
  305. label Hamming
  306. xywh {30 30 30 20}
  307. }
  308. MenuItem {} {
  309. label Hann
  310. xywh {10 10 30 20}
  311. }
  312. MenuItem {} {
  313. label Blackman
  314. xywh {20 20 30 20}
  315. }
  316. MenuItem {} {
  317. label BlackmanHarris
  318. xywh {30 30 30 20}
  319. }
  320. }
  321. Fl_Button {} {
  322. label S
  323. callback {char tmp[100];
  324. snprintf(tmp,100,"%g",control.get_stretch());
  325. const char *result=fl_input("Enter the stretch value",tmp);
  326. if (!result) return;
  327. double str=atof(result);
  328. if (str<1e-4) return;
  329. double stc=control.get_stretch_control(str,mode_choice->value());
  330. if ((stc<1e-4)||(stc>1.0)) return;
  331. stretch_slider->value(stc);
  332. stretch_slider->do_callback();}
  333. tooltip {set the stretch to a value} xywh {780 110 20 20}
  334. }
  335. Fl_Box resolution_box {
  336. xywh {10 187 790 18} box FLAT_BOX color 52 align 20
  337. }
  338. Fl_Group {} {
  339. label {Stretch Multiplier} open
  340. xywh {10 245 975 220} box THIN_UP_BOX labeltype ENGRAVED_LABEL
  341. } {
  342. Fl_Box stretch_free_edit {
  343. label Graph
  344. xywh {105 250 875 210} box FLAT_BOX color 17
  345. code0 {o->init(&control.ppar.stretch_multiplier,&control);}
  346. class FreeEditUI
  347. }
  348. Fl_Group stretch_multiplier_control {open
  349. xywh {15 250 85 210} box BORDER_FRAME color 0 align 208
  350. code0 {o->init(stretch_free_edit,FE_LINEAR,0,100.0,FE_LOG,0.1,50.0,1.0);}
  351. class FreeEditControls
  352. } {}
  353. }
  354. }
  355. Fl_Group {} {
  356. label Process open
  357. xywh {5 70 985 400} hide
  358. } {
  359. Fl_Group {} {open
  360. xywh {165 75 105 65} box BORDER_BOX
  361. } {
  362. Fl_Check_Button pitch_shift_enabled {
  363. label {Pitch Shift}
  364. callback {control.ppar.pitch_shift.enabled=o->value();
  365. control.update_process_parameters();}
  366. xywh {170 80 90 15} down_box DOWN_BOX labelfont 1
  367. }
  368. Fl_Counter pitch_shift_cents {
  369. label cents
  370. callback {control.ppar.pitch_shift.cents=(int)o->value();
  371. control.update_process_parameters();}
  372. xywh {170 100 90 20} minimum -3600 maximum 3600 step 1
  373. code0 {o->lstep(100);}
  374. }
  375. }
  376. Fl_Group {} {open
  377. xywh {275 75 135 100} box BORDER_BOX
  378. } {
  379. Fl_Check_Button octave_enabled {
  380. label {Octave Mixer}
  381. callback {control.ppar.octave.enabled=o->value();
  382. control.update_process_parameters();}
  383. xywh {280 80 110 15} down_box DOWN_BOX labelfont 1
  384. }
  385. Fl_Slider octave_om2 {
  386. label {-2}
  387. callback {control.ppar.octave.om2=pow(o->value(),2.0);
  388. control.update_process_parameters();}
  389. tooltip {2 octaves below} xywh {280 100 15 55} type {Vert Knob} minimum 1 maximum 0
  390. }
  391. Fl_Slider octave_om1 {
  392. label {-1}
  393. callback {control.ppar.octave.om1=pow(o->value(),2.0);
  394. control.update_process_parameters();}
  395. tooltip {1 octave below} xywh {300 100 15 55} type {Vert Knob} minimum 1 maximum 0
  396. }
  397. Fl_Slider octave_o0 {
  398. label 0
  399. callback {control.ppar.octave.o0=pow(o->value(),2.0);
  400. control.update_process_parameters();}
  401. tooltip {original (dry)} xywh {320 100 15 55} type {Vert Knob} minimum 1 maximum 0 value 1
  402. }
  403. Fl_Slider octave_o1 {
  404. label 1
  405. callback {control.ppar.octave.o1=pow(o->value(),2.0);
  406. control.update_process_parameters();}
  407. tooltip {1 octave above} xywh {340 100 15 55} type {Vert Knob} minimum 1 maximum 0
  408. }
  409. Fl_Slider octave_o15 {
  410. label {1.5}
  411. callback {control.ppar.octave.o15=pow(o->value(),2.0);
  412. control.update_process_parameters();}
  413. tooltip {3rd harmonic} xywh {360 100 15 55} type {Vert Knob} minimum 1 maximum 0
  414. }
  415. Fl_Slider octave_o2 {
  416. label 2
  417. callback {control.ppar.octave.o2=pow(o->value(),2.0);
  418. control.update_process_parameters();}
  419. tooltip {2 octaves above} xywh {380 100 15 55} type {Vert Knob} minimum 1 maximum 0
  420. }
  421. }
  422. Fl_Group {} {open
  423. xywh {165 140 105 65} box BORDER_BOX
  424. } {
  425. Fl_Check_Button freq_shift_enabled {
  426. label {Freq Shift}
  427. callback {control.ppar.freq_shift.enabled=o->value();
  428. control.update_process_parameters();}
  429. xywh {170 145 90 15} down_box DOWN_BOX labelfont 1
  430. }
  431. Fl_Counter freq_shift_Hz {
  432. label Hz
  433. callback {control.ppar.freq_shift.Hz=(int)o->value();
  434. control.update_process_parameters();}
  435. xywh {170 165 90 20} minimum -10000 maximum 10000 step 1
  436. code0 {o->lstep(100);}
  437. }
  438. }
  439. Fl_Group {} {open
  440. xywh {750 75 120 65} box BORDER_BOX
  441. } {
  442. Fl_Check_Button compressor_enabled {
  443. label Compress
  444. callback {control.ppar.compressor.enabled=o->value();
  445. control.update_process_parameters();}
  446. xywh {755 80 90 15} down_box DOWN_BOX labelfont 1
  447. }
  448. Fl_Slider compressor_power {
  449. label Power
  450. callback {control.ppar.compressor.power=o->value();
  451. control.update_process_parameters();}
  452. xywh {755 100 110 15} type {Horz Knob}
  453. }
  454. }
  455. Fl_Slider {} {
  456. label Volume
  457. callback {REALTYPE x=o->value();
  458. x=pow(10.0,pow(x,1.5)-1.0)-0.1;
  459. control.set_volume(x);}
  460. xywh {750 155 120 40} type {Horz Knob} labelfont 1 minimum 0.3 maximum 1.6 value 1
  461. }
  462. Fl_Group {} {open
  463. xywh {415 75 185 100} box BORDER_BOX
  464. } {
  465. Fl_Check_Button filter_enabled {
  466. label Filter
  467. callback {control.ppar.filter.enabled=o->value();
  468. control.update_process_parameters();}
  469. xywh {420 80 70 15} down_box DOWN_BOX labelfont 1
  470. }
  471. Fl_Value_Input filter_low {
  472. label {Freq1(Hz)}
  473. callback {control.ppar.filter.low=o->value();
  474. control.update_process_parameters();}
  475. xywh {420 101 100 24} align 8 maximum 10000
  476. }
  477. Fl_Value_Input filter_high {
  478. label {Freq2(Hz)}
  479. callback {control.ppar.filter.high=o->value();
  480. control.update_process_parameters();}
  481. xywh {420 126 100 24} align 8 maximum 25000 value 22000
  482. }
  483. Fl_Check_Button filter_stop {
  484. label BandStop
  485. callback {control.ppar.filter.stop=o->value();
  486. control.update_process_parameters();}
  487. tooltip {band-stop filter} xywh {500 80 90 15} down_box DOWN_BOX
  488. }
  489. Fl_Slider filter_hdamp {
  490. label DHF
  491. callback {control.ppar.filter.hdamp=o->value();
  492. control.update_process_parameters();}
  493. tooltip {Damp High Frequency} xywh {420 155 140 15} type {Horz Knob} align 8
  494. }
  495. }
  496. Fl_Group {} {open
  497. xywh {10 75 150 120} box BORDER_BOX
  498. } {
  499. Fl_Check_Button harmonics_enabled {
  500. label Harmonics
  501. callback {control.ppar.harmonics.enabled=o->value();
  502. control.update_process_parameters();}
  503. xywh {15 80 95 15} down_box DOWN_BOX labelfont 1
  504. }
  505. Fl_Value_Input harmonics_freq {
  506. label {F.Freq(Hz)}
  507. callback {control.ppar.harmonics.freq=o->value();
  508. control.update_process_parameters();}
  509. tooltip {fundamental frequency} xywh {15 101 65 24} align 8 minimum 1 maximum 20000 value 440
  510. }
  511. Fl_Value_Input harmonics_bandwidth {
  512. label {BW(cents)}
  513. callback {control.ppar.harmonics.bandwidth=o->value();
  514. control.update_process_parameters();}
  515. tooltip {bandwidth (cents)} xywh {15 126 65 24} align 8 minimum 0.1 maximum 200 value 25
  516. }
  517. Fl_Check_Button harmonics_gauss {
  518. label Gauss
  519. callback {control.ppar.harmonics.gauss=o->value();
  520. control.update_process_parameters();}
  521. tooltip {smooth the harmonics} xywh {85 155 65 15} down_box DOWN_BOX
  522. }
  523. Fl_Counter harmonics_nharmonics {
  524. label {no.hrm.}
  525. callback {control.ppar.harmonics.nharmonics=(int)o->value();
  526. control.update_process_parameters();}
  527. tooltip {number of harmonics} xywh {15 155 56 20} type Simple minimum 1 maximum 100 step 1 value 10
  528. }
  529. }
  530. Fl_Group {} {open
  531. xywh {275 180 325 40} box BORDER_BOX
  532. } {
  533. Fl_Check_Button spread_enabled {
  534. label Spread
  535. callback {control.ppar.spread.enabled=o->value();
  536. control.update_process_parameters();}
  537. xywh {280 185 90 15} down_box DOWN_BOX labelfont 1
  538. }
  539. Fl_Slider spread_bandwidth {
  540. label Bandwidth
  541. callback {control.ppar.spread.bandwidth=o->value();
  542. control.update_process_parameters();}
  543. xywh {360 185 230 15} type {Horz Knob} value 0.3
  544. }
  545. }
  546. Fl_Group {} {
  547. label ArbitraryFilter
  548. xywh {10 245 975 220} box THIN_UP_BOX labeltype ENGRAVED_LABEL
  549. } {
  550. Fl_Box filter_free_edit {
  551. label Graph
  552. xywh {105 250 875 210} box FLAT_BOX color 206 selection_color 0
  553. code0 {o->init(&control.ppar.free_filter,&control);}
  554. class FreeEditUI
  555. }
  556. Fl_Group arbitrary_filter_control {open
  557. xywh {15 250 85 210} box BORDER_FRAME color 0 align 208
  558. code0 {o->init(filter_free_edit,FE_LOG,20.0,25000.0,FE_DB,-60,20,0.0);}
  559. class FreeEditControls
  560. } {}
  561. }
  562. Fl_Group {} {open
  563. xywh {605 75 140 105} box BORDER_BOX
  564. } {
  565. Fl_Check_Button tonal_vs_noise_enabled {
  566. label {Tonal/Noise}
  567. callback {control.ppar.tonal_vs_noise.enabled=o->value();
  568. control.update_process_parameters();}
  569. xywh {610 80 115 20} down_box DOWN_BOX labelfont 1
  570. }
  571. Fl_Slider tonal_vs_noise_bandwidth {
  572. label Bandwidth
  573. callback {control.ppar.tonal_vs_noise.bandwidth=o->value();
  574. control.update_process_parameters();}
  575. xywh {610 141 130 15} type {Horz Knob} minimum 0.75 value 0.9
  576. }
  577. Fl_Slider tonal_vs_noise_preserve {
  578. label {noise <-->tonal}
  579. callback {control.ppar.tonal_vs_noise.preserve=o->value();
  580. control.update_process_parameters();}
  581. xywh {610 105 130 15} type {Horz Knob} minimum -1 value 0.5
  582. }
  583. }
  584. }
  585. Fl_Group {} {
  586. label {Binaural beats}
  587. xywh {5 70 985 400} box THIN_UP_BOX hide
  588. } {
  589. Fl_Box binaural_free_edit {
  590. label Graph
  591. xywh {135 75 845 390} box FLAT_BOX color 135
  592. code0 {o->init(&control.bbpar.free_edit,&control);}
  593. class FreeEditUI
  594. }
  595. Fl_Slider bbpar_mono {
  596. label Pow
  597. callback {control.bbpar.mono=o->value();
  598. control.update_process_parameters();}
  599. xywh {105 75 20 190} type {Vert Knob} labelfont 1 minimum 1 maximum 0 value 0.5
  600. }
  601. Fl_Group binaural_beats_control {
  602. label {FreeEdit Controls}
  603. xywh {10 75 80 205} box BORDER_FRAME color 47 align 208
  604. code0 {o->init(binaural_free_edit,FE_LINEAR,0,100.0,FE_LOG,0.1,50.0,8.0);}
  605. class FreeEditControls
  606. } {}
  607. Fl_Choice bbpar_stereo_mode {
  608. label {Stereo Mode}
  609. callback {control.bbpar.stereo_mode=(BB_STEREO_MODE)o->value();
  610. control.update_process_parameters();}
  611. xywh {10 305 110 20} down_box BORDER_BOX align 5
  612. } {
  613. MenuItem {} {
  614. label LeftRight
  615. xywh {10 10 36 21} labelfont 1
  616. }
  617. MenuItem {} {
  618. label RightLeft
  619. xywh {20 20 36 21} labelfont 1
  620. }
  621. MenuItem {} {
  622. label Symmetric
  623. xywh {30 30 36 21} labelfont 1
  624. }
  625. }
  626. }
  627. Fl_Group write_to_file_group {
  628. label {Write to file} open
  629. xywh {5 70 985 400} hide
  630. } {
  631. Fl_Button render_button {
  632. label {Render selection...}
  633. callback {render();}
  634. xywh {250 95 320 30} labelfont 1 labelsize 22
  635. }
  636. Fl_Value_Slider render_percent_slider {
  637. label { }
  638. xywh {15 245 970 65} type {Horz Fill} selection_color 4 align 70 maximum 100 step 0.1 textsize 14
  639. }
  640. Fl_Button cancel_render_button {
  641. label Cancel
  642. callback {if (fl_choice("Cancel audio rendering?","No","Yes",NULL)) control.info.cancel_render=true;}
  643. xywh {400 365 145 25} deactivate
  644. }
  645. Fl_Button {} {
  646. label {selection pos1}
  647. callback {selection_pos1->value(seek_slider->value());}
  648. tooltip {set selection start from Player's position} xywh {20 85 110 20} align 20
  649. }
  650. Fl_Button {} {
  651. label {selection pos2}
  652. callback {selection_pos2->value(seek_slider->value());}
  653. tooltip {set selection end from Player's position} xywh {20 110 110 20} align 20
  654. }
  655. Fl_Button {} {
  656. label {select all}
  657. callback {selection_pos1->value(0.0);
  658. selection_pos2->value(100.0);}
  659. tooltip {select the whole sound} xywh {20 135 110 20}
  660. }
  661. Fl_Value_Output selection_pos1 {
  662. label {%}
  663. xywh {135 85 70 20} align 72 maximum 100 step 0.01 textfont 1
  664. }
  665. Fl_Value_Output selection_pos2 {
  666. label {%}
  667. xywh {135 111 70 18} align 72 maximum 100 step 0.01 value 100 textfont 1
  668. }
  669. Fl_Check_Button {} {
  670. label 32bit
  671. callback {control.wav32bit=o->value();}
  672. xywh {250 135 100 15} down_box DOWN_BOX
  673. }
  674. }
  675. }
  676. Fl_Box infilename_output {
  677. tooltip {drag audio file here to open it} xywh {5 24 1005 22} box FLAT_BOX color 17 align 84
  678. class DDBox
  679. }
  680. Fl_Group {} {
  681. xywh {5 475 985 70} box BORDER_BOX
  682. } {
  683. Fl_Group {} {open
  684. xywh {10 490 190 40} box THIN_UP_BOX color 16
  685. } {
  686. Fl_Button play_button {
  687. label {@>}
  688. callback {if (control.playing_eof()&&(seek_slider->value()>99.0)){
  689. seek_slider->value(0.0);
  690. seek_slider->do_callback();
  691. };
  692. set_mode(PLAY);
  693. playing_for_button=true;
  694. eof_for_button=true;
  695. bool bypass=false;
  696. if (Fl::event_button()==FL_RIGHT_MOUSE) bypass=true;
  697. control.startplay(bypass);}
  698. tooltip Play xywh {20 500 40 20} box PLASTIC_UP_BOX
  699. }
  700. Fl_Button freeze_button {
  701. label {@<-> F}
  702. callback {control.freezeplay();
  703. set_mode(FREEZE);}
  704. tooltip Freeze xywh {65 500 40 20} box PLASTIC_UP_BOX
  705. }
  706. Fl_Button {} {
  707. label {@||}
  708. callback {set_mode(PAUSE);
  709. control.pauseplay();}
  710. tooltip Pause xywh {110 500 40 20} box PLASTIC_UP_BOX
  711. }
  712. Fl_Button {} {
  713. label {@square}
  714. callback {set_mode(STOP);
  715. control.stopplay();}
  716. tooltip Stop xywh {155 500 40 20} box PLASTIC_UP_BOX
  717. }
  718. }
  719. Fl_Value_Slider seek_slider {
  720. label Percents
  721. callback {control.set_seek_pos(o->value()/o->maximum());}
  722. xywh {205 490 780 20} type {Horz Knob} box THIN_UP_BOX color 16 selection_color 4 align 6 maximum 100 textsize 14
  723. }
  724. }
  725. }
  726. Fl_Window aboutwindow {
  727. label {About...}
  728. xywh {274 354 300 170} type Double color 7 hide modal
  729. } {
  730. Fl_Button {} {
  731. label OK
  732. callback {aboutwindow->hide();}
  733. xywh {110 140 64 20}
  734. }
  735. Fl_Box {} {
  736. label {Copyright (c) 2006-2011 Nasca Octavian PAUL, Tg. Mures, Romania}
  737. xywh {10 93 280 37} align 128
  738. }
  739. Fl_Box {} {
  740. label {This is a software for extreme time stretching of the audio.}
  741. xywh {5 53 290 32} align 128
  742. }
  743. Fl_Box {} {
  744. label {Paul's Extreme Sound Stretch}
  745. xywh {20 6 255 21} labelfont 1 align 128
  746. }
  747. Fl_Box {} {
  748. label version
  749. xywh {20 26 255 19} labelfont 1 align 128
  750. code0 {o->label(VERSION);}
  751. }
  752. }
  753. }
  754. Function {set_mode(Mode mode)} {private
  755. } {
  756. code {switch (mode){
  757. case STOP:
  758. play_button->labelcolor(FL_BLACK);
  759. mode_choice->activate();
  760. freeze_button->deactivate();
  761. break;
  762. case PAUSE:
  763. play_button->labelcolor(FL_BLACK);
  764. mode_choice->activate();
  765. break;
  766. case PLAY:
  767. play_button->labelcolor(FL_RED);
  768. mode_choice->deactivate();
  769. fftsize_slider->labelcolor(FL_BLACK);
  770. freeze_button->activate();
  771. break;
  772. case FREEZE:
  773. if (control.is_freeze()) freeze_button->labelcolor(FL_GREEN);
  774. else freeze_button->labelcolor(FL_BLACK);
  775. break;
  776. };
  777. window->redraw();} {}
  778. }
  779. Function {refresh()} {open
  780. } {
  781. code {double stretch_s=stretch_slider->value()/stretch_slider->maximum();
  782. int mode=mode_choice->value();
  783. double resolution_s=fftsize_slider->value()/fftsize_slider->maximum();
  784. control.set_stretch_controls(stretch_s,mode,resolution_s);
  785. stretch_slider->copy_label(control.get_stretch_info().c_str());
  786. fftsize_slider->copy_label(control.get_fftsize_info().c_str());
  787. resolution_box->copy_label(control.get_fftresolution_info().c_str());
  788. bool may_render=false;
  789. if (infilename_output->label()!=NULL){
  790. if (strlen(infilename_output->label())!=0)
  791. may_render=true;
  792. };
  793. if (!rendering){//do not change the status of render button while rendering
  794. if (may_render) {
  795. render_button->activate();
  796. render_menu->activate();
  797. } else {
  798. render_button->deactivate();
  799. render_menu->deactivate();
  800. };
  801. };} {}
  802. }
  803. Function {refreshgui()} {open
  804. } {
  805. code {stretch_slider->value(control.gui_sliders.stretch_s);
  806. fftsize_slider->value(control.gui_sliders.fftsize_s);
  807. mode_choice->value(control.gui_sliders.mode_s);
  808. window_choice->value(control.window_type);
  809. pitch_shift_enabled->value(control.ppar.pitch_shift.enabled);
  810. pitch_shift_cents->value(control.ppar.pitch_shift.cents);
  811. octave_enabled->value(control.ppar.octave.enabled);
  812. octave_om2->value(control.ppar.octave.om2);
  813. octave_om1->value(control.ppar.octave.om1);
  814. octave_o0->value(control.ppar.octave.o0);
  815. octave_o1->value(control.ppar.octave.o1);
  816. octave_o15->value(control.ppar.octave.o15);
  817. octave_o2->value(control.ppar.octave.o2);
  818. freq_shift_enabled->value(control.ppar.freq_shift.enabled);
  819. freq_shift_Hz->value(control.ppar.freq_shift.Hz);
  820. compressor_enabled->value(control.ppar.compressor.enabled);
  821. compressor_power->value(control.ppar.compressor.power);
  822. filter_enabled->value(control.ppar.filter.enabled);
  823. filter_stop->value(control.ppar.filter.stop);
  824. filter_low->value(control.ppar.filter.low);
  825. filter_high->value(control.ppar.filter.high);
  826. filter_hdamp->value(control.ppar.filter.hdamp);
  827. harmonics_enabled->value(control.ppar.harmonics.enabled);
  828. harmonics_freq->value(control.ppar.harmonics.freq);
  829. harmonics_bandwidth->value(control.ppar.harmonics.bandwidth);
  830. harmonics_nharmonics->value(control.ppar.harmonics.nharmonics);
  831. harmonics_gauss->value(control.ppar.harmonics.gauss);
  832. spread_enabled->value(control.ppar.spread.enabled);
  833. spread_bandwidth->value(control.ppar.spread.bandwidth);
  834. tonal_vs_noise_enabled->value(control.ppar.tonal_vs_noise.enabled);
  835. tonal_vs_noise_preserve->value(control.ppar.tonal_vs_noise.preserve);
  836. tonal_vs_noise_bandwidth->value(control.ppar.tonal_vs_noise.bandwidth);
  837. bbpar_mono->value(control.bbpar.mono);
  838. bbpar_stereo_mode->value(control.bbpar.stereo_mode);
  839. stretch_multiplier_control->refresh();
  840. arbitrary_filter_control->refresh();
  841. binaural_beats_control->refresh();} {}
  842. }
  843. Function {tickrefresh()} {} {
  844. code {seek_slider->value(seek_slider->maximum()*control.get_seek_pos());
  845. if (playing_for_button&&control.playing()){
  846. play_button->labelcolor(FL_GREEN);
  847. window->redraw();
  848. playing_for_button=false;
  849. };
  850. if (eof_for_button&&control.playing_eof()){
  851. play_button->labelcolor(FL_BLACK);
  852. window->redraw();
  853. eof_for_button=false;
  854. };
  855. if (control.info.render_percent>0.0){
  856. render_percent_slider->value(control.info.render_percent);
  857. };
  858. if (infilename_output->new_drag_file){
  859. open_input_file(infilename_output->drag_file.c_str());
  860. infilename_output->new_drag_file=false;
  861. };} {}
  862. }
  863. Function {tickdraw(GUI *o)} {return_type {static void}
  864. } {
  865. code {o->tickrefresh();} {}
  866. }
  867. Function {tick(void *v)} {return_type {static void}
  868. } {
  869. code {tickdraw((GUI *) v);
  870. Fl::add_timeout(1.0/3.0,tick,v);//3 fps} {}
  871. }
  872. decl {Control control;} {}
  873. decl {bool playing_for_button;} {}
  874. decl {bool rendering;} {}
  875. decl {bool eof_for_button;} {}
  876. }
  877. Function {file_exists(const char *filename)} {return_type bool
  878. } {
  879. code {struct stat buf;
  880. int i = stat ( filename, &buf );
  881. // File exists
  882. if ( i == 0 ) return true;
  883. else return false;} {}
  884. }
  885. Function {main(int argc, char *argv[])} {open return_type int
  886. } {
  887. code {GUI *gui=new GUI();
  888. if (argc>1){
  889. const char *filename=argv[1];
  890. if (filename[0]=='-'){
  891. if (argc>2) filename=argv[2];
  892. else filename=NULL;
  893. };
  894. if (filename) gui->open_input_file(filename);
  895. };
  896. gui->window->show();
  897. Fl::run();
  898. delete gui;
  899. return 0;} {selected
  900. }
  901. }