// generated by Fast Light User Interface Designer (fluid) version 1.0308

#include "ADnoteUI.h"
// ADNoteUI.cc
// Original ZynAddSubFX author Nasca Octavian Paul
// Copyright (C) 2002-2005 Nasca Octavian Paul
// Copyright 2009-2011, Alan Calvert
// Copyright 2014-2021, Will Godfrey

// This file is part of yoshimi, which is free software: you can redistribute
// it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.

// yoshimi is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.   See the GNU General Public License (version 2 or
// later) for more details.

// You should have received a copy of the GNU General Public License along with
// yoshimi; if not, write to the Free Software Foundation, Inc., 51 Franklin
// Street, Fifth Floor, Boston, MA  02110-1301, USA.

// This file is derivative of ZynAddSubFX original code.


#include "MasterUI.h"
#include "Misc/SynthHelper.h"
    using synth::getDetune;
#include "Misc/FormatFuncs.h"
    using func::asString;

void ADvoicelistitem::cb_voicevolume_i(mwheel_slider_rev* o, void*) {
  //
            int vol = lrint(o->value());
            if (synth->getGuiMaster()->partui->adnoteui->advoice->nvoice == nvoice)
                synth->getGuiMaster()->partui->adnoteui->advoice->voicevolume->value(vol);

            collect_data(synth, vol, 0, (TOPLEVEL::type::Write | TOPLEVEL::type::Integer), ADDVOICE::control::volume, npart, kititem, PART::engine::addVoice1 + nvoice);
}
void ADvoicelistitem::cb_voicevolume(mwheel_slider_rev* o, void* v) {
  ((ADvoicelistitem*)(o->parent()->parent()->user_data()))->cb_voicevolume_i(o,v);
}

void ADvoicelistitem::cb_voiceresonanceenabled_i(Fl_Check_Button2* o, void*) {
  //
    bool enab = _SYS_::F2B(o->value());
    synth->getGuiMaster()->partui->adnoteui->advoice->ResonanceEn->value(enab);

    collect_data(synth, enab, 0, (TOPLEVEL::type::Write | TOPLEVEL::type::Integer), ADDVOICE::control::enableResonance, npart, kititem, PART::engine::addVoice1 + nvoice);
}
void ADvoicelistitem::cb_voiceresonanceenabled(Fl_Check_Button2* o, void* v) {
  ((ADvoicelistitem*)(o->parent()->parent()->user_data()))->cb_voiceresonanceenabled_i(o,v);
}

void ADvoicelistitem::cb_voicelistvibratto_i(mwheel_slider_rev* o, void*) {
  //
            int lfodepth = lrint(o->value());
            if (synth->getGuiMaster()->partui->adnoteui->advoice->nvoice == nvoice)
                synth->getGuiMaster()->partui->adnoteui->advoice->voicefreqlfogroup->intensity->value(lfodepth);

            collect_data(synth, lfodepth, 0, (TOPLEVEL::type::Write | TOPLEVEL::type::Integer), 1, npart, kititem, PART::engine::addVoice1 + nvoice, 0, 1);
}
void ADvoicelistitem::cb_voicelistvibratto(mwheel_slider_rev* o, void* v) {
  ((ADvoicelistitem*)(o->parent()->parent()->user_data()))->cb_voicelistvibratto_i(o,v);
}

void ADvoicelistitem::cb_voicepanning_i(WidgetPDial* o, void*) {
  //
            int panning = lrint(o->value());
            if (synth->getGuiMaster()->partui->adnoteui->advoice->nvoice == nvoice)
            {
                synth->getGuiMaster()->partui->adnoteui->advoice->voicepan->value(panning);
                synth->getGuiMaster()->partui->adnoteui->advoice->voicerandompan->value(panning < 1);
            }

            collect_data(synth, panning, 0, (TOPLEVEL::type::Write | TOPLEVEL::type::Integer), ADDVOICE::control::panning, npart, kititem, PART::engine::addVoice1 + nvoice);
}
void ADvoicelistitem::cb_voicepanning(WidgetPDial* o, void* v) {
  ((ADvoicelistitem*)(o->parent()->parent()->user_data()))->cb_voicepanning_i(o,v);
}

void ADvoicelistitem::cb_voiceoscil_i(Fl_Group*, void*) {
  update_voiceoscil();
}
void ADvoicelistitem::cb_voiceoscil(Fl_Group* o, void* v) {
  ((ADvoicelistitem*)(o->parent()->parent()->user_data()))->cb_voiceoscil_i(o,v);
}

void ADvoicelistitem::cb_noiselabel_i(Fl_Box*, void*) {
  update_noiselabel();
    int tmp = pars->VoicePar[nvoice].Type;
    if (tmp == 0)
    {
        voiceresonanceenabled->activate();
        detunevalueoutput->activate();
        voicedetune->activate();
        return;
    }
    voiceresonanceenabled->deactivate();
    detunevalueoutput->deactivate();
    voicedetune->deactivate();
}
void ADvoicelistitem::cb_noiselabel(Fl_Box* o, void* v) {
  ((ADvoicelistitem*)(o->parent()->parent()->user_data()))->cb_noiselabel_i(o,v);
}

void ADvoicelistitem::cb_modoscil_i(Fl_Group*, void*) {
  update_modoscil();
}
void ADvoicelistitem::cb_modoscil(Fl_Group* o, void* v) {
  ((ADvoicelistitem*)(o->parent()->parent()->user_data()))->cb_modoscil_i(o,v);
}

void ADvoicelistitem::cb_modlabel_i(Fl_Box*, void*) {
  //
                update_modlabel();
}
void ADvoicelistitem::cb_modlabel(Fl_Box* o, void* v) {
  ((ADvoicelistitem*)(o->parent()->parent()->user_data()))->cb_modlabel_i(o,v);
}

void ADvoicelistitem::cb_detunevalueoutput_i(Fl_Value_Output* o, void*) {
  o->value(getDetune((pars->VoicePar[nvoice].PDetuneType == 0) ? (pars->GlobalPar.PDetuneType) : (pars->VoicePar[nvoice].PDetuneType), 0, pars->VoicePar[nvoice].PDetune) * pars->getBandwidthDetuneMultiplier());
}
void ADvoicelistitem::cb_detunevalueoutput(Fl_Value_Output* o, void* v) {
  ((ADvoicelistitem*)(o->parent()->parent()->user_data()))->cb_detunevalueoutput_i(o,v);
}

void ADvoicelistitem::cb_voicedetune_i(mwheel_slider_rev* o, void*) {
  //
            int detune = lrint(o->value());
            collect_data(synth, detune, TOPLEVEL::action::forceUpdate, TOPLEVEL::type::Write, ADDVOICE::control::detuneFrequency, npart, kititem, PART::engine::addVoice1 + nvoice);
}
void ADvoicelistitem::cb_voicedetune(mwheel_slider_rev* o, void* v) {
  ((ADvoicelistitem*)(o->parent()->parent()->user_data()))->cb_voicedetune_i(o,v);
}

void ADvoicelistitem::cb_itemedit_i(Fl_Button*, void*) {
  //
              synth->getGuiMaster()->partui->adnoteui->setVoiceTabs(nvoice);
              synth->getGuiMaster()->partui->adnoteui->set_voice(true);
              if ((Fl::event_button() == 3))
                  synth->getGuiMaster()->partui->adnoteui->ADnoteVoiceList->hide();
}
void ADvoicelistitem::cb_itemedit(Fl_Button* o, void* v) {
  ((ADvoicelistitem*)(o->parent()->parent()->user_data()))->cb_itemedit_i(o,v);
}

void ADvoicelistitem::cb_voiceenabled_i(Fl_Check_Button2* o, void*) {
  //
            bool enab = _SYS_::F2B(o->value());
            collect_data(synth, enab, TOPLEVEL::action::forceUpdate, (TOPLEVEL::type::Integer | TOPLEVEL::type::Write), ADDVOICE::control::enableVoice, npart, kititem, PART::engine::addVoice1 + nvoice);
}
void ADvoicelistitem::cb_voiceenabled(Fl_Check_Button2* o, void* v) {
  ((ADvoicelistitem*)(o->parent()->user_data()))->cb_voiceenabled_i(o,v);
}

Fl_Group* ADvoicelistitem::make_window() {
  { ADnoteVoiceListItem = new Fl_Group(0, 0, 635, 30);
    ADnoteVoiceListItem->box(FL_ENGRAVED_BOX);
    ADnoteVoiceListItem->color(FL_BACKGROUND_COLOR);
    ADnoteVoiceListItem->selection_color(FL_BACKGROUND_COLOR);
    ADnoteVoiceListItem->labeltype(FL_NO_LABEL);
    ADnoteVoiceListItem->labelfont(0);
    ADnoteVoiceListItem->labelsize(14);
    ADnoteVoiceListItem->labelcolor(FL_FOREGROUND_COLOR);
    ADnoteVoiceListItem->user_data((void*)(this));
    ADnoteVoiceListItem->align(Fl_Align(FL_ALIGN_TOP));
    ADnoteVoiceListItem->when(FL_WHEN_RELEASE);
    { Fl_Group* o = voicelistitemgroup = new Fl_Group(38, 1, 593, 25);
      voicelistitemgroup->box(FL_FLAT_BOX);
      { mwheel_slider_rev* o = voicevolume = new mwheel_slider_rev(155, 4, 122, 20);
        voicevolume->tooltip("Volume");
        voicevolume->type(5);
        voicevolume->box(FL_THIN_DOWN_BOX);
        voicevolume->color(FL_BACKGROUND_COLOR);
        voicevolume->selection_color(FL_BACKGROUND_COLOR);
        voicevolume->labeltype(FL_NORMAL_LABEL);
        voicevolume->labelfont(0);
        voicevolume->labelsize(8);
        voicevolume->labelcolor(FL_FOREGROUND_COLOR);
        voicevolume->maximum(127);
        voicevolume->step(1);
        voicevolume->callback((Fl_Callback*)cb_voicevolume);
        voicevolume->align(Fl_Align(FL_ALIGN_BOTTOM));
        voicevolume->when(FL_WHEN_CHANGED);
        o->value(pars->VoicePar[nvoice].PVolume);
        o->setValueType(VC_ADDVoiceVolume);o->useCustomTip(true);
      } // mwheel_slider_rev* voicevolume
      { Fl_Check_Button2* o = voiceresonanceenabled = new Fl_Check_Button2(305, 5, 15, 17);
        voiceresonanceenabled->tooltip("Resonance On/Off");
        voiceresonanceenabled->box(FL_NO_BOX);
        voiceresonanceenabled->down_box(FL_DOWN_BOX);
        voiceresonanceenabled->color(FL_BACKGROUND_COLOR);
        voiceresonanceenabled->selection_color(FL_FOREGROUND_COLOR);
        voiceresonanceenabled->labeltype(FL_EMBOSSED_LABEL);
        voiceresonanceenabled->labelfont(1);
        voiceresonanceenabled->labelsize(11);
        voiceresonanceenabled->labelcolor(FL_FOREGROUND_COLOR);
        voiceresonanceenabled->callback((Fl_Callback*)cb_voiceresonanceenabled);
        voiceresonanceenabled->align(Fl_Align(FL_ALIGN_LEFT));
        voiceresonanceenabled->when(FL_WHEN_RELEASE);
        o->value(pars->VoicePar[nvoice].Presonance);
      } // Fl_Check_Button2* voiceresonanceenabled
      { mwheel_slider_rev* o = voicelistvibratto = new mwheel_slider_rev(535, 4, 95, 20);
        voicelistvibratto->tooltip("Frequency LFO amount");
        voicelistvibratto->type(5);
        voicelistvibratto->box(FL_THIN_DOWN_BOX);
        voicelistvibratto->color(FL_BACKGROUND_COLOR);
        voicelistvibratto->selection_color(FL_BACKGROUND_COLOR);
        voicelistvibratto->labeltype(FL_NORMAL_LABEL);
        voicelistvibratto->labelfont(0);
        voicelistvibratto->labelsize(8);
        voicelistvibratto->labelcolor(FL_FOREGROUND_COLOR);
        voicelistvibratto->maximum(127);
        voicelistvibratto->step(1);
        voicelistvibratto->callback((Fl_Callback*)cb_voicelistvibratto);
        voicelistvibratto->align(Fl_Align(FL_ALIGN_TOP_LEFT));
        voicelistvibratto->when(FL_WHEN_CHANGED);
        voicelistvibratto->deactivate();
        o->value(pars->VoicePar[nvoice].FreqLfo->Pintensity);
        o->setValueType(VC_LFOdepthFreq);o->useCustomTip(true);
      } // mwheel_slider_rev* voicelistvibratto
      { WidgetPDial* o = voicepanning = new WidgetPDial(282, 4, 20, 20);
        voicepanning->tooltip("Voice panning");
        voicepanning->box(FL_ROUND_UP_BOX);
        voicepanning->color(FL_BACKGROUND_COLOR);
        voicepanning->selection_color(FL_INACTIVE_COLOR);
        voicepanning->labeltype(FL_NORMAL_LABEL);
        voicepanning->labelfont(0);
        voicepanning->labelsize(10);
        voicepanning->labelcolor(FL_FOREGROUND_COLOR);
        voicepanning->maximum(127);
        voicepanning->step(1);
        voicepanning->callback((Fl_Callback*)cb_voicepanning);
        voicepanning->align(Fl_Align(FL_ALIGN_LEFT));
        voicepanning->when(FL_WHEN_CHANGED);
        o->setValueType(VC_PanningStd);
        o->value(pars->VoicePar[nvoice].PPanning);
      } // WidgetPDial* voicepanning
      { Fl_Group* o = voiceoscil = new Fl_Group(88, 4, 30, 20);
        voiceoscil->box(FL_THIN_DOWN_FRAME);
        voiceoscil->color(FL_GRAY0);
        voiceoscil->selection_color((Fl_Color)71);
        voiceoscil->labelcolor((Fl_Color)179);
        voiceoscil->callback((Fl_Callback*)cb_voiceoscil);
        osc = new Oscilloscope(o->x(), o->y(), o->w(), o->h(), 20, "");
        update_voiceoscil();
        voiceoscil->end();
      } // Fl_Group* voiceoscil
      { noiselabel = new Fl_Box(93, 5, 20, 20, "N");
        noiselabel->labelfont(1);
        noiselabel->labelsize(13);
        noiselabel->labelcolor(FL_BACKGROUND2_COLOR);
        noiselabel->callback((Fl_Callback*)cb_noiselabel);
      } // Fl_Box* noiselabel
      { Fl_Group* o = modoscil = new Fl_Group(122, 4, 30, 20);
        modoscil->box(FL_THIN_DOWN_FRAME);
        modoscil->color(FL_GRAY0);
        modoscil->selection_color((Fl_Color)71);
        modoscil->labelcolor((Fl_Color)179);
        modoscil->callback((Fl_Callback*)cb_modoscil);
        modosc = new Oscilloscope(o->x(), o->y(), o->w(), o->h(), 20, "");
        update_modoscil();
        modoscil->end();
      } // Fl_Group* modoscil
      { modlabel = new Fl_Box(127, 5, 20, 20, "N");
        modlabel->labelfont(1);
        modlabel->labelsize(13);
        modlabel->labelcolor(FL_BACKGROUND2_COLOR);
        modlabel->callback((Fl_Callback*)cb_modlabel);
      } // Fl_Box* modlabel
      { Fl_Value_Output* o = detunevalueoutput = new Fl_Value_Output(326, 4, 40, 20);
        detunevalueoutput->box(FL_THIN_DOWN_BOX);
        detunevalueoutput->labelsize(10);
        detunevalueoutput->minimum(-5000);
        detunevalueoutput->maximum(5000);
        detunevalueoutput->textsize(11);
        detunevalueoutput->callback((Fl_Callback*)cb_detunevalueoutput);
        detunevalueoutput->align(Fl_Align(FL_ALIGN_CENTER));
        o->step(0.01, 1);
        o->value(getDetune(pars->VoicePar[nvoice].PDetuneType, 0, pars->VoicePar[nvoice].PDetune) * pars->getBandwidthDetuneMultiplier());
      } // Fl_Value_Output* detunevalueoutput
      { mwheel_slider_rev* o = voicedetune = new mwheel_slider_rev(365, 4, 164, 20);
        voicedetune->tooltip("Fine Detune (cents)");
        voicedetune->type(5);
        voicedetune->box(FL_THIN_DOWN_BOX);
        voicedetune->color(FL_BACKGROUND_COLOR);
        voicedetune->selection_color(FL_BACKGROUND_COLOR);
        voicedetune->labeltype(FL_NORMAL_LABEL);
        voicedetune->labelfont(0);
        voicedetune->labelsize(14);
        voicedetune->labelcolor(FL_FOREGROUND_COLOR);
        voicedetune->minimum(-8192);
        voicedetune->maximum(8191);
        voicedetune->step(1);
        voicedetune->callback((Fl_Callback*)cb_voicedetune);
        voicedetune->align(Fl_Align(FL_ALIGN_BOTTOM));
        voicedetune->when(FL_WHEN_CHANGED);
        o->value(pars->VoicePar[nvoice].PDetune - 8192);
      } // mwheel_slider_rev* voicedetune
      { itemedit = new Fl_Button(42, 4, 40, 20, "Edit");
        itemedit->tooltip("Right click: also close this");
        itemedit->box(FL_THIN_UP_BOX);
        itemedit->labelfont(1);
        itemedit->labelsize(12);
        itemedit->callback((Fl_Callback*)cb_itemedit);
      } // Fl_Button* itemedit
      if (pars->VoicePar[nvoice].Enabled == 0) o->deactivate();
      voicelistitemgroup->end();
    } // Fl_Group* voicelistitemgroup
    { Fl_Group* o = enabledpatch = new Fl_Group(4, 4, 34, 18, "1");
      enabledpatch->box(FL_UP_BOX);
      enabledpatch->color((Fl_Color)237);
      enabledpatch->labelfont(1);
      enabledpatch->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
      char tmp[12]; snprintf(tmp, 12, "%d", nvoice + 1); o->label(strdup(tmp));
      enabledpatch->end();
    } // Fl_Group* enabledpatch
    { Fl_Check_Button2* o = voiceenabled = new Fl_Check_Button2(18, 7, 15, 15);
      voiceenabled->box(FL_NO_BOX);
      voiceenabled->down_box(FL_DOWN_BOX);
      voiceenabled->color(FL_BACKGROUND_COLOR);
      voiceenabled->selection_color(FL_FOREGROUND_COLOR);
      voiceenabled->labeltype(FL_EMBOSSED_LABEL);
      voiceenabled->labelfont(0);
      voiceenabled->labelsize(14);
      voiceenabled->labelcolor(FL_FOREGROUND_COLOR);
      voiceenabled->callback((Fl_Callback*)cb_voiceenabled);
      voiceenabled->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
      voiceenabled->when(FL_WHEN_RELEASE);
      o->value(pars->VoicePar[nvoice].Enabled);
    } // Fl_Check_Button2* voiceenabled
    ADnoteVoiceListItem->end();
  } // Fl_Group* ADnoteVoiceListItem
  return ADnoteVoiceListItem;
}

ADvoicelistitem::ADvoicelistitem(int x,int y, int w, int h, const char *label):Fl_Group(x,y,w,h,label) {
  nvoice = 0; pars = NULL;
}

void ADvoicelistitem::init(ADnoteParameters *parameters, int npart_, int kititem_, int nvoice_) {
  //
      synth = parameters->getSynthEngine();
      pars = parameters;
      npart = npart_;
      kititem = kititem_;
      nvoice = nvoice_;
      fft = new fft::Calc(synth->oscilsize);
      oscil = new OscilGen(*fft, NULL, synth, parameters->VoicePar[nvoice].POscil);
      oscilFM = new OscilGen(*fft, NULL, synth, parameters->VoicePar[nvoice].POscilFM);
      make_window();
      if (pars->VoicePar[nvoice].PFreqLfoEnabled > 0)
          voicelistvibratto->activate();
      else
          voicelistvibratto->deactivate();
      ADnoteVoiceListItem->show();
      end();
}

void ADvoicelistitem::refreshlist() {
  //
          voiceenabled->value(pars->VoicePar[nvoice].Enabled);
          voiceresonanceenabled->value(pars->VoicePar[nvoice].Presonance);
          voicevolume->value(pars->VoicePar[nvoice].PVolume);
          voicedetune->value(pars->VoicePar[nvoice].PDetune - 8192);
          voicepanning->value(pars->VoicePar[nvoice].PPanning);
          voicelistvibratto->value(pars->VoicePar[nvoice].FreqLfo->Pintensity);
          int nvs = nvoice, nvp = nvoice;
          if (pars->VoicePar[nvoice].PVoice != -1)
              while (pars->VoicePar[nvs].PVoice != -1)
                  nvp = nvs = pars->VoicePar[nvs].PVoice;
          else if (pars->VoicePar[nvoice].Pextoscil != -1)
              nvs = pars->VoicePar[nvoice].Pextoscil;
          oscil->changeParams(pars->VoicePar[nvs].POscil);
          osc->init(oscil, 0, pars->VoicePar[nvp].Poscilphase, synth);
          if (pars->VoicePar[nvoice].Enabled == 0)
              voicelistitemgroup->deactivate();
          else
              voicelistitemgroup->activate();
          detunevalueoutput->do_callback();
          voiceoscil->do_callback();
          noiselabel->do_callback();
          modoscil->do_callback();
          modlabel->do_callback();
          ADnoteVoiceListItem->redraw();
}

void ADvoicelistitem::update_voiceoscil() {
  int nvs = nvoice, nvp = nvoice;
  if (pars->VoicePar[nvoice].PVoice != -1)
      while (pars->VoicePar[nvs].PVoice != -1)
          nvp = nvs = pars->VoicePar[nvs].PVoice;
  else if (pars->VoicePar[nvoice].Pextoscil != -1)
      nvs = pars->VoicePar[nvoice].Pextoscil;
  oscil->changeParams(pars->VoicePar[nvs].POscil);
  osc->init(oscil,0,pars->VoicePar[nvp].Poscilphase, synth);
  
  if (pars->VoicePar[nvoice].PVoice >= 0 || pars->VoicePar[nvoice].Type != 0)
      voiceoscil->deactivate();
  else
      voiceoscil->activate();
}

void ADvoicelistitem::update_noiselabel() {
  if (pars->VoicePar[nvoice].PVoice >= 0)
  {
      char str[15];
      snprintf(str, sizeof(str), "V%d", pars->VoicePar[nvoice].PVoice + 1);
      noiselabel->copy_label(str);
      noiselabel->labelcolor(EXTVOICE_COLOUR);
      noiselabel->show();
  }
  else if (pars->VoicePar[nvoice].Pextoscil >= 0)
  {
      char str[15];
      snprintf(str, sizeof(str), "O%d", pars->VoicePar[nvoice].Pextoscil + 1);
      noiselabel->copy_label(str);
      noiselabel->labelcolor(EXTOSC_COLOUR);
      noiselabel->show();
  }
  else if (pars->VoicePar[nvoice].Type == 1)
  {
      noiselabel->copy_label("N");
      noiselabel->labelcolor(7);
      noiselabel->show();
  }
  else if (pars->VoicePar[nvoice].Type == 2)
  {
      noiselabel->copy_label("N");
      noiselabel->labelcolor(5);
      noiselabel->show();
  }
  else if (pars->VoicePar[nvoice].Type == 3)
  {
      noiselabel->copy_label("N");
      noiselabel->labelcolor(6);
      noiselabel->show();
  }
  else
  {
      noiselabel->hide();
  }
}

void ADvoicelistitem::update_modoscil() {
  int nvs = nvoice, nvp = nvoice;
  if (pars->VoicePar[nvoice].PFMVoice != -1) {
      nvp = nvs = pars->VoicePar[nvs].PFMVoice;
      while (pars->VoicePar[nvs].PVoice != -1)
          nvp = nvs = pars->VoicePar[nvs].PVoice;
      oscilFM->changeParams(pars->VoicePar[nvs].POscil);
      modosc->init(oscilFM,0,pars->VoicePar[nvp].Poscilphase, synth);
  } else {
      if (pars->VoicePar[nvoice].PextFMoscil != -1)
          nvs = pars->VoicePar[nvoice].PextFMoscil;
      oscilFM->changeParams(pars->VoicePar[nvs].POscilFM);
      modosc->init(oscilFM,0,pars->VoicePar[nvp].PFMoscilphase, synth);
  }
  
  if (pars->VoicePar[nvoice].PFMEnabled == NONE || pars->VoicePar[nvoice].PFMVoice >= 0)
      modoscil->deactivate();
  else
      modoscil->activate();
}

void ADvoicelistitem::update_modlabel() {
  if (pars->VoicePar[nvoice].PFMEnabled == NONE)
  {
      modlabel->copy_label("OFF");
      modlabel->labelcolor(MODOFF_COLOUR);
      modlabel->deactivate();
      modlabel->show();
  }
  else
  {
      modlabel->activate();
      if (pars->VoicePar[nvoice].PFMVoice >= 0)
      {
          char str[15];
          snprintf(str, sizeof(str), "V%d", pars->VoicePar[nvoice].PFMVoice + 1);
          modlabel->copy_label(str);
          modlabel->labelcolor(EXTVOICE_COLOUR);
          modlabel->show();
      }
      else if (pars->VoicePar[nvoice].PextFMoscil >= 0)
      {
          char str[15];
          snprintf(str, sizeof(str), "M%d", pars->VoicePar[nvoice].PextFMoscil + 1);
          modlabel->copy_label(str);
          modlabel->labelcolor(EXTOSC_COLOUR);
          modlabel->show();
      }
      else
      {
          modlabel->hide();
      }
  }
}

void ADvoicelistitem::itemRtext(float dScale) {
  //
  
          int size11 = int(11 * dScale);
          int size12 = int(12 * dScale);
          int size14 = int(14 * dScale);
  
          voiceresonanceenabled->labelsize(size11);
          voiceoscil->labelsize(size14);
          noiselabel->labelsize(size14);
          modoscil->labelsize(size14);
          modlabel->labelsize(size14);
          detunevalueoutput->textsize(size11);
          itemedit->labelsize(size12);
          voiceenabled->labelsize(size12);
          enabledpatch->size(34 * dScale, 18 * dScale);
          enabledpatch->labelsize(size14);
}

ADvoicelistitem::~ADvoicelistitem() {
  //
          ADnoteVoiceListItem->hide();
          delete oscil;
          delete oscilFM;
          delete fft;
}

