# data file for the Fltk User Interface Designer (fluid)
version 1.0302 
header_name {.h} 
code_name {.cc}
decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {private local
} 

decl {//License: GNU GPL version 2 or later} {private local
} 

decl {\#include "Fl_Osc_Dial.H"} {public local
} 

decl {\#include "Fl_Osc_Choice.H"} {public local
} 

decl {\#include "Fl_Osc_Check.H"} {public local
} 

decl {\#include "Fl_Osc_Counter.H"} {public local
} 

decl {\#include "Fl_Osc_Output.H"} {public local
} 

decl {\#include "Fl_Osc_Slider.H"} {public local
} 

decl {\#include "Fl_Osc_Pane.H"} {public local
}

decl {\#include <cmath>} {private local
} 

decl {\#include <stdio.h>} {private global
} 

decl {\#include <stdlib.h>} {private global
} 

decl {\#include "../globals.h"} {public local
} 

decl {\#include "../Misc/Util.h"} {public local
} 

decl {\#include <FL/Fl_Group.H>} {public local
} 

decl {\#include "../Params/FilterParams.h"} {public local
} 

decl {\#include <FL/Fl_Box.H>} {public local
} 

decl {\#include <FL/fl_draw.H>} {public local
} 

decl {\#include <FL/fl_ask.H>} {public local
} 

decl {\#include "PresetsUI.h"} {public local
} 

decl {\#include "common.H"} {public local
} 

decl {\#include "FormantFilterGraph.H"} {public local
} 

decl {using namespace zyncarla;} {public local
}

