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