void ADvoiceUI::cb_ModFreqEn_i(Fl_Check_Button2* o, void*) {
  //
                    if (o->value() == 0)
                        voiceFMfreqenvgroup->deactivate();
                    else
                        voiceFMfreqenvgroup->activate();
                    o->redraw();
                    send_data(0, ADDVOICE::control::enableModulatorFrequencyEnvelope, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_ModFreqEn(Fl_Check_Button2* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->parent()->user_data()))->cb_ModFreqEn_i(o,v);
}

void ADvoiceUI::cb_ModCoarseDetune_i(Fl_Counter* o, void*) {
  //
                    send_data(0, ADDVOICE::control::modulatorCoarseDetune, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_ModCoarseDetune(Fl_Counter* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->parent()->user_data()))->cb_ModCoarseDetune_i(o,v);
}

void ADvoiceUI::cb_ModOctave_i(Fl_Counter* o, void*) {
  //
                    send_data(0, ADDVOICE::control::modulatorOctave, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_ModOctave(Fl_Counter* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->parent()->user_data()))->cb_ModOctave_i(o,v);
}

void ADvoiceUI::cb_fmdetunevalueoutput_i(Fl_Value_Output* o, void*) {
  o->value(getDetune((pars->VoicePar[nvoice].PFMDetuneType == 0) ? (pars->GlobalPar.PDetuneType) : (pars->VoicePar[nvoice].PFMDetuneType), 0, pars->VoicePar[nvoice].PFMDetune));
}
void ADvoiceUI::cb_fmdetunevalueoutput(Fl_Value_Output* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->parent()->user_data()))->cb_fmdetunevalueoutput_i(o,v);
}

void ADvoiceUI::cb_ModDetune_i(mwheel_slider_rev* o, void*) {
  //
                    send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::modulatorDetuneFrequency, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_ModDetune(mwheel_slider_rev* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->parent()->user_data()))->cb_ModDetune_i(o,v);
}

void ADvoiceUI::cb_ModDetuneType_i(Fl_Choice* o, void*) {
  //
                    send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::modulatorDetuneType, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_ModDetuneType(Fl_Choice* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->parent()->user_data()))->cb_ModDetuneType_i(o,v);
}

void ADvoiceUI::cb_detuneFromBaseOsc_i(Fl_Check_Button2* o, void*) {
  send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::modulatorDetuneFromBaseOsc, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_detuneFromBaseOsc(Fl_Check_Button2* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->parent()->user_data()))->cb_detuneFromBaseOsc_i(o,v);
}

void ADvoiceUI::cb_Mod440_i(Fl_Check_Button2* o, void*) {
  //
send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::modulatorFrequencyAs440Hz, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_Mod440(Fl_Check_Button2* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->parent()->user_data()))->cb_Mod440_i(o,v);
}

void ADvoiceUI::cb_ModVolume_i(mwheel_val_slider_rev* o, void*) {
  //
                    send_data(0, ADDVOICE::control::modulatorAmplitude, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_ModVolume(mwheel_val_slider_rev* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->parent()->user_data()))->cb_ModVolume_i(o,v);
}

void ADvoiceUI::cb_ModVsense_i(mwheel_val_slider_rev* o, void*) {
  //
                    send_data(0, ADDVOICE::control::modulatorVelocitySense, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_ModVsense(mwheel_val_slider_rev* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->parent()->user_data()))->cb_ModVsense_i(o,v);
}

void ADvoiceUI::cb_ModAmpEn_i(Fl_Check_Button2* o, void*) {
  //
                    if (o->value() == 0)
                        voiceFMampenvgroup->deactivate();
                    else
                        voiceFMampenvgroup->activate();
                    o->redraw();
                    send_data(0, ADDVOICE::control::enableModulatorAmplitudeEnvelope, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_ModAmpEn(Fl_Check_Button2* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->parent()->user_data()))->cb_ModAmpEn_i(o,v);
}

void ADvoiceUI::cb_ModFdamp_i(mwheel_val_slider_rev* o, void*) {
  //
                    send_data(0, ADDVOICE::control::modulatorHFdamping, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_ModFdamp(mwheel_val_slider_rev* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->parent()->user_data()))->cb_ModFdamp_i(o,v);
}

void ADvoiceUI::cb_changeFMoscilbutton_i(Fl_Button*, void*) {
  //
                    if (oscedit)
                        delete oscedit;
                    lastWaveW = 0;
                    int nv = nvoice;
                    if (pars->VoicePar[nvoice].PextFMoscil >= 0)
                        nv = pars->VoicePar[nvoice].PextFMoscil;
                    oscedit = new OscilEditor(pars->VoicePar[nv].POscilFM, modOscDisplay, NULL, NULL, synth, npart, kititem, nvoice + PART::engine::addMod1);
                    if ((Fl::event_button() == 3))
                        synth->getGuiMaster()->partui->adnoteui->ADnoteVoice->hide();
}
void ADvoiceUI::cb_changeFMoscilbutton(Fl_Button* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->parent()->parent()->user_data()))->cb_changeFMoscilbutton_i(o,v);
}

void ADvoiceUI::cb_ModPhase_i(mwheel_slider_rev* o, void*) {
  //
                    send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::modulatorOscillatorPhase, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_ModPhase(mwheel_slider_rev* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->parent()->parent()->user_data()))->cb_ModPhase_i(o,v);
}

void ADvoiceUI::cb_ExtModOsc_i(Fl_Choice* o, void*) {
  //
                    send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::modulatorOscillatorSource, o->value() - 1, TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_ExtModOsc(Fl_Choice* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->parent()->parent()->user_data()))->cb_ExtModOsc_i(o,v);
}

void ADvoiceUI::cb_modvoicelabel_i(Fl_Box*, void*) {
  update_modvoicelabel();
}
void ADvoiceUI::cb_modvoicelabel(Fl_Box* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->parent()->user_data()))->cb_modvoicelabel_i(o,v);
}

void ADvoiceUI::cb_ExtMod_i(Fl_Choice* o, void*) {
  //
                  send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::externalModulator, o->value() - 1, TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_ExtMod(Fl_Choice* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_ExtMod_i(o,v);
}

void ADvoiceUI::cb_ModType_i(Fl_Choice* o, void*) {
  //
                if (o->value() == 0)
                    voiceFMparametersgroup->deactivate();
                else
                    voiceFMparametersgroup->activate();
                o->redraw();
                send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::modulatorType, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_ModType(Fl_Choice* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->user_data()))->cb_ModType_i(o,v);
}

