# data file for the Fltk User Interface Designer (fluid)
version 1.0300 
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 "../Synth/OscilGen.h"} {public local
} 

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

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

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

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

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

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

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

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

decl {\#include <math.h>} {private local
} 

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

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

decl {\#include <string.h>} {private local
} 

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

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

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

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

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

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

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

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

decl {using namespace zyncarla;} {public local
}

class OGSlider {: {public Fl_Osc_TSlider}
} {
  Function {OGSlider(int x,int y, int w, int h, const char *label=0)
  :Fl_Osc_TSlider(x,y,w,h,label)} {open
  } { code {phase=false; } {} }

  Function {OSC_value(char c)} {open return_type void
  } { code {value(phase ? c : 127-c);
  selection_color(value() == reset_value ? 0 : 222);
  redraw();
  } {} }

  Function {cb(void)} {open return_type void
  } { code {
  selection_color(value() == reset_value ? 0 : 222);
  if(cb_data.first) cb_data.first(this, cb_data.second);
  } {} }
  
  Function {update(void)} {open return_type void
  } { code {} {} }
  
  decl {bool phase;} {public local
  }
} 
class OGWaveChoice {: {public Fl_Osc_Choice}
} {
   Function {OGWaveChoice(int x,int y, int w, int h, const char *label=0)
   :Fl_Osc_Choice(x,y,w,h,label)} {open
   } { code {} {}}
   Function {OSC_value(int i)} {open return_type void
   } { code { value(i == 127 ? size()-2 : i);
   ogui->setbfmodstatus(i); } {} }
   Function {cb(void)} {open return_type void
   } {
    code {
        int v = Fl_Osc_Choice::value();
	if (value() < size()-2)
	    oscWrite(ext, "i", v);
	else
	    oscWrite(ext);
	if(cb_data.first)
	    cb_data.first(this, cb_data.second);
} {}}

  decl { class OscilEditor *ogui;} { public }

}

