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.

992 lines
31KB

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