void ADvoiceUI::cb_FreqEn_i(Fl_Check_Button2* o, void*) {
  //
                  if (o->value() == 0)
                      voicefreqenvgroup->deactivate();
                  else
                      voicefreqenvgroup->activate();
                  o->redraw();
                  send_data(0, ADDVOICE::control::enableFrequencyEnvelope, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_FreqEn(Fl_Check_Button2* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_FreqEn_i(o,v);
}

void ADvoiceUI::cb_FreqLfoEn_i(Fl_Check_Button2* o, void*) {
  //
    bool enab = _SYS_::F2B(o->value());
    if (enab)
    {
        voicefreqlfogroup->activate();
        synth->getGuiMaster()->partui->adnoteui->voicelistitem[nvoice]->voicelistvibratto->activate();
    }
    else
    {
        voicefreqlfogroup->deactivate();
        synth->getGuiMaster()->partui->adnoteui->voicelistitem[nvoice]->voicelistvibratto->deactivate();
    }
    o->redraw();

    send_data(0, ADDVOICE::control::enableFrequencyLFO, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_FreqLfoEn(Fl_Check_Button2* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_FreqLfoEn_i(o,v);
}

void ADvoiceUI::cb_Octave_i(Fl_Counter* o, void*) {
  //
                  send_data(0, ADDVOICE::control::octave, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_Octave(Fl_Counter* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_Octave_i(o,v);
}

void ADvoiceUI::cb_CoarseDetune_i(Fl_Counter* o, void*) {
  //
                  send_data(0, ADDVOICE::control::coarseDetune, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_CoarseDetune(Fl_Counter* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_CoarseDetune_i(o,v);
}

void ADvoiceUI::cb_detunevalueoutput1_i(Fl_Value_Output* o, void*) {
  o->value(getDetune((pars->VoicePar[nvoice].PDetuneType==0)?(pars->GlobalPar.PDetuneType) : (pars->VoicePar[nvoice].PDetuneType),0,pars->VoicePar[nvoice].PDetune)*pars->getBandwidthDetuneMultiplier());
}
void ADvoiceUI::cb_detunevalueoutput1(Fl_Value_Output* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_detunevalueoutput1_i(o,v);
}

void ADvoiceUI::cb_Detune_i(mwheel_slider_rev* o, void*) {
  //
                int detune = lrint(o->value());
                send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::detuneFrequency, detune, TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_Detune(mwheel_slider_rev* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_Detune_i(o,v);
}

void ADvoiceUI::cb_FreqDetunetype_i(Fl_Choice* o, void*) {
  //
send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::detuneType, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_FreqDetunetype(Fl_Choice* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_FreqDetunetype_i(o,v);
}

void ADvoiceUI::cb_bend_i(WidgetPDial* o, void*) {
  //
send_data(0, ADDVOICE::control::pitchBendAdjustment, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_bend(WidgetPDial* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_bend_i(o,v);
}

void ADvoiceUI::cb_Freq440_i(Fl_Check_Button2* o, void*) {
  //
                  int x = lrint(o->value());
                  if (x == 0 && Mod440->value() == 0)
                      fixedfreqetdial->deactivate();
                  else
                      fixedfreqetdial->activate();
                  send_data(0, ADDVOICE::control::baseFrequencyAs440Hz, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_Freq440(Fl_Check_Button2* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_Freq440_i(o,v);
}

void ADvoiceUI::cb_fixedfreqetdial_i(WidgetPDial* o, void*) {
  //
send_data(0, ADDVOICE::control::equalTemperVariation, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_fixedfreqetdial(WidgetPDial* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_fixedfreqetdial_i(o,v);
}

void ADvoiceUI::cb_offset_i(WidgetPDial* o, void*) {
  //
send_data(0, ADDVOICE::control::pitchBendOffset, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_offset(WidgetPDial* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_offset_i(o,v);
}

void ADvoiceUI::cb_UseOsc_i(Fl_Choice* o, void*) {
  //
                send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::voiceOscillatorSource, o->value() - 1, TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_UseOsc(Fl_Choice* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->parent()->parent()->user_data()))->cb_UseOsc_i(o,v);
}

void ADvoiceUI::cb_changevoiceoscilbutton_i(Fl_Button*, void*) {
  //
    if (oscedit)
        delete oscedit;
    lastWaveW = 0;
    int nv = nvoice;
    if (pars->VoicePar[nvoice].Pextoscil >= 0)
        nv=pars->VoicePar[nvoice].Pextoscil;
    oscedit = new OscilEditor(pars->VoicePar[nv].POscil, oscDisplay, NULL, NULL, synth, npart, kititem, nvoice + PART::engine::addVoice1);
    if ((Fl::event_button() == 3))
        synth->getGuiMaster()->partui->adnoteui->ADnoteVoice->hide();
}
void ADvoiceUI::cb_changevoiceoscilbutton(Fl_Button* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->parent()->parent()->user_data()))->cb_changevoiceoscilbutton_i(o,v);
}

void ADvoiceUI::cb_VoiceOscPhase_i(mwheel_slider_rev* o, void*) {
  //
                send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::voiceOscillatorPhase, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_VoiceOscPhase(mwheel_slider_rev* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->parent()->parent()->user_data()))->cb_VoiceOscPhase_i(o,v);
}

void ADvoiceUI::cb_osclabel_i(Fl_Box*, void*) {
  update_osclabels();
}
void ADvoiceUI::cb_osclabel(Fl_Box* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_osclabel_i(o,v);
}

void ADvoiceUI::cb_ResonanceEn_i(Fl_Check_Button2* o, void*) {
  //
    bool enab = _SYS_::F2B(o->value());
    pars->VoicePar[nvoice].Presonance = enab;
    synth->getGuiMaster()->partui->adnoteui->voicelistitem[nvoice]->voiceresonanceenabled->value(enab);
    send_data(0, ADDVOICE::control::enableResonance, enab, TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_ResonanceEn(Fl_Check_Button2* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->user_data()))->cb_ResonanceEn_i(o,v);
}

void ADvoiceUI::cb_unisonsize_i(WidgetSpinner* o, void*) {
  //
send_data(0, ADDVOICE::control::unisonSize, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_unisonsize(WidgetSpinner* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_unisonsize_i(o,v);
}

void ADvoiceUI::cb_UnisonStereo_i(WidgetPDial* o, void*) {
  //
send_data(0, ADDVOICE::control::unisonStereoSpread, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_UnisonStereo(WidgetPDial* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_UnisonStereo_i(o,v);
}

void ADvoiceUI::cb_UnisonVib_i(WidgetPDial* o, void*) {
  //
send_data(0, ADDVOICE::control::unisonVibratoDepth, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_UnisonVib(WidgetPDial* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_UnisonVib_i(o,v);
}

void ADvoiceUI::cb_UnisonInvert_i(Fl_Choice* o, void*) {
  //
    send_data(0, ADDVOICE::control::unisonPhaseInvert, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_UnisonInvert(Fl_Choice* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_UnisonInvert_i(o,v);
}

void ADvoiceUI::cb_UnisonFreqSpread_i(mwheel_slider_rev* o, void*) {
  //
                  unisonspreadoutput->do_callback();
                  send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::unisonFrequencySpread, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_UnisonFreqSpread(mwheel_slider_rev* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_UnisonFreqSpread_i(o,v);
}

void ADvoiceUI::cb_unisonspreadoutput_i(Fl_Value_Output* o, void*) {
  o->value(pars->getUnisonFrequencySpreadCents(nvoice));
}
void ADvoiceUI::cb_unisonspreadoutput(Fl_Value_Output* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_unisonspreadoutput_i(o,v);
}

void ADvoiceUI::cb_UnisonVspeed_i(WidgetPDial* o, void*) {
  //
send_data(0, ADDVOICE::control::unisonVibratoSpeed, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_UnisonVspeed(WidgetPDial* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_UnisonVspeed_i(o,v);
}

void ADvoiceUI::cb_UnisonPhRnd_i(WidgetPDial* o, void*) {
  //
send_data(0, ADDVOICE::control::unisonPhaseRandomise, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_UnisonPhRnd(WidgetPDial* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_UnisonPhRnd_i(o,v);
}

void ADvoiceUI::cb_unisName_i(Fl_Box*, void*) {
  //;
}
void ADvoiceUI::cb_unisName(Fl_Box* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->parent()->user_data()))->cb_unisName_i(o,v);
}

void ADvoiceUI::cb_UnisonEn_i(Fl_Check_Button2* o, void*) {
  //
send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::enableUnison, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_UnisonEn(Fl_Check_Button2* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->user_data()))->cb_UnisonEn_i(o,v);
}

void ADvoiceUI::cb_voicevolume1_i(WidgetPDial* o, void*) {
  //
                int vol = lrint(o->value());
                synth->getGuiMaster()->partui->adnoteui->voicelistitem[nvoice]->voicevolume->value(vol);
                send_data(0, ADDVOICE::control::volume, vol, TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_voicevolume1(WidgetPDial* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->user_data()))->cb_voicevolume1_i(o,v);
}

void ADvoiceUI::cb_voicevsns_i(WidgetPDial* o, void*) {
  //
                send_data(0, ADDVOICE::control::velocitySense, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_voicevsns(WidgetPDial* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->user_data()))->cb_voicevsns_i(o,v);
}

void ADvoiceUI::cb_voicepan_i(WidgetPDial* o, void*) {
  //
    int pan = lrint(o->value());
    send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::panning, pan, TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_voicepan(WidgetPDial* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->user_data()))->cb_voicepan_i(o,v);
}

void ADvoiceUI::cb_voicewidth_i(WidgetPDial* o, void*) {
  //
    send_data(0, ADDVOICE::control::randomWidth, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_voicewidth(WidgetPDial* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->user_data()))->cb_voicewidth_i(o,v);
}

void ADvoiceUI::cb_voicerandompan_i(Fl_Check_Button2* o, void*) {
  //
        int tmp = o->value();
        if (tmp == 0)
            voicewidth->deactivate();
        else
            voicewidth->activate();
        send_data(0, ADDVOICE::control::enableRandomPan, tmp, TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_voicerandompan(Fl_Check_Button2* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->user_data()))->cb_voicerandompan_i(o,v);
}

void ADvoiceUI::cb_AmpEnvEn_i(Fl_Check_Button2* o, void*) {
  //
                if (o->value() == 0)
                    voiceampenvgroup->deactivate();
                else
                    voiceampenvgroup->activate();
                o->redraw();
                send_data(0, ADDVOICE::control::enableAmplitudeEnvelope, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_AmpEnvEn(Fl_Check_Button2* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->user_data()))->cb_AmpEnvEn_i(o,v);
}

void ADvoiceUI::cb_AmpLfoEn_i(Fl_Check_Button2* o, void*) {
  //
                if (o->value() == 0)
                    voiceamplfogroup->deactivate();
                else
                    voiceamplfogroup->activate();
                o->redraw();
                send_data(0, ADDVOICE::control::enableAmplitudeLFO, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_AmpLfoEn(Fl_Check_Button2* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->user_data()))->cb_AmpLfoEn_i(o,v);
}

void ADvoiceUI::cb_VolumeMinus_i(Fl_Check_Button2* o, void*) {
  //
send_data(0, ADDVOICE::control::invertPhase, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_VolumeMinus(Fl_Check_Button2* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->user_data()))->cb_VolumeMinus_i(o,v);
}

void ADvoiceUI::cb_FilterEnvEn_i(Fl_Check_Button2* o, void*) {
  //
                send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::enableFilterEnvelope, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_FilterEnvEn(Fl_Check_Button2* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->user_data()))->cb_FilterEnvEn_i(o,v);
}

void ADvoiceUI::cb_FilterLfoEn_i(Fl_Check_Button2* o, void*) {
  //
                send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::enableFilterLFO, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_FilterLfoEn(Fl_Check_Button2* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->user_data()))->cb_FilterLfoEn_i(o,v);
}

void ADvoiceUI::cb_Delay_i(mwheel_slider_rev* o, void*) {
  //
                send_data(0, ADDVOICE::control::delay, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_Delay(mwheel_slider_rev* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->user_data()))->cb_Delay_i(o,v);
}

void ADvoiceUI::cb_bypassfiltercheckbutton_i(Fl_Check_Button2* o, void*) {
  //
send_data(0, ADDVOICE::control::bypassGlobalFilter, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_bypassfiltercheckbutton(Fl_Check_Button2* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->user_data()))->cb_bypassfiltercheckbutton_i(o,v);
}

void ADvoiceUI::cb_FilterEn_i(Fl_Check_Button2* o, void*) {
  //
              bypassfiltercheckbutton->redraw();
              send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::enableFilter, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_FilterEn(Fl_Check_Button2* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->user_data()))->cb_FilterEn_i(o,v);
}

void ADvoiceUI::cb_ExtOsc_i(Fl_Choice* o, void*) {
  //
                  if (nvoice == 0)
                      o->deactivate();
                  if (_SYS_::F2B(o->value())) {
                      oscGroup->deactivate();
                      SoundType->deactivate();
                  } else {
                      oscGroup->activate();
                      SoundType->activate();
                  }
                  send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::soundType, 0, TOPLEVEL::type::Integer);
                  send_data(0, ADDVOICE::control::externalOscillator, o->value() - 1, TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_ExtOsc(Fl_Choice* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->user_data()))->cb_ExtOsc_i(o,v);
}

void ADvoiceUI::cb_SoundType_i(Fl_Choice* o, void*) {
  //
              int x = int(o->value());
              send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::soundType, x, TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_SoundType(Fl_Choice* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->parent()->user_data()))->cb_SoundType_i(o,v);
}

void ADvoiceUI::cb_noiselabel1_i(Fl_Box*, void*) {
  //
                update_osclabels();
}
void ADvoiceUI::cb_noiselabel1(Fl_Box* o, void* v) {
  ((ADvoiceUI*)(o->parent()->parent()->user_data()))->cb_noiselabel1_i(o,v);
}

void ADvoiceUI::cb_voiceonbutton_i(Fl_Check_Button2* o, void*) {
  //
    send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::enableVoice, o->value(), TOPLEVEL::type::Integer);
}
void ADvoiceUI::cb_voiceonbutton(Fl_Check_Button2* o, void* v) {
  ((ADvoiceUI*)(o->parent()->user_data()))->cb_voiceonbutton_i(o,v);
}

Fl_Group* ADvoiceUI::make_window() {
  { Fl_Group* o = ADnoteVoiceParameters = new Fl_Group(0, 0, 805, 610, "Voice");
    ADnoteVoiceParameters->box(FL_NO_BOX);
    ADnoteVoiceParameters->color(FL_BACKGROUND_COLOR);
    ADnoteVoiceParameters->selection_color(FL_BACKGROUND_COLOR);
    ADnoteVoiceParameters->labeltype(FL_NO_LABEL);
    ADnoteVoiceParameters->labelfont(0);
    ADnoteVoiceParameters->labelsize(14);
    ADnoteVoiceParameters->labelcolor(FL_FOREGROUND_COLOR);
    ADnoteVoiceParameters->user_data((void*)(this));
    ADnoteVoiceParameters->align(Fl_Align(FL_ALIGN_TOP));
    ADnoteVoiceParameters->when(FL_WHEN_RELEASE);
    { Fl_Box* o = new Fl_Box(8, 69, 277, 66);
      o->box(FL_PLASTIC_UP_BOX);
      o->color(FL_CYAN);
    } // Fl_Box* o
    { Fl_Group* o = voiceparametersgroup = new Fl_Group(0, 0, 805, 615);
      voiceparametersgroup->box(FL_THIN_UP_FRAME);
      voiceparametersgroup->color((Fl_Color)48);
      { voicemodegroup = new Fl_Group(0, 0, 805, 615);
        { voiceFMparametersgroup = new Fl_Group(575, 5, 230, 565, "MODULATOR");
          voiceFMparametersgroup->box(FL_THIN_UP_FRAME);
          voiceFMparametersgroup->color((Fl_Color)48);
          voiceFMparametersgroup->labelfont(1);
          voiceFMparametersgroup->labelsize(12);
          voiceFMparametersgroup->align(Fl_Align(FL_ALIGN_TOP|FL_ALIGN_INSIDE));
          { modfrequency = new Fl_Group(580, 204, 220, 161, "Mod FREQUENCY");
            modfrequency->box(FL_THIN_UP_FRAME);
            modfrequency->labelfont(1);
            modfrequency->labelsize(11);
            modfrequency->align(Fl_Align(FL_ALIGN_TOP|FL_ALIGN_INSIDE));
            { EnvelopeUI* o = voiceFMfreqenvgroup = new EnvelopeUI(585, 290, 210, 70, "ADSynth Modulator - Frequency Envelope");
              voiceFMfreqenvgroup->box(FL_FLAT_BOX);
              voiceFMfreqenvgroup->color((Fl_Color)51);
              voiceFMfreqenvgroup->selection_color(FL_BACKGROUND_COLOR);
              voiceFMfreqenvgroup->labeltype(FL_NORMAL_LABEL);
              voiceFMfreqenvgroup->labelfont(0);
              voiceFMfreqenvgroup->labelsize(14);
              voiceFMfreqenvgroup->labelcolor(FL_FOREGROUND_COLOR);
              voiceFMfreqenvgroup->align(Fl_Align(FL_ALIGN_WRAP|FL_ALIGN_INSIDE));
              voiceFMfreqenvgroup->when(FL_WHEN_RELEASE);
              o->init(pars->VoicePar[nvoice].FMFreqEnvelope, npart, kititem, nvoice + PART::engine::addMod1, 1);
              if (pars->VoicePar[nvoice].PFMFreqEnvelopeEnabled==0) o->deactivate();
              voiceFMfreqenvgroup->end();
            } // EnvelopeUI* voiceFMfreqenvgroup
            { Fl_Check_Button2* o = ModFreqEn = new Fl_Check_Button2(590, 295, 38, 14, "On");
              ModFreqEn->tooltip("Enable Frequency Envelope");
              ModFreqEn->box(FL_THIN_UP_BOX);
              ModFreqEn->down_box(FL_DOWN_BOX);
              ModFreqEn->color((Fl_Color)237);
              ModFreqEn->selection_color(FL_FOREGROUND_COLOR);
              ModFreqEn->labeltype(FL_NORMAL_LABEL);
              ModFreqEn->labelfont(1);
              ModFreqEn->labelsize(10);
              ModFreqEn->labelcolor(FL_FOREGROUND_COLOR);
              ModFreqEn->callback((Fl_Callback*)cb_ModFreqEn);
              ModFreqEn->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
              ModFreqEn->when(FL_WHEN_RELEASE);
              o->value(pars->VoicePar[nvoice].PFMFreqEnvelopeEnabled);
            } // Fl_Check_Button2* ModFreqEn
            { Fl_Counter* o = ModCoarseDetune = new Fl_Counter(730, 270, 60, 15, "Coarse Det.");
              ModCoarseDetune->tooltip("Coarse Detune");
              ModCoarseDetune->labelsize(10);
              ModCoarseDetune->minimum(-64);
              ModCoarseDetune->maximum(63);
              ModCoarseDetune->step(1);
              ModCoarseDetune->textfont(1);
              ModCoarseDetune->textsize(11);
              ModCoarseDetune->callback((Fl_Callback*)cb_ModCoarseDetune);
              ModCoarseDetune->align(Fl_Align(FL_ALIGN_TOP));
              int k = pars->VoicePar[nvoice].PFMCoarseDetune % 1024;
              if (k >= 512) k-= 1024;
              o->value(k);
              o->lstep(10);
            } // Fl_Counter* ModCoarseDetune
            { Fl_Counter* o = ModOctave = new Fl_Counter(670, 270, 45, 15, "Octave");
              ModOctave->tooltip("Octave");
              ModOctave->type(1);
              ModOctave->color((Fl_Color)237);
              ModOctave->selection_color(FL_FOREGROUND_COLOR);
              ModOctave->labelsize(10);
              ModOctave->minimum(-8);
              ModOctave->maximum(7);
              ModOctave->step(1);
              ModOctave->textfont(1);
              ModOctave->textsize(11);
              ModOctave->callback((Fl_Callback*)cb_ModOctave);
              ModOctave->align(Fl_Align(FL_ALIGN_TOP));
              int k = pars->VoicePar[nvoice].PFMCoarseDetune / 1024;
              if (k >= 8) k -= 16;
              o->value(k);
            } // Fl_Counter* ModOctave
            { Fl_Value_Output* o = fmdetunevalueoutput = new Fl_Value_Output(587, 239, 36, 16, "Detune");
              fmdetunevalueoutput->box(FL_THIN_DOWN_BOX);
              fmdetunevalueoutput->labelsize(10);
              fmdetunevalueoutput->minimum(-5000);
              fmdetunevalueoutput->maximum(5000);
              fmdetunevalueoutput->textfont(1);
              fmdetunevalueoutput->textsize(10);
              fmdetunevalueoutput->callback((Fl_Callback*)cb_fmdetunevalueoutput);
              fmdetunevalueoutput->align(Fl_Align(FL_ALIGN_TOP_LEFT));
              o->step(0.01, 1);
              o->value(getDetune((pars->VoicePar[nvoice].PFMDetuneType == 0) ? (pars->GlobalPar.PDetuneType) : (pars->VoicePar[nvoice].PFMDetuneType), 0, pars->VoicePar[nvoice].PFMDetune));
            } // Fl_Value_Output* fmdetunevalueoutput
            { mwheel_slider_rev* o = ModDetune = new mwheel_slider_rev(623, 239, 168, 16);
              ModDetune->tooltip("Fine Detune (cents)");
              ModDetune->type(5);
              ModDetune->box(FL_THIN_DOWN_BOX);
              ModDetune->color(FL_BACKGROUND_COLOR);
              ModDetune->selection_color(FL_BACKGROUND_COLOR);
              ModDetune->labeltype(FL_NORMAL_LABEL);
              ModDetune->labelfont(0);
              ModDetune->labelsize(14);
              ModDetune->labelcolor(FL_FOREGROUND_COLOR);
              ModDetune->minimum(-8192);
              ModDetune->maximum(8191);
              ModDetune->step(1);
              ModDetune->callback((Fl_Callback*)cb_ModDetune);
              ModDetune->align(Fl_Align(FL_ALIGN_BOTTOM));
              ModDetune->when(FL_WHEN_CHANGED);
              o->value(pars->VoicePar[nvoice].PFMDetune-8192);
            } // mwheel_slider_rev* ModDetune
            { Fl_Choice* o = ModDetuneType = new Fl_Choice(585, 270, 75, 15, "Detune Type");
              ModDetuneType->down_box(FL_BORDER_BOX);
              ModDetuneType->selection_color(FL_BACKGROUND_COLOR);
              ModDetuneType->labelsize(10);
              ModDetuneType->textfont(1);
              ModDetuneType->textsize(10);
              ModDetuneType->callback((Fl_Callback*)cb_ModDetuneType);
              ModDetuneType->align(Fl_Align(FL_ALIGN_TOP_LEFT));
              o->add("Default");o->add("L35cents");o->add("L10cents");o->add("E100cents");o->add("E1200cents");
              o->value(pars->VoicePar[nvoice].PFMDetuneType);
            } // Fl_Choice* ModDetuneType
            { Fl_Check_Button2* o = detuneFromBaseOsc = new Fl_Check_Button2(630, 220, 95, 15, "Follow voice");
              detuneFromBaseOsc->tooltip("Apply all detuning in the voice oscillator to the modulator as well.");
              detuneFromBaseOsc->box(FL_NO_BOX);
              detuneFromBaseOsc->down_box(FL_DOWN_BOX);
              detuneFromBaseOsc->color(FL_BACKGROUND_COLOR);
              detuneFromBaseOsc->selection_color(FL_FOREGROUND_COLOR);
              detuneFromBaseOsc->labeltype(FL_NORMAL_LABEL);
              detuneFromBaseOsc->labelfont(0);
              detuneFromBaseOsc->labelsize(11);
              detuneFromBaseOsc->labelcolor(FL_FOREGROUND_COLOR);
              detuneFromBaseOsc->callback((Fl_Callback*)cb_detuneFromBaseOsc);
              detuneFromBaseOsc->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
              detuneFromBaseOsc->when(FL_WHEN_RELEASE);
              o->value(pars->VoicePar[nvoice].PFMDetuneFromBaseOsc);
              if (pars->VoicePar[nvoice].PFMFixedFreq) o->deactivate();
            } // Fl_Check_Button2* detuneFromBaseOsc
            { Fl_Check_Button2* o = Mod440 = new Fl_Check_Button2(726, 220, 55, 15, "440Hz");
              Mod440->tooltip("Set the modulator base frequency to 440Hz");
              Mod440->box(FL_NO_BOX);
              Mod440->down_box(FL_DOWN_BOX);
              Mod440->color(FL_BACKGROUND_COLOR);
              Mod440->selection_color(FL_FOREGROUND_COLOR);
              Mod440->labeltype(FL_NORMAL_LABEL);
              Mod440->labelfont(1);
              Mod440->labelsize(11);
              Mod440->labelcolor(FL_FOREGROUND_COLOR);
              Mod440->callback((Fl_Callback*)cb_Mod440);
              Mod440->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
              Mod440->when(FL_WHEN_RELEASE);
              o->value(pars->VoicePar[nvoice].PFMFixedFreq);
            } // Fl_Check_Button2* Mod440
            modfrequency->end();
          } // Fl_Group* modfrequency
          { Modampgrp = new Fl_Group(580, 55, 220, 149, "Mod AMPLITUDE");
            Modampgrp->box(FL_THIN_UP_FRAME);
            Modampgrp->labelfont(1);
            Modampgrp->labelsize(11);
            Modampgrp->align(Fl_Align(FL_ALIGN_TOP|FL_ALIGN_INSIDE));
            { mwheel_val_slider_rev* o = ModVolume = new mwheel_val_slider_rev(585, 70, 160, 15, "Vol");
              ModVolume->tooltip("Volume");
              ModVolume->type(5);
              ModVolume->box(FL_THIN_DOWN_BOX);
              ModVolume->color(FL_BACKGROUND_COLOR);
              ModVolume->selection_color(FL_BACKGROUND_COLOR);
              ModVolume->labeltype(FL_NORMAL_LABEL);
              ModVolume->labelfont(0);
              ModVolume->labelsize(11);
              ModVolume->labelcolor(FL_FOREGROUND_COLOR);
              ModVolume->maximum(127);
              ModVolume->step(1);
              ModVolume->callback((Fl_Callback*)cb_ModVolume);
              ModVolume->align(Fl_Align(FL_ALIGN_RIGHT));
              ModVolume->when(FL_WHEN_CHANGED);
              o->value(pars->VoicePar[nvoice].PFMVolume);
            } // mwheel_val_slider_rev* ModVolume
            { mwheel_val_slider_rev* o = ModVsense = new mwheel_val_slider_rev(585, 90, 160, 15, "V.Sns");
              ModVsense->tooltip("Velocity Sensing Function - rightmost/max to disable)");
              ModVsense->type(5);
              ModVsense->box(FL_THIN_DOWN_BOX);
              ModVsense->color(FL_BACKGROUND_COLOR);
              ModVsense->selection_color(FL_BACKGROUND_COLOR);
              ModVsense->labeltype(FL_NORMAL_LABEL);
              ModVsense->labelfont(0);
              ModVsense->labelsize(11);
              ModVsense->labelcolor(FL_FOREGROUND_COLOR);
              ModVsense->maximum(127);
              ModVsense->step(1);
              ModVsense->callback((Fl_Callback*)cb_ModVsense);
              ModVsense->align(Fl_Align(FL_ALIGN_RIGHT));
              ModVsense->when(FL_WHEN_CHANGED);
              o->value(pars->VoicePar[nvoice].PFMVelocityScaleFunction);
            } // mwheel_val_slider_rev* ModVsense
            { EnvelopeUI* o = voiceFMampenvgroup = new EnvelopeUI(585, 129, 210, 70, "ADSynth Modulator - Amplitude Envelope");
              voiceFMampenvgroup->box(FL_FLAT_BOX);
              voiceFMampenvgroup->color((Fl_Color)51);
              voiceFMampenvgroup->selection_color(FL_BACKGROUND_COLOR);
              voiceFMampenvgroup->labeltype(FL_NORMAL_LABEL);
              voiceFMampenvgroup->labelfont(0);
              voiceFMampenvgroup->labelsize(14);
              voiceFMampenvgroup->labelcolor(FL_FOREGROUND_COLOR);
              voiceFMampenvgroup->align(Fl_Align(FL_ALIGN_WRAP|FL_ALIGN_INSIDE));
              voiceFMampenvgroup->when(FL_WHEN_RELEASE);
              o->init(pars->VoicePar[nvoice].FMAmpEnvelope, npart, kititem, nvoice + PART::engine::addMod1, 0);
              if (pars->VoicePar[nvoice].PFMAmpEnvelopeEnabled==0) o->deactivate();
              voiceFMampenvgroup->end();
            } // EnvelopeUI* voiceFMampenvgroup
            { Fl_Check_Button2* o = ModAmpEn = new Fl_Check_Button2(590, 134, 38, 14, "On");
              ModAmpEn->tooltip("Enable Amplitude Envelope");
              ModAmpEn->box(FL_THIN_UP_BOX);
              ModAmpEn->down_box(FL_DOWN_BOX);
              ModAmpEn->color((Fl_Color)237);
              ModAmpEn->selection_color(FL_FOREGROUND_COLOR);
              ModAmpEn->labeltype(FL_NORMAL_LABEL);
              ModAmpEn->labelfont(1);
              ModAmpEn->labelsize(10);
              ModAmpEn->labelcolor(FL_FOREGROUND_COLOR);
              ModAmpEn->callback((Fl_Callback*)cb_ModAmpEn);
              ModAmpEn->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
              ModAmpEn->when(FL_WHEN_RELEASE);
              o->value(pars->VoicePar[nvoice].PFMAmpEnvelopeEnabled);
            } // Fl_Check_Button2* ModAmpEn
            { mwheel_val_slider_rev* o = ModFdamp = new mwheel_val_slider_rev(585, 110, 160, 15, "F.Damp");
              ModFdamp->tooltip("Modulator Damp at Higher frequency");
              ModFdamp->type(5);
              ModFdamp->box(FL_THIN_DOWN_BOX);
              ModFdamp->color(FL_BACKGROUND_COLOR);
              ModFdamp->selection_color(FL_BACKGROUND_COLOR);
              ModFdamp->labeltype(FL_NORMAL_LABEL);
              ModFdamp->labelfont(0);
              ModFdamp->labelsize(11);
              ModFdamp->labelcolor(FL_FOREGROUND_COLOR);
              ModFdamp->minimum(-64);
              ModFdamp->maximum(63);
              ModFdamp->step(1);
              ModFdamp->callback((Fl_Callback*)cb_ModFdamp);
              ModFdamp->align(Fl_Align(FL_ALIGN_RIGHT));
              ModFdamp->when(FL_WHEN_CHANGED);
              o->value(pars->VoicePar[nvoice].PFMVolumeDamp-64);
            } // mwheel_val_slider_rev* ModFdamp
            Modampgrp->end();
          } // Fl_Group* Modampgrp
          { modOscDisplay = new Fl_Group(580, 365, 220, 200);
            { modoscil = new Fl_Group(580, 365, 220, 200, "                       ");
              modoscil->box(FL_THIN_UP_FRAME);
              modoscil->labelfont(1);
              modoscil->labelsize(11);
              modoscil->align(Fl_Align(FL_ALIGN_TOP|FL_ALIGN_INSIDE));
              { ModLocalOsc = new Fl_Text_Display(598, 385, 95, 2, "Local Oscillator");
                ModLocalOsc->box(FL_NO_BOX);
                ModLocalOsc->labelfont(1);
                ModLocalOsc->labelsize(12);
              } // Fl_Text_Display* ModLocalOsc
              { Fl_Button* o = changeFMoscilbutton = new Fl_Button(712, 370, 72, 18, "Waveform");
                changeFMoscilbutton->box(FL_THIN_UP_BOX);
                changeFMoscilbutton->labelfont(1);
                changeFMoscilbutton->labelsize(10);
                changeFMoscilbutton->callback((Fl_Callback*)cb_changeFMoscilbutton);
                if (pars->VoicePar[nvoice].PextFMoscil>=0) o->labelcolor(FL_BLUE);
              } // Fl_Button* changeFMoscilbutton
              { mwheel_slider_rev* o = ModPhase = new mwheel_slider_rev(711, 402, 74, 16, "Phase");
                ModPhase->tooltip("Phase offset");
                ModPhase->type(5);
                ModPhase->box(FL_THIN_DOWN_BOX);
                ModPhase->color(FL_BACKGROUND_COLOR);
                ModPhase->selection_color(FL_BACKGROUND_COLOR);
                ModPhase->labeltype(FL_NORMAL_LABEL);
                ModPhase->labelfont(0);
                ModPhase->labelsize(10);
                ModPhase->labelcolor(FL_FOREGROUND_COLOR);
                ModPhase->minimum(-64);
                ModPhase->maximum(63);
                ModPhase->step(1);
                ModPhase->callback((Fl_Callback*)cb_ModPhase);
                ModPhase->align(Fl_Align(FL_ALIGN_TOP));
                ModPhase->when(FL_WHEN_CHANGED);
                o->value(64-pars->VoicePar[nvoice].PFMoscilphase);
                o->setValueType(VC_PhaseOffset); o->useCustomTip(true);
              } // mwheel_slider_rev* ModPhase
              { Fl_Choice* o = ExtModOsc = new Fl_Choice(607, 402, 75, 16, "Use");
                ExtModOsc->tooltip("Use an earlier oscillator for this modulator. Only the base oscillator is use\
d, not other voice parameters.");
                ExtModOsc->down_box(FL_BORDER_BOX);
                ExtModOsc->selection_color(FL_BACKGROUND_COLOR);
                ExtModOsc->labelsize(10);
                ExtModOsc->textfont(1);
                ExtModOsc->textsize(10);
                ExtModOsc->callback((Fl_Callback*)cb_ExtModOsc);
                ExtModOsc->align(Fl_Align(FL_ALIGN_TOP));
                o->add("Internal");
                char tmp[50]; for (int i = 0; i < nvoice; ++i) {sprintf(tmp, "Mod.%2d", i + 1); o->add(tmp);};
                o->value(pars->VoicePar[nvoice].PextFMoscil + 1);
              } // Fl_Choice* ExtModOsc
              { Fl_Group* o = fmoscil = new Fl_Group(580, 425, 220, 140);
                fmoscil->box(FL_THIN_DOWN_BOX);
                fmoscil->color(FL_GRAY0);
                fmoscil->selection_color((Fl_Color)71);
                fmoscil->labelcolor((Fl_Color)179);
                oscFM = new Oscilloscope(o->x(),o->y(),o->w(),o->h(), 125,"");
                update_fmoscil();
                fmoscil->end();
              } // Fl_Group* fmoscil
              modoscil->end();
            } // Fl_Group* modoscil
            { modvoicelabel = new Fl_Box(600, 470, 190, 65, "Voice");
              modvoicelabel->labelfont(1);
              modvoicelabel->labelsize(40);
              modvoicelabel->labelcolor(FL_BACKGROUND2_COLOR);
              modvoicelabel->callback((Fl_Callback*)cb_modvoicelabel);
              update_modvoicelabel();
            } // Fl_Box* modvoicelabel
            modOscDisplay->end();
          } // Fl_Group* modOscDisplay
          { Fl_Choice* o = ExtMod = new Fl_Choice(692, 32, 104, 20, "Source");
            ExtMod->tooltip("Use an earlier voice as modulator. All parameters from the imported voice rem\
ain in effect, except for volume, panning, base frequency and pitch bend scali\
ng factor. The voice is also converted to mono. Parameters in the current voic\
e will then tweak the modulator further.");
            ExtMod->down_box(FL_BORDER_BOX);
            ExtMod->selection_color(FL_BACKGROUND_COLOR);
            ExtMod->labelsize(11);
            ExtMod->textfont(1);
            ExtMod->callback((Fl_Callback*)cb_ExtMod);
            ExtMod->align(Fl_Align(FL_ALIGN_TOP_RIGHT));
            o->add("Local");
            char tmp[50]; for (int i = 0; i < nvoice; ++i) {sprintf(tmp, "Voice %2d", i + 1); o->add(tmp);};
            o->value(pars->VoicePar[nvoice].PFMVoice + 1);
            if (lrint(o->value())) {modoscil->deactivate();}
          } // Fl_Choice* ExtMod
          voiceFMparametersgroup->end();
        } // Fl_Group* voiceFMparametersgroup
        { Fl_Choice* o = ModType = new Fl_Choice(580, 32, 90, 20, "Type:");
          ModType->down_box(FL_BORDER_BOX);
          ModType->color((Fl_Color)237);
          ModType->selection_color(FL_BACKGROUND_COLOR);
          ModType->labelsize(11);
          ModType->textfont(1);
          ModType->textsize(11);
          ModType->callback((Fl_Callback*)cb_ModType);
          ModType->align(Fl_Align(FL_ALIGN_TOP_LEFT));
          o->add("Off");o->add("Morph");o->add("Ring");o->add("PM");o->add("FM");o->add("PWM");
          o->value(pars->VoicePar[nvoice].PFMEnabled);
          if (o->value() == 0) voiceFMparametersgroup->deactivate();
        } // Fl_Choice* ModType
        { freqencygrp = new Fl_Group(5, 280, 570, 120, "FREQUENCY");
          freqencygrp->box(FL_THIN_UP_FRAME);
          freqencygrp->labelfont(1);
          freqencygrp->labelsize(12);
          freqencygrp->align(Fl_Align(FL_ALIGN_TOP|FL_ALIGN_INSIDE));
          { EnvelopeUI* o = voicefreqenvgroup = new EnvelopeUI(10, 325, 205, 70, "ADSynth Voice - Frequency Envelope");
            voicefreqenvgroup->box(FL_FLAT_BOX);
            voicefreqenvgroup->color((Fl_Color)51);
            voicefreqenvgroup->selection_color(FL_BACKGROUND_COLOR);
            voicefreqenvgroup->labeltype(FL_NORMAL_LABEL);
            voicefreqenvgroup->labelfont(0);
            voicefreqenvgroup->labelsize(14);
            voicefreqenvgroup->labelcolor(FL_FOREGROUND_COLOR);
            voicefreqenvgroup->align(Fl_Align(FL_ALIGN_WRAP|FL_ALIGN_INSIDE));
            voicefreqenvgroup->when(FL_WHEN_RELEASE);
            o->init(pars->VoicePar[nvoice].FreqEnvelope, npart, kititem, nvoice + PART::engine::addVoice1, 1);
            if (pars->VoicePar[nvoice].PFreqEnvelopeEnabled==0) o->deactivate();
            voicefreqenvgroup->end();
          } // EnvelopeUI* voicefreqenvgroup
          { Fl_Check_Button2* o = FreqEn = new Fl_Check_Button2(14, 330, 38, 14, "On");
            FreqEn->tooltip("Enable Frequency Envelope");
            FreqEn->box(FL_THIN_UP_BOX);
            FreqEn->down_box(FL_DOWN_BOX);
            FreqEn->color((Fl_Color)237);
            FreqEn->selection_color(FL_FOREGROUND_COLOR);
            FreqEn->labeltype(FL_NORMAL_LABEL);
            FreqEn->labelfont(1);
            FreqEn->labelsize(10);
            FreqEn->labelcolor(FL_FOREGROUND_COLOR);
            FreqEn->callback((Fl_Callback*)cb_FreqEn);
            FreqEn->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
            FreqEn->when(FL_WHEN_RELEASE);
            o->value(pars->VoicePar[nvoice].PFreqEnvelopeEnabled);
          } // Fl_Check_Button2* FreqEn
          { LFOUI* o = voicefreqlfogroup = new LFOUI(215, 325, 275, 70, "Frequency LFO     ");
            voicefreqlfogroup->box(FL_FLAT_BOX);
            voicefreqlfogroup->color(FL_DARK1);
            voicefreqlfogroup->selection_color(FL_BACKGROUND_COLOR);
            voicefreqlfogroup->labeltype(FL_NORMAL_LABEL);
            voicefreqlfogroup->labelfont(0);
            voicefreqlfogroup->labelsize(14);
            voicefreqlfogroup->labelcolor(FL_FOREGROUND_COLOR);
            voicefreqlfogroup->align(Fl_Align(FL_ALIGN_WRAP|FL_ALIGN_INSIDE));
            voicefreqlfogroup->when(FL_WHEN_RELEASE);
            o->init(pars->VoicePar[nvoice].FreqLfo, npart, kititem, PART::engine::addVoice1 + nvoice, 1);
            if (pars->VoicePar[nvoice].PFreqLfoEnabled==0) o->deactivate();
            voicefreqlfogroup->end();
          } // LFOUI* voicefreqlfogroup
          { Fl_Check_Button2* o = FreqLfoEn = new Fl_Check_Button2(220, 330, 38, 14, "On");
            FreqLfoEn->tooltip("Enable Frequency LFO");
            FreqLfoEn->box(FL_THIN_UP_BOX);
            FreqLfoEn->down_box(FL_DOWN_BOX);
            FreqLfoEn->color((Fl_Color)237);
            FreqLfoEn->selection_color(FL_FOREGROUND_COLOR);
            FreqLfoEn->labeltype(FL_NORMAL_LABEL);
            FreqLfoEn->labelfont(1);
            FreqLfoEn->labelsize(10);
            FreqLfoEn->labelcolor(FL_FOREGROUND_COLOR);
            FreqLfoEn->callback((Fl_Callback*)cb_FreqLfoEn);
            FreqLfoEn->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
            FreqLfoEn->when(FL_WHEN_RELEASE);
            o->value(pars->VoicePar[nvoice].PFreqLfoEnabled);
          } // Fl_Check_Button2* FreqLfoEn
          { Fl_Counter* o = Octave = new Fl_Counter(510, 306, 45, 15, "Octave");
            Octave->tooltip("Octave");
            Octave->type(1);
            Octave->color((Fl_Color)237);
            Octave->selection_color(FL_FOREGROUND_COLOR);
            Octave->labelsize(10);
            Octave->minimum(-8);
            Octave->maximum(7);
            Octave->step(1);
            Octave->value(4);
            Octave->textfont(1);
            Octave->textsize(11);
            Octave->callback((Fl_Callback*)cb_Octave);
            Octave->align(Fl_Align(FL_ALIGN_TOP));
            int k = pars->VoicePar[nvoice].PCoarseDetune / 1024;
            if (k >= 8) k -= 16;
            o->value(k);
          } // Fl_Counter* Octave
          { Fl_Counter* o = CoarseDetune = new Fl_Counter(496, 375, 68, 16, "Coarse Det.");
            CoarseDetune->tooltip("Coarse Detune");
            CoarseDetune->labelsize(10);
            CoarseDetune->minimum(-64);
            CoarseDetune->maximum(63);
            CoarseDetune->step(1);
            CoarseDetune->textfont(1);
            CoarseDetune->textsize(11);
            CoarseDetune->callback((Fl_Callback*)cb_CoarseDetune);
            CoarseDetune->align(Fl_Align(FL_ALIGN_TOP));
            int k = pars->VoicePar[nvoice].PCoarseDetune % 1024;
            if (k >= 512) k -= 1024;
            o->value(k);
            o->lstep(10);
          } // Fl_Counter* CoarseDetune
          { Fl_Value_Output* o = detunevalueoutput = new Fl_Value_Output(10, 306, 38, 16, "Detune");
            detunevalueoutput->box(FL_THIN_DOWN_BOX);
            detunevalueoutput->labelsize(10);
            detunevalueoutput->minimum(-5000);
            detunevalueoutput->maximum(5000);
            detunevalueoutput->textfont(1);
            detunevalueoutput->textsize(10);
            detunevalueoutput->callback((Fl_Callback*)cb_detunevalueoutput1);
            detunevalueoutput->align(Fl_Align(FL_ALIGN_TOP_LEFT));
            o->step(0.01, 1);
            o->value(getDetune((pars->VoicePar[nvoice].PDetuneType==0)?(pars->GlobalPar.PDetuneType) : (pars->VoicePar[nvoice].PDetuneType),0,pars->VoicePar[nvoice].PDetune)*pars->getBandwidthDetuneMultiplier());
          } // Fl_Value_Output* detunevalueoutput
          { mwheel_slider_rev* o = Detune = new mwheel_slider_rev(48, 306, 442, 16);
            Detune->tooltip("Fine Detune (cents)");
            Detune->type(5);
            Detune->box(FL_THIN_DOWN_BOX);
            Detune->color(FL_BACKGROUND_COLOR);
            Detune->selection_color(FL_BACKGROUND_COLOR);
            Detune->labeltype(FL_NORMAL_LABEL);
            Detune->labelfont(0);
            Detune->labelsize(14);
            Detune->labelcolor(FL_FOREGROUND_COLOR);
            Detune->minimum(-8192);
            Detune->maximum(8191);
            Detune->step(1);
            Detune->callback((Fl_Callback*)cb_Detune);
            Detune->align(Fl_Align(FL_ALIGN_BOTTOM));
            Detune->when(FL_WHEN_CHANGED);
            o->value(pars->VoicePar[nvoice].PDetune-8192);
          } // mwheel_slider_rev* Detune
          { Fl_Choice* o = FreqDetunetype = new Fl_Choice(495, 340, 75, 17, "Detune Type");
            FreqDetunetype->down_box(FL_BORDER_BOX);
            FreqDetunetype->labelsize(10);
            FreqDetunetype->textfont(1);
            FreqDetunetype->textsize(10);
            FreqDetunetype->callback((Fl_Callback*)cb_FreqDetunetype);
            FreqDetunetype->align(Fl_Align(FL_ALIGN_TOP_LEFT));
            o->add("Default");o->add("L35cents");o->add("L10cents");o->add("E100cents");o->add("E1200cents");
            o->value(pars->VoicePar[nvoice].PDetuneType);
          } // Fl_Choice* FreqDetunetype
          { WidgetPDial* o = bend = new WidgetPDial(70, 284, 20, 20, "Bend");
            bend->tooltip("Pitch bend scaling for this voice");
            bend->box(FL_ROUND_UP_BOX);
            bend->color(FL_BACKGROUND_COLOR);
            bend->selection_color(FL_INACTIVE_COLOR);
            bend->labeltype(FL_NORMAL_LABEL);
            bend->labelfont(0);
            bend->labelsize(10);
            bend->labelcolor(FL_FOREGROUND_COLOR);
            bend->maximum(127);
            bend->step(1);
            bend->callback((Fl_Callback*)cb_bend);
            bend->align(Fl_Align(FL_ALIGN_RIGHT));
            bend->when(FL_WHEN_CHANGED);
            o->value(pars->VoicePar[nvoice].PBendAdjust);
            o->setValueType(VC_PitchBend);
          } // WidgetPDial* bend
          { Fl_Check_Button2* o = Freq440 = new Fl_Check_Button2(400, 286, 55, 15, "440Hz");
            Freq440->tooltip("Set the voice base frequency to 440Hz");
            Freq440->box(FL_NO_BOX);
            Freq440->down_box(FL_DOWN_BOX);
            Freq440->color(FL_BACKGROUND_COLOR);
            Freq440->selection_color(FL_FOREGROUND_COLOR);
            Freq440->labeltype(FL_NORMAL_LABEL);
            Freq440->labelfont(1);
            Freq440->labelsize(11);
            Freq440->labelcolor(FL_FOREGROUND_COLOR);
            Freq440->callback((Fl_Callback*)cb_Freq440);
            Freq440->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
            Freq440->when(FL_WHEN_RELEASE);
            o->value(pars->VoicePar[nvoice].Pfixedfreq);
          } // Fl_Check_Button2* Freq440
          { WidgetPDial* o = fixedfreqetdial = new WidgetPDial(460, 284, 20, 20, "Eq.T.");
            fixedfreqetdial->tooltip("How the frequency varies according to the keyboard (leftmost for fixed freque\
ncy)");
            fixedfreqetdial->box(FL_ROUND_UP_BOX);
            fixedfreqetdial->color(FL_BACKGROUND_COLOR);
            fixedfreqetdial->selection_color(FL_INACTIVE_COLOR);
            fixedfreqetdial->labeltype(FL_NORMAL_LABEL);
            fixedfreqetdial->labelfont(0);
            fixedfreqetdial->labelsize(10);
            fixedfreqetdial->labelcolor(FL_FOREGROUND_COLOR);
            fixedfreqetdial->maximum(127);
            fixedfreqetdial->step(1);
            fixedfreqetdial->callback((Fl_Callback*)cb_fixedfreqetdial);
            fixedfreqetdial->align(Fl_Align(FL_ALIGN_RIGHT));
            fixedfreqetdial->when(FL_WHEN_CHANGED);
            o->value(pars->VoicePar[nvoice].PfixedfreqET);
            if (pars->VoicePar[nvoice].Pfixedfreq==0) o->deactivate();
            o->setValueType(VC_FixedFreqET);
          } // WidgetPDial* fixedfreqetdial
          { WidgetPDial* o = offset = new WidgetPDial(130, 284, 20, 20, "Offset");
            offset->tooltip("Offset of the frequency in Hz.");
            offset->box(FL_ROUND_UP_BOX);
            offset->color(FL_BACKGROUND_COLOR);
            offset->selection_color(FL_INACTIVE_COLOR);
            offset->labeltype(FL_NORMAL_LABEL);
            offset->labelfont(0);
            offset->labelsize(10);
            offset->labelcolor(FL_FOREGROUND_COLOR);
            offset->maximum(127);
            offset->step(1);
            offset->callback((Fl_Callback*)cb_offset);
            offset->align(Fl_Align(FL_ALIGN_RIGHT));
            offset->when(FL_WHEN_CHANGED);
            o->value(pars->VoicePar[nvoice].POffsetHz);
            o->setValueType(VC_FreqOffsetHz);
          } // WidgetPDial* offset
          freqencygrp->end();
        } // Fl_Group* freqencygrp
        { oscDisplay = new Fl_Group(5, 462, 570, 145);
          { Fl_Group* o = oscGroup = new Fl_Group(5, 462, 570, 145);
            oscGroup->labelfont(1);
            oscGroup->labelsize(13);
            oscGroup->align(Fl_Align(FL_ALIGN_TOP|FL_ALIGN_INSIDE));
            { oscParamBox = new Fl_Group(5, 478, 80, 128, "Local\nOscillator");
              oscParamBox->box(FL_THIN_UP_FRAME);
              oscParamBox->labelfont(1);
              oscParamBox->labelsize(12);
              oscParamBox->align(Fl_Align(FL_ALIGN_TOP|FL_ALIGN_INSIDE));
              { Fl_Choice* o = UseOsc = new Fl_Choice(9, 526, 72, 18, "Use");
                UseOsc->tooltip("Use an earlier oscillator for this voice. Only the base oscillator is used, n\
ot other voice parameters.");
                UseOsc->down_box(FL_BORDER_BOX);
                UseOsc->selection_color(FL_BACKGROUND_COLOR);
                UseOsc->labelsize(10);
                UseOsc->textfont(1);
                UseOsc->textsize(10);
                UseOsc->callback((Fl_Callback*)cb_UseOsc);
                UseOsc->align(Fl_Align(FL_ALIGN_TOP));
                o->add("Internal");
                char tmp[50]; for (int i = 0; i < nvoice; ++i) {sprintf(tmp, "Osc. %2d", i + 1); o->add(tmp);};
                o->value(pars->VoicePar[nvoice].Pextoscil + 1);
              } // Fl_Choice* UseOsc
              { Fl_Button* o = changevoiceoscilbutton = new Fl_Button(9, 548, 72, 22, "Waveform");
                changevoiceoscilbutton->box(FL_THIN_UP_BOX);
                changevoiceoscilbutton->labelfont(1);
                changevoiceoscilbutton->labelsize(11);
                changevoiceoscilbutton->callback((Fl_Callback*)cb_changevoiceoscilbutton);
                if (pars->VoicePar[nvoice].Pextoscil>=0) o->labelcolor(FL_BLUE);
              } // Fl_Button* changevoiceoscilbutton
              { mwheel_slider_rev* o = VoiceOscPhase = new mwheel_slider_rev(9, 586, 72, 16, "Phase");
                VoiceOscPhase->tooltip("Phase offset");
                VoiceOscPhase->type(5);
                VoiceOscPhase->box(FL_THIN_DOWN_BOX);
                VoiceOscPhase->color(FL_BACKGROUND_COLOR);
                VoiceOscPhase->selection_color(FL_BACKGROUND_COLOR);
                VoiceOscPhase->labeltype(FL_NORMAL_LABEL);
                VoiceOscPhase->labelfont(0);
                VoiceOscPhase->labelsize(10);
                VoiceOscPhase->labelcolor(FL_FOREGROUND_COLOR);
                VoiceOscPhase->minimum(-64);
                VoiceOscPhase->maximum(63);
                VoiceOscPhase->step(1);
                VoiceOscPhase->callback((Fl_Callback*)cb_VoiceOscPhase);
                VoiceOscPhase->align(Fl_Align(FL_ALIGN_TOP));
                VoiceOscPhase->when(FL_WHEN_CHANGED);
                o->value(64-pars->VoicePar[nvoice].Poscilphase);
                o->setValueType(VC_PhaseOffset); o->useCustomTip(true);
              } // mwheel_slider_rev* VoiceOscPhase
              oscParamBox->end();
            } // Fl_Group* oscParamBox
            { Fl_Group* o = voiceoscil = new Fl_Group(90, 462, 485, 145);
              voiceoscil->box(FL_THIN_DOWN_BOX);
              voiceoscil->color(FL_GRAY0);
              voiceoscil->selection_color((Fl_Color)71);
              voiceoscil->labelcolor((Fl_Color)179);
              osc = new Oscilloscope(o->x(),o->y(),o->w(),o->h(), 130, "");
              update_voiceoscil();
              voiceoscil->end();
            } // Fl_Group* voiceoscil
            if (pars->VoicePar[nvoice].PVoice >= 0) o->deactivate();
            oscGroup->end();
          } // Fl_Group* oscGroup
          { osclabel = new Fl_Box(135, 502, 400, 65, "Osc");
            osclabel->labelfont(1);
            osclabel->labelsize(50);
            osclabel->labelcolor(FL_BACKGROUND2_COLOR);
            osclabel->callback((Fl_Callback*)cb_osclabel);
          } // Fl_Box* osclabel
          oscDisplay->end();
        } // Fl_Group* oscDisplay
        { Fl_Box* o = new Fl_Box(205, 35, 85, 33);
          o->box(FL_THIN_UP_FRAME);
        } // Fl_Box* o
        { Fl_Check_Button2* o = ResonanceEn = new Fl_Check_Button2(238, 49, 17, 19, "Resonance");
          ResonanceEn->tooltip("Resonance On/Off");
          ResonanceEn->box(FL_NO_BOX);
          ResonanceEn->down_box(FL_DOWN_BOX);
          ResonanceEn->color(FL_BACKGROUND_COLOR);
          ResonanceEn->selection_color(FL_FOREGROUND_COLOR);
          ResonanceEn->labeltype(FL_NORMAL_LABEL);
          ResonanceEn->labelfont(0);
          ResonanceEn->labelsize(12);
          ResonanceEn->labelcolor(FL_FOREGROUND_COLOR);
          ResonanceEn->callback((Fl_Callback*)cb_ResonanceEn);
          ResonanceEn->align(Fl_Align(FL_ALIGN_TOP));
          ResonanceEn->when(FL_WHEN_RELEASE);
          o->value(pars->VoicePar[nvoice].Presonance);
        } // Fl_Check_Button2* ResonanceEn
        { Fl_Group* o = unisongroup = new Fl_Group(90, 402, 484, 56);
          unisongroup->box(FL_PLASTIC_UP_BOX);
          unisongroup->color((Fl_Color)231);
          unisongroup->deactivate();
          { WidgetSpinner* o = unisonsize = new WidgetSpinner(98, 434, 40, 16, "Size");
            unisonsize->tooltip("Number of unison sub-voices");
            unisonsize->box(FL_THIN_UP_BOX);
            unisonsize->color((Fl_Color)29);
            unisonsize->selection_color(FL_BACKGROUND_COLOR);
            unisonsize->labeltype(FL_NORMAL_LABEL);
            unisonsize->labelfont(0);
            unisonsize->labelsize(10);
            unisonsize->labelcolor(FL_FOREGROUND_COLOR);
            unisonsize->minimum(2);
            unisonsize->maximum(50);
            unisonsize->value(2);
            unisonsize->textsize(11);
            unisonsize->callback((Fl_Callback*)cb_unisonsize);
            unisonsize->align(Fl_Align(FL_ALIGN_TOP));
            unisonsize->when(FL_WHEN_RELEASE);
            int tmp = pars->VoicePar[nvoice].Unison_size;
            if (tmp < 2) tmp = 2;
            o->value(tmp);
          } // WidgetSpinner* unisonsize
          { WidgetPDial* o = UnisonStereo = new WidgetPDial(356, 422, 28, 28, "Stereo");
            UnisonStereo->tooltip("Stereo Spread");
            UnisonStereo->box(FL_ROUND_UP_BOX);
            UnisonStereo->color(FL_BACKGROUND_COLOR);
            UnisonStereo->selection_color(FL_INACTIVE_COLOR);
            UnisonStereo->labeltype(FL_NORMAL_LABEL);
            UnisonStereo->labelfont(0);
            UnisonStereo->labelsize(10);
            UnisonStereo->labelcolor(FL_FOREGROUND_COLOR);
            UnisonStereo->maximum(127);
            UnisonStereo->step(1);
            UnisonStereo->callback((Fl_Callback*)cb_UnisonStereo);
            UnisonStereo->align(Fl_Align(FL_ALIGN_TOP));
            UnisonStereo->when(FL_WHEN_CHANGED);
            o->value(pars->VoicePar[nvoice].Unison_stereo_spread);
          } // WidgetPDial* UnisonStereo
          { WidgetPDial* o = UnisonVib = new WidgetPDial(396, 422, 28, 28, "Vib.");
            UnisonVib->tooltip("Vibratto");
            UnisonVib->box(FL_ROUND_UP_BOX);
            UnisonVib->color(FL_BACKGROUND_COLOR);
            UnisonVib->selection_color(FL_INACTIVE_COLOR);
            UnisonVib->labeltype(FL_NORMAL_LABEL);
            UnisonVib->labelfont(0);
            UnisonVib->labelsize(10);
            UnisonVib->labelcolor(FL_FOREGROUND_COLOR);
            UnisonVib->maximum(127);
            UnisonVib->step(1);
            UnisonVib->callback((Fl_Callback*)cb_UnisonVib);
            UnisonVib->align(Fl_Align(FL_ALIGN_TOP));
            UnisonVib->when(FL_WHEN_CHANGED);
            o->value(pars->VoicePar[nvoice].Unison_vibrato);
          } // WidgetPDial* UnisonVib
          { Fl_Choice* o = UnisonInvert = new Fl_Choice(484, 426, 78, 18, "Invert");
            UnisonInvert->tooltip("Phase Invert");
            UnisonInvert->down_box(FL_BORDER_BOX);
            UnisonInvert->labelsize(10);
            UnisonInvert->textfont(1);
            UnisonInvert->textsize(11);
            UnisonInvert->callback((Fl_Callback*)cb_UnisonInvert);
            UnisonInvert->align(Fl_Align(FL_ALIGN_TOP));
            o->add("None");o->add("Random");o->add("50%");o->add("33%");o->add("25%");o->add("20%");
            o->value(pars->VoicePar[nvoice].Unison_invert_phase);
          } // Fl_Choice* UnisonInvert
          { mwheel_slider_rev* o = UnisonFreqSpread = new mwheel_slider_rev(181, 434, 120, 16, "Frequency Spread");
            UnisonFreqSpread->tooltip("Frequency Spread of the Unison");
            UnisonFreqSpread->type(5);
            UnisonFreqSpread->box(FL_THIN_DOWN_BOX);
            UnisonFreqSpread->color(FL_BACKGROUND_COLOR);
            UnisonFreqSpread->selection_color(FL_BACKGROUND_COLOR);
            UnisonFreqSpread->labeltype(FL_NORMAL_LABEL);
            UnisonFreqSpread->labelfont(0);
            UnisonFreqSpread->labelsize(10);
            UnisonFreqSpread->labelcolor(FL_FOREGROUND_COLOR);
            UnisonFreqSpread->maximum(127);
            UnisonFreqSpread->step(1);
            UnisonFreqSpread->value(64);
            UnisonFreqSpread->callback((Fl_Callback*)cb_UnisonFreqSpread);
            UnisonFreqSpread->align(Fl_Align(FL_ALIGN_TOP));
            UnisonFreqSpread->when(FL_WHEN_CHANGED);
            o->value(pars->VoicePar[nvoice].Unison_frequency_spread);
          } // mwheel_slider_rev* UnisonFreqSpread
          { Fl_Value_Output* o = unisonspreadoutput = new Fl_Value_Output(145, 434, 38, 16, "(cents)");
            unisonspreadoutput->box(FL_THIN_DOWN_BOX);
            unisonspreadoutput->labelsize(10);
            unisonspreadoutput->maximum(1000);
            unisonspreadoutput->textsize(10);
            unisonspreadoutput->callback((Fl_Callback*)cb_unisonspreadoutput);
            unisonspreadoutput->align(Fl_Align(FL_ALIGN_TOP_LEFT));
            o->step(0.1, 1);
            o->value(pars->getUnisonFrequencySpreadCents(nvoice));
          } // Fl_Value_Output* unisonspreadoutput
          { WidgetPDial* o = UnisonVspeed = new WidgetPDial(436, 422, 28, 28, "V.speed");
            UnisonVspeed->tooltip("Vibratto Average Speed");
            UnisonVspeed->box(FL_ROUND_UP_BOX);
            UnisonVspeed->color(FL_BACKGROUND_COLOR);
            UnisonVspeed->selection_color(FL_INACTIVE_COLOR);
            UnisonVspeed->labeltype(FL_NORMAL_LABEL);
            UnisonVspeed->labelfont(0);
            UnisonVspeed->labelsize(10);
            UnisonVspeed->labelcolor(FL_FOREGROUND_COLOR);
            UnisonVspeed->maximum(127);
            UnisonVspeed->step(1);
            UnisonVspeed->callback((Fl_Callback*)cb_UnisonVspeed);
            UnisonVspeed->align(Fl_Align(FL_ALIGN_TOP));
            UnisonVspeed->when(FL_WHEN_CHANGED);
            o->value(pars->VoicePar[nvoice].Unison_vibrato_speed);
          } // WidgetPDial* UnisonVspeed
          { WidgetPDial* o = UnisonPhRnd = new WidgetPDial(316, 422, 28, 28, "Ph.rnd");
            UnisonPhRnd->tooltip("Phase randomness");
            UnisonPhRnd->box(FL_ROUND_UP_BOX);
            UnisonPhRnd->color(FL_BACKGROUND_COLOR);
            UnisonPhRnd->selection_color(FL_INACTIVE_COLOR);
            UnisonPhRnd->labeltype(FL_NORMAL_LABEL);
            UnisonPhRnd->labelfont(0);
            UnisonPhRnd->labelsize(10);
            UnisonPhRnd->labelcolor(FL_FOREGROUND_COLOR);
            UnisonPhRnd->maximum(127);
            UnisonPhRnd->step(1);
            UnisonPhRnd->callback((Fl_Callback*)cb_UnisonPhRnd);
            UnisonPhRnd->align(Fl_Align(FL_ALIGN_TOP));
            UnisonPhRnd->when(FL_WHEN_CHANGED);
            o->value(pars->VoicePar[nvoice].Unison_phase_randomness);
          } // WidgetPDial* UnisonPhRnd
          { unisName = new Fl_Box(186, 402, 73, 25, "UNISON");
            unisName->labelfont(1);
            unisName->labelsize(12);
            unisName->callback((Fl_Callback*)cb_unisName);
          } // Fl_Box* unisName
          int tmp = pars->VoicePar[nvoice].Unison_size; if (tmp > 1) o->activate();
          unisonsize->labelcolor(FL_BLACK);int i = -1; while (true){ i++; if (pars->ADnote_unison_sizes[i] == 0) break; if (pars->ADnote_unison_sizes[i] == tmp){ unisonsize->labelcolor(FL_RED); break;}}
          unisongroup->end();
        } // Fl_Group* unisongroup
        { Fl_Check_Button2* o = UnisonEn = new Fl_Check_Button2(94, 408, 38, 14, "On");
          UnisonEn->box(FL_THIN_UP_BOX);
          UnisonEn->down_box(FL_DOWN_BOX);
          UnisonEn->color((Fl_Color)237);
          UnisonEn->selection_color(FL_FOREGROUND_COLOR);
          UnisonEn->labeltype(FL_NORMAL_LABEL);
          UnisonEn->labelfont(1);
          UnisonEn->labelsize(10);
          UnisonEn->labelcolor(FL_FOREGROUND_COLOR);
          UnisonEn->callback((Fl_Callback*)cb_UnisonEn);
          UnisonEn->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
          UnisonEn->when(FL_WHEN_RELEASE);
          int tmp = (pars->VoicePar[nvoice].Unison_size);
          o->value(tmp > 1);
        } // Fl_Check_Button2* UnisonEn
        voicemodegroup->end();
      } // Fl_Group* voicemodegroup
      { amplitudegroup = new Fl_Group(5, 68, 285, 212, "AMPLITUDE");
        amplitudegroup->box(FL_UP_FRAME);
        amplitudegroup->labelfont(1);
        amplitudegroup->labelsize(12);
        amplitudegroup->align(Fl_Align(FL_ALIGN_TOP|FL_ALIGN_INSIDE));
        { WidgetPDial* o = voicevolume = new WidgetPDial(30, 86, 33, 33, "Volume");
          voicevolume->tooltip("Volume");
          voicevolume->box(FL_ROUND_UP_BOX);
          voicevolume->color(FL_BACKGROUND_COLOR);
          voicevolume->selection_color(FL_INACTIVE_COLOR);
          voicevolume->labeltype(FL_NORMAL_LABEL);
          voicevolume->labelfont(0);
          voicevolume->labelsize(10);
          voicevolume->labelcolor(FL_FOREGROUND_COLOR);
          voicevolume->maximum(127);
          voicevolume->step(1);
          voicevolume->callback((Fl_Callback*)cb_voicevolume1);
          voicevolume->align(Fl_Align(FL_ALIGN_BOTTOM));
          voicevolume->when(FL_WHEN_CHANGED);
          o->setValueType(VC_ADDVoiceVolume);
          o->value(pars->VoicePar[nvoice].PVolume);
        } // WidgetPDial* voicevolume
        { WidgetPDial* o = voicevsns = new WidgetPDial(86, 87, 33, 33, "Vel Sens");
          voicevsns->tooltip("Velocity Sensing Function - rightmost/max disables)");
          voicevsns->box(FL_ROUND_UP_BOX);
          voicevsns->color(FL_BACKGROUND_COLOR);
          voicevsns->selection_color(FL_INACTIVE_COLOR);
          voicevsns->labeltype(FL_NORMAL_LABEL);
          voicevsns->labelfont(0);
          voicevsns->labelsize(10);
          voicevsns->labelcolor(FL_FOREGROUND_COLOR);
          voicevsns->maximum(127);
          voicevsns->step(1);
          voicevsns->callback((Fl_Callback*)cb_voicevsns);
          voicevsns->align(Fl_Align(FL_ALIGN_BOTTOM));
          voicevsns->when(FL_WHEN_CHANGED);
          o->value(pars->VoicePar[nvoice].PAmpVelocityScaleFunction);
          o->setValueType(VC_AmpVelocitySense);
        } // WidgetPDial* voicevsns
        { WidgetPDial* o = voicepan = new WidgetPDial(160, 86, 33, 33, "Pan");
          voicepan->tooltip("Voice panning");
          voicepan->box(FL_ROUND_UP_BOX);
          voicepan->color(FL_BACKGROUND_COLOR);
          voicepan->selection_color(FL_INACTIVE_COLOR);
          voicepan->labeltype(FL_NORMAL_LABEL);
          voicepan->labelfont(0);
          voicepan->labelsize(10);
          voicepan->labelcolor(FL_FOREGROUND_COLOR);
          voicepan->maximum(127);
          voicepan->step(1);
          voicepan->callback((Fl_Callback*)cb_voicepan);
          voicepan->align(Fl_Align(FL_ALIGN_BOTTOM_LEFT));
          voicepan->when(FL_WHEN_CHANGED);
          o->setValueType(VC_PanningStd);
          o->value(pars->VoicePar[nvoice].PPanning);
        } // WidgetPDial* voicepan
        { WidgetPDial* o = voicewidth = new WidgetPDial(235, 86, 33, 33, "Width");
          voicewidth->tooltip("Voice random width");
          voicewidth->box(FL_ROUND_UP_BOX);
          voicewidth->color(FL_BACKGROUND_COLOR);
          voicewidth->selection_color(FL_INACTIVE_COLOR);
          voicewidth->labeltype(FL_NORMAL_LABEL);
          voicewidth->labelfont(0);
          voicewidth->labelsize(10);
          voicewidth->labelcolor(FL_FOREGROUND_COLOR);
          voicewidth->maximum(63);
          voicewidth->step(1);
          voicewidth->value(63);
          voicewidth->callback((Fl_Callback*)cb_voicewidth);
          voicewidth->align(Fl_Align(FL_ALIGN_BOTTOM));
          voicewidth->when(FL_WHEN_CHANGED);
          o->setValueType(VC_PanningRandom);
          o->value(pars->VoicePar[nvoice].PWidth);
        } // WidgetPDial* voicewidth
        { Fl_Check_Button2* o = voicerandompan = new Fl_Check_Button2(205, 94, 15, 15, "Rand");
          voicerandompan->tooltip("Enable random panning");
          voicerandompan->box(FL_NO_BOX);
          voicerandompan->down_box(FL_DOWN_BOX);
          voicerandompan->color((Fl_Color)48);
          voicerandompan->selection_color(FL_FOREGROUND_COLOR);
          voicerandompan->labeltype(FL_NORMAL_LABEL);
          voicerandompan->labelfont(0);
          voicerandompan->labelsize(11);
          voicerandompan->labelcolor(FL_FOREGROUND_COLOR);
          voicerandompan->callback((Fl_Callback*)cb_voicerandompan);
          voicerandompan->align(Fl_Align(FL_ALIGN_TOP));
          voicerandompan->when(FL_WHEN_RELEASE);
          o->value(pars->VoicePar[nvoice].PRandom);
          if (o->value() == 0) voicewidth->deactivate(); else voicewidth->activate();
        } // Fl_Check_Button2* voicerandompan
        { EnvelopeUI* o = voiceampenvgroup = new EnvelopeUI(10, 135, 205, 70, "ADSynth Voice - Amplitude Envelope");
          voiceampenvgroup->box(FL_FLAT_BOX);
          voiceampenvgroup->color((Fl_Color)51);
          voiceampenvgroup->selection_color(FL_BACKGROUND_COLOR);
          voiceampenvgroup->labeltype(FL_NORMAL_LABEL);
          voiceampenvgroup->labelfont(0);
          voiceampenvgroup->labelsize(14);
          voiceampenvgroup->labelcolor(FL_FOREGROUND_COLOR);
          voiceampenvgroup->align(Fl_Align(FL_ALIGN_WRAP|FL_ALIGN_INSIDE));
          voiceampenvgroup->when(FL_WHEN_RELEASE);
          o->init(pars->VoicePar[nvoice].AmpEnvelope, npart, kititem, nvoice + PART::engine::addVoice1, 0);
          if (!pars->VoicePar[nvoice].PAmpEnvelopeEnabled) o->deactivate();
          voiceampenvgroup->end();
        } // EnvelopeUI* voiceampenvgroup
        { Fl_Check_Button2* o = AmpEnvEn = new Fl_Check_Button2(14, 139, 38, 14, "On");
          AmpEnvEn->tooltip("Enable Amplitude Envelope");
          AmpEnvEn->box(FL_THIN_UP_BOX);
          AmpEnvEn->down_box(FL_DOWN_BOX);
          AmpEnvEn->color((Fl_Color)237);
          AmpEnvEn->selection_color(FL_FOREGROUND_COLOR);
          AmpEnvEn->labeltype(FL_NORMAL_LABEL);
          AmpEnvEn->labelfont(1);
          AmpEnvEn->labelsize(10);
          AmpEnvEn->labelcolor(FL_FOREGROUND_COLOR);
          AmpEnvEn->callback((Fl_Callback*)cb_AmpEnvEn);
          AmpEnvEn->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
          AmpEnvEn->when(FL_WHEN_RELEASE);
          o->value(pars->VoicePar[nvoice].PAmpEnvelopeEnabled);
        } // Fl_Check_Button2* AmpEnvEn
        { LFOUI* o = voiceamplfogroup = new LFOUI(10, 205, 275, 70, "Amplitude LFO     ");
          voiceamplfogroup->box(FL_FLAT_BOX);
          voiceamplfogroup->color(FL_DARK1);
          voiceamplfogroup->selection_color(FL_BACKGROUND_COLOR);
          voiceamplfogroup->labeltype(FL_NORMAL_LABEL);
          voiceamplfogroup->labelfont(0);
          voiceamplfogroup->labelsize(14);
          voiceamplfogroup->labelcolor(FL_FOREGROUND_COLOR);
          voiceamplfogroup->align(Fl_Align(FL_ALIGN_WRAP|FL_ALIGN_INSIDE));
          voiceamplfogroup->when(FL_WHEN_RELEASE);
          o->init(pars->VoicePar[nvoice].AmpLfo, npart, kititem, PART::engine::addVoice1 + nvoice, 0);
          if (pars->VoicePar[nvoice].PAmpLfoEnabled==0) o->deactivate();
          voiceamplfogroup->end();
        } // LFOUI* voiceamplfogroup
        { Fl_Check_Button2* o = AmpLfoEn = new Fl_Check_Button2(14, 210, 38, 14, "On");
          AmpLfoEn->tooltip("Enable Amplitude LFO");
          AmpLfoEn->box(FL_THIN_UP_BOX);
          AmpLfoEn->down_box(FL_DOWN_BOX);
          AmpLfoEn->color((Fl_Color)237);
          AmpLfoEn->selection_color(FL_FOREGROUND_COLOR);
          AmpLfoEn->labeltype(FL_NORMAL_LABEL);
          AmpLfoEn->labelfont(1);
          AmpLfoEn->labelsize(10);
          AmpLfoEn->labelcolor(FL_FOREGROUND_COLOR);
          AmpLfoEn->callback((Fl_Callback*)cb_AmpLfoEn);
          AmpLfoEn->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
          AmpLfoEn->when(FL_WHEN_RELEASE);
          o->value(pars->VoicePar[nvoice].PAmpLfoEnabled);
        } // Fl_Check_Button2* AmpLfoEn
        { Fl_Check_Button2* o = VolumeMinus = new Fl_Check_Button2(10, 75, 50, 10, "Minus");
          VolumeMinus->tooltip("Reverse phase relative to other voices");
          VolumeMinus->box(FL_NO_BOX);
          VolumeMinus->down_box(FL_DOWN_BOX);
          VolumeMinus->color(FL_BACKGROUND_COLOR);
          VolumeMinus->selection_color(FL_FOREGROUND_COLOR);
          VolumeMinus->labeltype(FL_NORMAL_LABEL);
          VolumeMinus->labelfont(0);
          VolumeMinus->labelsize(12);
          VolumeMinus->labelcolor(FL_FOREGROUND_COLOR);
          VolumeMinus->callback((Fl_Callback*)cb_VolumeMinus);
          VolumeMinus->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
          VolumeMinus->when(FL_WHEN_RELEASE);
          o->value(pars->VoicePar[nvoice].PVolumeminus);
        } // Fl_Check_Button2* VolumeMinus
        { Fl_Box* o = new Fl_Box(140, 85, 4, 44);
          o->box(FL_THIN_DOWN_FRAME);
        } // Fl_Box* o
        amplitudegroup->end();
      } // Fl_Group* amplitudegroup
      { Fl_Group* o = voicefiltergroup = new Fl_Group(290, 35, 285, 245, "FILTER      ");
        voicefiltergroup->box(FL_UP_FRAME);
        voicefiltergroup->labelfont(1);
        voicefiltergroup->labelsize(12);
        voicefiltergroup->align(Fl_Align(FL_ALIGN_TOP|FL_ALIGN_INSIDE));
        { FilterUI* o = voicefilter = new FilterUI(295, 60, 275, 75, "ADsynth Voice - Filter");
          voicefilter->box(FL_FLAT_BOX);
          voicefilter->color(FL_LIGHT1);
          voicefilter->selection_color(FL_BACKGROUND_COLOR);
          voicefilter->labeltype(FL_NORMAL_LABEL);
          voicefilter->labelfont(0);
          voicefilter->labelsize(14);
          voicefilter->labelcolor(FL_FOREGROUND_COLOR);
          voicefilter->align(Fl_Align(FL_ALIGN_WRAP|FL_ALIGN_INSIDE));
          voicefilter->when(FL_WHEN_RELEASE);
          o->init(pars->VoicePar[nvoice].VoiceFilter,&pars->VoicePar[nvoice].PFilterVelocityScale, &pars->VoicePar[nvoice].PFilterVelocityScaleFunction, npart, kititem, PART::engine::addVoice1 + nvoice);
          voicefilter->end();
        } // FilterUI* voicefilter
        { EnvelopeUI* o = voicefilterenvgroup = new EnvelopeUI(295, 135, 275, 70, "ADSynth Voice - Filter Envelope");
          voicefilterenvgroup->box(FL_FLAT_BOX);
          voicefilterenvgroup->color((Fl_Color)51);
          voicefilterenvgroup->selection_color(FL_BACKGROUND_COLOR);
          voicefilterenvgroup->labeltype(FL_NORMAL_LABEL);
          voicefilterenvgroup->labelfont(0);
          voicefilterenvgroup->labelsize(14);
          voicefilterenvgroup->labelcolor(FL_FOREGROUND_COLOR);
          voicefilterenvgroup->align(Fl_Align(FL_ALIGN_WRAP|FL_ALIGN_INSIDE));
          voicefilterenvgroup->when(FL_WHEN_RELEASE);
          o->init(pars->VoicePar[nvoice].FilterEnvelope, npart, kititem, nvoice + PART::engine::addVoice1, 2);
          if (pars->VoicePar[nvoice].PFilterEnvelopeEnabled==0) o->deactivate();
          voicefilterenvgroup->end();
        } // EnvelopeUI* voicefilterenvgroup
        { Fl_Check_Button2* o = FilterEnvEn = new Fl_Check_Button2(300, 140, 38, 14, "On");
          FilterEnvEn->tooltip("Enable Filter Envelope");
          FilterEnvEn->box(FL_THIN_UP_BOX);
          FilterEnvEn->down_box(FL_DOWN_BOX);
          FilterEnvEn->color((Fl_Color)237);
          FilterEnvEn->selection_color(FL_FOREGROUND_COLOR);
          FilterEnvEn->labeltype(FL_NORMAL_LABEL);
          FilterEnvEn->labelfont(1);
          FilterEnvEn->labelsize(10);
          FilterEnvEn->labelcolor(FL_FOREGROUND_COLOR);
          FilterEnvEn->callback((Fl_Callback*)cb_FilterEnvEn);
          FilterEnvEn->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
          FilterEnvEn->when(FL_WHEN_RELEASE);
          o->value(pars->VoicePar[nvoice].PFilterEnvelopeEnabled);
        } // Fl_Check_Button2* FilterEnvEn
        { LFOUI* o = voicefilterlfogroup = new LFOUI(295, 205, 275, 70, "Filter LFO     ");
          voicefilterlfogroup->box(FL_FLAT_BOX);
          voicefilterlfogroup->color(FL_DARK1);
          voicefilterlfogroup->selection_color(FL_BACKGROUND_COLOR);
          voicefilterlfogroup->labeltype(FL_NORMAL_LABEL);
          voicefilterlfogroup->labelfont(0);
          voicefilterlfogroup->labelsize(14);
          voicefilterlfogroup->labelcolor(FL_FOREGROUND_COLOR);
          voicefilterlfogroup->align(Fl_Align(FL_ALIGN_WRAP|FL_ALIGN_INSIDE));
          voicefilterlfogroup->when(FL_WHEN_RELEASE);
          o->init(pars->VoicePar[nvoice].FilterLfo, npart, kititem, PART::engine::addVoice1 + nvoice, 2);
          if (pars->VoicePar[nvoice].PFilterLfoEnabled==0) o->deactivate();
          voicefilterlfogroup->end();
        } // LFOUI* voicefilterlfogroup
        { Fl_Check_Button2* o = FilterLfoEn = new Fl_Check_Button2(300, 210, 38, 14, "On");
          FilterLfoEn->tooltip("Enable Filter LFO");
          FilterLfoEn->box(FL_THIN_UP_BOX);
          FilterLfoEn->down_box(FL_DOWN_BOX);
          FilterLfoEn->color((Fl_Color)237);
          FilterLfoEn->selection_color(FL_FOREGROUND_COLOR);
          FilterLfoEn->labeltype(FL_NORMAL_LABEL);
          FilterLfoEn->labelfont(1);
          FilterLfoEn->labelsize(10);
          FilterLfoEn->labelcolor(FL_FOREGROUND_COLOR);
          FilterLfoEn->callback((Fl_Callback*)cb_FilterLfoEn);
          FilterLfoEn->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
          FilterLfoEn->when(FL_WHEN_RELEASE);
          o->value(pars->VoicePar[nvoice].PFilterLfoEnabled);
        } // Fl_Check_Button2* FilterLfoEn
        if (pars->VoicePar[nvoice].PFilterEnabled==0) o->deactivate();
        voicefiltergroup->end();
      } // Fl_Group* voicefiltergroup
      { Fl_Box* o = new Fl_Box(5, 35, 64, 33);
        o->box(FL_THIN_UP_FRAME);
      } // Fl_Box* o
      { Fl_Group* o = new Fl_Group(69, 35, 136, 33);
        o->box(FL_THIN_UP_FRAME);
        { mwheel_slider_rev* o = Delay = new mwheel_slider_rev(76, 50, 124, 12, "Delay");
          Delay->tooltip("Time before the voice activates");
          Delay->type(5);
          Delay->box(FL_THIN_DOWN_BOX);
          Delay->color(FL_BACKGROUND_COLOR);
          Delay->selection_color(FL_BACKGROUND_COLOR);
          Delay->labeltype(FL_NORMAL_LABEL);
          Delay->labelfont(0);
          Delay->labelsize(11);
          Delay->labelcolor(FL_FOREGROUND_COLOR);
          Delay->maximum(127);
          Delay->step(1);
          Delay->callback((Fl_Callback*)cb_Delay);
          Delay->align(Fl_Align(FL_ALIGN_TOP));
          Delay->when(FL_WHEN_CHANGED);
          o->value(pars->VoicePar[nvoice].PDelay);
          o->setValueType(VC_ADDVoiceDelay);o->useCustomTip(true);
        } // mwheel_slider_rev* Delay
        o->end();
      } // Fl_Group* o
      { Fl_Check_Button2* o = bypassfiltercheckbutton = new Fl_Check_Button2(450, 41, 14, 14, "Bypass Global");
        bypassfiltercheckbutton->box(FL_NO_BOX);
        bypassfiltercheckbutton->down_box(FL_DOWN_BOX);
        bypassfiltercheckbutton->color(FL_BACKGROUND_COLOR);
        bypassfiltercheckbutton->selection_color(FL_FOREGROUND_COLOR);
        bypassfiltercheckbutton->labeltype(FL_NORMAL_LABEL);
        bypassfiltercheckbutton->labelfont(0);
        bypassfiltercheckbutton->labelsize(12);
        bypassfiltercheckbutton->labelcolor(FL_FOREGROUND_COLOR);
        bypassfiltercheckbutton->callback((Fl_Callback*)cb_bypassfiltercheckbutton);
        bypassfiltercheckbutton->align(Fl_Align(FL_ALIGN_RIGHT));
        bypassfiltercheckbutton->when(FL_WHEN_RELEASE);
        o->value(pars->VoicePar[nvoice].Pfilterbypass);
      } // Fl_Check_Button2* bypassfiltercheckbutton
      { Fl_Check_Button2* o = FilterEn = new Fl_Check_Button2(294, 41, 38, 14, "On");
        FilterEn->tooltip("Enable Filter");
        FilterEn->box(FL_THIN_UP_BOX);
        FilterEn->down_box(FL_DOWN_BOX);
        FilterEn->color((Fl_Color)237);
        FilterEn->selection_color(FL_FOREGROUND_COLOR);
        FilterEn->labeltype(FL_NORMAL_LABEL);
        FilterEn->labelfont(1);
        FilterEn->labelsize(10);
        FilterEn->labelcolor(FL_FOREGROUND_COLOR);
        FilterEn->callback((Fl_Callback*)cb_FilterEn);
        FilterEn->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
        FilterEn->when(FL_WHEN_RELEASE);
        o->value(pars->VoicePar[nvoice].PFilterEnabled);
      } // Fl_Check_Button2* FilterEn
      { extvoicegroup = new Fl_Group(5, 400, 80, 76, "Voice");
        extvoicegroup->box(FL_THIN_UP_FRAME);
        extvoicegroup->labelfont(1);
        extvoicegroup->labelsize(12);
        extvoicegroup->align(Fl_Align(FL_ALIGN_TOP|FL_ALIGN_INSIDE));
        { Fl_Choice* o = ExtOsc = new Fl_Choice(8, 430, 74, 18, "Source");
          ExtOsc->tooltip("Use an earlier voice as input to this voice. All parameters from the imported\
 voice remain in effect, except for volume, panning, base frequency and pitch \
bend scaling factor. The voice is also converted to mono. Parameters in the cu\
rrent voice will then tweak the signal further.");
          ExtOsc->down_box(FL_BORDER_BOX);
          ExtOsc->selection_color(FL_BACKGROUND_COLOR);
          ExtOsc->labelsize(10);
          ExtOsc->textfont(1);
          ExtOsc->textsize(10);
          ExtOsc->callback((Fl_Callback*)cb_ExtOsc);
          ExtOsc->align(Fl_Align(FL_ALIGN_TOP_LEFT));
          o->add("Local");
          char tmp[50]; for (int i = 0; i < nvoice; ++i) {sprintf(tmp, "Voice %2d", i + 1); o->add(tmp);};
          o->value(pars->VoicePar[nvoice].PVoice + 1);
          if (nvoice == 0) o->deactivate();
        } // Fl_Choice* ExtOsc
        { Fl_Choice* o = SoundType = new Fl_Choice(8, 454, 74, 18);
          SoundType->tooltip("Oscillator Type (sound/noise)");
          SoundType->down_box(FL_BORDER_BOX);
          SoundType->selection_color(FL_BACKGROUND_COLOR);
          SoundType->labelsize(10);
          SoundType->textfont(1);
          SoundType->textsize(10);
          SoundType->callback((Fl_Callback*)cb_SoundType);
          SoundType->when(FL_WHEN_RELEASE_ALWAYS);
          o->add("Sound");o->add("Whit Ns");o->add("Pink Ns");;o->add("Spot Ns");
          o->value(pars->VoicePar[nvoice].Type);
          if (pars->VoicePar[nvoice].Type!=0) voicemodegroup->deactivate();
          if (pars->VoicePar[nvoice].PVoice >= 0) o->deactivate();
        } // Fl_Choice* SoundType
        extvoicegroup->end();
      } // Fl_Group* extvoicegroup
      { noiselabel = new Fl_Box(130, 500, 400, 65, "Noise");
        noiselabel->labelfont(1);
        noiselabel->labelsize(50);
        noiselabel->labelcolor(FL_BACKGROUND2_COLOR);
        noiselabel->callback((Fl_Callback*)cb_noiselabel1);
        update_osclabels();
      } // Fl_Box* noiselabel
      if (pars->VoicePar[nvoice].Enabled==0) o->deactivate();
      voiceparametersgroup->end();
    } // Fl_Group* voiceparametersgroup
    { Fl_Check_Button2* o = voiceonbutton = new Fl_Check_Button2(12, 41, 50, 20, "On");
      voiceonbutton->box(FL_THIN_UP_BOX);
      voiceonbutton->down_box(FL_DOWN_BOX);
      voiceonbutton->color((Fl_Color)237);
      voiceonbutton->selection_color(FL_FOREGROUND_COLOR);
      voiceonbutton->labeltype(FL_NORMAL_LABEL);
      voiceonbutton->labelfont(1);
      voiceonbutton->labelsize(14);
      voiceonbutton->labelcolor(FL_FOREGROUND_COLOR);
      voiceonbutton->callback((Fl_Callback*)cb_voiceonbutton);
      voiceonbutton->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
      voiceonbutton->when(FL_WHEN_RELEASE);
      o->value(pars->VoicePar[nvoice].Enabled);
    } // Fl_Check_Button2* voiceonbutton
    { Vname = new Fl_Group(476, 10, 63, 16, "VOICE");
      Vname->labelfont(1);
      Vname->align(Fl_Align(FL_ALIGN_CENTER));
      Vname->end();
    } // Fl_Group* Vname
    o->copy_label(synth->getGuiMaster()->setPartWindowTitle("AddSynth Voice Oscillator").c_str());
    ADnoteVoiceParameters->end();
    ADnoteVoiceParameters->resizable(ADnoteVoiceParameters);
  } // Fl_Group* ADnoteVoiceParameters
  return ADnoteVoiceParameters;
}

ADvoiceUI::ADvoiceUI(int x,int y, int w, int h, const char *label):Fl_Group(x,y,w,h,label) {
  //
          nvoice = 0;
          pars = NULL;
          oscedit = NULL;
          lastWaveW = 0;
}

void ADvoiceUI::send_data(int action, int control, float value, int type) {
  //
      type |= TOPLEVEL::type::Write;
      collect_data(synth, value, action, type, control, npart, kititem, nvoice + PART::engine::addVoice1);
}

void ADvoiceUI::returns_update(CommandBlock *getData) {
  //
      float value = getData->data.value;
      unsigned char control = getData->data.control;
      unsigned char voice = getData->data.engine;
      //std::cout << "voice " << int(voice) << "   nvoice " << int(nvoice) << std::endl;
      if (voice >= PART::engine::addMod1)
          voice -= PART::engine::addMod1;
      else if (voice >= PART::engine::addVoice1)
          voice -= PART::engine::addVoice1;
      int tmp;
      bool val_bool = _SYS_::F2B(value);
      if (control != ADDVOICE::control::enableVoice &&  voice != nvoice)
          return;
  
      switch(control)
      {
          case ADDVOICE::control::volume:
              voicevolume->value(value);
              synth->getGuiMaster()->partui->adnoteui->voicelistitem[voice]->voicevolume->value(value);
              break;
  
          case ADDVOICE::control::velocitySense:
              voicevsns->value(value);
              break;
  
          case ADDVOICE::control::panning:
              voicepan->value(value);
              synth->getGuiMaster()->partui->adnoteui->voicelistitem[voice]->voicepanning->value(value);
              break;
  
          case ADDVOICE::control::enableRandomPan:
              voicerandompan->value(val_bool);
              if (val_bool)
                  voicewidth->activate();
              else
                  voicewidth->deactivate();
              break;
  
          case ADDVOICE::control::randomWidth:
              voicewidth->value(value);
              break;
  
          case ADDVOICE::control::invertPhase:
              VolumeMinus->value(val_bool);
              break;
  
          case ADDVOICE::control::enableAmplitudeEnvelope:
              AmpEnvEn->value(val_bool);
              if (val_bool == 0)
                      voiceampenvgroup->deactivate();
                  else
                      voiceampenvgroup->activate();
              break;
  
          case ADDVOICE::control::enableAmplitudeLFO:
              AmpLfoEn->value(val_bool);
              if (val_bool == 0)
                      voiceamplfogroup->deactivate();
                  else
                      voiceamplfogroup->activate();
              break;
  
          case ADDVOICE::control::modulatorType:
              ModType->value((int)value);
              synth->getGuiMaster()->partui->adnoteui->voicelistitem[voice]->update_modlabel();
              if (value == 0)
                      voiceFMparametersgroup->deactivate();
                  else
                      voiceFMparametersgroup->activate();
              break;
  
          case ADDVOICE::control::externalModulator:
              tmp = (int) value;
              ExtMod->value(tmp + 1);
              if (tmp >= 0)
              {
                  modoscil->deactivate();
              }
              else
              {
                  modoscil->activate();
              }
              voiceFMparametersgroup->redraw();
              update_fmoscil();
              oscFM->redraw();
              modoscil->redraw();
              modvoicelabel->do_callback();
              break;
  
          case ADDVOICE::control::detuneFrequency:
              if (voice == nvoice)
                  Detune->value(value);
              detunevalueoutput->do_callback();
              synth->getGuiMaster()->partui->adnoteui->voicelistitem[voice]->voicedetune->value(value);
              synth->getGuiMaster()->partui->adnoteui->voicelistitem[voice]->detunevalueoutput->do_callback();
              break;
  
          case ADDVOICE::control::equalTemperVariation:
              fixedfreqetdial->value(value);
              break;
  
          case ADDVOICE::control::baseFrequencyAs440Hz:
              Freq440->value(val_bool);
              if (value == 0 && Mod440->value() == 0)
                  fixedfreqetdial->deactivate();
              else
                  fixedfreqetdial->activate();
              break;
  
          case ADDVOICE::control::octave:
              Octave->value((int) value);
              break;
  
          case ADDVOICE::control::detuneType:
              FreqDetunetype->value((int) value);
              detunevalueoutput->do_callback();
              break;
  
          case ADDVOICE::control::coarseDetune:
              CoarseDetune->value((int) value);
              break;
  
          case ADDVOICE::control::pitchBendAdjustment:
              bend->value(value);
              break;
  
          case ADDVOICE::control::pitchBendOffset:
              offset->value(value);
              break;
  
          case ADDVOICE::control::enableFrequencyEnvelope:
              FreqEn->value(val_bool);
              if (val_bool == 0)
                  voicefreqenvgroup->deactivate();
              else
                  voicefreqenvgroup->activate();
              break;
  
          case ADDVOICE::control::enableFrequencyLFO:
              FreqLfoEn->value(val_bool);
               if (val_bool == 0)
                   voicefreqlfogroup->deactivate();
               else
                   voicefreqlfogroup->activate();
              break;
  
          case ADDVOICE::control::unisonFrequencySpread:
              UnisonFreqSpread->value(value);
              unisonspreadoutput->do_callback();
              break;
  
          case ADDVOICE::control::unisonPhaseRandomise:
              UnisonPhRnd->value(value);
              break;
  
          case ADDVOICE::control::unisonStereoSpread:
              UnisonStereo->value(value);
              break;
  
          case ADDVOICE::control::unisonVibratoDepth:
              UnisonVib->value(value);
              break;
  
          case ADDVOICE::control::unisonVibratoSpeed:
              UnisonVspeed->value(value);
              break;
  
          case ADDVOICE::control::unisonSize:
              {
                  tmp = int(value);
                  unisonsize->value(tmp);
                  int colr = FL_BLACK;
                  int i = 0;
                  while (pars->ADnote_unison_sizes[i] != 0)
                  {
                      if (pars->ADnote_unison_sizes[i] == tmp)
                      {
                          colr = FL_RED;
                          break;
                      }
                      ++ i;
                  }
                  unisonsize->labelcolor(colr);
                  unisongroup->redraw();
                  UnisonEn->redraw();
              }
              break;
  
          case ADDVOICE::control::unisonPhaseInvert:
              UnisonInvert->value(value);
              break;
  
          case ADDVOICE::control::enableUnison:
              UnisonEn->value(val_bool);
              if (val_bool == 0)
              {
                  unisonsize->value(2);
                  unisongroup->deactivate();
              }
              else
              {
                  unisongroup->activate();
                  int colr = FL_BLACK;
                  int i = -1;
                  while (true)
                  {
                      ++i;
                      if (pars->ADnote_unison_sizes[i] == 0)
                          break;
                      if (pars->ADnote_unison_sizes[i] == int(unisonsize->value()))
                      {
                          colr = FL_RED;
                          break;
                      }
                  }
                  unisonsize->labelcolor(colr);
                  unisongroup->redraw();
                   UnisonEn->redraw();
              }
              break;
  
          case ADDVOICE::control::enableFilter:
              FilterEn->value(val_bool);
              if (val_bool)
                    voicefiltergroup->activate();
                else
                    voicefiltergroup->deactivate();
                bypassfiltercheckbutton->redraw(); // yes it's needed!
              break;
  
          case ADDVOICE::control::bypassGlobalFilter:
              bypassfiltercheckbutton->value(val_bool);
              break;
          case ADDVOICE::control::enableFilterEnvelope:
              FilterEnvEn->value(val_bool);
              if (val_bool)
                  voicefilterenvgroup->activate();
              else
                  voicefilterenvgroup->deactivate();
              FilterEnvEn->redraw(); // yes it's needed!
              break;
  
          case ADDVOICE::control::enableFilterLFO:
              FilterLfoEn->value(val_bool);
              if (val_bool)
                  voicefilterlfogroup->activate();
              else
                  voicefilterlfogroup->deactivate();
              FilterLfoEn->redraw(); // yes it's needed!
              break;
  
          case ADDVOICE::control::modulatorAmplitude:
              ModVolume->value(value);
              break;
  
          case ADDVOICE::control::modulatorVelocitySense:
              ModVsense->value(value);
              break;
  
          case ADDVOICE::control::modulatorHFdamping:
              ModFdamp->value(value);
              break;
  
          case ADDVOICE::control::enableModulatorAmplitudeEnvelope:
              ModAmpEn->value(val_bool);
              if (val_bool)
                  voiceFMampenvgroup->activate();
              else
                  voiceFMampenvgroup->deactivate();
              break;
  
          case ADDVOICE::control::modulatorDetuneFrequency:
              ModDetune->value(value);
              fmdetunevalueoutput->do_callback();
              break;
  
          case ADDVOICE::control::modulatorDetuneFromBaseOsc:
              detuneFromBaseOsc->value(value);
              break;
  
  
          case ADDVOICE::control::modulatorFrequencyAs440Hz:
              tmp = (val_bool);
              Mod440->value(tmp);
              if (tmp == 0 && lrint(Freq440->value() == 0))
                  fixedfreqetdial->deactivate();
              else
                  fixedfreqetdial->activate();
              if (tmp != 0)
                  detuneFromBaseOsc->deactivate();
              else
                  detuneFromBaseOsc->activate();
              break;
          case ADDVOICE::control::modulatorOctave:
              ModOctave->value((int) value);
              break;
  
          case ADDVOICE::control::modulatorDetuneType:
              ModDetuneType->value((int) value);
              fmdetunevalueoutput->do_callback();
              break;
  
          case ADDVOICE::control::modulatorCoarseDetune:
              ModCoarseDetune->value((int) value);
              break;
  
          case ADDVOICE::control::enableModulatorFrequencyEnvelope:
              ModFreqEn->value(val_bool);
              if (val_bool == 0)
                  voiceFMfreqenvgroup->deactivate();
              else
                  voiceFMfreqenvgroup->activate();
              break;
  
          case ADDVOICE::control::modulatorOscillatorPhase:
              ModPhase->value(value);
              oscFM->phase = 64 - lrint(value);
              update_fmoscil();
              oscFM->redraw();
              modoscil->redraw();
              modvoicelabel->do_callback();
              break;
  
          case ADDVOICE::control::modulatorOscillatorSource:
              tmp = int(value);
              ExtModOsc->value(tmp + 1);
              if (tmp < 0)
              {
                  tmp = voice;
                  changeFMoscilbutton->labelcolor(FL_BLACK);
              }
              else
                  changeFMoscilbutton->labelcolor(FL_BLUE);
              update_fmoscil();
              voiceFMparametersgroup->redraw();
              oscFM->redraw();
              modoscil->redraw();
              modvoicelabel->do_callback();
              break;
  
          case ADDVOICE::control::delay:
              Delay->value(value);
              break;
  
          case ADDVOICE::control::enableVoice:
              tmp = (val_bool);
              voiceonbutton->value(tmp);
              synth->getGuiMaster()->partui->adnoteui->voicelistitem[voice]->voiceenabled->value(tmp);
              synth->getGuiMaster()->partui->adnoteui->setVoiceTabs(voice, false);
              synth->getGuiMaster()->partui->adnoteui->setTabColour(voice);
              if (tmp)
              {
                  nvoice = voice;
                  voiceparametersgroup->activate();
                  synth->getGuiMaster()->partui->adnoteui->voicelistitem[voice]->voicelistitemgroup->activate();
              }
              else
              {
                  voiceparametersgroup->deactivate();
                  synth->getGuiMaster()->partui->adnoteui->voicelistitem[voice]->voicelistitemgroup->deactivate();
              }
              voiceonbutton->redraw();
              synth->getGuiMaster()->partui->adnoteui->voiceTabBar->redraw();
              break;
  
          case ADDVOICE::control::enableResonance:
              tmp = (val_bool);
              if (voice == nvoice)
                  ResonanceEn->value(tmp);
              synth->getGuiMaster()->partui->adnoteui->voicelistitem[voice]->voiceresonanceenabled->value(tmp);
              break;
  
          case ADDVOICE::control::voiceOscillatorPhase:
              tmp = (int)value;
              VoiceOscPhase->value(tmp);
              osc->phase = 64 - tmp;
              update_voiceoscil();
              voiceoscil->redraw();
              osclabel->redraw();
              break;
  
          case ADDVOICE::control::voiceOscillatorSource:
              tmp = int(value);
              UseOsc->value(tmp + 1);
              if (tmp < 0)
              {
                  tmp = voice;
                  changevoiceoscilbutton->labelcolor(FL_BLACK);
              }
              else
                  changevoiceoscilbutton->labelcolor(FL_BLUE);
              changevoiceoscilbutton->redraw();
              update_voiceoscil();
              voiceoscil->redraw();
              update_osclabels();
              break;
  
          case ADDVOICE::control::soundType:
              tmp = lrint(value);
              SoundType->value(tmp);
              if (tmp)
                  voicemodegroup->deactivate();
              else
                  voicemodegroup->activate();
              update_osclabels();
              break;
  
          case ADDVOICE::control::externalOscillator:
              tmp = int(value);
              ExtOsc->value(tmp + 1);
              update_voiceoscil();
              voiceoscil->redraw();
              update_osclabels();
              break;
      }
}

void ADvoiceUI::update_osclabels() {
  //
      if (pars->VoicePar[nvoice].PVoice >= 0)
  {
      char str[15];
      snprintf(str, sizeof(str), "Voice %d", pars->VoicePar[nvoice].PVoice + 1);
      osclabel->copy_label(str);
      osclabel->labelcolor(EXTVOICE_COLOUR);
      osclabel->show();
      noiselabel->hide();
  }
  else if (pars->VoicePar[nvoice].Type == 0 && pars->VoicePar[nvoice].Pextoscil >= 0)
  {
      char str[15];
      snprintf(str, sizeof(str), "Osc. %d", pars->VoicePar[nvoice].Pextoscil + 1);
      osclabel->copy_label(str);
      osclabel->labelcolor(EXTOSC_COLOUR);
      osclabel->show();
      noiselabel->hide();
  }
  else if (pars->VoicePar[nvoice].Type == 1)
  {
      noiselabel->copy_label("White Noise");
      noiselabel->labelcolor(7);
      noiselabel->show();
      osclabel->hide();
  }
  else if (pars->VoicePar[nvoice].Type == 2)
  {
      noiselabel->copy_label("Pink Noise");
      noiselabel->labelcolor(5);
      noiselabel->show();
      osclabel->hide();
  }
  else if (pars->VoicePar[nvoice].Type == 3)
  {
      noiselabel->copy_label("Spot Noise");
      noiselabel->labelcolor(6);
      noiselabel->show();
      osclabel->hide();
  }
  else
  {
      noiselabel->hide();
      osclabel->hide();
  }
}

void ADvoiceUI::update_modvoicelabel() {
  if (pars->VoicePar[nvoice].PFMVoice >= 0)
  {
      char str[15];
      snprintf(str, sizeof(str), "Voice %d", pars->VoicePar[nvoice].PFMVoice + 1);
      modvoicelabel->copy_label(str);
      modvoicelabel->labelcolor(EXTVOICE_COLOUR);
      modvoicelabel->show();
  }
  else if (pars->VoicePar[nvoice].PextFMoscil >= 0)
  {
      char str[15];
      snprintf(str, sizeof(str), "Mod. %d", pars->VoicePar[nvoice].PextFMoscil + 1);
      modvoicelabel->copy_label(str);
      modvoicelabel->labelcolor(EXTOSC_COLOUR);
      modvoicelabel->show();
  }
  else
  {
      modvoicelabel->hide();
  }
}

void ADvoiceUI::update_voiceoscil() {
  int nvs = nvoice, nvp = nvoice;
  if (pars->VoicePar[nvoice].PVoice != -1)
      while (pars->VoicePar[nvs].PVoice != -1)
          nvp = nvs = pars->VoicePar[nvs].PVoice;
  else if (pars->VoicePar[nvoice].Pextoscil != -1)
      nvs = pars->VoicePar[nvoice].Pextoscil;
  oscil->changeParams(pars->VoicePar[nvs].POscil);
  osc->init(oscil,0,pars->VoicePar[nvp].Poscilphase, synth);
}

void ADvoiceUI::update_fmoscil() {
  int nv=nvoice;
  if (pars->VoicePar[nvoice].PFMVoice >= 0) {
      nv = pars->VoicePar[nvoice].PFMVoice;
      while (pars->VoicePar[nv].PVoice >= 0) {
          nv = pars->VoicePar[nv].PVoice;
      }
      oscilFM->changeParams(pars->VoicePar[nv].POscil);
      oscFM->init(oscilFM,0,pars->VoicePar[nv].Poscilphase, synth);
  } else {
      if (pars->VoicePar[nvoice].PextFMoscil >= 0) {
          nv = pars->VoicePar[nvoice].PextFMoscil;
      }
      oscilFM->changeParams(pars->VoicePar[nv].POscilFM);
      oscFM->init(oscilFM,0,pars->VoicePar[nvoice].PFMoscilphase, synth);
  }
}

void ADvoiceUI::voiceRtext(float dScale) {
  //
     if (oscedit)
     {
         if (oscedit->osceditUI->visible() && lastWaveW != oscedit->osceditUI->w())
         {
             lastWaveW = oscedit->osceditUI->w();
             oscedit->waveRtext();
         }
     }
     voiceampenvgroup->wincheck();
     voicefilterenvgroup->wincheck();
     voicefreqenvgroup->wincheck();
  
     voiceFMampenvgroup->wincheck();
     voiceFMfreqenvgroup->wincheck();
  
     if (!ADnoteVoiceParameters->visible())
         return;
  
     if (dScale == lastdScale)
         return;
  
     voiceamplfogroup->lfoRtext(dScale);
     voiceampenvgroup->envRtext(dScale);
  
     voicefilterlfogroup->lfoRtext(dScale);
     voicefilterenvgroup->envRtext(dScale);
  
     voicefreqlfogroup->lfoRtext(dScale);
     voicefreqenvgroup->envRtext(dScale);
  
     voicefilter->filterRtext(dScale);
  
     lastdScale = dScale;
  
     int size = int(10 * dScale);
     int size11 = int(11 * dScale);
     int size12 = int(12 * dScale);
     int size14 = int(14 * dScale);
  
     voiceonbutton->labelsize(size14);
     Vname->labelsize(size14);
  
     ResonanceEn->labelsize(size11);
     amplitudegroup->labelsize(size12);
     voicevolume->labelsize(size);
     voicevsns->labelsize(size);
     voicepan->labelsize(size);
     voicewidth->labelsize(size);
     voicerandompan->labelsize(size11);
     AmpEnvEn->labelsize(size);
     AmpLfoEn->labelsize(size);
     VolumeMinus->labelsize(size);
  
     voicefiltergroup->labelsize(size12);
     FilterEnvEn->labelsize(size);
     FilterLfoEn->labelsize(size);
  
     Delay->labelsize(size11);
     bypassfiltercheckbutton->labelsize(size12);
     FilterEn->labelsize(size);
  
     freqencygrp->labelsize(size12);
     FreqEn->labelsize(size);
     FreqLfoEn->labelsize(size);
     Octave->labelsize(size);
     	Octave->textsize(size11);
     CoarseDetune->labelsize(size);
         CoarseDetune->textsize(size11);
     detunevalueoutput->labelsize(size);
     	detunevalueoutput->textsize(size);
     FreqDetunetype->labelsize(size);
         FreqDetunetype->textsize(size11);
     bend->labelsize(size);
     Freq440->labelsize(size11);
     fixedfreqetdial->labelsize(size);
     offset->labelsize(size);
  
     unisonsize->labelsize(size);
          unisonsize->textsize(size11);
     UnisonStereo->labelsize(size);
     UnisonVib->labelsize(size);
     UnisonFreqSpread->labelsize(size);
     unisonspreadoutput->labelsize(size);
          unisonspreadoutput->textsize(size11);
     UnisonVspeed->labelsize(size);
     UnisonPhRnd->labelsize(size);
     UnisonInvert->labelsize(size);
         UnisonInvert->textsize(size11);
     UnisonEn->labelsize(size);
     unisName->labelsize(size12);
  
     extvoicegroup->labelsize(size12);
     ExtOsc->labelsize(size);
         ExtOsc->textsize(size);
     SoundType->labelsize(size);
         SoundType->textsize(size);
  
     oscParamBox->labelsize(size12);
     UseOsc->labelsize(size);
         UseOsc->textsize(size);
     changevoiceoscilbutton->labelsize(size);
     VoiceOscPhase->labelsize(size);
  
     noiselabel->labelsize(int(50 * dScale));
     osclabel->labelsize(int(50 * dScale));
  
     voiceFMparametersgroup->labelsize(size12);
     voiceFMampenvgroup->envRtext(dScale);
     voiceFMfreqenvgroup->envRtext(dScale);
  
     ExtMod->labelsize(size11);
         ExtMod->textsize(size14);
  
     Modampgrp->labelsize(size11);
     ModVolume->labelsize(size11);
         ModVolume->textsize(size);
     ModVsense->labelsize(size11);
         ModVsense->textsize(size);
     ModFdamp->labelsize(size11);
         ModFdamp->textsize(size);
     ModAmpEn->labelsize(size);
  
     modfrequency->labelsize(size11);
     ModCoarseDetune->labelsize(size);
         ModCoarseDetune->textsize(size);
     ModOctave->labelsize(size);
         ModOctave->textsize(size);
     fmdetunevalueoutput->labelsize(size);
         fmdetunevalueoutput->textsize(size);
     detuneFromBaseOsc->labelsize(size11);
     Mod440->labelsize(size11);
     ModDetuneType->labelsize(size);
         ModDetuneType->textsize(size11);
  
     ModFreqEn->labelsize(size);
  
     ModType->labelsize(size11);
         ModType->textsize(size14);
  
    ModLocalOsc->labelsize(size12);
    changeFMoscilbutton->labelsize(size);
    ModPhase->labelsize(size);
    ExtModOsc->labelsize(size);
        ExtModOsc->textsize(size);
  
    modvoicelabel->labelsize(int(40 * dScale));
}

void ADvoiceUI::init(ADnoteParameters *parameters,int npart_, int kititem_, int nvoice_) {
  //
          synth = parameters->getSynthEngine();
          pars = parameters;
          npart = npart_;
          kititem = kititem_;
          nvoice = nvoice_;
          lastdScale = 0;
          fft = new fft::Calc(synth->oscilsize);
          oscil = new OscilGen(*fft, NULL, synth, parameters->VoicePar[nvoice].POscil);
          oscilFM = new OscilGen(*fft, NULL, synth, parameters->VoicePar[nvoice].POscilFM);
          make_window();
          end();
          if (nvoice == 0)
          {
              UseOsc->deactivate();
              ExtMod->deactivate();
              ExtModOsc->deactivate();
          }
  
          ADnoteVoiceParameters->show();
}

ADvoiceUI::~ADvoiceUI() {
  //
          ADnoteVoiceParameters->hide();
          hide();
          if (oscedit)
              delete oscedit;
          delete oscil;
          delete oscilFM;
          delete fft;
}

void ADnoteUI::cb_ADnoteGlobalParameters_i(Fl_Double_Window* o, void*) {
  //
    saveWin(synth,  ADnoteGlobalParameters->w(),  ADnoteGlobalParameters->h(), ADnoteGlobalParameters->x(), ADnoteGlobalParameters->y(), false, "AddSynth");
    globalSeen = false;
    resui->resonancewindow->hide();
    o->hide();
}
void ADnoteUI::cb_ADnoteGlobalParameters(Fl_Double_Window* o, void* v) {
  ((ADnoteUI*)(o->user_data()))->cb_ADnoteGlobalParameters_i(o,v);
}

void ADnoteUI::cb_octave_i(Fl_Counter* o, void*) {
  //
    send_data(0, ADDSYNTH::control::octave, o->value(), TOPLEVEL::type::Integer);
}
void ADnoteUI::cb_octave(Fl_Counter* o, void* v) {
  ((ADnoteUI*)(o->parent()->parent()->user_data()))->cb_octave_i(o,v);
}

void ADnoteUI::cb_coarsedet_i(Fl_Counter* o, void*) {
  //
    send_data(0, ADDSYNTH::control::coarseDetune, o->value(), TOPLEVEL::type::Integer);
}
void ADnoteUI::cb_coarsedet(Fl_Counter* o, void* v) {
  ((ADnoteUI*)(o->parent()->parent()->user_data()))->cb_coarsedet_i(o,v);
}

void ADnoteUI::cb_freq_i(mwheel_slider_rev* o, void*) {
  //
            detunevalueoutput->do_callback();
            send_data(0, ADDSYNTH::control::detuneFrequency, o->value(), TOPLEVEL::type::Integer);
}
void ADnoteUI::cb_freq(mwheel_slider_rev* o, void* v) {
  ((ADnoteUI*)(o->parent()->parent()->user_data()))->cb_freq_i(o,v);
}

void ADnoteUI::cb_detunevalueoutput2_i(Fl_Value_Output* o, void*) {
  o->value(getDetune(pars->GlobalPar.PDetuneType,0,pars->GlobalPar.PDetune));
}
void ADnoteUI::cb_detunevalueoutput2(Fl_Value_Output* o, void* v) {
  ((ADnoteUI*)(o->parent()->parent()->user_data()))->cb_detunevalueoutput2_i(o,v);
}

void ADnoteUI::cb_detunetype_i(Fl_Choice* o, void*) {
  //
    send_data(0, ADDSYNTH::control::detuneType, o->value() + 1, TOPLEVEL::type::Integer);
}
void ADnoteUI::cb_detunetype(Fl_Choice* o, void* v) {
  ((ADnoteUI*)(o->parent()->parent()->user_data()))->cb_detunetype_i(o,v);
}

void ADnoteUI::cb_relBwidth_i(WidgetPDial* o, void*) {
  //
    send_data(0, ADDSYNTH::control::relativeBandwidth, o->value(), TOPLEVEL::type::Integer);
}
void ADnoteUI::cb_relBwidth(WidgetPDial* o, void* v) {
  ((ADnoteUI*)(o->parent()->parent()->user_data()))->cb_relBwidth_i(o,v);
}

void ADnoteUI::cb_globalvolume_i(WidgetPDial* o, void*) {
  //
send_data(0, ADDSYNTH::control::volume, o->value(), TOPLEVEL::type::Integer);
}
void ADnoteUI::cb_globalvolume(WidgetPDial* o, void* v) {
  ((ADnoteUI*)(o->parent()->parent()->user_data()))->cb_globalvolume_i(o,v);
}

void ADnoteUI::cb_vsns_i(WidgetPDial* o, void*) {
  send_data(0, ADDSYNTH::control::velocitySense, o->value(), TOPLEVEL::type::Integer);
}
void ADnoteUI::cb_vsns(WidgetPDial* o, void* v) {
  ((ADnoteUI*)(o->parent()->parent()->user_data()))->cb_vsns_i(o,v);
}

void ADnoteUI::cb_globalpan_i(WidgetPDial* o, void*) {
  //
    send_data(0, ADDSYNTH::control::panning, o->value(), TOPLEVEL::type::Integer);
}
void ADnoteUI::cb_globalpan(WidgetPDial* o, void* v) {
  ((ADnoteUI*)(o->parent()->parent()->user_data()))->cb_globalpan_i(o,v);
}

void ADnoteUI::cb_globalwidth_i(WidgetPDial* o, void*) {
  //
    send_data(0, ADDSYNTH::control::randomWidth, o->value(), TOPLEVEL::type::Integer);
}
void ADnoteUI::cb_globalwidth(WidgetPDial* o, void* v) {
  ((ADnoteUI*)(o->parent()->parent()->user_data()))->cb_globalwidth_i(o,v);
}

void ADnoteUI::cb_globalrandompan_i(Fl_Check_Button2* o, void*) {
  //
        int tmp = o->value();
        if (tmp == 0)
            globalwidth->deactivate();
        else
            globalwidth->activate();
        send_data(0, ADDSYNTH::control::enableRandomPan, tmp, TOPLEVEL::type::Integer);
}
void ADnoteUI::cb_globalrandompan(Fl_Check_Button2* o, void* v) {
  ((ADnoteUI*)(o->parent()->parent()->user_data()))->cb_globalrandompan_i(o,v);
}

void ADnoteUI::cb_depop_i(WidgetPDial* o, void*) {
  //
send_data(0, ADDSYNTH::control::dePop, o->value(), TOPLEVEL::type::Integer);
}
void ADnoteUI::cb_depop(WidgetPDial* o, void* v) {
  ((ADnoteUI*)(o->parent()->parent()->user_data()))->cb_depop_i(o,v);
}

void ADnoteUI::cb_pstr_i(WidgetPDial* o, void*) {
  //
send_data(0, ADDSYNTH::control::punchStrength, o->value(), TOPLEVEL::type::Integer);
}
void ADnoteUI::cb_pstr(WidgetPDial* o, void* v) {
  ((ADnoteUI*)(o->parent()->parent()->user_data()))->cb_pstr_i(o,v);
}

void ADnoteUI::cb_pt_i(WidgetPDial* o, void*) {
  //
send_data(0, ADDSYNTH::control::punchDuration, o->value(), TOPLEVEL::type::Integer);
}
void ADnoteUI::cb_pt(WidgetPDial* o, void* v) {
  ((ADnoteUI*)(o->parent()->parent()->user_data()))->cb_pt_i(o,v);
}

void ADnoteUI::cb_pstc_i(WidgetPDial* o, void*) {
  //
send_data(0, ADDSYNTH::control::punchStretch, o->value(), TOPLEVEL::type::Integer);
}
void ADnoteUI::cb_pstc(WidgetPDial* o, void* v) {
  ((ADnoteUI*)(o->parent()->parent()->user_data()))->cb_pstc_i(o,v);
}

void ADnoteUI::cb_pvel_i(WidgetPDial* o, void*) {
  //
send_data(0, ADDSYNTH::control::punchVelocity, o->value(), TOPLEVEL::type::Integer);
}
void ADnoteUI::cb_pvel(WidgetPDial* o, void* v) {
  ((ADnoteUI*)(o->parent()->parent()->user_data()))->cb_pvel_i(o,v);
}

void ADnoteUI::cb_rndgrp_i(Fl_Check_Button2* o, void*) {
  pars->GlobalPar.Hrandgrouping = lrint(o->value());
send_data(0, ADDSYNTH::control::randomGroup, o->value(), TOPLEVEL::type::Integer);
}
void ADnoteUI::cb_rndgrp(Fl_Check_Button2* o, void* v) {
  ((ADnoteUI*)(o->parent()->parent()->user_data()))->cb_rndgrp_i(o,v);
}

void ADnoteUI::cb_stereo_i(Fl_Check_Button2* o, void*) {
  //
send_data(0, ADDSYNTH::control::stereo, o->value(), TOPLEVEL::type::Integer);
}
void ADnoteUI::cb_stereo(Fl_Check_Button2* o, void* v) {
  ((ADnoteUI*)(o->parent()->user_data()))->cb_stereo_i(o,v);
}

void ADnoteUI::cb_showvoicelist_i(Fl_Button*, void*) {
  //
            for (int i = 0; i < NUM_VOICES; ++i)
                voicelistitem[i]->refreshlist();
            int fetchW, fetchH, fetchX, fetchY, fetchO;
            loadWin(synth, fetchW, fetchH, fetchX, fetchY, fetchO, "AddSynth-list");

            if (fetchW < listDW || fetchH < listDH)
            {
                fetchW = listDW;
                fetchH = listDH;
            }
            checkSane(fetchX, fetchY,fetchW, fetchH, listDW, listDH);
            ADnoteVoiceList->resize(fetchX, fetchY,fetchW, fetchH);
            lastlistW = 0;
            ADnoteVoiceList->show();
            listSeen = true;


            if (Fl::event_button() == 3)
                ADnoteGlobalParameters->hide();
}
void ADnoteUI::cb_showvoicelist(Fl_Button* o, void* v) {
  ((ADnoteUI*)(o->parent()->user_data()))->cb_showvoicelist_i(o,v);
}

void ADnoteUI::cb_showvoicepars_i(Fl_Button*, void*) {
  //
    set_voice(false);
    if ((Fl::event_button() == 3))
        ADnoteGlobalParameters->hide();
}
void ADnoteUI::cb_showvoicepars(Fl_Button* o, void* v) {
  ((ADnoteUI*)(o->parent()->user_data()))->cb_showvoicepars_i(o,v);
}

void ADnoteUI::cb_globalclose_i(Fl_Button*, void*) {
  //
            saveWin(synth,  ADnoteGlobalParameters->w(),  ADnoteGlobalParameters->h(), ADnoteGlobalParameters->x(), ADnoteGlobalParameters->y(), false, "AddSynth");
            globalSeen = false;
            resui->resonancewindow->hide();
            ADnoteGlobalParameters->hide();
            if (Fl::event_button() == 3)
            {
                if (synth->getGuiMaster()->partui->partKitOn)
                    synth->getGuiMaster()->partui->instrumentkitlist->show();
                else
                    synth->getGuiMaster()->partui->instrumenteditwindow->show();
            };
}
void ADnoteUI::cb_globalclose(Fl_Button* o, void* v) {
  ((ADnoteUI*)(o->parent()->user_data()))->cb_globalclose_i(o,v);
}

void ADnoteUI::cb_resonance_i(Fl_Button*, void*) {
  //
    resui->resonancewindow->redraw();
    resui->Show();
    if ((Fl::event_button() == 3))
        ADnoteGlobalParameters->hide();
}
void ADnoteUI::cb_resonance(Fl_Button* o, void* v) {
  ((ADnoteUI*)(o->parent()->user_data()))->cb_resonance_i(o,v);
}

void ADnoteUI::cb_globalcopy_i(Fl_Button*, void*) {
  synth->getGuiMaster()->getPresetsUi()->copy(pars);
}
void ADnoteUI::cb_globalcopy(Fl_Button* o, void* v) {
  ((ADnoteUI*)(o->parent()->user_data()))->cb_globalcopy_i(o,v);
}

void ADnoteUI::cb_globalpaste_i(Fl_Button*, void*) {
  synth->getGuiMaster()->getPresetsUi()->paste(pars,this);
}
void ADnoteUI::cb_globalpaste(Fl_Button* o, void* v) {
  ((ADnoteUI*)(o->parent()->user_data()))->cb_globalpaste_i(o,v);
}

void ADnoteUI::cb_ADnoteVoice_i(Fl_Double_Window* o, void*) {
  saveWin(synth, o->w(), o->h(), o->x(), o->y(), false,"AddSynth-voice");
o->hide();
}
void ADnoteUI::cb_ADnoteVoice(Fl_Double_Window* o, void* v) {
  ((ADnoteUI*)(o->user_data()))->cb_ADnoteVoice_i(o,v);
}

void ADnoteUI::cb_Vclose_i(Fl_Button*, void*) {
  //
            ADnoteVoice->hide();
            saveWin(synth, ADnoteVoice->w(), ADnoteVoice->h(), ADnoteVoice->x(), ADnoteVoice->y(), false, "AddSynth-voice");
            voiceSeen = false;
            if (Fl::event_button() == 3)
            {
                if (fromVoiceList)
                    ADnoteVoiceList->show();
                else
                    ShowGlobal();
            };
}
void ADnoteUI::cb_Vclose(Fl_Button* o, void* v) {
  ((ADnoteUI*)(o->parent()->user_data()))->cb_Vclose_i(o,v);
}

void ADnoteUI::cb_Vcopy_i(Fl_Button*, void*) {
  synth->getGuiMaster()->getPresetsUi()->copy(pars,nvoice);
}
void ADnoteUI::cb_Vcopy(Fl_Button* o, void* v) {
  ((ADnoteUI*)(o->parent()->user_data()))->cb_Vcopy_i(o,v);
}

void ADnoteUI::cb_Vpaste_i(Fl_Button*, void*) {
  synth->getGuiMaster()->getPresetsUi()->paste(pars,this,nvoice);
}
void ADnoteUI::cb_Vpaste(Fl_Button* o, void* v) {
  ((ADnoteUI*)(o->parent()->user_data()))->cb_Vpaste_i(o,v);
}

void ADnoteUI::cb_g1_i(Fl_Button* o, void*) {
  setVoiceTabs(0, !o->value());
}
void ADnoteUI::cb_g1(Fl_Button* o, void* v) {
  ((ADnoteUI*)(o->parent()->user_data()))->cb_g1_i(o,v);
}

void ADnoteUI::cb_g2_i(Fl_Button* o, void*) {
  setVoiceTabs(1, !o->value());
}
void ADnoteUI::cb_g2(Fl_Button* o, void* v) {
  ((ADnoteUI*)(o->parent()->user_data()))->cb_g2_i(o,v);
}

void ADnoteUI::cb_g3_i(Fl_Button* o, void*) {
  setVoiceTabs(2, !o->value());
}
void ADnoteUI::cb_g3(Fl_Button* o, void* v) {
  ((ADnoteUI*)(o->parent()->user_data()))->cb_g3_i(o,v);
}

void ADnoteUI::cb_g4_i(Fl_Button* o, void*) {
  setVoiceTabs(3, !o->value());
}
void ADnoteUI::cb_g4(Fl_Button* o, void* v) {
  ((ADnoteUI*)(o->parent()->user_data()))->cb_g4_i(o,v);
}

void ADnoteUI::cb_g5_i(Fl_Button* o, void*) {
  setVoiceTabs(4, !o->value());
}
void ADnoteUI::cb_g5(Fl_Button* o, void* v) {
  ((ADnoteUI*)(o->parent()->user_data()))->cb_g5_i(o,v);
}

void ADnoteUI::cb_g6_i(Fl_Button* o, void*) {
  setVoiceTabs(5, !o->value());
}
void ADnoteUI::cb_g6(Fl_Button* o, void* v) {
  ((ADnoteUI*)(o->parent()->user_data()))->cb_g6_i(o,v);
}

void ADnoteUI::cb_g7_i(Fl_Button* o, void*) {
  setVoiceTabs(6, !o->value());
}
void ADnoteUI::cb_g7(Fl_Button* o, void* v) {
  ((ADnoteUI*)(o->parent()->user_data()))->cb_g7_i(o,v);
}

void ADnoteUI::cb_g8_i(Fl_Button* o, void*) {
  setVoiceTabs(7, !o->value());
}
void ADnoteUI::cb_g8(Fl_Button* o, void* v) {
  ((ADnoteUI*)(o->parent()->user_data()))->cb_g8_i(o,v);
}

void ADnoteUI::cb_ADnoteVoiceList_i(Fl_Double_Window* o, void*) {
  if (listSeen)
    saveWin(synth, o->w(), o->h(), o->x(), o->y(), false,"AddSynth-list");
listSeen = false;
o->hide();
}
void ADnoteUI::cb_ADnoteVoiceList(Fl_Double_Window* o, void* v) {
  ((ADnoteUI*)(o->user_data()))->cb_ADnoteVoiceList_i(o,v);
}

void ADnoteUI::cb_listClose_i(Fl_Button*, void*) {
  //
            ADnoteVoiceList->hide();
            listSeen = false;
            saveWin(synth, ADnoteVoiceList->w(), ADnoteVoiceList->h(), ADnoteVoiceList->x(), ADnoteVoiceList->y(), false, "AddSynth-list");

            if (Fl::event_button() == 3)
                ShowGlobal();
}
void ADnoteUI::cb_listClose(Fl_Button* o, void* v) {
  ((ADnoteUI*)(o->parent()->user_data()))->cb_listClose_i(o,v);
}

Fl_Double_Window* ADnoteUI::make_window() {
// globalrandompan MUST be after globalwidth
  { Fl_Double_Window* o = ADnoteGlobalParameters = new Fl_Double_Window(575, 405, "ADsynth Global Parameters of the Instrument");
    ADnoteGlobalParameters->callback((Fl_Callback*)cb_ADnoteGlobalParameters, (void*)(this));
    { globalfreq = new Fl_Group(5, 255, 570, 115, "FREQUENCY");
      globalfreq->box(FL_THIN_UP_BOX);
      globalfreq->labelfont(1);
      globalfreq->labelsize(12);
      globalfreq->align(Fl_Align(FL_ALIGN_TOP|FL_ALIGN_INSIDE));
      { EnvelopeUI* o = freqenv = new EnvelopeUI(10, 295, 205, 70, "ADSynth Global - Frequency Envelope");
        freqenv->box(FL_FLAT_BOX);
        freqenv->color((Fl_Color)51);
        freqenv->selection_color(FL_BACKGROUND_COLOR);
        freqenv->labeltype(FL_NORMAL_LABEL);
        freqenv->labelfont(0);
        freqenv->labelsize(12);
        freqenv->labelcolor(FL_FOREGROUND_COLOR);
        freqenv->align(Fl_Align(FL_ALIGN_WRAP|FL_ALIGN_INSIDE));
        freqenv->when(FL_WHEN_RELEASE);
        o->init(pars->GlobalPar.FreqEnvelope, npart, kititem, 0, 1);
        freqenv->end();
      } // EnvelopeUI* freqenv
      { Fl_Counter* o = octave = new Fl_Counter(495, 275, 45, 15, "Octave");
        octave->tooltip("Octave");
        octave->type(1);
        octave->color((Fl_Color)237);
        octave->selection_color(FL_FOREGROUND_COLOR);
        octave->labelsize(10);
        octave->minimum(-8);
        octave->maximum(7);
        octave->step(1);
        octave->textfont(1);
        octave->textsize(11);
        octave->callback((Fl_Callback*)cb_octave);
        octave->align(Fl_Align(FL_ALIGN_TOP));
        int k = pars->GlobalPar.PCoarseDetune / 1024; if (k >= 8) k -= 16;
        o->value(k);
      } // Fl_Counter* octave
      { Fl_Counter* o = coarsedet = new Fl_Counter(500, 345, 60, 20, "Coarse det.");
        coarsedet->tooltip("Coarse Detune");
        coarsedet->labelsize(10);
        coarsedet->minimum(-64);
        coarsedet->maximum(63);
        coarsedet->step(1);
        coarsedet->textfont(1);
        coarsedet->textsize(11);
        coarsedet->callback((Fl_Callback*)cb_coarsedet);
        coarsedet->align(Fl_Align(FL_ALIGN_TOP_LEFT));
        int k = pars->GlobalPar.PCoarseDetune % 1024; if (k >= 512) k -= 1024;
        o->value(k);
        o->lstep(10);
      } // Fl_Counter* coarsedet
      { LFOUI* o = freqlfo = new LFOUI(215, 295, 275, 70, "Frequency LFO");
        freqlfo->box(FL_FLAT_BOX);
        freqlfo->color(FL_DARK1);
        freqlfo->selection_color(FL_BACKGROUND_COLOR);
        freqlfo->labeltype(FL_NORMAL_LABEL);
        freqlfo->labelfont(0);
        freqlfo->labelsize(12);
        freqlfo->labelcolor(FL_FOREGROUND_COLOR);
        freqlfo->align(Fl_Align(FL_ALIGN_WRAP|FL_ALIGN_INSIDE));
        freqlfo->when(FL_WHEN_RELEASE);
        o->init(pars->GlobalPar.FreqLfo, npart, kititem, 0, 1);
        freqlfo->end();
      } // LFOUI* freqlfo
      { mwheel_slider_rev* o = freq = new mwheel_slider_rev(57, 275, 433, 15);
        freq->tooltip("Fine Detune (cents)");
        freq->type(5);
        freq->box(FL_THIN_DOWN_BOX);
        freq->color(FL_BACKGROUND_COLOR);
        freq->selection_color(FL_BACKGROUND_COLOR);
        freq->labeltype(FL_NORMAL_LABEL);
        freq->labelfont(0);
        freq->labelsize(14);
        freq->labelcolor(FL_FOREGROUND_COLOR);
        freq->minimum(-8192);
        freq->maximum(8191);
        freq->step(1);
        freq->callback((Fl_Callback*)cb_freq);
        freq->align(Fl_Align(FL_ALIGN_BOTTOM));
        freq->when(FL_WHEN_CHANGED);
        o->value(pars->GlobalPar.PDetune - 8192);
      } // mwheel_slider_rev* freq
      { Fl_Value_Output* o = detunevalueoutput = new Fl_Value_Output(12, 275, 45, 15, "Detune");
        detunevalueoutput->labelsize(10);
        detunevalueoutput->minimum(-5000);
        detunevalueoutput->maximum(5000);
        detunevalueoutput->textfont(1);
        detunevalueoutput->textsize(10);
        detunevalueoutput->callback((Fl_Callback*)cb_detunevalueoutput2);
        detunevalueoutput->align(Fl_Align(FL_ALIGN_TOP_LEFT));
        o->step(0.01, 1);
        o->value(getDetune(pars->GlobalPar.PDetuneType, 0, pars->GlobalPar.PDetune));
      } // Fl_Value_Output* detunevalueoutput
      { Fl_Choice* o = detunetype = new Fl_Choice(495, 313, 75, 17, "Detune Type");
        detunetype->down_box(FL_BORDER_BOX);
        detunetype->labelsize(10);
        detunetype->textfont(1);
        detunetype->textsize(11);
        detunetype->callback((Fl_Callback*)cb_detunetype);
        detunetype->align(Fl_Align(FL_ALIGN_TOP_LEFT));
        o->add("L35 cents");o->add("L10cents");o->add("E100cents");o->add("E1200cents");
        o->value(pars->GlobalPar.PDetuneType-1);
      } // Fl_Choice* detunetype
      { WidgetPDial* o = relBwidth = new WidgetPDial(545, 270, 25, 25, "relBW");
        relBwidth->tooltip("Bandwidth - modify the relative fine detune of the voices");
        relBwidth->box(FL_ROUND_UP_BOX);
        relBwidth->color(FL_BACKGROUND_COLOR);
        relBwidth->selection_color(FL_INACTIVE_COLOR);
        relBwidth->labeltype(FL_NORMAL_LABEL);
        relBwidth->labelfont(0);
        relBwidth->labelsize(10);
        relBwidth->labelcolor(FL_FOREGROUND_COLOR);
        relBwidth->maximum(127);
        relBwidth->step(1);
        relBwidth->callback((Fl_Callback*)cb_relBwidth);
        relBwidth->align(Fl_Align(FL_ALIGN_TOP));
        relBwidth->when(FL_WHEN_CHANGED);
        o->value(pars->GlobalPar.PBandwidth);
      } // WidgetPDial* relBwidth
      globalfreq->end();
    } // Fl_Group* globalfreq
    { Fl_Box* o = new Fl_Box(10, 7, 275, 68);
      o->box(FL_PLASTIC_UP_BOX);
      o->color(FL_CYAN);
    } // Fl_Box* o
    { amplitudegrp = new Fl_Group(5, 7, 285, 250, "AMPLITUDE");
      amplitudegrp->box(FL_THIN_UP_FRAME);
      amplitudegrp->labelfont(1);
      amplitudegrp->labelsize(12);
      amplitudegrp->align(Fl_Align(FL_ALIGN_TOP|FL_ALIGN_INSIDE));
      { WidgetPDial* o = globalvolume = new WidgetPDial(30, 23, 35, 35, "Volume");
        globalvolume->tooltip("Volume");
        globalvolume->box(FL_ROUND_UP_BOX);
        globalvolume->color(FL_BACKGROUND_COLOR);
        globalvolume->selection_color(FL_INACTIVE_COLOR);
        globalvolume->labeltype(FL_NORMAL_LABEL);
        globalvolume->labelfont(0);
        globalvolume->labelsize(10);
        globalvolume->labelcolor(FL_FOREGROUND_COLOR);
        globalvolume->maximum(127);
        globalvolume->step(1);
        globalvolume->callback((Fl_Callback*)cb_globalvolume);
        globalvolume->align(Fl_Align(FL_ALIGN_BOTTOM));
        globalvolume->when(FL_WHEN_CHANGED);
        o->setValueType(VC_InstrumentVolume);
        o->value(pars->GlobalPar.PVolume);
      } // WidgetPDial* globalvolume
      { WidgetPDial* o = vsns = new WidgetPDial(85, 23, 35, 35, "Vel Sens");
        vsns->tooltip("Velocity Sensing Function - rightmost/max to disable");
        vsns->box(FL_ROUND_UP_BOX);
        vsns->color(FL_BACKGROUND_COLOR);
        vsns->selection_color(FL_INACTIVE_COLOR);
        vsns->labeltype(FL_NORMAL_LABEL);
        vsns->labelfont(0);
        vsns->labelsize(10);
        vsns->labelcolor(FL_FOREGROUND_COLOR);
        vsns->maximum(127);
        vsns->step(1);
        vsns->callback((Fl_Callback*)cb_vsns);
        vsns->align(Fl_Align(FL_ALIGN_BOTTOM));
        vsns->when(FL_WHEN_CHANGED);
        o->value(pars->GlobalPar.PAmpVelocityScaleFunction);
        o->setValueType(VC_AmpVelocitySense);
      } // WidgetPDial* vsns
      { WidgetPDial* o = globalpan = new WidgetPDial(155, 23, 35, 35, "Pan");
        globalpan->tooltip("Global panning");
        globalpan->box(FL_ROUND_UP_BOX);
        globalpan->color(FL_BACKGROUND_COLOR);
        globalpan->selection_color(FL_INACTIVE_COLOR);
        globalpan->labeltype(FL_NORMAL_LABEL);
        globalpan->labelfont(0);
        globalpan->labelsize(10);
        globalpan->labelcolor(FL_FOREGROUND_COLOR);
        globalpan->maximum(127);
        globalpan->step(1);
        globalpan->callback((Fl_Callback*)cb_globalpan);
        globalpan->align(Fl_Align(FL_ALIGN_BOTTOM));
        globalpan->when(FL_WHEN_CHANGED);
        o->setValueType(VC_PanningStd);
        o->value(pars->GlobalPar.PPanning);
      } // WidgetPDial* globalpan
      { WidgetPDial* o = globalwidth = new WidgetPDial(235, 23, 35, 35, "Width");
        globalwidth->tooltip("Global random width");
        globalwidth->box(FL_ROUND_UP_BOX);
        globalwidth->color(FL_BACKGROUND_COLOR);
        globalwidth->selection_color(FL_INACTIVE_COLOR);
        globalwidth->labeltype(FL_NORMAL_LABEL);
        globalwidth->labelfont(0);
        globalwidth->labelsize(10);
        globalwidth->labelcolor(FL_FOREGROUND_COLOR);
        globalwidth->maximum(63);
        globalwidth->step(1);
        globalwidth->value(63);
        globalwidth->callback((Fl_Callback*)cb_globalwidth);
        globalwidth->align(Fl_Align(FL_ALIGN_BOTTOM));
        globalwidth->when(FL_WHEN_CHANGED);
        o->setValueType(VC_PanningRandom);
        o->value(pars->GlobalPar.PWidth);
      } // WidgetPDial* globalwidth
      { Fl_Check_Button2* o = globalrandompan = new Fl_Check_Button2(205, 32, 15, 15, "Rand");
        globalrandompan->tooltip("Enable random panning");
        globalrandompan->box(FL_NO_BOX);
        globalrandompan->down_box(FL_DOWN_BOX);
        globalrandompan->color((Fl_Color)48);
        globalrandompan->selection_color(FL_FOREGROUND_COLOR);
        globalrandompan->labeltype(FL_NORMAL_LABEL);
        globalrandompan->labelfont(0);
        globalrandompan->labelsize(11);
        globalrandompan->labelcolor(FL_FOREGROUND_COLOR);
        globalrandompan->callback((Fl_Callback*)cb_globalrandompan);
        globalrandompan->align(Fl_Align(FL_ALIGN_TOP));
        globalrandompan->when(FL_WHEN_RELEASE);
        o->value(pars->GlobalPar.PRandom);
        if (o->value() == 0) globalwidth->deactivate(); else globalwidth->activate();
      } // Fl_Check_Button2* globalrandompan
      { WidgetPDial* o = depop = new WidgetPDial(130, 227, 25, 25, "D.Pop");
        depop->tooltip("Pop Suppression");
        depop->box(FL_ROUND_UP_BOX);
        depop->color(FL_BACKGROUND_COLOR);
        depop->selection_color(FL_INACTIVE_COLOR);
        depop->labeltype(FL_NORMAL_LABEL);
        depop->labelfont(0);
        depop->labelsize(10);
        depop->labelcolor(FL_FOREGROUND_COLOR);
        depop->maximum(127);
        depop->step(1);
        depop->callback((Fl_Callback*)cb_depop);
        depop->align(Fl_Align(FL_ALIGN_TOP));
        depop->when(FL_WHEN_CHANGED);
        o->value(pars->GlobalPar.Fadein_adjustment);
      } // WidgetPDial* depop
      { WidgetPDial* o = pstr = new WidgetPDial(170, 227, 25, 25, "P.Str.");
        pstr->tooltip("Punch Strength");
        pstr->box(FL_ROUND_UP_BOX);
        pstr->color(FL_BACKGROUND_COLOR);
        pstr->selection_color(FL_INACTIVE_COLOR);
        pstr->labeltype(FL_NORMAL_LABEL);
        pstr->labelfont(0);
        pstr->labelsize(10);
        pstr->labelcolor(FL_FOREGROUND_COLOR);
        pstr->maximum(127);
        pstr->step(1);
        pstr->callback((Fl_Callback*)cb_pstr);
        pstr->align(Fl_Align(FL_ALIGN_TOP));
        pstr->when(FL_WHEN_CHANGED);
        o->value(pars->GlobalPar.PPunchStrength);
      } // WidgetPDial* pstr
      { WidgetPDial* o = pt = new WidgetPDial(200, 227, 25, 25, "P.t.");
        pt->tooltip("Punch Time (duration)");
        pt->box(FL_ROUND_UP_BOX);
        pt->color(FL_BACKGROUND_COLOR);
        pt->selection_color(FL_INACTIVE_COLOR);
        pt->labeltype(FL_NORMAL_LABEL);
        pt->labelfont(0);
        pt->labelsize(10);
        pt->labelcolor(FL_FOREGROUND_COLOR);
        pt->maximum(127);
        pt->step(1);
        pt->callback((Fl_Callback*)cb_pt);
        pt->align(Fl_Align(FL_ALIGN_TOP));
        pt->when(FL_WHEN_CHANGED);
        o->value(pars->GlobalPar.PPunchTime);
      } // WidgetPDial* pt
      { WidgetPDial* o = pstc = new WidgetPDial(230, 227, 25, 25, "P.Stc.");
        pstc->tooltip("Punch Stretch");
        pstc->box(FL_ROUND_UP_BOX);
        pstc->color(FL_BACKGROUND_COLOR);
        pstc->selection_color(FL_INACTIVE_COLOR);
        pstc->labeltype(FL_NORMAL_LABEL);
        pstc->labelfont(0);
        pstc->labelsize(10);
        pstc->labelcolor(FL_FOREGROUND_COLOR);
        pstc->maximum(127);
        pstc->step(1);
        pstc->callback((Fl_Callback*)cb_pstc);
        pstc->align(Fl_Align(FL_ALIGN_TOP));
        pstc->when(FL_WHEN_CHANGED);
        o->value(pars->GlobalPar.PPunchStretch);
      } // WidgetPDial* pstc
      { WidgetPDial* o = pvel = new WidgetPDial(260, 227, 25, 25, "P.Vel.");
        pvel->tooltip("Punch Velocity Sensing");
        pvel->box(FL_ROUND_UP_BOX);
        pvel->color(FL_BACKGROUND_COLOR);
        pvel->selection_color(FL_INACTIVE_COLOR);
        pvel->labeltype(FL_NORMAL_LABEL);
        pvel->labelfont(0);
        pvel->labelsize(10);
        pvel->labelcolor(FL_FOREGROUND_COLOR);
        pvel->maximum(127);
        pvel->step(1);
        pvel->callback((Fl_Callback*)cb_pvel);
        pvel->align(Fl_Align(FL_ALIGN_TOP));
        pvel->when(FL_WHEN_CHANGED);
        o->value(pars->GlobalPar.PPunchVelocitySensing);
      } // WidgetPDial* pvel
      { EnvelopeUI* o = ampenv = new EnvelopeUI(10, 75, 205, 70, "ADSynth Global - Amplitude Envelope");
        ampenv->box(FL_FLAT_BOX);
        ampenv->color((Fl_Color)51);
        ampenv->selection_color(FL_BACKGROUND_COLOR);
        ampenv->labeltype(FL_NORMAL_LABEL);
        ampenv->labelfont(0);
        ampenv->labelsize(12);
        ampenv->labelcolor(FL_FOREGROUND_COLOR);
        ampenv->align(Fl_Align(FL_ALIGN_WRAP|FL_ALIGN_INSIDE));
        ampenv->when(FL_WHEN_RELEASE);
        o->init(pars->GlobalPar.AmpEnvelope, npart, kititem, 0, 0);
        ampenv->end();
      } // EnvelopeUI* ampenv
      { LFOUI* o = amplfo = new LFOUI(10, 145, 275, 70, "Amplitude LFO");
        amplfo->box(FL_FLAT_BOX);
        amplfo->color(FL_DARK1);
        amplfo->selection_color(FL_BACKGROUND_COLOR);
        amplfo->labeltype(FL_NORMAL_LABEL);
        amplfo->labelfont(0);
        amplfo->labelsize(12);
        amplfo->labelcolor(FL_FOREGROUND_COLOR);
        amplfo->align(Fl_Align(FL_ALIGN_WRAP|FL_ALIGN_INSIDE));
        amplfo->when(FL_WHEN_RELEASE);
        o->init(pars->GlobalPar.AmpLfo, npart, kititem, 0, 0);
        amplfo->end();
      } // LFOUI* amplfo
      { Fl_Check_Button2* o = rndgrp = new Fl_Check_Button2(8, 234, 63, 18, "Rnd Grp");
        rndgrp->tooltip("Disable individual Harmonic Amplitude randomisation for voices that use the s\
ame oscillator");
        rndgrp->box(FL_NO_BOX);
        rndgrp->down_box(FL_DOWN_BOX);
        rndgrp->color(FL_BACKGROUND_COLOR);
        rndgrp->selection_color(FL_FOREGROUND_COLOR);
        rndgrp->labeltype(FL_NORMAL_LABEL);
        rndgrp->labelfont(0);
        rndgrp->labelsize(11);
        rndgrp->labelcolor(FL_FOREGROUND_COLOR);
        rndgrp->callback((Fl_Callback*)cb_rndgrp);
        rndgrp->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
        rndgrp->when(FL_WHEN_RELEASE);
        o->value(pars->GlobalPar.Hrandgrouping);
      } // Fl_Check_Button2* rndgrp
      { Fl_Box* o = new Fl_Box(135, 21, 4, 47);
        o->box(FL_THIN_DOWN_FRAME);
      } // Fl_Box* o
      amplitudegrp->end();
    } // Fl_Group* amplitudegrp
    { filtergrp = new Fl_Group(290, 5, 285, 250, "FILTER");
      filtergrp->box(FL_THIN_UP_BOX);
      filtergrp->labelfont(1);
      filtergrp->labelsize(12);
      filtergrp->align(Fl_Align(FL_ALIGN_TOP|FL_ALIGN_INSIDE));
      { EnvelopeUI* o = filterenv = new EnvelopeUI(295, 110, 275, 70, "ADSynth Global - Filter Envelope");
        filterenv->box(FL_FLAT_BOX);
        filterenv->color((Fl_Color)51);
        filterenv->selection_color(FL_BACKGROUND_COLOR);
        filterenv->labeltype(FL_NORMAL_LABEL);
        filterenv->labelfont(0);
        filterenv->labelsize(12);
        filterenv->labelcolor(FL_FOREGROUND_COLOR);
        filterenv->align(Fl_Align(FL_ALIGN_WRAP|FL_ALIGN_INSIDE));
        filterenv->when(FL_WHEN_RELEASE);
        o->init(pars->GlobalPar.FilterEnvelope, npart, kititem, 0, 2);
        filterenv->end();
      } // EnvelopeUI* filterenv
      { LFOUI* o = filterlfo = new LFOUI(295, 180, 275, 70, "Filter LFO");
        filterlfo->box(FL_FLAT_BOX);
        filterlfo->color(FL_DARK1);
        filterlfo->selection_color(FL_BACKGROUND_COLOR);
        filterlfo->labeltype(FL_NORMAL_LABEL);
        filterlfo->labelfont(0);
        filterlfo->labelsize(12);
        filterlfo->labelcolor(FL_FOREGROUND_COLOR);
        filterlfo->align(Fl_Align(FL_ALIGN_WRAP|FL_ALIGN_INSIDE));
        filterlfo->when(FL_WHEN_RELEASE);
        o->init(pars->GlobalPar.FilterLfo, npart, kititem, 0, 2);
        filterlfo->end();
      } // LFOUI* filterlfo
      { FilterUI* o = filterui = new FilterUI(295, 35, 275, 75, "ADsynth Global - Filter");
        filterui->box(FL_FLAT_BOX);
        filterui->color(FL_LIGHT1);
        filterui->selection_color(FL_BACKGROUND_COLOR);
        filterui->labeltype(FL_NORMAL_LABEL);
        filterui->labelfont(0);
        filterui->labelsize(12);
        filterui->labelcolor(FL_FOREGROUND_COLOR);
        filterui->align(Fl_Align(FL_ALIGN_WRAP|FL_ALIGN_INSIDE));
        filterui->when(FL_WHEN_RELEASE);
        o->init(pars->GlobalPar.GlobalFilter, &pars->GlobalPar.PFilterVelocityScale, &pars->GlobalPar.PFilterVelocityScaleFunction, npart, kititem, 0);
        filterui->end();
      } // FilterUI* filterui
      filtergrp->end();
    } // Fl_Group* filtergrp
    { Fl_Box* o = new Fl_Box(6, 218, 18, 18);
      o->box(FL_THIN_UP_BOX);
      o->color((Fl_Color)237);
    } // Fl_Box* o
    { Fl_Check_Button2* o = stereo = new Fl_Check_Button2(8, 220, 61, 15, " Stereo");
      stereo->box(FL_NO_BOX);
      stereo->down_box(FL_DOWN_BOX);
      stereo->color((Fl_Color)237);
      stereo->selection_color(FL_FOREGROUND_COLOR);
      stereo->labeltype(FL_NORMAL_LABEL);
      stereo->labelfont(0);
      stereo->labelsize(11);
      stereo->labelcolor(FL_FOREGROUND_COLOR);
      stereo->callback((Fl_Callback*)cb_stereo);
      stereo->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
      stereo->when(FL_WHEN_RELEASE);
      o->value(pars->GlobalPar.PStereo);
    } // Fl_Check_Button2* stereo
    { showvoicelist = new Fl_Button(191, 375, 121, 25, "Show Voice List");
      showvoicelist->tooltip("Right click: also close this");
      showvoicelist->labelfont(1);
      showvoicelist->labelsize(12);
      showvoicelist->callback((Fl_Callback*)cb_showvoicelist);
    } // Fl_Button* showvoicelist
    { showvoicepars = new Fl_Button(5, 375, 180, 25, "Show Voice Parameters");
      showvoicepars->tooltip("Right click: also close this");
      showvoicepars->labelfont(1);
      showvoicepars->labelsize(12);
      showvoicepars->callback((Fl_Callback*)cb_showvoicepars);
    } // Fl_Button* showvoicepars
    { globalclose = new Fl_Button(517, 375, 54, 25, "Close");
      globalclose->tooltip("Right click: also reopen previous");
      globalclose->box(FL_THIN_UP_BOX);
      globalclose->labelfont(1);
      globalclose->labelsize(12);
      globalclose->callback((Fl_Callback*)cb_globalclose);
    } // Fl_Button* globalclose
    { resonance = new Fl_Button(318, 375, 90, 25, "Resonance");
      resonance->tooltip("Resonance. Right click: also close this");
      resonance->labelfont(1);
      resonance->labelsize(12);
      resonance->callback((Fl_Callback*)cb_resonance);
    } // Fl_Button* resonance
    { globalcopy = new Fl_Button(455, 380, 25, 15, "C");
      globalcopy->box(FL_THIN_UP_BOX);
      globalcopy->color((Fl_Color)179);
      globalcopy->labelfont(1);
      globalcopy->labelsize(11);
      globalcopy->labelcolor(FL_BACKGROUND2_COLOR);
      globalcopy->callback((Fl_Callback*)cb_globalcopy);
    } // Fl_Button* globalcopy
    { globalpaste = new Fl_Button(485, 380, 25, 15, "P");
      globalpaste->box(FL_THIN_UP_BOX);
      globalpaste->color((Fl_Color)179);
      globalpaste->labelfont(1);
      globalpaste->labelsize(11);
      globalpaste->labelcolor(FL_BACKGROUND2_COLOR);
      globalpaste->callback((Fl_Callback*)cb_globalpaste);
    } // Fl_Button* globalpaste
    o->copy_label(synth->getGuiMaster()->setPartWindowTitle("AddSynth Global").c_str());
    addDW = 535; addDH = 405;
    o->size_range(addDW, addDH, 0, 0, 0, 0, 1);
    ADnoteGlobalParameters->end();
    ADnoteGlobalParameters->resizable(ADnoteGlobalParameters);
  } // Fl_Double_Window* ADnoteGlobalParameters
  { Fl_Double_Window* o = ADnoteVoice = new Fl_Double_Window(805, 610, "ADsynth Voice Parameters");
    ADnoteVoice->callback((Fl_Callback*)cb_ADnoteVoice, (void*)(this));
    { ADvoiceUI* o = advoice = new ADvoiceUI(0, 0, 809, 615);
      advoice->box(FL_BORDER_BOX);
      advoice->color(FL_BACKGROUND_COLOR);
      advoice->selection_color(FL_BACKGROUND_COLOR);
      advoice->labeltype(FL_NORMAL_LABEL);
      advoice->labelfont(0);
      advoice->labelsize(14);
      advoice->labelcolor(FL_FOREGROUND_COLOR);
      advoice->align(Fl_Align(FL_ALIGN_TOP));
      advoice->when(FL_WHEN_RELEASE);
      o->init(pars, npart, kititem, nvoice);
      o->show();
      advoice->end();
    } // ADvoiceUI* advoice
    { Vclose = new Fl_Button(695, 575, 90, 25, "Close");
      Vclose->tooltip("Right click: also reopen previous");
      Vclose->box(FL_THIN_UP_BOX);
      Vclose->labelfont(1);
      Vclose->labelsize(12);
      Vclose->callback((Fl_Callback*)cb_Vclose);
    } // Fl_Button* Vclose
    { Vcopy = new Fl_Button(600, 580, 25, 15, "C");
      Vcopy->box(FL_THIN_UP_BOX);
      Vcopy->color((Fl_Color)179);
      Vcopy->labelfont(1);
      Vcopy->labelsize(11);
      Vcopy->labelcolor(FL_BACKGROUND2_COLOR);
      Vcopy->callback((Fl_Callback*)cb_Vcopy);
    } // Fl_Button* Vcopy
    { Vpaste = new Fl_Button(630, 580, 25, 15, "P");
      Vpaste->box(FL_THIN_UP_BOX);
      Vpaste->color((Fl_Color)179);
      Vpaste->labelfont(1);
      Vpaste->labelsize(11);
      Vpaste->labelcolor(FL_BACKGROUND2_COLOR);
      Vpaste->callback((Fl_Callback*)cb_Vpaste);
    } // Fl_Button* Vpaste
    { Fl_Button* o = g1 = new Fl_Button(8, 3, 50, 32, "1");
      g1->box(FL_PLASTIC_THIN_UP_BOX);
      g1->down_box(FL_PLASTIC_THIN_UP_BOX);
      g1->selection_color((Fl_Color)231);
      g1->labelfont(1);
      g1->callback((Fl_Callback*)cb_g1);
      o->value(1);
    } // Fl_Button* g1
    { Fl_Button* o = g2 = new Fl_Button(60, 3, 50, 32, "2");
      g2->box(FL_PLASTIC_THIN_UP_BOX);
      g2->down_box(FL_PLASTIC_THIN_UP_BOX);
      g2->selection_color((Fl_Color)231);
      g2->labelfont(1);
      g2->callback((Fl_Callback*)cb_g2);
      o->value(0);
    } // Fl_Button* g2
    { Fl_Button* o = g3 = new Fl_Button(112, 3, 50, 32, "3");
      g3->box(FL_PLASTIC_THIN_UP_BOX);
      g3->down_box(FL_PLASTIC_THIN_UP_BOX);
      g3->selection_color((Fl_Color)231);
      g3->labelfont(1);
      g3->callback((Fl_Callback*)cb_g3);
      o->value(0);
    } // Fl_Button* g3
    { Fl_Button* o = g4 = new Fl_Button(164, 3, 50, 32, "4 ");
      g4->box(FL_PLASTIC_THIN_UP_BOX);
      g4->down_box(FL_PLASTIC_THIN_UP_BOX);
      g4->selection_color((Fl_Color)231);
      g4->labelfont(1);
      g4->callback((Fl_Callback*)cb_g4);
      o->value(0);
    } // Fl_Button* g4
    { Fl_Button* o = g5 = new Fl_Button(216, 3, 50, 32, "5");
      g5->box(FL_PLASTIC_THIN_UP_BOX);
      g5->down_box(FL_PLASTIC_THIN_UP_BOX);
      g5->selection_color((Fl_Color)231);
      g5->labelfont(1);
      g5->callback((Fl_Callback*)cb_g5);
      o->value(0);
    } // Fl_Button* g5
    { Fl_Button* o = g6 = new Fl_Button(268, 3, 50, 32, "6");
      g6->box(FL_PLASTIC_THIN_UP_BOX);
      g6->down_box(FL_PLASTIC_THIN_UP_BOX);
      g6->selection_color((Fl_Color)231);
      g6->labelfont(1);
      g6->callback((Fl_Callback*)cb_g6);
      o->value(0);
    } // Fl_Button* g6
    { Fl_Button* o = g7 = new Fl_Button(320, 3, 50, 32, "7");
      g7->box(FL_PLASTIC_THIN_UP_BOX);
      g7->down_box(FL_PLASTIC_THIN_UP_BOX);
      g7->selection_color((Fl_Color)231);
      g7->labelfont(1);
      g7->callback((Fl_Callback*)cb_g7);
      o->value(0);
    } // Fl_Button* g7
    { Fl_Button* o = g8 = new Fl_Button(372, 3, 50, 32, "8");
      g8->box(FL_PLASTIC_THIN_UP_BOX);
      g8->down_box(FL_PLASTIC_THIN_UP_BOX);
      g8->selection_color((Fl_Color)231);
      g8->labelfont(1);
      g8->callback((Fl_Callback*)cb_g8);
      o->value(0);
    } // Fl_Button* g8
    { voiceTabBar = new Fl_Group(4, 30, 524, 5);
      voiceTabBar->box(FL_PLASTIC_THIN_DOWN_BOX);
      voiceTabBar->color(FL_CYAN);
      voiceTabBar->end();
    } // Fl_Group* voiceTabBar
    o->copy_label(synth->getGuiMaster()->setPartWindowTitle("AddSynth Voice").c_str());
    voiceDW = int(760 * 9 / 10); voiceDH = int(610 * 9 / 10);
    o->size_range(voiceDW, voiceDH, 0, 0, 0, 0, 1);
    ADnoteVoice->end();
    ADnoteVoice->resizable(ADnoteVoice);
  } // Fl_Double_Window* ADnoteVoice
  { Fl_Double_Window* o = ADnoteVoiceList = new Fl_Double_Window(705, 260, "ADsynth Voices list");
    ADnoteVoiceList->callback((Fl_Callback*)cb_ADnoteVoiceList, (void*)(this));
    { listNo = new Fl_Text_Display(24, 15, 30, 10, "No.");
      listNo->box(FL_NO_BOX);
      listNo->labelfont(1);
      listNo->labelsize(11);
    } // Fl_Text_Display* listNo
    { listVolume = new Fl_Text_Display(230, 15, 30, 10, "Volume");
      listVolume->box(FL_NO_BOX);
      listVolume->labelfont(1);
      listVolume->labelsize(11);
    } // Fl_Text_Display* listVolume
    { listDetune = new Fl_Text_Display(458, 15, 25, 10, "Detune");
      listDetune->box(FL_NO_BOX);
      listDetune->labelfont(1);
      listDetune->labelsize(11);
    } // Fl_Text_Display* listDetune
    { listPan = new Fl_Text_Display(298, 15, 30, 10, "Pan");
      listPan->box(FL_NO_BOX);
      listPan->labelfont(1);
      listPan->labelsize(11);
    } // Fl_Text_Display* listPan
    { listVibrato = new Fl_Text_Display(618, 15, 30, 10, "Vibrato Depth");
      listVibrato->box(FL_NO_BOX);
      listVibrato->labelfont(1);
      listVibrato->labelsize(11);
    } // Fl_Text_Display* listVibrato
    { listResonance = new Fl_Text_Display(329, 15, 25, 10, "Res");
      listResonance->box(FL_NO_BOX);
      listResonance->labelfont(1);
      listResonance->labelsize(11);
    } // Fl_Text_Display* listResonance
    { listClose = new Fl_Button(582, 235, 62, 20, "Close");
      listClose->tooltip("Right click: also reopen previous");
      listClose->labelfont(1);
      listClose->labelsize(12);
      listClose->callback((Fl_Callback*)cb_listClose);
    } // Fl_Button* listClose
    { Fl_Group* o = new Fl_Group(5, 15, 695, 214);
      o->box(FL_THIN_UP_BOX);
      { Fl_Group* o = new Fl_Group(17, 27, 668, 200);
        //
              for (int i = 0; i < NUM_VOICES; ++i)
              {
                  voicelistitem[i] = new ADvoicelistitem(4, 8, 620, 25, "");
                  voicelistitem[i]->init(pars, npart, kititem, i);
              }
        o->end();
      } // Fl_Group* o
      o->end();
    } // Fl_Group* o
    { listWave = new Fl_Text_Display(105, 15, 30, 10, "Wave");
      listWave->box(FL_NO_BOX);
      listWave->labelfont(1);
      listWave->labelsize(11);
    } // Fl_Text_Display* listWave
    { listModulator = new Fl_Text_Display(145, 15, 30, 10, "Mod");
      listModulator->box(FL_NO_BOX);
      listModulator->labelfont(1);
      listModulator->labelsize(11);
    } // Fl_Text_Display* listModulator
    o->copy_label(synth->getGuiMaster()->setPartWindowTitle("AddSynth Voice List").c_str());
    listDW = 705; listDH = 260;
    o->size_range(listDW,listDH,0,0,0,0,1);
    ADnoteVoiceList->end();
    ADnoteVoiceList->resizable(ADnoteVoiceList);
  } // Fl_Double_Window* ADnoteVoiceList
  return ADnoteVoiceList;
}

void ADnoteUI::setVoiceTabs(int num, bool edit ) {
  //
      g1->value(0);
      g2->value(0);
      g3->value(0);
      g4->value(0);
      g5->value(0);
      g6->value(0);
      g7->value(0);
      g8->value(0);
      switch (num)
      {
          case 0:
              g1->value(1);
              if (edit)
                  editVoice(0);
              break;
          case 1:
              g2->value(1);
              if (edit)
                  editVoice(1);
              break;
          case 2:
              g3->value(1);
              if (edit)
                  editVoice(2);
              break;
          case 3:
              g4->value(1);
              if (edit)
                  editVoice(3);
              break;
          case 4:
              g5->value(1);
              if (edit)
                  editVoice(4);
              break;
          case 5:
              g6->value(1);
              if (edit)
                  editVoice(5);
              break;
          case 6:
              g7->value(1);
              if (edit)
                  editVoice(6);
              break;
          case 7:
              g8->value(1);
              if (edit)
                  editVoice(7);
              break;
      }
}

void ADnoteUI::setTabColour(int num) {
  //
      int set = 16;
      if (pars->VoicePar[num].Enabled)
          set = 0;
  
      switch (num)
      {
          case 0:
              g1->labelcolor(set);
              break;
          case 1:
              g2->labelcolor(set);
              break;
          case 2:
              g3->labelcolor(set);
              break;
          case 3:
              g4->labelcolor(set);
              break;
          case 4:
              g5->labelcolor(set);
              break;
          case 5:
              g6->labelcolor(set);
              break;
          case 6:
              g7->labelcolor(set);
              break;
          case 7:
              g8->labelcolor(set);
              break;
      }
}

void ADnoteUI::send_data(int action, int control, float value, int type) {
  //
      type |= TOPLEVEL::type::Write;
      collect_data(synth, value, action, type, control, npart, kititem, 0);
}

void ADnoteUI::returns_update(CommandBlock *getData) {
  //
      float value = getData->data.value;
      unsigned char control = getData->data.control;
      bool val_bool = _SYS_::F2B(value);
      switch(control)
      {
          case ADDSYNTH::control::volume:
              globalvolume->value(value);
              break;
  
          case ADDSYNTH::control::velocitySense:
              vsns->value(value);
              break;
  
          case ADDSYNTH::control::panning:
              globalpan->value(value);
              amplitudegrp->changed();
              break;
  
          case ADDSYNTH::control::enableRandomPan:
              globalrandompan->value(val_bool);
              if (val_bool)
                  globalwidth->activate();
              else
                  globalwidth->deactivate();
              amplitudegrp->changed();
              break;
  
          case ADDSYNTH::control::randomWidth:
              globalwidth->value(value);
              amplitudegrp->changed();
              break;
  
          case ADDSYNTH::control::detuneFrequency:
              freq->value(value);
              detunevalueoutput->do_callback();
              break;
  
          case ADDSYNTH::control::octave:
              octave->value((int) value);
              break;
  
          case ADDSYNTH::control::detuneType:
              detunetype->value(int(value) -1);
              break;
  
          case ADDSYNTH::control::coarseDetune:
              coarsedet->value((int) value);
              break;
  
          case ADDSYNTH::control::relativeBandwidth:
              relBwidth->value(value);
              break;
  
          case ADDSYNTH::control::stereo:
              stereo->value(val_bool);
              break;
  
          case ADDSYNTH::control::randomGroup:
              rndgrp->value(val_bool);
              break;
  
          case ADDSYNTH::control::dePop:
              depop->value(value);
              break;
  
          case ADDSYNTH::control::punchStrength:
              pstr->value(value);
              break;
  
          case ADDSYNTH::control::punchDuration:
              pt->value(value);
              break;
  
          case ADDSYNTH::control::punchStretch:
              pstc->value(value);
              break;
  
          case ADDSYNTH::control::punchVelocity:
              pvel->value(value);
              break;
  
      }
}

ADnoteUI::ADnoteUI(ADnoteParameters *parameters, int npart_, int kititem_) {
  //
          synth = parameters->getSynthEngine();
          pars = parameters;
          npart = npart_;
          kititem = kititem_;
          globalSeen = false;
          lastglobalW = 0;
          voiceSeen = false;
          lastvoiceW = 0;
          nvoice = 0;
          resui = new ResonanceUI(pars->GlobalPar.Reson, npart, kititem, 0);
          lastlistW = 0;
          listSeen = false;
          lastResuiW = 0;
          make_window();
          for (int i = 0; i < NUM_VOICES; ++i)
          {
              setTabColour(i);
          }
}

ADnoteUI::~ADnoteUI() {
  //
          if(listSeen)
              saveWin(synth, ADnoteVoiceList->w(), ADnoteVoiceList->h(), ADnoteVoiceList->x(), ADnoteVoiceList->y(), listSeen, "AddSynth-list");
          ADnoteVoiceList->hide();
          listSeen = false;
          if (globalSeen)
              saveWin(synth,  ADnoteGlobalParameters->w(),  ADnoteGlobalParameters->h(), ADnoteGlobalParameters->x(), ADnoteGlobalParameters->y(), globalSeen, "AddSynth");
          ADnoteGlobalParameters->hide();
          globalSeen = false;
          if (voiceSeen)
              saveWin(synth, ADnoteVoice->w(), ADnoteVoice->h(), ADnoteVoice->x(), ADnoteVoice->y(), voiceSeen, "AddSynth-voice");
          voiceSeen = false;
          ADnoteVoice->hide();
          resui->resonancewindow->hide();
          delete ADnoteVoiceList;
          delete ADnoteGlobalParameters;
          delete ADnoteVoice;
          delete resui;
}

void ADnoteUI::refresh() {
  //
          globalvolume->value(pars->GlobalPar.PVolume);
          vsns->value(pars->GlobalPar.PAmpVelocityScaleFunction);
          globalpan->value(pars->GlobalPar.PPanning);
  
          stereo->value(pars->GlobalPar.PStereo);
          rndgrp->value(pars->GlobalPar.Hrandgrouping);
          pstr->value(pars->GlobalPar.PPunchStrength);
          pt->value(pars->GlobalPar.PPunchTime);
          pstc->value(pars->GlobalPar.PPunchStretch);
          pvel->value(pars->GlobalPar.PPunchVelocitySensing);
          detunevalueoutput->value(getDetune(pars->GlobalPar.PDetuneType, 0, pars->GlobalPar.PDetune));
          freq->value(pars->GlobalPar.PDetune - 8192);
  
          int k = pars->GlobalPar.PCoarseDetune / 1024;
          if (k >= 8)
              k -= 16;
          octave->value(k);
  
          detunetype->value(pars->GlobalPar.PDetuneType - 1);
          k = pars->GlobalPar.PCoarseDetune % 1024;
          if (k >= 512)
              k -= 1024;
          coarsedet->value(k);
          amplfo->refresh();
          freqlfo->refresh();
          filterlfo->refresh();
  
          ampenv->refresh();
          freqenv->refresh();
          filterenv->refresh();
          filterui->refresh();
          for (int i = 0; i < NUM_VOICES; ++i)
              voicelistitem[i]->refreshlist();
  
          resui->refresh();
          editVoice(nvoice);
}

void ADnoteUI::ShowGlobal() {
  //
      int fetchW, fetchH, fetchX, fetchY, fetchO;
      loadWin(synth, fetchW, fetchH, fetchX, fetchY, fetchO, "AddSynth");
  
      if (fetchW < addDW || fetchH < addDH)
      {
          fetchW = addDW;
          fetchH = addDH;
      }
      checkSane(fetchX, fetchY, fetchW, fetchH, addDW, addDH);
  
  
      lastglobalW = 0;
      ADnoteGlobalParameters->resize(fetchX, fetchY, fetchW, fetchH);
      ADnoteGlobalParameters->show();
      globalSeen = true;
}

void ADnoteUI::set_voice(bool type) {
  //
  
      voicelistitem[nvoice]->refreshlist();
      int fetchW, fetchH, fetchX, fetchY, fetchO;
  
      if (!voiceSeen)
      {
          loadWin(synth, fetchW, fetchH, fetchX, fetchY, fetchO, "AddSynth-voice");
          if (fetchW < voiceDW || fetchH < voiceDH)
          {
              fetchW = voiceDW;
              fetchH = voiceDH;
          }
          ADnoteVoice->resize(fetchX, fetchY, fetchW, fetchH);
          checkSane(fetchX, fetchY, fetchW, fetchH, voiceDW, voiceDH);
      }
  
      ADnoteVoice->redraw();
      ADnoteVoice->show();
      lastvoiceW = 0;
      voiceSeen = true;
      fromVoiceList = type;
}

void ADnoteUI::wincheck() {
  //
      addRtext();
      addVoiceRtext();
  
      if (ADnoteVoiceList->visible())
          addVoiceListRtext();
  
      if (resui->resonancewindow->visible() && lastResuiW != resui->resonancewindow->w())
      {
          resui->resonanceRtext();
          lastResuiW = resui->resonancewindow->w();
      }
  
      if (ampenv)
          ampenv->wincheck();
      if (filterenv)
          filterenv->wincheck();
      if (freqenv)
          freqenv->wincheck();
}

void ADnoteUI::addRtext() {
  //
      ampenv->wincheck();
      freqenv->wincheck();
      filterenv->wincheck();
  
      if (lastglobalW < 3)
      {
         ++lastglobalW;
         return; // in case it is  called before completely redrawn
      }
  
      if (lastglobalW == ADnoteGlobalParameters->w())
          return;
      lastglobalW = ADnoteGlobalParameters->w();
  
      float dScale = ADnoteGlobalParameters->w() / float(addDW);
      if (dScale < 0.2f)
          dScale = 0.2f;
  
      amplfo->lfoRtext(dScale);
      ampenv->envRtext(dScale);
  
      freqlfo->lfoRtext(dScale);
      freqenv->envRtext(dScale);
  
      filterlfo->lfoRtext(dScale);
      filterenv->envRtext(dScale);
  
      filterui->filterRtext(dScale);
  
      int size = int(10 * dScale);
      int size11 = int(11 * dScale);
      int size12 = int(12 * dScale);
  
      amplitudegrp->labelsize(size12);
      globalvolume->labelsize(size);
      vsns->labelsize(size);
      globalpan->labelsize(size);
      globalwidth->labelsize(size);
      globalrandompan->labelsize(size);
      depop->labelsize(size);
      pstr->labelsize(size);
      pt->labelsize(size);
      pstc->labelsize(size);
      pvel->labelsize(size);
      rndgrp->labelsize(size);
  
      stereo->labelsize(size11);
  
      filtergrp->labelsize(size12);
  
      globalfreq->labelsize(size12);
      detunevalueoutput->labelsize(size);
          detunevalueoutput->textsize(size);
      octave->labelsize(size);
          octave->textsize(size11);
      relBwidth->labelsize(size);
      detunetype->labelsize(size);
          detunetype->textsize(size11);
  
      coarsedet->labelsize(size);
          coarsedet->textsize(size11);
  
      showvoicepars->labelsize(size12);
      showvoicelist->labelsize(size12);
      resonance->labelsize(size12);
      globalcopy->labelsize(size11);
      globalpaste->labelsize(size11);
      globalclose->labelsize(size11);
  
      ADnoteGlobalParameters->redraw();
}

void ADnoteUI::addVoiceRtext() {
  // this is just for the outer skin
  
      float dScale = ADnoteVoice->w() / float(voiceDW);
      if (dScale < 0.2f)
          dScale = 0.2f;
  
      advoice->voiceRtext(dScale); // must be entered (for waveform)
  
      if (!ADnoteVoice->visible())
          return;
  
      if (lastvoiceW < 2) // extra time to settle
      {
          ++lastvoiceW;
          return;
      }
  
      if (ADnoteVoice->w() == lastvoiceW)
          return;
  
      lastvoiceW = ADnoteVoice->w();
  
      Vclose->labelsize(int(12 * dScale));
  
      Vcopy->labelsize(int(11 * dScale));
      Vpaste->labelsize(int(11 * dScale));
  
      /*
       * scaling of tabs is in near tab size jumps so we
       * have to try to get the best overall size/position
      */
      int size = int((12 * dScale) + (1.85f * dScale * dScale));
      g1->labelsize(size);
      g2->labelsize(size);
      g3->labelsize(size);
      g4->labelsize(size);
      g5->labelsize(size);
      g6->labelsize(size);
      g7->labelsize(size);
      g8->labelsize(size);
  
     ADnoteVoice->redraw();
}

void ADnoteUI::addVoiceListRtext() {
  //
  
      if (lastlistW < 3)
      {
          ++lastlistW;
          return;
      }
      if (lastlistW == ADnoteVoiceList->w())
          return;
  
      lastlistW = ADnoteVoiceList->w();
  
      float dScale = ADnoteVoiceList->w() / float(listDW);
      if (dScale < 0.2f)
          dScale = 0.2f;;
  
      for (int i = 0; i < NUM_VOICES; ++i)
      {
          voicelistitem[i]->resize(15 * dScale, (27 + (25 * i)) * dScale, 670 * dScale, 25 * dScale);
          voicelistitem[i]->itemRtext(dScale);
      }
  
      int size11 = int(11 * dScale);
      listNo->labelsize(size11);
      listVolume->labelsize(size11);
      listDetune->labelsize(size11);
      listPan->labelsize(size11);
      listVibrato->labelsize(size11);
      listResonance->labelsize(size11);
      listWave->labelsize(size11);
      listModulator->labelsize(size11);
      listClose->labelsize(int(14 * dScale));
  
      ADnoteVoiceList->redraw();
}

void ADnoteUI::editVoice(int nvoice_) {
  //
          nvoice = nvoice_;
  
          int adW = advoice->ADnoteVoiceParameters->w();
          int adH = advoice->ADnoteVoiceParameters->h();
          advoice->hide();
          ADnoteVoice->remove(advoice);
          delete advoice;
  
          advoice = new ADvoiceUI(0, 0, adW, adH);
          ADnoteVoice->add(advoice);
          advoice->init(pars, npart, kititem, nvoice);
          advoice->ADnoteVoiceParameters->size(adW, adH);
          advoice->show();
          addVoiceRtext();
}