class FilterUI {open : {public Fl_Osc_Group,PresetsUI_}
} {
  Function {FilterUI(int x,int y, int w, int h, const char *label=0):Fl_Osc_Group(x,y,w,h)} {} {
    code {nvowel=0;nformant=0;nseqpos=0;} {}
  }
  Function {~FilterUI()} {} {
    code {filterui->hide();
formantparswindow->hide();
hide();
//delete (filterui);
delete (formantparswindow);} {}
  }
  Function {make_window()} {open
  } {
    Fl_Window filterui {open
      xywh {516 484 275 70} type Double color 50 labelfont 1
      class Fl_Osc_Group visible
    } {
      Fl_Button {} {
        label P
        callback {presetsui->paste(filterui->loc(),this);}
        xywh {203 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
      }
      Fl_Group filterparamswindow {
        label {Filter Parameters}
        xywh {0 0 275 75} box UP_FRAME color 183 labeltype ENGRAVED_LABEL labelsize 10 align 17
        code0 {set_module_parameters( o );}
      } {
        Fl_Choice analogfiltertypechoice {
          label FilterType
          tooltip {The Filter type} xywh {10 50 50 15} down_box BORDER_BOX labelsize 10 align 5 textsize 10
          code1 {o->init("Ptype");}
          class Fl_Osc_Choice
        } {
          MenuItem {} {
            label LPF1
            xywh {40 40 100 20} labelfont 1 labelsize 10
          }
          MenuItem {} {
            label HPF1
            xywh {50 50 100 20} labelfont 1 labelsize 10
          }
          MenuItem {} {
            label LPF2
            xywh {60 60 100 20} labelfont 1 labelsize 10
          }
          MenuItem {} {
            label HPF2
            xywh {70 70 100 20} labelfont 1 labelsize 10
          }
          MenuItem {} {
            label BPF2
            xywh {82 82 100 20} labelfont 1 labelsize 10
          }
          MenuItem {} {
            label NF2
            xywh {94 94 100 20} labelfont 1 labelsize 10
          }
          MenuItem {} {
            label PkF2
            xywh {104 104 100 20} labelfont 1 labelsize 10
          }
          MenuItem {} {
            label LSh2
            xywh {114 114 100 20} labelfont 1 labelsize 10
          }
          MenuItem {} {
            label HSh2
            xywh {124 124 100 20} labelfont 1 labelsize 10
          }
        }
        Fl_Choice svfiltertypechoice {
          label FilterType
          tooltip {The Filter type} xywh {10 50 50 15} down_box BORDER_BOX labelsize 10 align 5 textsize 10
          code1 {o->init("Ptype");}
          class Fl_Osc_Choice
        } {
          MenuItem {} {
            label 1LPF
            xywh {134 134 100 20} labelfont 1 labelsize 10
          }
          MenuItem {} {
            label 1HPF
            xywh {144 144 100 20} labelfont 1 labelsize 10
          }
          MenuItem {} {
            label 1BPF
            xywh {154 154 100 20} labelfont 1 labelsize 10
          }
          MenuItem {} {
            label 1NF
            xywh {164 164 100 20} labelfont 1 labelsize 10
          }
        }
        Fl_Choice filtertype {
          label Category
          callback {refresh();}
          tooltip {The Category of the Filter (Analog/Formantic/etc.)} xywh {10 20 60 15} down_box BORDER_BOX labelsize 10 align 5 textsize 10
          code0 {o->init("Pcategory");}
          class Fl_Osc_Choice
        } {
          MenuItem {} {
            label Analog
            xywh {50 50 100 20} labelfont 1 labelsize 10
          }
          MenuItem {} {
            label Formant
            xywh {60 60 100 20} labelfont 1 labelsize 10
          }
          MenuItem {} {
            label StVarF
            xywh {70 70 100 20} labelfont 1 labelsize 10
          }
        }
        Fl_Dial cfreqdial {
          label {C.Freq}
          tooltip {Center Frequency of the Filter or the base position in the vowel's sequence} xywh {75 25 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("Pfreq");}
          class Fl_Osc_Dial
        }
        Fl_Dial qdial {
          label Q
          callback {formantfiltergraph->redraw();}
          tooltip {Filter resonance or bandwidth} xywh {110 25 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("Pq");}
          class Fl_Osc_Dial
        }
        Fl_Dial freqtrdial {
          label {freq.tr.}
          tooltip {Filter frequency tracking (left is negative, middle is 0, and right is positive)} xywh {215 25 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("Pfreqtrack");}
          class Fl_Osc_Dial
        }
        Fl_Dial vsnsadial {
          label {V.SnsA.}
          tooltip {Velocity sensing amount of the Filter} xywh {145 25 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {if(!alt_root.empty()) o->alt_init(alt_root, "VelocityScale"); }
          code1 {else {o->deactivate(); o->value(127);o->mark_dead();}}
          class Fl_Osc_Dial
        }
        Fl_Dial vsnsdial {
          label {V.Sns.}
          tooltip {Velocity Sensing Function of the Filter} xywh {180 25 30 30} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {if(!alt_root.empty()) o->alt_init(alt_root, "VelocityScaleFunction"); }
          code1 {else {o->deactivate(); o->value(127);o->mark_dead();}}
          class Fl_Osc_Dial
        }
        Fl_Dial gaindial {
          label gain
          callback {formantfiltergraph->redraw();}
          tooltip {Filter output gain/damp} xywh {250 35 20 20} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
          code0 {o->init("Pgain");}
          class Fl_Osc_Dial
        }
        Fl_Choice stcounter {
          label St
          callback {formantfiltergraph->redraw();} open
          tooltip {Filter stages (in order to increase dB/oct. value and the order of the filter)} xywh {235 5 35 15} down_box BORDER_BOX labelsize 10 textfont 1 textsize 10
          code1 {for (int i=0;i<MAX_FILTER_STAGES;i++) {char tmp[10];snprintf(tmp,10,"%dx",i+1);o->add(tmp);};}
          code2 {o->init("Pstages");}
          class Fl_Osc_Choice
        } {}
      }
      Fl_Button editbutton {
        label Edit
        callback {formantparswindow->show();}
        xywh {15 40 50 25} labelfont 1 labelsize 11
      }
      Fl_Button {} {
        label C
        callback {presetsui->copy(filterui->loc());}
        xywh {186 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
      }
      Fl_Button {} {
        label P
        callback {presetsui->paste(filterui->loc(),this);}
        xywh {203 5 15 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 10 labelcolor 55
      }
    }
  }
  Function {make_formant_window()} {open
  } {
    Fl_Window formantparswindow {
      label {Formant Filter Parameters} open
      xywh {536 611 700 205} type Double
      class Fl_Osc_Window visible
    } {
      Fl_Button {} {
        label P
        callback {presetsui->paste(filterui->loc(),this,nvowel);}
        xywh {665 25 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
        code0 {formantparswindow->osc = osc;}
        code1 {formantparswindow->base = loc();}
      }
      Fl_Group {} {open
        xywh {485 47 105 113} box THIN_UP_BOX
        class Fl_Osc_Group
      } {
        Fl_Counter {} {
          label {Formant }
          callback {nformant=(int) o->value();
          formantparsgroup->reext("Pvowels"+to_s(nvowel)+"/Pformants"+to_s(nformant)+"/");
update_formant_window();
formantfiltergraph->redraw();}
          xywh {545 80 40 15} type Simple labelfont 1 labelsize 10 align 4 minimum 0 maximum 127 step 1 textsize 10
          code0 {o->bounds(0,FF_MAX_FORMANTS-1);}
          code1 {o->value(nformant);}
        }
        Fl_Counter {} {
          label {Vowel no.}
          callback {nvowel=(int) o->value();
          formantparsgroup->reext("Pvowels"+to_s(nvowel)+"/Pformants"+to_s(nformant)+"/");
update_formant_window();
formantfiltergraph->redraw();}
          xywh {545 55 40 20} type Simple labelfont 1 labelsize 10 align 4 minimum 0 maximum 127 step 1 textfont 1 textsize 11
          code0 {o->bounds(0,FF_MAX_VOWELS-1);}
          code1 {o->value(nvowel);}
        }
        Fl_Group formantparsgroup {open
          xywh {490 105 95 50} box ENGRAVED_FRAME
          class Fl_Osc_Group
        } {
          Fl_Box {} {
            label dummy selected
            xywh {515 130 35 16} hide deactivate
            code0 {formantparsgroup->ext = "Pvowels0/Pformants0/";}
          }
          Fl_Dial formant_freq_dial {
            label freq
            callback {formantfiltergraph->update();}
            tooltip {Formant frequency} xywh {495 115 25 25} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
            code0 {//TODO get widget renaming working here!!!}
            code1 {o->init("freq");}
            class Fl_Osc_Dial
          }
          Fl_Dial formant_q_dial {
            label Q
            callback {formantfiltergraph->update();}
            tooltip {Formant's Q} xywh {525 115 24 25} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
            code0 {o->init("q");}
            class Fl_Osc_Dial
          }
          Fl_Dial formant_amp_dial {
            label amp
            callback {formantfiltergraph->update();}
            tooltip {Formant amplitude} xywh {555 115 24 25} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
            code0 {o->init("amp");}
            class Fl_Osc_Dial
          }
        }
      }
      Fl_Group {} {open
        xywh {590 47 100 113} box THIN_UP_BOX
        class Fl_Osc_Group
      } {
        Fl_Counter sequencesize {
          label {Seq.Size}
          callback {update_formant_window();}
          xywh {595 62 55 20} type Simple labelfont 1 labelsize 10 align 5 minimum 0 maximum 127 step 1 textfont 1 textsize 11
          code0 {o->bounds(1,FF_MAX_SEQUENCE-1);}
          code1 {o->init("Psequencesize");}
          class Fl_Osc_Counter
        }
        Fl_Counter {} {
          label {S.Pos.}
          callback {nseqpos = o->value();update_formant_window();vowel_counter->oscMove("vowel_seq"+to_s(nseqpos));}
          tooltip {Current position from the sequence} xywh {595 97 40 15} type Simple labelfont 1 labelsize 10 align 9 minimum 0 maximum 127 step 1 textsize 10
          code0 {o->bounds(0,FF_MAX_SEQUENCE-2);}
          code1 {o->value(nseqpos);}
        }
        Fl_Counter vowel_counter {
          label Vowel
          callback {(void)o;//pars->Psequence[nseqpos].nvowel=(int) o->value(); pars->changed=true;}
          xywh {640 97 40 15} type Simple labelsize 10 align 1 minimum 0 maximum 127 step 1 textsize 10
          code0 {o->bounds(0,FF_MAX_VOWELS-1);}
          code1 {o->init("vowel_seq0");}
          class Fl_Osc_Counter
        }
        Fl_Check_Button {} {
          label {Neg.Input}
          tooltip {Negate the input from LFO/envelopes/etc.} xywh {625 132 60 20} down_box DOWN_BOX labelsize 10
          code0 {o->init("Psequencereversed");}
          class Fl_Osc_Check
        }
        Fl_Dial strchdial {
          label Strch
          tooltip {Sequence Stretch} xywh {595 130 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
          code0 {o->init("Psequencestretch");}
          class Fl_Osc_Dial
        }
      }
      Fl_Counter numformants {
        label {Num.Formants}
        callback {update_formant_window();
formantfiltergraph->redraw();}
        xywh {485 15 65 20} type Simple labelfont 0 labelsize 10 align 5 minimum 0 maximum 127 step 1
        code0 {o->bounds(1,FF_MAX_FORMANTS);}
        code1 {o->init("Pnumformants");}
        class Fl_Osc_Counter
      }
      Fl_Dial frsldial {
        label {Fr.Sl.}
        tooltip {Formant's Slowness (Morphing)} xywh {565 15 25 25} box ROUND_UP_BOX labelfont 0 labelsize 10 align 1 maximum 127 step 1
        code0 {o->init("Pformantslowness");}
        class Fl_Osc_Dial
      }
      Fl_Value_Output centerfreqvo {
        label {C.f.}
        callback {o->value(o->newvalue()/1000.0);}
        tooltip {Center Frequency (kHz)} xywh {511 164 40 18} when 3 minimum 1 maximum 10 step 0.01 value 1 textfont 1 textsize 11 labelsize 13
        code0 {o->init("centerfreq");}
        class Fl_Osc_Output
      }
      Fl_Value_Output octavesfreqvo {
        label {Oct.}
        callback {o->value(o->newvalue());}
        tooltip {No. of octaves} xywh {511 182 40 18} when 3 minimum 1 maximum 127 step 0.01 value 5 textfont 1 textsize 11 labelsize 13
        code0 {o->init("octavesfreq");}
        class Fl_Osc_Output
      }
      Fl_Slider cfknob {
        callback {centerfreqvo->update();}
        xywh {555 167 84 15} type {Horz Knob} box FLAT_BOX maximum 127
        code0 {o->init("Pcenterfreq", 'i');}
        class Fl_Osc_Slider
      }
      Fl_Slider octknob {
        callback {octavesfreqvo->update();}
        xywh {555 185 84 15} type {Horz Knob} box FLAT_BOX maximum 127
        code0 {o->init("Poctavesfreq", 'i');}
        class Fl_Osc_Slider
      }
      Fl_Box formantfiltergraph {
        xywh {5 5 475 195} box BORDER_BOX
        code0 {o->init(&nvowel,&nformant);}
        class FormantFilterGraph
      }
      Fl_Dial wvknob {
        label {Vw.Cl.}
        tooltip {Vowel "clearness" (how the mixed vowels are avoided)} xywh {600 15 25 25} box ROUND_UP_BOX labelfont 0 labelsize 10 align 1 maximum 127 step 1
        code0 {o->init("Pvowelclearness");}
        class Fl_Osc_Dial
      }
      Fl_Button {} {
        label Close
        callback {formantparswindow->hide();}
        xywh {645 180 50 25} box THIN_UP_BOX
      }
      Fl_Button {} {
        label C
        callback {presetsui->copy(filterui->loc(),nvowel);}
        xywh {635 25 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
      }
      Fl_Box {} {
        label Vowel
        xywh {635 6 55 15} labelfont 1
      }
    }
  }
  Function {update_formant_window()} {open
  } {
    code {//formant_freq_dial->value(pars->Pvowels[nvowel].formants[nformant].freq);
//formant_q_dial->value(pars->Pvowels[nvowel].formants[nformant].q);
//formant_amp_dial->value(pars->Pvowels[nvowel].formants[nformant].amp);
if (nformant<numformants->value()) formantparsgroup->activate();
	else formantparsgroup->deactivate();

if (nseqpos<sequencesize->value()) vowel_counter->activate();
	else vowel_counter->deactivate();


//vowel_counter->value(pars->Psequence[nseqpos].nvowel);} {}
  }
  Function {refresh()} {open
  } {
    code {update_formant_window();
formantfiltergraph->redraw();
const int Pcategory = filtertype->value();
const int Ptype     = analogfiltertypechoice->value();

if (Pcategory==2) svfiltertypechoice->value(Ptype);
if (Pcategory==0) analogfiltertypechoice->value(Ptype);

const int categ=Pcategory;
if ((categ==0)||(categ==2)) {
	if (categ==0) {
           analogfiltertypechoice->show();
           svfiltertypechoice->hide();
        } else {
           svfiltertypechoice->show();
           analogfiltertypechoice->hide();
        };
	editbutton->hide();
        formantparswindow->hide();
        cfreqdial->label("C.freq");
} else {
	analogfiltertypechoice->hide();
	svfiltertypechoice->hide();
	editbutton->show();
        cfreqdial->label("BS.pos");
};

filterparamswindow->redraw();} {}
  }
  Function {rebase(std::string new_base)} {open
  } {
    code {
    formantparswindow->rebase(new_base+"VoiceFilter/");
    Fl_Osc_Group::rebase(new_base);
  } {}
  }
  Function {init(std::string alt_root_, Fl_Osc_Interface *osc_, std::string base_, std::string ext_)} {} {
    code {alt_root = alt_root_;
osc  = osc_;
base = base_;
ext  = ext_;

assert(osc);

make_window();
end();
make_formant_window();


filterui->resize(this->x(),this->y(),this->w(),this->h());

switchcategory(0);

formantparswindow->label(this->label());

update_formant_window();} {}
  }
  Function {switchcategory(int newcat)} {open
  } {
    code {
    //TODO update Pgain & filter type on switch Pgain=64;
    (void) newcat;
refresh();} {}
  }
  Function {use_for_dynamic_filter()} {open
  } {
    code {freqtrdial->deactivate();
gaindial->when(0);

cfknob->when(FL_WHEN_RELEASE);
octknob->when(FL_WHEN_RELEASE);

frsldial->when(0);
wvknob->when(0);
formant_freq_dial->when(0);
formant_q_dial->when(0);
formant_amp_dial->when(0);
strchdial->when(0);} {}
  }
  decl {std::string alt_root;} {private local
  }
  decl {int nvowel,nformant,nseqpos;} {private local
  }
} 
