# data file for the Fltk User Interface Designer (fluid)
version 1.0304
header_name {.h}
code_name {.cpp}
comment {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 Library 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.

} {selected in_source in_header
}

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

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

decl {\#include "Misc/SynthEngine.h"} {private local
}

decl {\#include "UI/WidgetCheckButton.h"} {public global
}

decl {\#include "UI/WidgetSpinner.h"} {public global
}

decl {\#include "Misc/Bank.h"} {private local
}

decl {\#include "MasterUI.h"} {private local
}

decl {\#include "Misc/FileMgrFuncs.h"} {private local
}

decl {\#include "Misc/NumericFuncs.h"} {private local
}

decl {\#include "Misc/TextMsgBuffer.h"

    namespace { // Implementation details...
        TextMsgBuffer& textMsgBuffer = TextMsgBuffer::instance();
    }} {private local
}

decl {extern SynthEngine *firstSynth;} {private local
}

class ConfigUI {open
} {
  Function {make_window()} {} {
    Fl_Window configwindow {
      label {Yoshimi Settings}
      callback {close->do_callback();}
      xywh {691 66 390 330} type Double hide resizable
      code0 {o->copy_label(synth->makeUniqueName("Settings").c_str());}
      code1 {if (synth->getIsLV2Plugin()){jackTab->deactivate();alsaTab->deactivate();}}
      code2 {confDW = o->w();confDH = o->h();}
      code3 {o->size_range(confDW, confDH, 0, 0, 0, 0, 1);}
    } {
      Fl_Button Tab1 {
        label {&Main Settings}
        callback {mainTab->show();
patch1->show();
patch2->hide();
patch3->hide();
patch4->hide();
patch5->hide();
switchesTab->hide();
jackTab->hide();
alsaTab->hide();
midiTab->hide();}
        xywh {5 5 91 22} box THIN_UP_FRAME selection_color 47 labelsize 12
      }
      Fl_Button Tab2 {
        label {&Switches}
        callback {switchesTab->show();
patch2->show();
patch1->hide();
patch3->hide();
patch4->hide();
patch5->hide();mainTab->hide();
jackTab->hide();
alsaTab->hide();
midiTab->hide();}
        xywh {98 5 66 22} box THIN_UP_FRAME selection_color 47 labelsize 12
      }
      Fl_Button Tab3 {
        label {&Jack}
        callback {jackTab->show();
patch3->show();
patch1->hide();
patch2->hide();
patch4->hide();
patch5->hide();mainTab->hide();
switchesTab->hide();
alsaTab->hide();
midiTab->hide();}
        xywh {166 5 38 22} box THIN_UP_FRAME selection_color 47 labelsize 12
      }
      Fl_Button Tab4 {
        label {&Alsa}
        callback {alsaTab->show();
patch4->show();
patch1->hide();
patch2->hide();
patch3->hide();
patch5->hide();
mainTab->hide();
switchesTab->hide();
jackTab->hide();
midiTab->hide();}
        xywh {206 5 38 22} box THIN_UP_FRAME selection_color 47 labelsize 12
      }
      Fl_Button Tab5 {
        label {MIDI &CCs}
        callback {midiTab->show();
patch5->show();
patch1->hide();
patch2->hide();
patch3->hide();
patch4->hide();
mainTab->hide();
switchesTab->hide();
jackTab->hide();
alsaTab->hide();}
        xywh {246 5 58 22} box THIN_UP_FRAME selection_color 47 labelsize 12
      }
      Fl_Group configTabs {
        xywh {5 5 380 298}
      } {
        Fl_Group mainTab {
          xywh {5 25 382 277} box THIN_UP_BOX labelsize 12
        } {
          Fl_Choice osc_size {
            label {* AddSynth Oscillator Size}
            callback {//
                        send_data(0, CONFIG::control::oscillatorSize, 256 << o->value(), TOPLEVEL::type::Integer);}
            tooltip {ADSynth Oscillator Size (samples)} xywh {250 32 100 20} down_box BORDER_BOX labelsize 12 textfont 1 textsize 12
            code0 {o->add("256");o->add("512");o->add("1024");o->add("2048");o->add("4096");o->add("8192");o->add("16384");}
            code1 {o->value(func::bitFindHigh(synth->getRuntime().Oscilsize) - 8);}
          } {}
          Fl_Choice buff_size {
            label {* Internal Buffer Size}
            callback {//
                        send_data(0, CONFIG::control::bufferSize, 16 << o->value(), TOPLEVEL::type::Integer);}
            tooltip {Number of samples. Smaller has more accurate internal timings but this may change some sounds.} xywh {249 60 100 20} down_box BORDER_BOX labelsize 12 textfont 1 textsize 12
            code0 {o->add("16");o->add("32");o->add("64");o->add("128");o->add("256");o->add("512");o->add("1024");o->add("2048");o->add("4096");o->add("8192");}
            code1 {o->value(func::bitFindHigh(synth->getRuntime().Buffersize) - 4);}
            code2 {//if (synth->getIsLV2Plugin()) o->deactivate();}
          } {}
          Fl_Choice pad_interpol {
            label {PADsynth Interpolation}
            callback {//
                        send_data(0, CONFIG::control::padSynthInterpolation, o->value(), TOPLEVEL::type::Integer);}
            xywh {250 88 100 20} down_box BORDER_BOX labelsize 12 textfont 1 textsize 12
            code0 {o->add("Linear(fast)");o->add("Cubic(slow)");}
            code1 {o->value(synth->getRuntime().Interpolation);}
          } {}
          Fl_Choice v_keyboard {
            label {Virtual Keyboard Layout}
            callback {//
                        send_data(0, CONFIG::control::virtualKeyboardLayout, o->value(), TOPLEVEL::type::Integer);}
            xywh {250 116 100 20} down_box BORDER_BOX labelsize 12 textfont 1 textsize 12
            code0 {o->add("QWERTY");o->add("Dvorak");o->add("QWERTZ");o->add("AZERTY");}
            code1 {o->value(synth->getRuntime().VirKeybLayout);}
          } {}
          Fl_Counter compression {
            label {XML Compression Level}
            callback {//
                        send_data(0, CONFIG::control::XMLcompressionLevel, o->value(), TOPLEVEL::type::Integer);}
            tooltip {gzip compression level (0 - uncompressed)} xywh {284 144 65 20} type Simple labelsize 12 align 4 minimum 0 maximum 9 step 1 textfont 1 textsize 12
            code0 {o->value(synth->getRuntime().GzipCompression);}
            code1 {if (synth->getUniqueId() != 0) o->hide();}
          }
          Fl_Choice reports {
            label {Send reports to:}
            callback {//
                        send_data(TOPLEVEL::action::forceUpdate, CONFIG::control::reportsDestination, o->value(), TOPLEVEL::type::Integer);}
            tooltip {Some system errors always go to stdout} xywh {200 172 150 20} down_box BORDER_BOX labelsize 12 textfont 1 textsize 12
            code0 {o->add("stdout");o->add("Console Window");}
            code1 {o->value(synth->getRuntime().toConsole);}
          } {}
          Fl_Counter logText {
            label {Console Text Size}
            callback {//
                        send_data(0, CONFIG::control::logTextSize, o->value(), TOPLEVEL::type::Integer);
                        synth->getGuiMaster()->yoshiLog->setLogText(o->value());}
            xywh {284 200 65 20} type Simple labelsize 12 align 4 minimum 11 maximum 100 step 1 value 12 textfont 1 textsize 12
            code1 {o->value(synth->getRuntime().consoleTextSize);}
            code2 {if (synth->getRuntime().toConsole) o->activate(); else o->deactivate();}
          }
          Fl_Choice instrument {
            label {Saved Instrument Format}
            callback {//
                        send_data(0, CONFIG::control::savedInstrumentFormat, o->value() + 1, TOPLEVEL::type::Integer);}
            tooltip {Yoshimi format includes Controllers and Humanise} xywh {200 228 150 20} down_box BORDER_BOX labelsize 12 textfont 1 textsize 12
            code0 {o->add("Legacy");o->add("Yoshimi");o->add("Both");}
            code1 {o->value(synth->getRuntime().instrumentFormat - 1);}
          } {}
          Fl_Choice PanelLayout {
            label {Mixer Panel Layout}
            callback {//
    int style = 2 - int(o->value());
    synth->getGuiMaster()->changepanelstyle(style);}
            tooltip {Select single row or compact format} xywh {200 256 150 20} down_box BORDER_BOX labelsize 12 textfont 1 textsize 12
            code0 {o->add("2 row x 8 entries");o->add("1 row x 16 entries");}
            code1 {o->value(synth->getRuntime().single_row_panel);}
          } {}
          Fl_Box settingsNote {
            label {* Changing these settings requires a restart}
            xywh {41 280 306 17} labelfont 1 labelsize 12 labelcolor 38 align 128
            code0 {if (synth->getUniqueId() != 0) o->hide();}
          }
        }
        Fl_Group switchesTab {
          xywh {5 25 382 277} box THIN_UP_BOX labelsize 12 hide
        } {
          Fl_Check_Button bankHighlight {
            label {Enable Bank Highlight}
            callback {//
                        send_data(0, CONFIG::control::enableHighlight, o->value(), TOPLEVEL::type::Integer);}
            tooltip {Show the last patch fetched from or saved to a bank} xywh {190 40 27 25} down_box DOWN_BOX labelsize 12 align 4
            code0 {o->value(synth->getRuntime().bankHighlight);}
            class Fl_Check_Button2
          }
          Fl_Check_Button setDefaultState {
            label {* Start With Default State}
            callback {//
                        send_data(0, CONFIG::control::defaultStateStart, o->value(), TOPLEVEL::type::Integer);}
            tooltip {If you change this you must re-save the default state
or when that loads it will revert to the previous value} xywh {190 60 27 25} down_box DOWN_BOX labelsize 12 align 4
            code0 {o->value(synth->getRuntime().loadDefaultState);}
            code1 {if (synth->getIsLV2Plugin()) o->deactivate();}
            class Fl_Check_Button2
          }
          Fl_Check_Button nonFatal {
            label {Hide Non Fatal Errors}
            callback {//
                        send_data(0, CONFIG::control::hideNonFatalErrors, o->value(), TOPLEVEL::type::Integer);}
            xywh {190 80 27 25} down_box DOWN_BOX labelsize 12 align 4
            code0 {o->value(synth->getRuntime().hideErrors);}
            code1 {if (synth->getIsLV2Plugin()) o->deactivate();}
            class Fl_Check_Button2
          }
          Fl_Check_Button showSplash {
            label {Show Splash Screen}
            callback {//
                        send_data(0, CONFIG::control::showSplash, o->value(), TOPLEVEL::type::Integer);}
            xywh {190 100 27 25} down_box DOWN_BOX labelsize 12 align 4
            code0 {o->value(synth->getRuntime().showSplash);}
            code1 {if (synth->getUniqueId() != 0) o->hide(); else if (synth->getIsLV2Plugin()) o->deactivate();}
            class Fl_Check_Button2
          }
          Fl_Check_Button logTimes {
            label {Log Load times}
            callback {//
                        send_data(0, CONFIG::control::logInstrumentLoadTimes, o->value(), TOPLEVEL::type::Integer);}
            xywh {190 120 27 25} down_box DOWN_BOX labelsize 12 align 4
            code0 {o->value(synth->getRuntime().showTimes);}
            class Fl_Check_Button2
          }
          Fl_Check_Button logXML {
            label {Log XML Headers}
            callback {//
                        send_data(0, CONFIG::control::logXMLheaders, o->value(), TOPLEVEL::type::Integer);}
            xywh {190 140 27 25} down_box DOWN_BOX labelsize 12 align 4
            code0 {o->value(synth->getRuntime().logXMLheaders);}
            code1 {if (synth->getIsLV2Plugin()) o->deactivate();}
            class Fl_Check_Button2
          }
          Fl_Check_Button saveAllXML {
            label {Include all data in XML files}
            callback {//
                        send_data(0, CONFIG::control::saveAllXMLdata, o->value(), TOPLEVEL::type::Integer);}
            xywh {190 160 27 25} down_box DOWN_BOX labelsize 12 align 4
            code0 {o->value(synth->getRuntime().xmlmax);}
            class Fl_Check_Button2
          }
          Fl_Check_Button enableGUI {
            label {* Enable GUI}
            callback {//
                        int tmp = o->value();
                        int doit = true;
                        if (tmp == 0)
                            doit = choice(synth, "", "Yes", "No", "Are you sure you want to disable the GUI?\\nThis can only be restored via the command line.") > 1;
                        if (doit)
                            send_data(0, CONFIG::control::enableGUI, o->value(), TOPLEVEL::type::Integer);
                        else
                            o->value(1);}
            tooltip {Enable starting with this graphical  interface} xywh {190 180 27 25} down_box DOWN_BOX labelsize 12 align 4
            code0 {o->value(synth->getRuntime().showGui);}
            code1 {if (synth->getUniqueId() != 0) o->hide(); else if (synth->getIsLV2Plugin()) o->deactivate();}
            class Fl_Check_Button2
          }
          Fl_Check_Button enableCLI {
            label {* Enable CLI}
            callback {//
                        send_data(0, CONFIG::control::enableCLI, o->value(), TOPLEVEL::type::Integer);}
            tooltip {Enable starting with interactive command line interface} xywh {190 200 27 25} down_box DOWN_BOX labelsize 12 align 4
            code0 {o->value(synth->getRuntime().showCli);}
            code1 {if (synth->getUniqueId() != 0) o->hide(); else if (synth->getIsLV2Plugin()) o->deactivate();}
            class Fl_Check_Button2
          }
          Fl_Check_Button enableAuto {
            label {Enable Auto Instance}
            callback {//
                        send_data(0, CONFIG::control::enableAutoInstance, o->value(), TOPLEVEL::type::Integer);}
            tooltip {Allow main instance to start all those open when last closed.} xywh {190 220 27 25} down_box DOWN_BOX labelsize 12 align 4
            code0 {o->value(synth->getRuntime().autoInstance);}
            code1 {if (synth->getUniqueId() != 0) o->hide(); else if (synth->getIsLV2Plugin()) o->deactivate();}
            class Fl_Check_Button2
          }
          Fl_Check_Button singleMaster {
            label {* Enable Single Master}
            callback {//
          send_data(0, CONFIG::control::enableSinglePath, o->value(), TOPLEVEL::type::Integer);}
            tooltip {Redirect new start from desktop to create new instance instead.} xywh {190 240 27 25} down_box DOWN_BOX labelsize 12 align 4 hide
            code0 {o->value(fetchData(0, CONFIG::control::enableSinglePath, TOPLEVEL::section::config));}
            class Fl_Check_Button2
          }
          Fl_Text_Display historyLocks {
            label {History Locks}
            xywh {278 110 50 1} box NO_BOX labelsize 12 align 129 textsize 12
          }
          Fl_Check_Button H_instrument {
            label Instrument
            callback {//
                       send_data(TOPLEVEL::action::lowPrio, CONFIG::control::historyLock, o->value(), TOPLEVEL::type::Integer, TOPLEVEL::section::config,TOPLEVEL::XML::Instrument);}
            xywh {240 120 27 25} down_box DOWN_BOX labelsize 12 align 8
            code0 {o->value(_SYS_::F2B(fetchData(0, CONFIG::control::historyLock, TOPLEVEL::section::config, TOPLEVEL::XML::Instrument, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, TOPLEVEL::action::lowPrio)));}
            class Fl_Check_Button2
          }
          Fl_Check_Button H_patchset {
            label {Patch Set}
            callback {//
                       send_data(TOPLEVEL::action::lowPrio, CONFIG::control::historyLock, o->value(), TOPLEVEL::type::Integer, TOPLEVEL::section::config,TOPLEVEL::XML::Patch);}
            xywh {240 140 27 25} down_box DOWN_BOX labelsize 12 align 8
            code0 {o->value(_SYS_::F2B(fetchData(0, CONFIG::control::historyLock, TOPLEVEL::section::config, TOPLEVEL::XML::Patch, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, TOPLEVEL::action::lowPrio)));}
            class Fl_Check_Button2
          }
          Fl_Check_Button H_scale {
            label Scale
            callback {//
                       send_data(TOPLEVEL::action::lowPrio, CONFIG::control::historyLock, o->value(), TOPLEVEL::type::Integer, TOPLEVEL::section::config,TOPLEVEL::XML::Scale);}
            xywh {240 160 27 25} down_box DOWN_BOX labelsize 12 align 8
            code0 {o->value(_SYS_::F2B(fetchData(0, CONFIG::control::historyLock, TOPLEVEL::section::config, TOPLEVEL::XML::Scale, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, TOPLEVEL::action::lowPrio)));}
            class Fl_Check_Button2
          }
          Fl_Check_Button H_state {
            label State
            callback {//
                       send_data(TOPLEVEL::action::lowPrio, CONFIG::control::historyLock, o->value(), TOPLEVEL::type::Integer, TOPLEVEL::section::config,TOPLEVEL::XML::State);}
            xywh {240 180 27 25} down_box DOWN_BOX labelsize 12 align 8
            code0 {o->value(_SYS_::F2B(fetchData(0, CONFIG::control::historyLock, TOPLEVEL::section::config, TOPLEVEL::XML::State, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, TOPLEVEL::action::lowPrio)));}
            class Fl_Check_Button2
          }
          Fl_Check_Button H_vector {
            label Vector
            callback {//
                       send_data(TOPLEVEL::action::lowPrio, CONFIG::control::historyLock, o->value(), TOPLEVEL::type::Integer, TOPLEVEL::section::config,TOPLEVEL::XML::Vector);}
            xywh {240 200 27 25} down_box DOWN_BOX labelsize 12 align 8
            code0 {o->value(_SYS_::F2B(fetchData(0, CONFIG::control::historyLock, TOPLEVEL::section::config, TOPLEVEL::XML::Vector, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, TOPLEVEL::action::lowPrio)));}
            class Fl_Check_Button2
          }
          Fl_Check_Button H_mlearn {
            label {Midi Learn}
            callback {//
                       send_data(TOPLEVEL::action::lowPrio, CONFIG::control::historyLock, o->value(), TOPLEVEL::type::Integer, TOPLEVEL::section::config,TOPLEVEL::XML::MLearn);}
            xywh {240 220 27 25} down_box DOWN_BOX labelsize 12 align 8
            code0 {o->value(_SYS_::F2B(fetchData(0, CONFIG::control::historyLock, TOPLEVEL::section::config, TOPLEVEL::XML::MLearn, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, TOPLEVEL::action::lowPrio)));}
            class Fl_Check_Button2
          }
          Fl_Box switchesNote {
            label {* Changing these settings requires a restart}
            xywh {38 276 306 17} labelfont 1 labelsize 12 labelcolor 38 align 128
          }
          Fl_Group {} {open
            tooltip {When locked new entries will not not be added or change the list order} xywh {230 70 130 180} box EMBOSSED_FRAME
          } {}
        }
        Fl_Group jackTab {
          xywh {5 25 385 277} box THIN_UP_BOX labelsize 12 hide
        } {
          Fl_Input jackSource {
            label {Jack MIDI Source}
            callback {//
                        string tmp = string(o->value());
                        send_data(TOPLEVEL::action::lowPrio, CONFIG::control::jackMidiSource, 0, TOPLEVEL::type::Integer, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, textMsgBuffer.push(tmp));}
            tooltip {Device Jack tries to connect to for input.} xywh {195 62 120 22} labelsize 12 textfont 1 textsize 12
            code0 {o->value(synth->getRuntime().jackMidiDevice.c_str());}
          }
          Fl_Check_Button jackMidi {
            label {Set as preferred MIDI}
            callback {//
                        send_data(TOPLEVEL::action::forceUpdate, CONFIG::control::jackPreferredMidi, o->value(), TOPLEVEL::type::Integer);}
            xywh {195 88 37 26} down_box DOWN_BOX labelsize 12 align 4
            code0 {if (synth->getRuntime().midiEngine == jack_midi) o->value(1);}
            class Fl_Check_Button2
          }
          Fl_Input jackServer {
            label {Jack Server}
            callback {//
                        string tmp = string(o->value());
                        send_data(TOPLEVEL::action::lowPrio, CONFIG::control::jackServer, 0, TOPLEVEL::type::Integer, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, textMsgBuffer.push(tmp));}
            tooltip {Name of the jack server to connect to - default, ...} xywh {195 182 120 22} labelsize 12 textfont 1 textsize 12
            code0 {o->value(synth->getRuntime().jackServer.c_str());}
          }
          Fl_Check_Button jackAudio {
            label {Set as preferred audio}
            callback {//
                        send_data(TOPLEVEL::action::forceUpdate, CONFIG::control::jackPreferredAudio, o->value(), TOPLEVEL::type::Integer);}
            xywh {195 209 37 26} down_box DOWN_BOX labelsize 12 align 4
            code0 {if (synth->getRuntime().audioEngine == jack_audio) o->value(1);}
            class Fl_Check_Button2
          }
          Fl_Check_Button connectJackAudio {
            label {Autoconnect audio}
            callback {//
                        send_data(0, CONFIG::control::jackAutoConnectAudio, o->value(), TOPLEVEL::type::Integer);}
            xywh {195 233 37 26} down_box DOWN_BOX labelsize 12 align 4
            code0 {o->value(synth->getRuntime().connectJackaudio);}
            class Fl_Check_Button2
          }
          Fl_Box jackNote {
            label {Changing settings requires a restart}
            xywh {60 276 267 17} labelfont 1 labelsize 12 labelcolor 38 align 128
          }
        }
        Fl_Group alsaTab {
          xywh {5 25 384 277} box THIN_UP_BOX labelsize 12 hide
        } {
          Fl_Choice alsaType {
            label {Alsa Connection Type}
            callback {if (o->value() == 0) // fixed
    alsaSource->activate();
else
     alsaSource->deactivate();


send_data (0, CONFIG::control::alsaMidiType, o->value(), TOPLEVEL::type::Integer, TOPLEVEL::section::config);}
            xywh {195 45 120 22} box DOWN_BOX down_box BORDER_BOX labelsize 12 textfont 1 textsize 12
            code0 {o->add("Fixed");o->add("Search");o->add("External");}
          } {}
          Fl_Input alsaSource {
            label {Alsa MIDI Source}
            callback {//
                        string tmp = string(o->value());
                        send_data(TOPLEVEL::action::lowPrio, CONFIG::control::alsaMidiSource, 0, TOPLEVEL::type::Integer, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, textMsgBuffer.push(tmp));}
            tooltip {Device Alsa tries to connect to for input.} xywh {195 80 120 22} labelsize 12 textfont 1 textsize 12
            code0 {o->value(synth->getRuntime().alsaMidiDevice.c_str());}
          }
          Fl_Check_Button alsaMidi {
            label {Set as preferred MIDI}
            callback {//
                        send_data(TOPLEVEL::action::forceUpdate, CONFIG::control::alsaPreferredMidi, o->value(), TOPLEVEL::type::Integer);}
            xywh {195 110 37 26} down_box DOWN_BOX labelsize 12 align 4
            code0 {if (synth->getRuntime().midiEngine == alsa_midi) o->value(1);}
            class Fl_Check_Button2
          }
          Fl_Input alsaDevice {
            label {Alsa Audio Device}
            callback {//
                        string tmp = string(o->value());
                        send_data(TOPLEVEL::action::lowPrio, CONFIG::control::alsaAudioDevice, 0, TOPLEVEL::type::Integer, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, textMsgBuffer.push(tmp));}
            tooltip {Alsa audio device - default, hw:0, ...} xywh {195 143 120 22} labelsize 12 textfont 1 textsize 12
            code0 {o->value(synth->getRuntime().alsaAudioDevice.c_str());}
          }
          Fl_Choice alsaSamplerate {
            label {Sample Rate}
            callback {//
    send_data(0, CONFIG::control::alsaSampleRate, o->value(), TOPLEVEL::type::Integer);}
            xywh {195 199 80 22} down_box BORDER_BOX labelsize 12 textfont 1 textsize 12
            code0 {o->add("192000");o->add("96000");o->add("48000");o->add("44100");}
            code1 {o->value(convertSrate(synth->getRuntime().Samplerate));}
          } {}
          Fl_Check_Button alsaAudio {
            label {Set as preferred audio}
            callback {//
                        send_data(TOPLEVEL::action::forceUpdate, CONFIG::control::alsaPreferredAudio, o->value(), TOPLEVEL::type::Integer);}
            xywh {195 169 37 26} down_box DOWN_BOX labelsize 12 align 4
            code0 {if (synth->getRuntime().audioEngine == alsa_audio) o->value(1);}
            class Fl_Check_Button2
          }
          Fl_Box alsaNote {
            label {Changing settings requires a restart}
            xywh {60 276 267 17} labelfont 1 labelsize 12 labelcolor 38 align 128
          }
        }
        Fl_Group midiTab {
          callback {//
                        EPCvalue = synth->getRuntime().midi_upper_voice_C;
                        if (EPCvalue >= 128)
                        {
                            EPCspinner->value(110);
                            EPCspinner->deactivate();
                        }
                        else
                        {
                            EPCspinner->value(EPCvalue);
                            EPCspinner->activate();
                        }
                        /*BankRootvalue = synth->getRuntime().midi_bank_root;
                        if (BankRootvalue >= 128)
                        {
                            BankRoot->value(0);
                            BankRoot->deactivate();
                        }
                        else
                        {
                            BankRoot->value(BankRootvalue);
                            BankRoot->activate();
                        }*/}
          tooltip {MIDI CC preferences} xywh {5 25 381 275} box THIN_UP_BOX labelsize 12 hide
          code0 {EPCvalue = synth->getRuntime().midi_upper_voice_C;}
          code1 {BankRootvalue = synth->getRuntime().midi_bank_root;}
        } {
          Fl_Choice bankrootchange {
            label {Bank Root Change}
            callback {//
                        int candidate;
                        switch (o->value())
                        {
                            case 0:
                                candidate = 32;
                                break;
                            case 1:
                                candidate = 0;
                                break;
                            default:
                                candidate = 128;
                                break;
                        }
                        string name = testCC(candidate, CONFIG::control::bankRootCC);
                        if (!name.empty())
                        {
                            o->value(oldBank);
                            o->redraw();
                            switch(oldBank)
                            {
                                case 0:
                                    candidate = 32;
                                    break;
                                case 1:
                                    candidate = 0;
                                    break;
                                default:
                                    candidate = 128;
                                    break;
                            }
                            alert(synth, "In use for " + name);
                        }
                        send_data(0, CONFIG::control::bankRootCC, candidate, TOPLEVEL::type::Integer);}
            tooltip {CC0 = msb, CC32 = lsb} xywh {234 57 53 18} down_box BORDER_BOX labelsize 12 align 132 textfont 1 textsize 12
            code0 {o->add("LSB");o->add("MSB");o->add("Off");}
            code1 {int bankRoot = synth->getRuntime().midi_bank_root;}
            code2 {if (bankRoot == 32) o->value(0); else if (bankRoot == 0) o->value(1); else o->value(2);}
            code3 {oldBank = o->value();}
          } {}
          Fl_Choice bankchange {
            label {Bank Change}
            callback {//
                        int candidate;
                        switch (o->value())
                        {
                            case 0:
                                candidate = 32;
                                break;
                            case 1:
                                candidate = 0;
                                break;
                            default:
                                candidate = 128;
                                break;
                        }
                        string name = testCC(candidate, CONFIG::control::bankCC);
                        if (!name.empty())
                        {
                            o->value(oldBank);
                            o->redraw();
                            switch(oldBank)
                            {
                                case 0:
                                    candidate = 32;
                                    break;
                                case 1:
                                    candidate = 0;
                                    break;
                                default:
                                    candidate = 128;
                                    break;
                            }
                            alert(synth, "In use for " + name);
                        }
                        send_data(0, CONFIG::control::bankCC, candidate, TOPLEVEL::type::Integer);}
            tooltip {CC0 = msb, CC32 = lsb} xywh {235 80 53 18} down_box BORDER_BOX labelsize 12 align 132 textfont 1 textsize 12
            code0 {o->add("LSB");o->add("MSB");o->add("Off");}
            code1 {if (synth->getRuntime().midi_bank_C == 32) o->value(0); else if (synth->getRuntime().midi_bank_C == 0) o->value(1); else o->value(2);}
            code2 {oldBank = o->value();}
          } {}
          Fl_Check_Button progenable {
            label {Enable Program Change}
            callback {//
                        send_data(0, CONFIG::control::enableProgramChange, o->value(), TOPLEVEL::type::Integer);}
            tooltip {MIDI program change enable/disable} xywh {234 110 18 18} down_box DOWN_BOX value 1 labelsize 12 align 4
            code0 {o->value(synth->getRuntime().EnableProgChange);}
            class Fl_Check_Button2
          }
          Fl_Check_Button progpartenable {
            label {Enable Part On Program Change}
            callback {//
                        send_data(0, CONFIG::control::instChangeEnablesPart, o->value(), TOPLEVEL::type::Integer);}
            tooltip {Part enabled if MIDI program changed} xywh {234 130 18 18} down_box DOWN_BOX labelsize 12 align 4
            code0 {o->value(synth->getRuntime().enable_part_on_voice_load);}
            class Fl_Check_Button2
          }
          Fl_Spinner EPCspinner {
            label {Extended Program Change CC}
            callback {//
                        Epend->show();}
            xywh {235 180 50 18} labelsize 12 minimum 0 maximum 127 value 110 textfont 1 textsize 12
            code0 {EPCvalue = synth->getRuntime().midi_upper_voice_C;}
            code1 {if (EPCvalue < 128) o->value(EPCvalue); else o->value(110);}
            class WidgetSpinner
          }
          Fl_Button Epend {
            label Pending
            callback {//
                        int candidate = EPCspinner->value();
                        if (candidate == EPCvalue)
                        {
                            o->hide();
                            return;
                        }
                        string name = testCC(candidate, CONFIG::control::extendedProgramChangeCC);
                        if (!name.empty())
                        {
                            alert(synth, "In use for " + name);
                            if (EPCvalue < 128)
                            {
                                EPCspinner->value(EPCvalue);
                                EPCspinner->redraw();
                            }
                            return;
                        }
                        EPCvalue = candidate;
                        o->hide();
                        send_data(0, CONFIG::control::extendedProgramChangeCC, EPCvalue, TOPLEVEL::type::Integer);}
            tooltip {Click to set} xywh {300 180 70 20} box PLASTIC_UP_BOX color 90 labelsize 12 hide
          }
          Fl_Check_Button Epcheck {
            label {Enable Extended Program Change}
            callback {// for some weird reason this *must* be the last item in the group
                        if (o->value() == 0)
                        {
                            EPCspinner->value(110);
                            EPCspinner->deactivate();
                            Epend->hide();
                            send_data(0, CONFIG::control::extendedProgramChangeCC, 128, TOPLEVEL::type::Integer);
                        }
                        else
                        {
                            EPCspinner->activate();
                            Epend->show();
                            EPCspinner->value(110);
                            EPCvalue = 128;
                        }
                        EPCspinner->redraw();}
            xywh {234 160 18 18} down_box DOWN_BOX labelsize 12 align 4
            code0 {o->value((synth->getRuntime().midi_upper_voice_C < 128));}
            code1 {if (o->value() == 0) EPCspinner->deactivate();}
            class Fl_Check_Button2
          }
          Fl_Check_Button enableNRPN {
            label {Enable Incoming NRPNs}
            callback {//
                        send_data(0, CONFIG::control::enableNRPNs, o->value(), TOPLEVEL::type::Integer);}
            xywh {234 210 18 18} down_box DOWN_BOX labelsize 12 align 4
            code0 {o->value(synth->getRuntime().enable_NRPN);}
            class Fl_Check_Button2
          }
          Fl_Check_Button ignoreReset {
            label {Ignore Reset all CCs}
            callback {//
                        send_data(0, CONFIG::control::ignoreResetAllCCs, o->value(), TOPLEVEL::type::Integer);}
            xywh {234 230 18 18} down_box DOWN_BOX labelsize 12 align 4
            code0 {o->value(synth->getRuntime().ignoreResetCCs);}
            class Fl_Check_Button2
          }
          Fl_Check_Button midiMon {
            label {Log Incoming Events}
            callback {//
                        send_data(0, CONFIG::control::logIncomingCCs, o->value(), TOPLEVEL::type::Integer);}
            xywh {234 250 18 18} down_box DOWN_BOX labelsize 12 align 4
            code0 {o->value(synth->getRuntime().monitorCCin);}
            class Fl_Check_Button2
          }
          Fl_Check_Button midiLearned {
            label {Show Learn Editor}
            callback {//
                        send_data(0, CONFIG::control::showLearnEditor, o->value(), TOPLEVEL::type::Integer);}
            tooltip {Open the MIDI learn window for editing when a new CC has been learned} xywh {234 270 18 18} down_box DOWN_BOX labelsize 12 align 4
            code0 {o->value(synth->getRuntime().showLearnedCC);}
            class Fl_Check_Button2
          }
        }
      }
      Fl_Button close {
        label {Close Unsaved}
        callback {//
         configwindow->hide();
         configSeen = false;
         saveWin(synth, configwindow->w(), configwindow->h(),configwindow->x(), configwindow->y(), false, "Config")}
        xywh {275 305 105 20} box THIN_UP_BOX labelsize 12
      }
      Fl_Button save {
        label {Save and Close}
        callback {//
         send_data(TOPLEVEL::action::lowPrio | TOPLEVEL::action::forceUpdate, CONFIG::control::saveCurrentConfig, o->value(), TOPLEVEL::type::Integer, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, textMsgBuffer.push("DUMMY"));
         configwindow->hide();
         configSeen = false;
         saveWin(synth, configwindow->w(), configwindow->h(),configwindow->x(), configwindow->y(), false, "Config")}
        xywh {155 305 105 20} box THIN_UP_BOX labelsize 12
      }
      Fl_Box patch1 {
        xywh {6 24 89 3} box FLAT_BOX
      }
      Fl_Box patch2 {
        xywh {98 24 65 3} box FLAT_BOX
      }
      Fl_Box patch3 {
        xywh {166 24 37 3} box FLAT_BOX
      }
      Fl_Box patch4 {
        xywh {206 24 37 3} box FLAT_BOX
      }
      Fl_Box patch5 {
        xywh {246 24 57 3} box FLAT_BOX
      }
    }
    Fl_Window presets {
      label Presets
      callback {pClose->do_callback();}
      xywh {5 437 460 295} type Double hide resizable
      code0 {o->copy_label(synth->makeUniqueName("Presets").c_str());}
      code1 {preDW = o->w();preDH = o->h();}
      code2 {o->size_range(preDW, preDH, 0, 0, 0, 0, 1);}
    } {
      Fl_Browser presetbrowse {
        callback {//
                    activatebutton_presetdir(o->value() != 0);}
        tooltip {Click on an entry to make it the readable one.} xywh {5 5 450 200} type Hold labelsize 12 textsize 12
      }
      Fl_Button addpreset {
        label {Add preset directory...}
        callback {//
                    string dirname = setfiler(synth,"Path for Presets dir", "", false, TOPLEVEL::XML::Dir);
                    if (dirname.length() < 3)
                        return;

                    send_data(TOPLEVEL::action::lowPrio | TOPLEVEL::action::forceUpdate,CONFIG::control::addPresetRootDir, 0, TOPLEVEL::type::Integer, UNUSED, UNUSED, UNUSED, UNUSED, UNUSED, textMsgBuffer.push(dirname));
                    if (presetbrowse->size() >= MAX_PRESET_DIRS)
                        o->deactivate();}
        xywh {10 220 85 35} box THIN_UP_BOX labelsize 12 align 128
      }
      Fl_Button removepresetbutton {
        label {Remove preset dir...}
        callback {//
                    if (presetbrowse->value() != 0)
                        send_data(TOPLEVEL::action::lowPrio | TOPLEVEL::action::forceUpdate,CONFIG::control::removePresetRootDir, presetbrowse->value() - 1, TOPLEVEL::type::Integer);}
        xywh {115 220 85 35} box THIN_UP_BOX labelsize 12 align 128
        code0 {o->deactivate();}
      }
      Fl_Button makedefaultpresetbutton {
        label {Make Current}
        callback {//
                    send_data(TOPLEVEL::action::lowPrio | TOPLEVEL::action::forceUpdate,CONFIG::control::currentPresetRoot, presetbrowse->value() - 1, TOPLEVEL::type::Integer);}
        xywh {220 220 85 35} box THIN_UP_BOX labelsize 12 align 128
        code0 {o->deactivate();}
      }
      Fl_Button pSave {
        label {Save and Close}
        callback {//
                    synth->getRuntime().saveConfig();
                    presets->hide();}
        xywh {208 268 118 20} box THIN_UP_BOX labelsize 12
      }
      Fl_Button pClose {
        label {Close Unsaved}
        callback {//
        saveWin(synth, presets->w(), presets->h(), presets->x(), presets->y(), false, "Config-presets");
        presetsSeen = false;
        presets->hide();}
        xywh {334 268 118 20} box THIN_UP_BOX labelsize 12
      }
    }
  }
  Function {send_data(int action, int control, float value, int type, int part = UNUSED, int kit = UNUSED, int engine = UNUSED, int insert = UNUSED, int par = UNUSED, int miscmsg = UNUSED)} {} {
    code {//
            type |= TOPLEVEL::type::Write;
            if (part == UNUSED)
                part = TOPLEVEL::section::config;;
            collect_data(synth, value, action, type, control, part, kit, engine, insert, par, UNUSED, miscmsg);} {}
  }
  Function {fetchData(float value, int control, int part, int kititem = UNUSED, int engine = UNUSED, int insert = UNUSED, int parameter = UNUSED, int offset = UNUSED, int miscmsg = UNUSED, int request = UNUSED)} {return_type float
  } {
    code {//
        return collect_readData(synth, value, control, part, kititem, engine, insert, parameter, offset, miscmsg, request);} {}
  }
  Function {returns_update(CommandBlock *getData)} {} {
    code {//
            int value_int = lrint(getData->data.value);
            bool wasFromHere = ((getData->data.source & TOPLEVEL::action::noAction) == TOPLEVEL::action::fromGUI);
            unsigned char control = getData->data.control;
            unsigned char kititem = getData->data.kit;
            unsigned char miscmsg = getData->data.miscmsg;
            string msg = textMsgBuffer.fetch(miscmsg);

            bool value_bool = value_int > 0;
            int tmp;
            string name;
            switch (control)
            {
                case CONFIG::control::oscillatorSize:
                    tmp = 0;
                    while (value_int > 256)
                    {
                        value_int = value_int >> 1;
                        ++ tmp; // count the bits for switch number
                    }
                    osc_size->value(tmp);
                    break;
                case 1:
                    tmp = CONFIG::control::bufferSize;
                    while (value_int > 16)
                    {
                        value_int = value_int >> 1;
                        ++ tmp; // count the bits for switch number
                    }
                    buff_size->value(tmp - 1);
                    break;
                case CONFIG::control::padSynthInterpolation:
                    pad_interpol->value(value_int);
                    break;
                case CONFIG::control::virtualKeyboardLayout:
                    v_keyboard->value(value_int);
                    break;
                case CONFIG::control::XMLcompressionLevel:
                    compression->value(value_int);
                    break;
                case CONFIG::control::reportsDestination:
                    if(!wasFromHere)
                        reports->value(value_bool);
                    synth->getGuiMaster()->setLogging(value_bool);
                    if (value_bool)
                        logText->activate();
                    else
                        logText->deactivate();;
                    break;
                case CONFIG::control::logTextSize:
                    logText->value(value_int);
                    //synth->getGuiMaster()->yoshiLog->logConsole->setLogText(value_int);
                    break;
                case CONFIG::control::savedInstrumentFormat:
                    instrument->value(value_int - 1);
                    break;

                case CONFIG::control::defaultStateStart:
                    setDefaultState->value(value_bool);
                    break;
                case CONFIG::control::hideNonFatalErrors:
                    nonFatal->value(value_bool);
                    break;
                case CONFIG::control::showSplash:
                    showSplash->value(value_bool);
                    break;
                case CONFIG::control::logInstrumentLoadTimes:
                    logTimes->value(value_bool);
                    break;
                case CONFIG::control::logXMLheaders:
                    logXML->value(value_bool);
                    break;
                case CONFIG::control::saveAllXMLdata:
                    saveAllXML->value(value_bool);
                    break;
                case CONFIG::control::enableGUI:
                    enableGUI->value(value_bool);
                    break;
                case CONFIG::control::enableCLI:
                    enableCLI->value(value_bool);
                    break;
                case CONFIG::control::enableAutoInstance:
                    enableAuto->value(value_bool);
                    break;
                case CONFIG::control::enableSinglePath:
                    singleMaster->value(value_bool);
                    break;
                case CONFIG::control::enableHighlight:
                    bankHighlight->value(value_bool);
                    break;

                case CONFIG::control::historyLock:
                    if (!wasFromHere)
                    {
                        switch (kititem)
                        {
                            case TOPLEVEL::XML::Instrument:
                                H_instrument->value(value_int);
                                break;
                            case TOPLEVEL::XML::Patch:
                                H_patchset->value(value_int);
                                break;
                            case TOPLEVEL::XML::Scale:
                                H_scale->value(value_int);
                                break;
                            case TOPLEVEL::XML::State:
                                H_state->value(value_int);
                                break;
                            case TOPLEVEL::XML::Vector:
                                H_vector->value(value_int);
                                break;
                            case TOPLEVEL::XML::MLearn:
                                H_mlearn->value(value_int);
                                break;
                            default:
                                break;
                        }
                    }
                    break;

                case CONFIG::control::jackMidiSource:
                    jackSource->value(msg.c_str());
                    break;
                case CONFIG::control::jackPreferredMidi:
                    jackMidi->value(value_bool);
                    alsaMidi->value(!value_bool);
                    break;
                case CONFIG::control::jackServer:
                    jackServer->value(msg.c_str());
                    break;
                case CONFIG::control::jackPreferredAudio:
                    jackAudio->value(value_bool);
                    alsaAudio->value(!value_bool);
                    break;
                case CONFIG::control::jackAutoConnectAudio:
                    connectJackAudio->value(value_bool);
                    break;

                case CONFIG::control::alsaMidiSource:
                    alsaSource->value(msg.c_str());
                    break;
                case CONFIG::control::alsaPreferredMidi:
                    alsaMidi->value(value_bool);
                    jackMidi->value(!value_bool);
                    break;
                case CONFIG::control::alsaMidiType:
                    alsaType->value(value_int);
                    if (value_int == 0) // fixed
                        alsaSource->activate();
                    else
                        alsaSource->deactivate();
                    break;
                case CONFIG::control::alsaAudioDevice:
                    alsaDevice->value(msg.c_str());
                    break;
                case CONFIG::control::alsaPreferredAudio:
                    alsaAudio->value(value_bool);
                    jackAudio->value(!value_bool);
                    break;
                case CONFIG::control::alsaSampleRate:
                    alsaSamplerate->value(convertSrate(value_int));
                    break;
                case CONFIG::control::addPresetRootDir:
                case CONFIG::control::removePresetRootDir:
                case CONFIG::control::currentPresetRoot:
                {
                    if (msg.find("FAILED") == 1)
                    {
                        if (wasFromHere)
                            alert(synth, msg);
                    }
                    else
                        readpresetcfg();
                    break;
                }
                case CONFIG::control::bankRootCC:
                    switch (value_int)
                    {
                        case 0:
                            bankrootchange->value(1);
                            break;
                        case 32:
                            bankrootchange->value(0);
                            break;
                        default:
                            bankrootchange->value(2);
                            break;
                    }
                    break;

                case CONFIG::control::bankCC:
                    switch (value_int)
                    {
                        case 0:
                            bankchange->value(1);
                            break;
                        case 32:
                            bankchange->value(0);
                            break;
                        default:
                            bankchange->value(2);
                            break;
                    }
                    break;
                case CONFIG::control::enableProgramChange:
                    progenable->value(value_bool);
                    break;
                case CONFIG::control::instChangeEnablesPart:
                    progpartenable->value(value_bool);
                    break;
                case CONFIG::control::extendedProgramChangeCC:
                    if (value_int > 119)
                    {
                        EPCspinner->value(110);
                        EPCspinner->deactivate();
                        Epcheck->value(0);
                    }
                    else
                    {
                        EPCspinner->value(value_int);
                        EPCspinner->activate();
                        Epcheck->value(1);
                    }
                    break;
                case CONFIG::control::ignoreResetAllCCs:
                    ignoreReset->value(value_bool);
                    break;
                case CONFIG::control::logIncomingCCs:
                    midiMon->value(value_bool);
                    break;
                case CONFIG::control::showLearnEditor:
                    midiLearned->value(value_bool);
                    break;
                case CONFIG::control::enableNRPNs:
                    enableNRPN->value(value_bool);
                    break;

                case CONFIG::control::saveCurrentConfig:
                    name = msg;
                    if (wasFromHere && name.find("FAILED") == 1)
                        alert(synth, name);
                    break;
    }} {}
  }
  Function {ConfigUI(SynthEngine *_synth)} {} {
    code {//
            synth = _synth;
            make_window();
            readpresetcfg();
            configSeen = false;
            presetsSeen = false;
            selectedRootID = -1;
            Tab1->do_callback();} {}
  }
  Function {~ConfigUI()} {} {
    code {//
        if (presetsSeen)
            saveWin(synth, presets->w(), presets->h(), presets->x(), presets->y(), true, "Config-presets");
        presets->hide();
        delete presets;

        if (configSeen)
            saveWin(synth, configwindow->w(), configwindow->h(),configwindow->x(), configwindow->y(), true, "Config");
        configwindow->hide();
        delete configwindow;} {}
  }
  Function {activatebutton_presetdir(bool active)} {} {
    code {//
            if (active)
            {
                removepresetbutton->activate();
                makedefaultpresetbutton->activate();
            }
            else
            {
                removepresetbutton->deactivate();
                makedefaultpresetbutton->deactivate();
            }} {}
  }
  Function {recoverID()} {return_type int
  } {
    code {//
            if (selectedRootID >= 0)
            {
                return selectedRootID;
            }
            return 0;} {}
  }
  Function {readpresetcfg()} {} {
    code {//
            presetbrowse->clear();
            for (int i = 0; i < MAX_PRESET_DIRS; ++i)
                if (firstSynth->getRuntime().presetsDirlist[i].size())
                {
                    string name;
                    if (i == synth->getRuntime().currentPreset)
                        name = "* ";
                    else
                        name = "  ";
                    name += firstSynth->getRuntime().presetsDirlist[i];
                    presetbrowse->add(name.c_str());
                }} {}
  }
  Function {convertSrate(int source)} {return_type int
  } {
    code {//
    int result = 2;
    switch (source)
    {
        case 0:
            result = 192000;
            break;
        case 1:
            result = 96000;
            break;
        case 2:
            result = 48000;
            break;
        case 3:
            result = 44100;
            break;
        case 192000:
            result = 0;
            break;
        case 96000:
            result = 1;
            break;
        case 48000:
            result = 2;
            break;
        case 44100:
            result = 3;
            break;
    }
    return result;} {}
  }
  Function {update_config(int tabnumber)} {} {
    code {//
            int tmp;
            switch (tabnumber)
            {
                case 1 : // Main
                    osc_size->value( (int)(logf(synth->getRuntime().Oscilsize / 256.0f - 1.0f) / logf(2.0f)) + 1);
                    buff_size->value( (int)(logf(synth->getRuntime().Buffersize / 16.0f - 1.0f) / logf(2.0f)) + 1);
                    pad_interpol->value(synth->getRuntime().Interpolation);
                    v_keyboard->value(synth->getRuntime().VirKeybLayout);
                    compression->value(synth->getRuntime().GzipCompression);
                    reports->value(synth->getRuntime().toConsole);
                    instrument->value(synth->getRuntime().instrumentFormat - 1);
                    break;

                case 2 : // Jack
                    jackSource->value(synth->getRuntime().jackMidiDevice.c_str());
                    if (synth->getRuntime().midiEngine == jack_midi)
                    {
                        jackMidi->value(1);
                        alsaMidi->value(0);
                    }
                    jackServer->value(synth->getRuntime().jackServer.c_str());
                    if (synth->getRuntime().audioEngine == jack_audio)
                    {
                        jackAudio->value(1);
                        alsaAudio->value(0);
                    }
                    break;

                case 3 : // Alsa
                    {
                        alsaSource->value(synth->getRuntime().alsaMidiDevice.c_str());
                        if (synth->getRuntime().midiEngine == alsa_midi)
                        {
                            alsaMidi->value(1);
                            jackMidi->value(0);
                        }
                        alsaDevice->value(synth->getRuntime().alsaAudioDevice.c_str());
                        if (synth->getRuntime().audioEngine == alsa_audio)
                        {
                            alsaAudio->value(1);
                            jackAudio->value(0);
                        }
                        alsaSamplerate->value(convertSrate(synth->getRuntime().Samplerate));
                    }
                    break;

                case 4 : // MIDI
                    switch (synth->getRuntime().midi_bank_root)
                    {
                        case 32:
                            bankrootchange->value(0);
                            break;
                        case 0:
                            bankrootchange->value(1);
                            break;
                        default:
                            bankrootchange->value(2);
                            break;
                    }

                    switch (synth->getRuntime().midi_bank_C)
                    {
                        case 32:
                            bankchange->value(0);
                            break;
                        case 0:
                            bankchange->value(1);
                            break;
                        default:
                            bankchange->value(2);
                            break;
                    }
                    progenable->value(synth->getRuntime().EnableProgChange);
                    progpartenable->value(synth->getRuntime().enable_part_on_voice_load);

                    tmp = synth->getRuntime().midi_upper_voice_C;
                    if (tmp == 128)
                    {
                        EPCspinner->value(110);
                        EPCspinner->deactivate();
                        Epcheck->value(0);
                    }
                    else
                    {
                        EPCspinner->value(tmp);
                        EPCspinner->activate();
                        Epcheck->value(1);
                    }
                    Epend->hide();
                    enableNRPN->value(synth->getRuntime().enable_NRPN);
                    ignoreReset->value(synth->getRuntime().ignoreResetCCs);
                    midiMon->value(synth->getRuntime().monitorCCin);
                    midiLearned->value(synth->getRuntime().showLearnedCC);
                    break;

                case 5 : // Switches
                    setDefaultState->value(synth->getRuntime().loadDefaultState > 0);
                    nonFatal->value(synth->getRuntime().hideErrors);
                    showSplash->value(synth->getRuntime().showSplash);
                    logTimes->value(synth->getRuntime().showTimes);
                    logXML->value(synth->getRuntime().logXMLheaders);
                    saveAllXML->value(synth->getRuntime().xmlmax);
                    enableGUI->value(synth->getRuntime().showGui);
                    enableCLI->value(synth->getRuntime().showCli);
                    break;
    }} {}
  }
  Function {Show(SynthEngine *synth)} {} {
    code {//
                    if (synth->getIsLV2Plugin() == false && synth->getUniqueId() == 0)
                        singleMaster->show();
                    int tmp = fetchData (0, CONFIG::control::alsaMidiType,TOPLEVEL::section::config);
                    alsaType->value(tmp);
                    if (tmp == 0)
                        alsaSource->activate();
                    else
                        alsaSource->deactivate();

                    int fetchW, fetchH, fetchX, fetchY, fetchO;
                    checkSane(fetchX, fetchY, fetchW, fetchH, confDW, confDH);
                    loadWin(synth, fetchW, fetchH, fetchX, fetchY, fetchO, "Config");
                    if (fetchW < confDW || fetchH < confDH)
                    {
                        fetchW = confDW;
                        fetchH = confDH;
                    }
                    configwindow->resize(fetchX, fetchY, fetchW, fetchH);
                    lastconfigW = 0;
                    configSeen = true;
                    configwindow->show();} {}
  }
  Function {Showpresets(SynthEngine *synth)} {} {
    code {//
                int fetchW, fetchH, fetchX, fetchY, fetchO;
                loadWin(synth, fetchW, fetchH, fetchX, fetchY, fetchO, "Config-presets");

                if (fetchW < preDW || fetchH < preDH)
                {
                    fetchW = preDW;
                    fetchH = preDH;
                }
                presets->resize(fetchX, fetchY, fetchW, fetchH);
                presets->resizable();
                lastpresetW = 0;
                presetsSeen = true;
                presets->show();} {}
  }
  Function {configRtext()} {} {
    code {//
    if (lastconfigW == configwindow->w())
        return;
    lastconfigW = configwindow->w();

    float dScale =  configwindow->w() / confDW;

    int size = int(dScale * 12);

    Tab1->labelsize(size);
    osc_size->labelsize(size);
        osc_size->textsize(size);

    buff_size->labelsize(size);
        buff_size->textsize(size);

    pad_interpol->labelsize(size);
        pad_interpol->textsize(size);

    v_keyboard->labelsize(size);
        v_keyboard->textsize(size);

    compression->labelsize(size);
        compression->textsize(size);
    reports->labelsize(size);
        reports->textsize(size);
    logText->labelsize(size);
        logText->textsize(size);

    instrument->labelsize(size);
        instrument->textsize(size);

    PanelLayout->labelsize(size);
        PanelLayout->textsize(size);

    settingsNote->labelsize(size);

//
    Tab2->labelsize(size);
    bankHighlight->labelsize(size);
    setDefaultState->labelsize(size);
    nonFatal->labelsize(size);
    showSplash->labelsize(size);
    logTimes->labelsize(size);
    logXML->labelsize(size);
    saveAllXML->labelsize(size);
    enableGUI->labelsize(size);
    enableCLI->labelsize(size);
    enableAuto->labelsize(size);
    singleMaster->labelsize(size);

    historyLocks->labelsize(size);
    H_instrument->labelsize(size);
    H_patchset->labelsize(size);
    H_scale->labelsize(size);
    H_state->labelsize(size);
    H_vector->labelsize(size);
    H_mlearn->labelsize(size);

    switchesNote->labelsize(size);
//
    Tab3->labelsize(size);
    jackSource->labelsize(size);
        jackSource->textsize(size);
    jackMidi->labelsize(size);
    jackServer->labelsize(size);
        jackServer->textsize(size);
    jackAudio->labelsize(size);
    connectJackAudio->labelsize(size);

    jackNote->labelsize(size);
//
    Tab4->labelsize(size);
    alsaType->labelsize(size);
        alsaType->textsize(size);

    alsaSource->labelsize(size);
        alsaSource->textsize(size);
    alsaMidi->labelsize(size);
    alsaDevice->labelsize(size);
    alsaDevice->textsize(size);

    alsaAudio->labelsize(size);
    alsaSamplerate->labelsize(size);
        alsaSamplerate->textsize(size);

    alsaNote->labelsize(size);

//
    Tab5->labelsize(size);
    bankrootchange->labelsize(size);
        bankrootchange->textsize(size);

    bankchange->labelsize(size);
        bankchange->textsize(size);

    progenable->labelsize(size);
    progpartenable->labelsize(size);
    EPCspinner->labelsize(size);
        EPCspinner->textsize(size);
    Epend->labelsize(size);
    Epcheck->labelsize(size);
    enableNRPN->labelsize(size);
    ignoreReset->labelsize(size);
    midiMon->labelsize(size);
    midiLearned->labelsize(size);
//
    close->labelsize(size);
    save->labelsize(size);

    configwindow->redraw();} {}
  }
  Function {presetsRtext()} {} {
    code {//
    if (lastpresetW == presets->w())
        return;

    lastpresetW = presets->w();

    float dScale = presets->w() / preDW;

    int size = int(12 * dScale);

    addpreset->labelsize(size);
    removepresetbutton->labelsize(size);
    makedefaultpresetbutton->labelsize(size);
    pSave->labelsize(size);
    pClose->labelsize(size);

    presetbrowse->textsize(size);

    presets->redraw();} {}
  }
  Function {testCC(int value, int control)} {return_type string
  } {
    code {//
            CommandBlock getData;
            getData.data.value = value;
            getData.data.control = control;
            getData.data.part = 248;
            synth->interchange.testLimits(&getData);
            return textMsgBuffer.fetch(getData.data.miscmsg);} {}
  }
  decl {SynthEngine *synth;} {private local
  }
  decl {long selectedRootID;} {private local
  }
  decl {int EPCvalue;} {private local
  }
  decl {int BankRootvalue;} {private local
  }
  decl {int oldBank;} {private local
  }
  decl {int oldrootID;} {private local
  }
  decl {float confDW;} {private local
  }
  decl {float confDH;} {private local
  }
  decl {float preDW;} {private local
  }
  decl {float preDH;} {private local
  }
  decl {int lastconfigW;} {private local
  }
  decl {int lastpresetW;} {private local
  }
  decl {bool configSeen;} {private local
  }
  decl {bool presetsSeen;} {private local
  }
}
