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.

974 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. control.update_player_stretch();} selected
  261. xywh {850 110 135 20} down_box BORDER_BOX
  262. } {
  263. MenuItem {} {
  264. label Stretch
  265. xywh {10 10 30 20}
  266. }
  267. MenuItem {} {
  268. label HyperStretch
  269. xywh {20 20 30 20}
  270. }
  271. MenuItem {} {
  272. label Shorten
  273. xywh {0 0 30 20}
  274. }
  275. }
  276. Fl_Choice window_choice {
  277. label {Type:}
  278. callback {FFTWindow w=W_RECTANGULAR;
  279. switch(o->value()){
  280. case 0:
  281. w=W_RECTANGULAR;
  282. break;
  283. case 1:
  284. w=W_HAMMING;
  285. break;
  286. case 2:
  287. w=W_HANN;
  288. break;
  289. case 3:
  290. w=W_BLACKMAN;
  291. break;
  292. case 4:
  293. w=W_BLACKMAN_HARRIS;
  294. break;
  295. };
  296. control.set_window_type(w);
  297. refresh();}
  298. xywh {850 185 135 20} down_box BORDER_BOX when 1
  299. code0 {o->value(2);}
  300. } {
  301. MenuItem {} {
  302. label Rectangular
  303. xywh {40 40 30 20}
  304. }
  305. MenuItem {} {
  306. label Hamming
  307. xywh {30 30 30 20}
  308. }
  309. MenuItem {} {
  310. label Hann
  311. xywh {10 10 30 20}
  312. }
  313. MenuItem {} {
  314. label Blackman
  315. xywh {20 20 30 20}
  316. }
  317. MenuItem {} {
  318. label BlackmanHarris
  319. xywh {30 30 30 20}
  320. }
  321. }
  322. Fl_Button {} {
  323. label S
  324. callback {char tmp[100];
  325. snprintf(tmp,100,"%g",control.get_stretch());
  326. const char *result=fl_input("Enter the stretch value",tmp);
  327. if (!result) return;
  328. double str=atof(result);
  329. if (str<1e-4) return;
  330. double stc=control.get_stretch_control(str,mode_choice->value());
  331. if ((stc<1e-4)||(stc>1.0)) return;
  332. stretch_slider->value(stc);
  333. stretch_slider->do_callback();}
  334. tooltip {set the stretch to a value} xywh {780 110 20 20}
  335. }
  336. Fl_Box resolution_box {
  337. xywh {10 187 790 18} box FLAT_BOX color 52 align 20
  338. }
  339. Fl_Group {} {
  340. label {Stretch Multiplier} open
  341. xywh {10 245 975 220} box THIN_UP_BOX labeltype ENGRAVED_LABEL
  342. } {
  343. Fl_Box stretch_free_edit {
  344. label Graph
  345. xywh {105 250 875 210} box FLAT_BOX color 17
  346. code0 {o->init(&control.ppar.stretch_multiplier,&control);}
  347. class FreeEditUI
  348. }
  349. Fl_Group stretch_multiplier_control {open
  350. xywh {15 250 85 210} box BORDER_FRAME color 0 align 208
  351. code0 {o->init(stretch_free_edit,FE_LINEAR,0,100.0,FE_LOG,0.1,50.0,1.0);}
  352. class FreeEditControls
  353. } {}
  354. }
  355. Fl_Slider onset_slider {
  356. label {Onset sensitivity:}
  357. callback {refresh();
  358. control.update_player_stretch();}
  359. xywh {135 213 140 15} type {Horz Knob} box FLAT_BOX align 4
  360. }
  361. }
  362. Fl_Group {} {
  363. label Process open
  364. xywh {5 70 985 400} hide
  365. } {
  366. Fl_Group {} {open
  367. xywh {165 75 105 65} box BORDER_BOX
  368. } {
  369. Fl_Check_Button pitch_shift_enabled {
  370. label {Pitch Shift}
  371. callback {control.ppar.pitch_shift.enabled=o->value();
  372. control.update_process_parameters();}
  373. xywh {170 80 90 15} down_box DOWN_BOX labelfont 1
  374. }
  375. Fl_Counter pitch_shift_cents {
  376. label cents
  377. callback {control.ppar.pitch_shift.cents=(int)o->value();
  378. control.update_process_parameters();}
  379. xywh {170 100 90 20} minimum -3600 maximum 3600 step 1
  380. code0 {o->lstep(100);}
  381. }
  382. }
  383. Fl_Group {} {open
  384. xywh {275 75 135 100} box BORDER_BOX
  385. } {
  386. Fl_Check_Button octave_enabled {
  387. label {Octave Mixer}
  388. callback {control.ppar.octave.enabled=o->value();
  389. control.update_process_parameters();}
  390. xywh {280 80 110 15} down_box DOWN_BOX labelfont 1
  391. }
  392. Fl_Slider octave_om2 {
  393. label {-2}
  394. callback {control.ppar.octave.om2=pow(o->value(),2.0);
  395. control.update_process_parameters();}
  396. tooltip {2 octaves below} xywh {280 100 15 55} type {Vert Knob} minimum 1 maximum 0
  397. }
  398. Fl_Slider octave_om1 {
  399. label {-1}
  400. callback {control.ppar.octave.om1=pow(o->value(),2.0);
  401. control.update_process_parameters();}
  402. tooltip {1 octave below} xywh {300 100 15 55} type {Vert Knob} minimum 1 maximum 0
  403. }
  404. Fl_Slider octave_o0 {
  405. label 0
  406. callback {control.ppar.octave.o0=pow(o->value(),2.0);
  407. control.update_process_parameters();}
  408. tooltip {original (dry)} xywh {320 100 15 55} type {Vert Knob} minimum 1 maximum 0 value 1
  409. }
  410. Fl_Slider octave_o1 {
  411. label 1
  412. callback {control.ppar.octave.o1=pow(o->value(),2.0);
  413. control.update_process_parameters();}
  414. tooltip {1 octave above} xywh {340 100 15 55} type {Vert Knob} minimum 1 maximum 0
  415. }
  416. Fl_Slider octave_o15 {
  417. label {1.5}
  418. callback {control.ppar.octave.o15=pow(o->value(),2.0);
  419. control.update_process_parameters();}
  420. tooltip {3rd harmonic} xywh {360 100 15 55} type {Vert Knob} minimum 1 maximum 0
  421. }
  422. Fl_Slider octave_o2 {
  423. label 2
  424. callback {control.ppar.octave.o2=pow(o->value(),2.0);
  425. control.update_process_parameters();}
  426. tooltip {2 octaves above} xywh {380 100 15 55} type {Vert Knob} minimum 1 maximum 0
  427. }
  428. }
  429. Fl_Group {} {open
  430. xywh {165 140 105 65} box BORDER_BOX
  431. } {
  432. Fl_Check_Button freq_shift_enabled {
  433. label {Freq Shift}
  434. callback {control.ppar.freq_shift.enabled=o->value();
  435. control.update_process_parameters();}
  436. xywh {170 145 90 15} down_box DOWN_BOX labelfont 1
  437. }
  438. Fl_Counter freq_shift_Hz {
  439. label Hz
  440. callback {control.ppar.freq_shift.Hz=(int)o->value();
  441. control.update_process_parameters();}
  442. xywh {170 165 90 20} minimum -10000 maximum 10000 step 1
  443. code0 {o->lstep(100);}
  444. }
  445. }
  446. Fl_Group {} {open
  447. xywh {750 75 120 65} box BORDER_BOX
  448. } {
  449. Fl_Check_Button compressor_enabled {
  450. label Compress
  451. callback {control.ppar.compressor.enabled=o->value();
  452. control.update_process_parameters();}
  453. xywh {755 80 90 15} down_box DOWN_BOX labelfont 1
  454. }
  455. Fl_Slider compressor_power {
  456. label Power
  457. callback {control.ppar.compressor.power=o->value();
  458. control.update_process_parameters();}
  459. xywh {755 100 110 15} type {Horz Knob}
  460. }
  461. }
  462. Fl_Slider {} {
  463. label Volume
  464. callback {REALTYPE x=o->value();
  465. x=pow(10.0,pow(x,1.5)-1.0)-0.1;
  466. control.set_volume(x);}
  467. xywh {750 155 120 40} type {Horz Knob} labelfont 1 minimum 0.3 maximum 1.6 value 1
  468. }
  469. Fl_Group {} {open
  470. xywh {415 75 185 100} box BORDER_BOX
  471. } {
  472. Fl_Check_Button filter_enabled {
  473. label Filter
  474. callback {control.ppar.filter.enabled=o->value();
  475. control.update_process_parameters();}
  476. xywh {420 80 70 15} down_box DOWN_BOX labelfont 1
  477. }
  478. Fl_Value_Input filter_low {
  479. label {Freq1(Hz)}
  480. callback {control.ppar.filter.low=o->value();
  481. control.update_process_parameters();}
  482. xywh {420 101 100 24} align 8 maximum 10000
  483. }
  484. Fl_Value_Input filter_high {
  485. label {Freq2(Hz)}
  486. callback {control.ppar.filter.high=o->value();
  487. control.update_process_parameters();}
  488. xywh {420 126 100 24} align 8 maximum 25000 value 22000
  489. }
  490. Fl_Check_Button filter_stop {
  491. label BandStop
  492. callback {control.ppar.filter.stop=o->value();
  493. control.update_process_parameters();}
  494. tooltip {band-stop filter} xywh {500 80 90 15} down_box DOWN_BOX
  495. }
  496. Fl_Slider filter_hdamp {
  497. label DHF
  498. callback {control.ppar.filter.hdamp=o->value();
  499. control.update_process_parameters();}
  500. tooltip {Damp High Frequency} xywh {420 155 140 15} type {Horz Knob} align 8
  501. }
  502. }
  503. Fl_Group {} {open
  504. xywh {10 75 150 120} box BORDER_BOX
  505. } {
  506. Fl_Check_Button harmonics_enabled {
  507. label Harmonics
  508. callback {control.ppar.harmonics.enabled=o->value();
  509. control.update_process_parameters();}
  510. xywh {15 80 95 15} down_box DOWN_BOX labelfont 1
  511. }
  512. Fl_Value_Input harmonics_freq {
  513. label {F.Freq(Hz)}
  514. callback {control.ppar.harmonics.freq=o->value();
  515. control.update_process_parameters();}
  516. tooltip {fundamental frequency} xywh {15 101 65 24} align 8 minimum 1 maximum 20000 value 440
  517. }
  518. Fl_Value_Input harmonics_bandwidth {
  519. label {BW(cents)}
  520. callback {control.ppar.harmonics.bandwidth=o->value();
  521. control.update_process_parameters();}
  522. tooltip {bandwidth (cents)} xywh {15 126 65 24} align 8 minimum 0.1 maximum 200 value 25
  523. }
  524. Fl_Check_Button harmonics_gauss {
  525. label Gauss
  526. callback {control.ppar.harmonics.gauss=o->value();
  527. control.update_process_parameters();}
  528. tooltip {smooth the harmonics} xywh {85 155 65 15} down_box DOWN_BOX
  529. }
  530. Fl_Counter harmonics_nharmonics {
  531. label {no.hrm.}
  532. callback {control.ppar.harmonics.nharmonics=(int)o->value();
  533. control.update_process_parameters();}
  534. tooltip {number of harmonics} xywh {15 155 56 20} type Simple minimum 1 maximum 100 step 1 value 10
  535. }
  536. }
  537. Fl_Group {} {open
  538. xywh {275 180 325 40} box BORDER_BOX
  539. } {
  540. Fl_Check_Button spread_enabled {
  541. label Spread
  542. callback {control.ppar.spread.enabled=o->value();
  543. control.update_process_parameters();}
  544. xywh {280 185 90 15} down_box DOWN_BOX labelfont 1
  545. }
  546. Fl_Slider spread_bandwidth {
  547. label Bandwidth
  548. callback {control.ppar.spread.bandwidth=o->value();
  549. control.update_process_parameters();}
  550. xywh {360 185 230 15} type {Horz Knob} value 0.3
  551. }
  552. }
  553. Fl_Group {} {
  554. label ArbitraryFilter
  555. xywh {10 245 975 220} box THIN_UP_BOX labeltype ENGRAVED_LABEL
  556. } {
  557. Fl_Box filter_free_edit {
  558. label Graph
  559. xywh {105 250 875 210} box FLAT_BOX color 206 selection_color 0
  560. code0 {o->init(&control.ppar.free_filter,&control);}
  561. class FreeEditUI
  562. }
  563. Fl_Group arbitrary_filter_control {open
  564. xywh {15 250 85 210} box BORDER_FRAME color 0 align 208
  565. code0 {o->init(filter_free_edit,FE_LOG,20.0,25000.0,FE_DB,-60,20,0.0);}
  566. class FreeEditControls
  567. } {}
  568. }
  569. Fl_Group {} {open
  570. xywh {605 75 140 105} box BORDER_BOX
  571. } {
  572. Fl_Check_Button tonal_vs_noise_enabled {
  573. label {Tonal/Noise}
  574. callback {control.ppar.tonal_vs_noise.enabled=o->value();
  575. control.update_process_parameters();}
  576. xywh {610 80 115 20} down_box DOWN_BOX labelfont 1
  577. }
  578. Fl_Slider tonal_vs_noise_bandwidth {
  579. label Bandwidth
  580. callback {control.ppar.tonal_vs_noise.bandwidth=o->value();
  581. control.update_process_parameters();}
  582. xywh {610 141 130 15} type {Horz Knob} minimum 0.75 value 0.9
  583. }
  584. Fl_Slider tonal_vs_noise_preserve {
  585. label {noise <-->tonal}
  586. callback {control.ppar.tonal_vs_noise.preserve=o->value();
  587. control.update_process_parameters();}
  588. xywh {610 105 130 15} type {Horz Knob} minimum -1 value 0.5
  589. }
  590. }
  591. }
  592. Fl_Group {} {
  593. label {Binaural beats}
  594. xywh {5 70 985 400} box THIN_UP_BOX hide
  595. } {
  596. Fl_Box binaural_free_edit {
  597. label Graph
  598. xywh {135 75 845 390} box FLAT_BOX color 135
  599. code0 {o->init(&control.bbpar.free_edit,&control);}
  600. class FreeEditUI
  601. }
  602. Fl_Slider bbpar_mono {
  603. label Pow
  604. callback {control.bbpar.mono=o->value();
  605. control.update_process_parameters();}
  606. xywh {105 75 20 190} type {Vert Knob} labelfont 1 minimum 1 maximum 0 value 0.5
  607. }
  608. Fl_Group binaural_beats_control {
  609. label {FreeEdit Controls}
  610. xywh {10 75 80 205} box BORDER_FRAME color 47 align 208
  611. code0 {o->init(binaural_free_edit,FE_LINEAR,0,100.0,FE_LOG,0.1,50.0,8.0);}
  612. class FreeEditControls
  613. } {}
  614. Fl_Choice bbpar_stereo_mode {
  615. label {Stereo Mode}
  616. callback {control.bbpar.stereo_mode=(BB_STEREO_MODE)o->value();
  617. control.update_process_parameters();}
  618. xywh {10 305 110 20} down_box BORDER_BOX align 5
  619. } {
  620. MenuItem {} {
  621. label LeftRight
  622. xywh {10 10 36 21} labelfont 1
  623. }
  624. MenuItem {} {
  625. label RightLeft
  626. xywh {20 20 36 21} labelfont 1
  627. }
  628. MenuItem {} {
  629. label Symmetric
  630. xywh {30 30 36 21} labelfont 1
  631. }
  632. }
  633. }
  634. Fl_Group write_to_file_group {
  635. label {Write to file} open
  636. xywh {5 70 985 400} hide
  637. } {
  638. Fl_Button render_button {
  639. label {Render selection...}
  640. callback {render();}
  641. xywh {250 95 320 30} labelfont 1 labelsize 22
  642. }
  643. Fl_Value_Slider render_percent_slider {
  644. label { }
  645. xywh {15 245 970 65} type {Horz Fill} selection_color 4 align 70 maximum 100 step 0.1 textsize 14
  646. }
  647. Fl_Button cancel_render_button {
  648. label Cancel
  649. callback {if (fl_choice("Cancel audio rendering?","No","Yes",NULL)) control.info.cancel_render=true;}
  650. xywh {400 365 145 25} deactivate
  651. }
  652. Fl_Button {} {
  653. label {selection pos1}
  654. callback {selection_pos1->value(seek_slider->value());}
  655. tooltip {set selection start from Player's position} xywh {20 85 110 20} align 20
  656. }
  657. Fl_Button {} {
  658. label {selection pos2}
  659. callback {selection_pos2->value(seek_slider->value());}
  660. tooltip {set selection end from Player's position} xywh {20 110 110 20} align 20
  661. }
  662. Fl_Button {} {
  663. label {select all}
  664. callback {selection_pos1->value(0.0);
  665. selection_pos2->value(100.0);}
  666. tooltip {select the whole sound} xywh {20 135 110 20}
  667. }
  668. Fl_Value_Output selection_pos1 {
  669. label {%}
  670. xywh {135 85 70 20} align 72 maximum 100 step 0.01 textfont 1
  671. }
  672. Fl_Value_Output selection_pos2 {
  673. label {%}
  674. xywh {135 111 70 18} align 72 maximum 100 step 0.01 value 100 textfont 1
  675. }
  676. Fl_Check_Button {} {
  677. label 32bit
  678. callback {control.wav32bit=o->value();}
  679. xywh {250 135 100 15} down_box DOWN_BOX
  680. }
  681. }
  682. }
  683. Fl_Box infilename_output {
  684. tooltip {drag audio file here to open it} xywh {5 24 1005 22} box FLAT_BOX color 17 align 84
  685. class DDBox
  686. }
  687. Fl_Group {} {open
  688. xywh {5 475 985 70} box BORDER_BOX
  689. } {
  690. Fl_Group {} {open
  691. xywh {10 490 190 40} box THIN_UP_BOX color 16
  692. } {
  693. Fl_Button play_button {
  694. label {@>}
  695. callback {if (control.playing_eof()&&(seek_slider->value()>99.0)){
  696. seek_slider->value(0.0);
  697. seek_slider->do_callback();
  698. };
  699. set_mode(PLAY);
  700. playing_for_button=true;
  701. eof_for_button=true;
  702. bool bypass=false;
  703. if (Fl::event_button()==FL_RIGHT_MOUSE) bypass=true;
  704. control.startplay(bypass);}
  705. tooltip {Play - right click to play the original sound} xywh {20 500 40 20} box PLASTIC_UP_BOX
  706. }
  707. Fl_Button freeze_button {
  708. label {@<-> F}
  709. callback {control.freezeplay();
  710. set_mode(FREEZE);}
  711. tooltip Freeze xywh {65 500 40 20} box PLASTIC_UP_BOX
  712. }
  713. Fl_Button {} {
  714. label {@||}
  715. callback {set_mode(PAUSE);
  716. control.pauseplay();}
  717. tooltip Pause xywh {110 500 40 20} box PLASTIC_UP_BOX
  718. }
  719. Fl_Button {} {
  720. label {@square}
  721. callback {set_mode(STOP);
  722. control.stopplay();}
  723. tooltip Stop xywh {155 500 40 20} box PLASTIC_UP_BOX
  724. }
  725. }
  726. Fl_Value_Slider seek_slider {
  727. label Percents
  728. callback {control.set_seek_pos(o->value()/o->maximum());}
  729. xywh {205 490 780 20} type {Horz Knob} box THIN_UP_BOX color 16 selection_color 4 align 6 maximum 100 textsize 14
  730. }
  731. }
  732. }
  733. Fl_Window aboutwindow {
  734. label {About...}
  735. xywh {274 354 300 170} type Double color 7 hide modal
  736. } {
  737. Fl_Button {} {
  738. label OK
  739. callback {aboutwindow->hide();}
  740. xywh {110 140 64 20}
  741. }
  742. Fl_Box {} {
  743. label {Copyright (c) 2006-2011 Nasca Octavian PAUL, Tg. Mures, Romania}
  744. xywh {10 93 280 37} align 128
  745. }
  746. Fl_Box {} {
  747. label {This is a software for extreme time stretching of the audio.}
  748. xywh {5 53 290 32} align 128
  749. }
  750. Fl_Box {} {
  751. label {Paul's Extreme Sound Stretch}
  752. xywh {20 6 255 21} labelfont 1 align 128
  753. }
  754. Fl_Box {} {
  755. label version
  756. xywh {20 26 255 19} labelfont 1 align 128
  757. code0 {o->label(VERSION);}
  758. }
  759. }
  760. }
  761. Function {set_mode(Mode mode)} {open private
  762. } {
  763. code {switch (mode){
  764. case STOP:
  765. play_button->labelcolor(FL_BLACK);
  766. //mode_choice->activate();
  767. freeze_button->deactivate();
  768. break;
  769. case PAUSE:
  770. play_button->labelcolor(FL_BLACK);
  771. //mode_choice->activate();
  772. break;
  773. case PLAY:
  774. play_button->labelcolor(FL_RED);
  775. //mode_choice->deactivate();
  776. fftsize_slider->labelcolor(FL_BLACK);
  777. freeze_button->activate();
  778. break;
  779. case FREEZE:
  780. if (control.is_freeze()) freeze_button->labelcolor(FL_GREEN);
  781. else freeze_button->labelcolor(FL_BLACK);
  782. break;
  783. };
  784. window->redraw();} {}
  785. }
  786. Function {refresh()} {open
  787. } {
  788. code {double stretch_s=stretch_slider->value()/stretch_slider->maximum();
  789. int mode=mode_choice->value();
  790. double resolution_s=fftsize_slider->value()/fftsize_slider->maximum();
  791. double onset=onset_slider->value();
  792. control.set_stretch_controls(stretch_s,mode,resolution_s,onset);
  793. stretch_slider->copy_label(control.get_stretch_info().c_str());
  794. fftsize_slider->copy_label(control.get_fftsize_info().c_str());
  795. resolution_box->copy_label(control.get_fftresolution_info().c_str());
  796. bool may_render=false;
  797. if (infilename_output->label()!=NULL){
  798. if (strlen(infilename_output->label())!=0)
  799. may_render=true;
  800. };
  801. if (!rendering){//do not change the status of render button while rendering
  802. if (may_render) {
  803. render_button->activate();
  804. render_menu->activate();
  805. } else {
  806. render_button->deactivate();
  807. render_menu->deactivate();
  808. };
  809. };} {}
  810. }
  811. Function {refreshgui()} {open
  812. } {
  813. code {stretch_slider->value(control.gui_sliders.stretch_s);
  814. fftsize_slider->value(control.gui_sliders.fftsize_s);
  815. mode_choice->value(control.gui_sliders.mode_s);
  816. window_choice->value(control.window_type);
  817. onset_slider->value(control.get_onset_detection_sensitivity());
  818. pitch_shift_enabled->value(control.ppar.pitch_shift.enabled);
  819. pitch_shift_cents->value(control.ppar.pitch_shift.cents);
  820. octave_enabled->value(control.ppar.octave.enabled);
  821. octave_om2->value(control.ppar.octave.om2);
  822. octave_om1->value(control.ppar.octave.om1);
  823. octave_o0->value(control.ppar.octave.o0);
  824. octave_o1->value(control.ppar.octave.o1);
  825. octave_o15->value(control.ppar.octave.o15);
  826. octave_o2->value(control.ppar.octave.o2);
  827. freq_shift_enabled->value(control.ppar.freq_shift.enabled);
  828. freq_shift_Hz->value(control.ppar.freq_shift.Hz);
  829. compressor_enabled->value(control.ppar.compressor.enabled);
  830. compressor_power->value(control.ppar.compressor.power);
  831. filter_enabled->value(control.ppar.filter.enabled);
  832. filter_stop->value(control.ppar.filter.stop);
  833. filter_low->value(control.ppar.filter.low);
  834. filter_high->value(control.ppar.filter.high);
  835. filter_hdamp->value(control.ppar.filter.hdamp);
  836. harmonics_enabled->value(control.ppar.harmonics.enabled);
  837. harmonics_freq->value(control.ppar.harmonics.freq);
  838. harmonics_bandwidth->value(control.ppar.harmonics.bandwidth);
  839. harmonics_nharmonics->value(control.ppar.harmonics.nharmonics);
  840. harmonics_gauss->value(control.ppar.harmonics.gauss);
  841. spread_enabled->value(control.ppar.spread.enabled);
  842. spread_bandwidth->value(control.ppar.spread.bandwidth);
  843. tonal_vs_noise_enabled->value(control.ppar.tonal_vs_noise.enabled);
  844. tonal_vs_noise_preserve->value(control.ppar.tonal_vs_noise.preserve);
  845. tonal_vs_noise_bandwidth->value(control.ppar.tonal_vs_noise.bandwidth);
  846. bbpar_mono->value(control.bbpar.mono);
  847. bbpar_stereo_mode->value(control.bbpar.stereo_mode);
  848. stretch_multiplier_control->refresh();
  849. arbitrary_filter_control->refresh();
  850. binaural_beats_control->refresh();} {}
  851. }
  852. Function {tickrefresh()} {} {
  853. code {seek_slider->value(seek_slider->maximum()*control.get_seek_pos());
  854. if (playing_for_button&&control.playing()){
  855. play_button->labelcolor(FL_GREEN);
  856. window->redraw();
  857. playing_for_button=false;
  858. };
  859. if (eof_for_button&&control.playing_eof()){
  860. play_button->labelcolor(FL_BLACK);
  861. window->redraw();
  862. eof_for_button=false;
  863. };
  864. if (control.info.render_percent>0.0){
  865. render_percent_slider->value(control.info.render_percent);
  866. };
  867. if (infilename_output->new_drag_file){
  868. open_input_file(infilename_output->drag_file.c_str());
  869. infilename_output->new_drag_file=false;
  870. };} {}
  871. }
  872. Function {tickdraw(GUI *o)} {return_type {static void}
  873. } {
  874. code {o->tickrefresh();} {}
  875. }
  876. Function {tick(void *v)} {return_type {static void}
  877. } {
  878. code {tickdraw((GUI *) v);
  879. Fl::add_timeout(1.0/3.0,tick,v);//3 fps} {}
  880. }
  881. decl {Control control;} {}
  882. decl {bool playing_for_button;} {}
  883. decl {bool rendering;} {}
  884. decl {bool eof_for_button;} {}
  885. }
  886. Function {file_exists(const char *filename)} {return_type bool
  887. } {
  888. code {struct stat buf;
  889. int i = stat ( filename, &buf );
  890. // File exists
  891. if ( i == 0 ) return true;
  892. else return false;} {}
  893. }
  894. Function {main(int argc, char *argv[])} {open return_type int
  895. } {
  896. code {GUI *gui=new GUI();
  897. if (argc>1){
  898. const char *filename=argv[1];
  899. if (filename[0]=='-'){
  900. if (argc>2) filename=argv[2];
  901. else filename=NULL;
  902. };
  903. if (filename) gui->open_input_file(filename);
  904. };
  905. gui->window->show();
  906. Fl::run();
  907. delete gui;
  908. return 0;} {}
  909. }