class Oscilharmonic {: {public Fl_Group}
} {
  Function {make_window()} {open private
  } {
    Fl_Window harmonic {open
      private xywh {467 756 100 225} type Double box NO_BOX
      class Fl_Osc_Group visible
    } {
      Fl_Slider mag {
        callback {int x=127-(int)o->value();
//if (x==64) o->selection_color(0);
//    else o->selection_color(222);

 o->osc->writeValue(o->loc+"magnitude"+to_s(n), (char)x);
 if (x==64) {
    o->osc->writeValue(o->loc+"phase"+to_s(n), (char)64);
    phase->value(64);
    phase->selection_color(0);
 }
 o->osc->requestValue(o->loc+"prepare");
 o->osc->requestValue(o->loc+"spectrum");
 o->osc->requestValue(o->loc+"waveform");

display->redraw();}
        xywh {0 15 15 115} type {Vert Knob} box NO_BOX selection_color 222 maximum 127 step 1 value 64
        code0 {o->phase=false;o->ext = "magnitude"+to_s(n);//o->value(127-oscil->Phmag[n]);}
        code1 {//if (oscil->Phmag[n]==64) o->selection_color(0);}
        class OGSlider
      }
      Fl_Slider phase {
        callback {
o->osc->writeValue(o->loc+"phase"+to_s(n), (char) o->value());
o->osc->requestValue(o->loc+"prepare");
o->osc->requestValue(o->loc+"spectrum");
o->osc->requestValue(o->loc+"waveform");

display->redraw();}
        xywh {0 135 15 75} type {Vert Knob} box NO_BOX selection_color 222 maximum 127 step 1 value 64
        code0 {o->phase=true;o->ext = "phase"+to_s(n);//o->value(oscil->Phphase[n]);}
        class OGSlider
      }
      Fl_Box {} {
        xywh {15 70 5 5} box FLAT_BOX color 45
      }
      Fl_Box {} {
        xywh {15 170 5 5} box FLAT_BOX color 45
      }
      Fl_Box {} {
        label 01
        xywh {0 210 20 15} labelfont 1 labelsize 9 align 20
        code0 {char tmp[10];snprintf(tmp,10,"%d",n+1);o->label(strdup(tmp));}
      }
      Fl_Box {} {
        label 01
        xywh {0 0 20 15} labelfont 1 labelsize 9 align 20
        code0 {char tmp[10];snprintf(tmp,10,"%d",n+1);o->label(strdup(tmp));}
      }
    }
  }
  Function {Oscilharmonic(int x,int y, int w, int h, const char *label=0):Fl_Group(x,y,w,h,label)} {} {
    code {n=0;
display=NULL;} {}
  }
  Function {init(int n_,Fl_Group *display_, std::string loc_, Fl_Osc_Interface *osc_)} {open
  } {
    code {assert(osc_);
assert(!loc_.empty());

n=n_;
display=display_;
osc = osc_;
loc = loc_;
make_window();
mag->osc = osc;
mag->loc = loc;
mag->reset_value = 63;
mag->set_transform([](float x){return 63.0f - x;});
phase->osc = osc;
phase->loc = loc;
phase->reset_value = 64;
phase->set_rounding(1);
phase->set_transform([](float x){return 180*(1 - x/64.0f);});

osc->createLink(loc+"magnitude"+to_s(n), mag);
osc->createLink(loc+"phase"+to_s(n), phase);
osc->requestValue(loc+"magnitude"+to_s(n));
osc->requestValue(loc+"phase"+to_s(n));
end();
harmonic->show();} {}
  }
  Function {refresh()} {open
  } {
    code {osc->requestValue(loc+"magnitude"+to_s(n));//mag->value(127-oscil->Phmag[n]);
osc->requestValue(loc+"phase"+to_s(n));//phase->value(oscil->Phphase[n]);
} {}
  }
  Function {~Oscilharmonic()} {open
  } {
    code {osc->removeLink(loc+"magnitude"+to_s(n), mag);
osc->removeLink(loc+"phase"+to_s(n), phase);

harmonic->hide();
delete harmonic;} {}
  }
  decl {Fl_Group *display;} {private local
  }
  decl {int n;} {private local
  }
  decl {Fl_Osc_Interface *osc;} {private local
  }
  decl {std::string loc;} {private local
  }
} 
class OscilEditor {open : {public PresetsUI_}
} {
  Function {make_window()} {open
  } {
    Fl_Window osceditUI {
      label {ADsynth Oscillator Editor} open
      xywh {52 100 735 595} type Double
      code0 {(void)o;//if (oscil->ADvsPAD) o->label("PADsynth Harmonic Content Editor");} visible
    } {
      Fl_Group dummy {open
        xywh {0 0 735 595} box FLAT_BOX
        class Fl_Osc_Group
      } {
        Fl_Button applybutton {
          label Apply
          callback {
          dummy->osc->requestValue(loc+"../prepare");}
          xywh {305 285 60 20} box THIN_UP_BOX labelfont 1
          code0 {if(adnotep) o->hide();}
          code1 {dummy->base = loc;}
          code2 {dummy->osc = osc;}
        }
        Fl_Group oscildisplaygroup {open
          xywh {10 10 360 300} box UP_FRAME
        } {
          Fl_Group {} {open
            xywh {15 90 350 190} box THIN_DOWN_BOX color 32 selection_color 71 labelcolor 179
            code0 {oscilo=new Fl_Oscilloscope(o->x(),o->y(),o->w(),o->h(),"");}
            code1 {oscilo->parent(o);oscilo->init(false);}
          } {}
          Fl_Box {} {
            label Oscillator
            xywh {125 15 110 20} labelfont 1
          }
          Fl_Value_Slider rndslider {
            label rnd
            callback {}
            tooltip {Oscilator Phase Randomness: smaller than 0 is "group", larger than 0 is for each harmonic} xywh {145 290 100 10} type {Horz Knob} box NO_BOX labelsize 10 align 5 minimum -64 maximum 63 step 1
            code0 {(void)o->init("Prand"); if (!adnotep) o->hide();}
	    class Fl_Osc_VSlider
          }
          Fl_Group {} {open
            xywh {15 35 350 50} box THIN_DOWN_BOX color 32 selection_color 218 labelcolor 63
            code0 {oscils=new Fl_OscilSpectrum(o->x(),o->y(),o->w(),o->h(),"");}
            code1 {oscils->parent(o);oscils->init(false);}
          } {}
          Fl_Group {} {open
            xywh {251 282 115 25} box UP_FRAME
            code0 {if (!adnotep) o->hide();}
          } {
            Fl_Choice hrndtype {
              label {H.rnd}
              tooltip {Harmonic Amplitude Randomness} xywh {286 287 50 15} down_box BORDER_BOX labelsize 10 textsize 10
              code0 {o->init("Pamprandtype");}
              class Fl_Osc_Choice
            } {
              MenuItem {} {
                label None
                xywh {65 65 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Pow
                xywh {75 75 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Sin
                xywh {85 85 100 20} labelfont 1 labelsize 10
              }
            }
            Fl_Dial hrnddial {
              tooltip {Oscillator's spectrum adjust parameter} xywh {345 285 18 18} maximum 127 step 1
              code0 {o->init("Pamprandpower");o->reset_value=64;}
              class Fl_Osc_Dial
            }
          }
          Fl_Choice magtype {
            label {Mag.Type}
            callback {redrawoscil();}
            xywh {75 285 65 20} down_box BORDER_BOX labelsize 11 when 1 textsize 11
            code0 {o->init("Phmagtype");}
            class Fl_Osc_Choice
          } {
            MenuItem {} {
              label Linear
              xywh {10 10 100 20} labelfont 1 labelsize 11
            }
            MenuItem {} {
              label {-40dB}
              xywh {20 20 100 20} labelfont 1 labelsize 11
            }
            MenuItem {} {
              label {-60dB}
              xywh {30 30 100 20} labelfont 1 labelsize 11
            }
            MenuItem {} {
              label {-80dB}
              xywh {40 40 100 20} labelfont 1 labelsize 11
            }
            MenuItem {} {
              label {-100dB}
              xywh {50 50 100 20} labelfont 1 labelsize 11
            }
          }
        }
        Fl_Group basefuncdisplaygroup {open
          xywh {370 10 360 300} box UP_FRAME
          code0 {o->base = loc;}
          code1 {o->osc = osc; bftype->ogui = this;}
          code2 {assert(osc);}
          class Fl_Osc_Group
        } {
          Fl_Group {} {
            xywh {375 90 350 190} box THIN_DOWN_BOX color 32 selection_color 71 labelcolor 179
            code0 {oscilo_base=new Fl_Oscilloscope(o->x(),o->y(),o->w(),o->h(),"");}
            code1 {oscilo_base->parent(o);oscilo_base->init(true);}
          } {}
          Fl_Dial bfpar {
            callback {redrawoscil(); if(bfparval){bfparval->value(o->value());}}
            tooltip {Base Function Parameter} xywh {525 285 20 20} minimum -64 maximum 63 step 1
            code0 {o->init("Pbasefuncpar");}
            class Fl_Osc_Dial
          }
          Fl_Choice bftype {
            label {Base.F..}
            callback {basefuncdisplaygroup->redraw();
redrawoscil();

if(!basefuncmodulation) return;
setbfmodstatus(o->value());
}
            xywh {375 290 90 15} down_box BORDER_BOX labelsize 10 align 5 when 1 textsize 11
            class OGWaveChoice
          } {
            MenuItem {} {
              label Sine
              xywh {15 15 100 20} labelfont 1 labelsize 11
            }
            MenuItem {} {
              label Triangle
              xywh {25 25 100 20} labelfont 1 labelsize 11
            }
            MenuItem {} {
              label Pulse
              xywh {35 35 100 20} labelfont 1 labelsize 11
            }
            MenuItem {} {
              label Saw
              xywh {45 45 100 20} labelfont 1 labelsize 11
            }
            MenuItem {} {
              label Power
              xywh {55 55 100 20} labelfont 1 labelsize 11
            }
            MenuItem {} {
              label Gauss
              xywh {55 55 100 20} labelfont 1 labelsize 11
            }
            MenuItem {} {
              label Diode
              xywh {65 65 100 20} labelfont 1 labelsize 11
            }
            MenuItem {} {
              label AbsSine
              xywh {75 75 100 20} labelfont 1 labelsize 11
            }
            MenuItem {} {
              label PulseSine
              xywh {85 85 100 20} labelfont 1 labelsize 11
            }
            MenuItem {} {
              label StrchSine
              xywh {95 95 100 20} labelfont 1 labelsize 11
            }
            MenuItem {} {
              label Chirp
              xywh {105 105 100 20} labelfont 1 labelsize 11
            }
            MenuItem {} {
              label AbsStrSine
              xywh {107 107 100 20} labelfont 1 labelsize 11
            }
            MenuItem {} {
              label Chebyshev
              xywh {117 117 100 20} labelfont 1 labelsize 11
            }
            MenuItem {} {
              label Sqr
              xywh {127 127 100 20} labelfont 1 labelsize 11
            }
            MenuItem {} {
              label Spike
              xywh {127 127 100 20} labelfont 1 labelsize 11
            }
            MenuItem {} {
              label Circle
              xywh {127 127 100 20} labelfont 1 labelsize 11
            }
	    MenuItem {} {
	      label User
	      xywh {127 127 100 20} labelfont 1 labelsize 11 hide
	    }
          }
          Fl_Box {} {
            label {Base Func.}
            xywh {485 15 110 20} labelfont 1
          }
          Fl_Group {} {open
            xywh {375 35 350 50} box THIN_DOWN_BOX color 32 selection_color 218 labelcolor 63
            code0 {oscils_base=new Fl_OscilSpectrum (o->x(),o->y(),o->w(),o->h(),"");}
            code1 {oscils_base->parent(o);oscils_base->init(true);}
          } {}
          Fl_Value_Output bfparval {
            label {Par.}
            xywh {495 290 25 15} labelsize 12 minimum -63 maximum 63 step 1
            code0 {o->value(bfpar->value());}

          }
          Fl_Group basefuncmodulation {open
            xywh {555 281 169 25} box UP_FRAME
            code0 {}
            } {
            Fl_Choice bfmodtype {
              label {B.F.Mod.}
              callback {basefuncdisplaygroup->redraw();
redrawoscil();}
              tooltip {Base function modulation} xywh {604 286 50 15} down_box BORDER_BOX labelsize 10 when 1 textsize 10
              code0 {o->init("Pbasefuncmodulation");}
              class Fl_Osc_Choice
            } {
              MenuItem {} {
                label None
                xywh {55 55 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Rev
                xywh {65 65 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Sine
                xywh {75 75 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Pow
                xywh {85 85 100 20} labelfont 1 labelsize 10
              }
              MenuItem {} {
                label Chop
                xywh {95 95 100 20} labelfont 1 labelsize 10
              }
            }
            Fl_Dial bfmodpar1 {
              callback {redrawoscil();}
              tooltip {Oscillator's modulation parameter 1} xywh {664 286 15 15} maximum 127 step 1
              code0 {o->init("Pbasefuncmodulationpar1");o->reset_value=64;}
              class Fl_Osc_Dial
            }
            Fl_Dial bfmodpar2 {
              callback {redrawoscil();}
              tooltip {Oscillator's modulation parameter 2} xywh {684 286 15 15} maximum 127 step 1
              code0 {o->init("Pbasefuncmodulationpar2");o->reset_value=64;}
              class Fl_Osc_Dial
            }
            Fl_Dial bfmodpar3 {
              callback {redrawoscil();} selected
              tooltip {Oscillator's modulation parameter 3} xywh {704 286 15 15} maximum 127 step 1
              code0 {o->init("Pbasefuncmodulationpar3");o->reset_value=32;}
              class Fl_Osc_Dial
            }
          }
        }
        Fl_Button {} {
          label {Use as base}
          callback {osc->requestValue(loc+"use-as-base");
if (autoclearbutton->value()){
   for (int i=1;i<(MAX_AD_HARMONICS - 1);i++){
      h[i]->mag->value(63);
      h[i]->mag->do_callback();
      h[i]->phase->value(64);
      h[i]->phase->do_callback();
   };

   harmonicshiftcounter->value(0);

   h[0]->mag->value(0);
   h[0]->mag->do_callback();
   h[0]->phase->value(64);
   h[0]->phase->do_callback();
   wshbutton->value(0);
   wshbutton->do_callback();
   fltbutton->value(0);
   fltbutton->do_callback();
   sabutton->value(0);
   sabutton->do_callback();
   bfmodtype->value(0);
   bfmodtype->do_callback();
};

 osc->requestValue(loc+"prepare");
 bftype->update();

basefuncdisplaygroup->redraw();
redrawoscil();}
          tooltip {Use this Oscillator as base function} xywh {10 318 85 20} box THIN_UP_BOX labelfont 1 labelsize 11
        }
        Fl_Button {} {
          label Close
          callback {osceditUI->hide();}
          xywh {673 570 62 25} box THIN_UP_BOX
        }
        Fl_Button {} {
          label Clear
          callback {if (!fl_choice("Clear the harmonics settings?","No","Yes",NULL)) return;

for (int i=1;i<(MAX_AD_HARMONICS - 1);i++){
    h[i]->mag->value(63);
    h[i]->mag->do_callback();
    h[i]->phase->value(64);
    h[i]->phase->do_callback();
};
h[0]->mag->value(0);
h[0]->mag->do_callback();
h[0]->phase->value(64);
h[0]->phase->do_callback();

//harmonics->redraw();
osc->requestValue(loc+"prepare");
redrawoscil();}
          xywh {675 510 55 15} box THIN_UP_BOX labelfont 1 labelsize 11
        }
        Fl_Group {} {
          xywh {140 313 150 30} box UP_FRAME
        } {
          Fl_Choice wshbutton {
            label {Wsh.}
            callback {basefuncdisplaygroup->redraw();
redrawoscil();}
            tooltip {Waveshaping function} xywh {170 320 55 20} down_box BORDER_BOX labelsize 10 when 1 textsize 10
            code0 {o->init("Pwaveshapingfunction");}
            class Fl_Osc_Choice
          } {
            MenuItem {} {
              label None
              xywh {30 30 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label Atan
              xywh {40 40 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label Asym1
              xywh {50 50 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label Pow
              xywh {60 60 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label Sine
              xywh {70 70 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label Qnts
              xywh {80 80 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label Zigzg
              xywh {90 90 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label Lmt
              xywh {100 100 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label LmtU
              xywh {110 110 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label LmtL
              xywh {120 120 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label ILmt
              xywh {132 132 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label Clip
              xywh {142 142 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label Asym2
              xywh {90 90 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label Pow2
              xywh {100 100 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label Sgm
              xywh {95 95 100 20} labelfont 1 labelsize 10
            }
          }
          Fl_Dial wshpar {
            callback {redrawoscil();if(wsparval){wsparval->value(o->value());}}
            tooltip {Waveshaping Parameter} xywh {265 318 20 20} minimum -64 maximum 63 step 1
            code0 {o->init("Pwaveshaping");}
            class Fl_Osc_Dial
          }
          Fl_Value_Output wsparval {
            xywh {233 321 25 15} labelsize 12 minimum -63 maximum 63 step 1
            code0 {o->value(wshpar->value());}
          }
        }
        Fl_Check_Button autoclearbutton {
          label {Clr.}
          tooltip {Auto clear when using the oscillator as base function} xywh {98 318 40 20} box THIN_UP_BOX value 1 labelfont 1 labelsize 10
        }
        Fl_Group {} {
          xywh {290 313 155 30} box UP_FRAME
        } {
          Fl_Choice fltbutton {
            label Filter
            callback {redrawoscil();}
            tooltip {Oscillator's filter type} xywh {320 318 50 20} down_box BORDER_BOX labelsize 10 when 1 textsize 10
            code0 {o->init("Pfiltertype");}
            class Fl_Osc_Choice
          } {
            MenuItem {} {
              label None
              xywh {40 40 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label LP1
              xywh {50 50 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label HP1a
              xywh {60 60 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label HP1b
              xywh {70 70 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label BP1
              xywh {80 80 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label BS1
              xywh {90 90 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label LP2
              xywh {60 60 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label HP2
              xywh {70 70 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label BP2
              xywh {70 70 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label BS2
              xywh {80 80 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label Cos
              xywh {80 80 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label Sin
              xywh {90 90 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label LSh
              xywh {100 100 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label S
              xywh {110 110 100 20} labelfont 1 labelsize 10
            }
          }
          Fl_Dial filtervalue1 {
            callback {redrawoscil();}
            tooltip {Oscillator's filter parameter1} xywh {372 318 20 20} maximum 127 step 1
            code0 {o->init("Pfilterpar1");o->reset_value=64;}
            class Fl_Osc_Dial
          }
          Fl_Check_Button filterpref {
            label p
            callback {redrawoscil();}
            tooltip {Apply the filter before the waveshaping} xywh {420 318 20 20} down_box DOWN_BOX labelsize 10 align 24
          }
          Fl_Dial filtervalue2 {
            callback {redrawoscil();}
            tooltip {Oscillator's filter parameter2} xywh {395 318 20 20} maximum 127 step 1
            code0 {o->init("Pfilterpar2");o->reset_value=64;}
            class Fl_Osc_Dial
          }
        }
        Fl_Group {} {
          xywh {595 313 135 30} box UP_FRAME
        } {
          Fl_Choice sabutton {
            label {Sp.adj.}
            callback {redrawoscil();}
            tooltip {Oscillator's spectrum adjust} xywh {635 318 60 20} down_box BORDER_BOX labelsize 10 when 1 textsize 10
            code0 {o->init("Psatype");}
            class Fl_Osc_Choice
          } {
            MenuItem {} {
              label None
              xywh {60 60 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label Pow
              xywh {70 70 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label ThrsD
              xywh {80 80 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label ThrsU
              xywh {90 90 100 20} labelfont 1 labelsize 10
            }
          }
          Fl_Dial sadjpar {
            callback {redrawoscil();}
            tooltip {Oscillator's spectrum adjust parameter} xywh {700 318 20 20} maximum 127 step 1
            code0 {o->init("Psapar");o->reset_value=64;}
            class Fl_Osc_Dial
          }
        }
        Fl_Group {} {
          xywh {670 345 65 65} box UP_FRAME
        } {
          Fl_Counter harmonicshiftcounter {
            label {Harmonic Shift}
            callback {redrawoscil();}
            code0 {o->init("Pharmonicshift");}
            xywh {675 370 55 15} type Simple labelsize 10 align 129 minimum -64 maximum 64 step 1 textfont 1 textsize 10
            class Fl_Osc_Counter
          }
          Fl_Check_Button harmonicshiftpre {
            label preH
            callback {redrawoscil();}
            code0 {o->init("Pharmonicshiftfirst");}
            tooltip {Apply the harmonic shift before the waveshaping and filtering} xywh {695 390 34 15} down_box DOWN_BOX labelsize 10 align 24
            class Fl_Osc_Check
          }
          Fl_Button {} {
            label R
            callback {//oscil->Pharmonicshift=0;
harmonicshiftcounter->value(0);
redrawoscil();}
            xywh {675 390 20 15} box THIN_UP_BOX labelfont 1 labelsize 10
          }
        }
        Fl_Group {} {
          xywh {670 415 65 90} box UP_FRAME
        } {
          Fl_Choice adhrtype {
            label {Adpt.Harm.}
            callback {redrawoscil();}
            tooltip {The type of the addaptive harmonics} xywh {675 430 55 15} down_box BORDER_BOX labelsize 10 align 129 when 3 textsize 10
            code0 {o->init("Padaptiveharmonics");}
            class Fl_Osc_Choice
          } {
            MenuItem {} {
              label OFF
              xywh {85 85 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label ON
              xywh {95 95 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label Square
              xywh {105 105 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label 2xSub
              xywh {115 115 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label 2xAdd
              xywh {125 125 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label 3xSub
              xywh {125 125 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label 3xAdd
              xywh {135 135 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label 4xSub
              xywh {135 135 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label 4xAdd
              xywh {145 145 100 20} labelfont 1 labelsize 10
            }
          }
          Fl_Dial adhrpow {
            label pow
            callback {redrawoscil();}
            tooltip {Adaptive harmonics power} xywh {705 465 25 25} labelsize 10 maximum 200 step 1
            code0 {o->init("Padaptiveharmonicspower");o->reset_value=100;}
            class Fl_Osc_Dial
          }
          Fl_Dial adhrbf {
            label baseF
            callback {redrawoscil();}
            tooltip {Adaptive harmonics base frequency} xywh {675 465 25 25} labelsize 10 maximum 255 step 1
            code0 {o->init("Padaptiveharmonicsbasefreq");o->reset_value=128;}
            class Fl_Osc_Dial
          }
          Fl_Slider adhrpar {
            code0 {o->init("Padaptiveharmonicspar", 'i');o->reset_value=50;}
            callback {redrawoscil();}
            xywh {675 450 55 10} type {Horz Knob} box NO_BOX maximum 100 step 1 value 50
            class Fl_Osc_TSlider
          }
        }
        Fl_Group {} {
          xywh {445 313 150 30} box UP_FRAME
        } {
          Fl_Choice modtype {
            label {Mod.}
            callback {redrawoscil();}
            tooltip modulation xywh {475 320 50 15} down_box BORDER_BOX labelsize 10 when 1 textsize 10
            code0 {o->init("Pmodulation");}
            class Fl_Osc_Choice
          } {
            MenuItem {} {
              label None
              xywh {65 65 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label Rev
              xywh {75 75 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label Sine
              xywh {85 85 100 20} labelfont 1 labelsize 10
            }
            MenuItem {} {
              label Pow
              xywh {95 95 100 20} labelfont 1 labelsize 10
            }
          }
          Fl_Dial modpar1 {
            callback {redrawoscil();}
            tooltip {Oscillator's modulation parameter 1} xywh {535 320 15 15} maximum 127 step 1
            code0 {o->init("Pmodulationpar1");o->reset_value=64;}
            class Fl_Osc_Dial
          }
          Fl_Dial modpar2 {
            callback {redrawoscil();}
            tooltip {Oscillator's modulation parameter 2} xywh {555 320 15 15} maximum 127 step 1
            code0 {o->init("Pmodulationpar2");o->reset_value=64;}
            class Fl_Osc_Dial
          }
          Fl_Dial modpar3 {
            callback {redrawoscil();}
            tooltip {Oscillator's modulation parameter 3} xywh {575 320 15 15} maximum 127 step 1
            code0 {o->init("Pmodulationpar3");o->reset_value=32;}
            class Fl_Osc_Dial
          }
        }
        Fl_Button {} {
          label Sine
          callback {if (!fl_choice("Convert to SINE?","No","Yes",NULL)) return;

osc->requestValue(loc+"convert2sine");
bftype->update();
bfpar->value(0);
bfpar->do_callback();

redrawoscil();
refresh();}
          xywh {675 530 55 15} box THIN_UP_BOX labelfont 1 labelsize 11
        }
        Fl_Button {} {
          label C
          callback {presetsui->copy(dummy->loc());}
          xywh {675 550 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
        }
        Fl_Button {} {
          label P
          callback {presetsui->paste(dummy->loc(), this);}
          xywh {705 550 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 55
        }
        Fl_Scroll _this_has_to_be_the_last {
          xywh {10 345 660 250} type HORIZONTAL box FLAT_BOX
        } {
          Fl_Pack harmonics {open
            xywh {15 350 650 225} type HORIZONTAL
            code0 {for (int i=0;i<(MAX_AD_HARMONICS - 1);i++){h[i]=new Oscilharmonic(0,0,20,o->h(),"");h[i]->init(i,oscildisplaygroup,loc,osc);}}
          } {}
        }
      }
    }
  }
  Function {OscilEditor(bool adnotep_, std::string loc_, Fl_Osc_Interface *osc_)} {open
  } {
    code { assert(osc_);
assert(!loc_.empty());

initialized = false;

adnotep = adnotep_;
osc = osc_;
loc = loc_;

oscilo = NULL;
oscilo_base = NULL;
oscils = NULL;
oscils_base = NULL;

osceditUI = NULL;
dummy = NULL;
applybutton = NULL;
oscildisplaygroup = NULL;
rndslider = NULL;
hrndtype = NULL;
magtype = NULL;
basefuncdisplaygroup = NULL;
bfpar = NULL;
bftype = NULL;
make_window();
bftype->init("Pcurrentbasefunc");
initialized = true;

refresh();
osceditUI->show();} {}
  }
  Function {~OscilEditor()} {open
  } {
    code {osceditUI->hide();
for (int i=0; i<(MAX_AD_HARMONICS - 1); ++i)
    delete h[i];

delete oscilo;
delete oscilo_base;
delete oscils;
delete oscils_base;
delete osceditUI;} {}
  }
  Function {refresh()} {} {
    code {magtype->update();

    for (int i=0;i<(MAX_AD_HARMONICS - 1);i++) h[i]->refresh();

    osc->requestValue(loc+"prepare");

    basefuncdisplaygroup->redraw();
redrawoscil();} {}
  }
  Function {redrawoscil()} {open
  } {
    code {
    if(!initialized) //Must have been called during initialization
        return;
    //get data from backend
osc->requestValue(loc+"prepare");
oscilo->update();
oscils->update();
oscilo_base->update();
oscils_base->update();} {}
  }
  Function {setbfmodstatus(int menuentry)} {open
  } {
    code {
    switch (menuentry){
    case 0:
         bfpar->deactivate();
         bfparval->deactivate();
         basefuncmodulation->deactivate();
         break;
    case 127:
         bfpar->deactivate();
         bfparval->deactivate();
         basefuncmodulation->activate();
         break;
    default:
         bfpar->activate();
         bfparval->activate();
         basefuncmodulation->activate();
    }
    } {} }

  decl {Oscilharmonic *h[(MAX_AD_HARMONICS - 1)];} {private local
  }
  decl {std::string loc;} {private local
  }
  decl {Fl_Osc_Interface *osc;} {private local
  }
  decl {Fl_Oscilloscope *oscilo, *oscilo_base;} {private local
  }
  decl {Fl_OscilSpectrum *oscils, *oscils_base;} {private local
  }
  decl {bool adnotep;} {private local
  }
  decl {bool initialized;} {private local
  }
} 
