1# data file for the Fltk User Interface Designer (fluid)
2version 1.0305
3header_name {.h}
4code_name {.cc}
5comment {ADNoteUI.h} {not_in_source in_header
6}
7
8comment {ADNoteUI.cc} {in_source not_in_header
9}
10
11comment {Original ZynAddSubFX author Nasca Octavian Paul
12Copyright (C) 2002-2005 Nasca Octavian Paul
13Copyright 2009-2011, Alan Calvert
14Copyright 2014-2021, Will Godfrey
15
16This file is part of yoshimi, which is free software: you can redistribute
17it and/or modify it under the terms of the GNU Library General Public
18License as published by the Free Software Foundation; either version 2 of
19the License, or (at your option) any later version.
20
21yoshimi is distributed in the hope that it will be useful, but WITHOUT ANY
22WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
23FOR A PARTICULAR PURPOSE.   See the GNU General Public License (version 2 or
24later) for more details.
25
26You should have received a copy of the GNU General Public License along with
27yoshimi; if not, write to the Free Software Foundation, Inc., 51 Franklin
28Street, Fifth Floor, Boston, MA  02110-1301, USA.
29
30This file is derivative of ZynAddSubFX original code.
31
32} {selected in_source in_header
33}
34
35decl {\#include <FL/Fl_Box.H>
36    \#include <FL/Fl_Group.H>
37    \#include "Params/ADnoteParameters.h"
38    \#include "Misc/SynthEngine.h"
39    \#include "UI/MiscGui.h"
40    \#include "UI/WidgetPDial.h"
41    \#include "UI/WidgetMWSlider.h"
42    \#include "UI/WidgetCheckButton.h"
43    \#include "UI/WidgetSpinner.h"
44    \#include "FilterUI.h"
45    \#include "PresetsUI.h"} {public global
46}
47
48decl {\#include <string>
49    \#include "ResonanceUI.h"
50    \#include "EnvelopeUI.h"
51    \#include "LFOUI.h"
52    \#include "OscilGenUI.h"} {public global
53}
54
55decl {\#include "MasterUI.h"} {private global
56}
57
58decl {\#include "Misc/SynthHelper.h"
59    using synth::getDetune;} {private local
60}
61
62decl {\#include "Misc/FormatFuncs.h"
63    using func::asString;} {private local
64}
65
66class ADvoicelistitem {: {public Fl_Group}
67} {
68  Function {make_window()} {} {
69    Fl_Window ADnoteVoiceListItem {
70      xywh {125 238 635 30} type Double box ENGRAVED_BOX hide
71      class Fl_Group
72    } {
73      Fl_Group voicelistitemgroup {
74        xywh {38 1 593 25} box FLAT_BOX
75        code0 {if (pars->VoicePar[nvoice].Enabled == 0) o->deactivate();}
76      } {
77        Fl_Value_Slider voicevolume {
78          callback {//
79            int vol = lrint(o->value());
80            if (synth->getGuiMaster()->partui->adnoteui->advoice->nvoice == nvoice)
81                synth->getGuiMaster()->partui->adnoteui->advoice->voicevolume->value(vol);
82
83            collect_data(synth, vol, 0, (TOPLEVEL::type::Write | TOPLEVEL::type::Integer), ADDVOICE::control::volume, npart, kititem, PART::engine::addVoice1 + nvoice);}
84          tooltip Volume xywh {155 4 122 20} type {Horz Knob} box THIN_DOWN_BOX labelsize 8 maximum 127 step 1
85          code0 {o->value(pars->VoicePar[nvoice].PVolume);}
86          code1 {o->setValueType(VC_ADDVoiceVolume);o->useCustomTip(true);}
87          class mwheel_slider_rev
88        }
89        Fl_Check_Button voiceresonanceenabled {
90          callback {//
91    bool enab = _SYS_::F2B(o->value());
92    synth->getGuiMaster()->partui->adnoteui->advoice->ResonanceEn->value(enab);
93
94    collect_data(synth, enab, 0, (TOPLEVEL::type::Write | TOPLEVEL::type::Integer), ADDVOICE::control::enableResonance, npart, kititem, PART::engine::addVoice1 + nvoice);}
95          tooltip {Resonance On/Off} xywh {305 5 15 17} down_box DOWN_BOX labeltype EMBOSSED_LABEL labelfont 1 labelsize 11 align 4
96          code0 {o->value(pars->VoicePar[nvoice].Presonance);}
97          class Fl_Check_Button2
98        }
99        Fl_Value_Slider voicelistvibratto {
100          callback {//
101            int lfodepth = lrint(o->value());
102            if (synth->getGuiMaster()->partui->adnoteui->advoice->nvoice == nvoice)
103                synth->getGuiMaster()->partui->adnoteui->advoice->voicefreqlfogroup->intensity->value(lfodepth);
104
105            collect_data(synth, lfodepth, 0, (TOPLEVEL::type::Write | TOPLEVEL::type::Integer), 1, npart, kititem, PART::engine::addVoice1 + nvoice, 0, 1);}
106          tooltip {Frequency LFO amount} xywh {535 4 95 20} type {Horz Knob} box THIN_DOWN_BOX labelsize 8 align 5 maximum 127 step 1 deactivate
107          code0 {o->value(pars->VoicePar[nvoice].FreqLfo->Pintensity);}
108          code1 {o->setValueType(VC_LFOdepthFreq);o->useCustomTip(true);}
109          class mwheel_slider_rev
110        }
111        Fl_Dial voicepanning {
112          callback {//
113            int panning = lrint(o->value());
114            if (synth->getGuiMaster()->partui->adnoteui->advoice->nvoice == nvoice)
115            {
116                synth->getGuiMaster()->partui->adnoteui->advoice->voicepan->value(panning);
117                synth->getGuiMaster()->partui->adnoteui->advoice->voicerandompan->value(panning < 1);
118            }
119
120            collect_data(synth, panning, 0, (TOPLEVEL::type::Write | TOPLEVEL::type::Integer), ADDVOICE::control::panning, npart, kititem, PART::engine::addVoice1 + nvoice);}
121          tooltip {Voice panning} xywh {282 4 20 20} box ROUND_UP_BOX labelsize 10 align 4 maximum 127 step 1
122          code0 {o->setValueType(VC_PanningStd);}
123          code1 {o->value(pars->VoicePar[nvoice].PPanning);}
124          class WidgetPDial
125        }
126        Fl_Group voiceoscil {
127          callback {update_voiceoscil();}
128          xywh {88 4 30 20} box THIN_DOWN_FRAME color 32 selection_color 71 labelcolor 179
129          code0 {osc = new Oscilloscope(o->x(), o->y(), o->w(), o->h(), 20, "");}
130          code1 {update_voiceoscil();}
131        } {}
132        Fl_Box noiselabel {
133          label N
134          callback {update_noiselabel();
135    int tmp = pars->VoicePar[nvoice].Type;
136    if (tmp == 0)
137    {
138        voiceresonanceenabled->activate();
139        detunevalueoutput->activate();
140        voicedetune->activate();
141        return;
142    }
143    voiceresonanceenabled->deactivate();
144    detunevalueoutput->deactivate();
145    voicedetune->deactivate();}
146          xywh {93 5 20 20} labelfont 1 labelsize 13 labelcolor 7
147        }
148        Fl_Group modoscil {
149          callback {update_modoscil();}
150          xywh {122 4 30 20} box THIN_DOWN_FRAME color 32 selection_color 71 labelcolor 179
151          code0 {modosc = new Oscilloscope(o->x(), o->y(), o->w(), o->h(), 20, "");}
152          code1 {update_modoscil();}
153        } {}
154        Fl_Box modlabel {
155          label N
156          callback {//
157                update_modlabel();}
158          xywh {127 5 20 20} labelfont 1 labelsize 13 labelcolor 7
159        }
160        Fl_Value_Output detunevalueoutput {
161          callback {o->value(getDetune((pars->VoicePar[nvoice].PDetuneType == 0) ? (pars->GlobalPar.PDetuneType) : (pars->VoicePar[nvoice].PDetuneType), 0, pars->VoicePar[nvoice].PDetune) * pars->getBandwidthDetuneMultiplier());}
162          xywh {326 4 40 20} box THIN_DOWN_BOX labelsize 10 align 0 minimum -5000 maximum 5000 textsize 11
163          code0 {o->step(0.01, 1);}
164          code1 {o->value(getDetune(pars->VoicePar[nvoice].PDetuneType, 0, pars->VoicePar[nvoice].PDetune) * pars->getBandwidthDetuneMultiplier());}
165        }
166        Fl_Slider voicedetune {
167          callback {//
168            int detune = lrint(o->value());
169            collect_data(synth, detune, TOPLEVEL::action::forceUpdate, TOPLEVEL::type::Write, ADDVOICE::control::detuneFrequency, npart, kititem, PART::engine::addVoice1 + nvoice);}
170          tooltip {Fine Detune (cents)} xywh {365 4 164 20} type {Horz Knob} box THIN_DOWN_BOX minimum -8192 maximum 8191 step 1
171          code0 {o->value(pars->VoicePar[nvoice].PDetune - 8192);}
172          class mwheel_slider_rev
173        }
174        Fl_Button itemedit {
175          label Edit
176          callback {//
177              synth->getGuiMaster()->partui->adnoteui->setVoiceTabs(nvoice);
178              synth->getGuiMaster()->partui->adnoteui->set_voice(true);
179              if ((Fl::event_button() == 3))
180                  synth->getGuiMaster()->partui->adnoteui->ADnoteVoiceList->hide();}
181          tooltip {Right click: also close this} xywh {42 4 40 20} box THIN_UP_BOX labelfont 1 labelsize 12
182        }
183      }
184      Fl_Group enabledpatch {
185        label 1
186        xywh {4 4 34 18} box UP_BOX color 237 labelfont 1 align 20
187        code0 {char tmp[12]; snprintf(tmp, 12, "%d", nvoice + 1); o->label(strdup(tmp));}
188      } {}
189      Fl_Check_Button voiceenabled {
190        callback {//
191            bool enab = _SYS_::F2B(o->value());
192            collect_data(synth, enab, TOPLEVEL::action::forceUpdate, (TOPLEVEL::type::Integer | TOPLEVEL::type::Write), ADDVOICE::control::enableVoice, npart, kititem, PART::engine::addVoice1 + nvoice);}
193        xywh {18 7 15 15} down_box DOWN_BOX labeltype EMBOSSED_LABEL
194        code1 {o->value(pars->VoicePar[nvoice].Enabled);}
195        class Fl_Check_Button2
196      }
197    }
198  }
199  Function {ADvoicelistitem(int x,int y, int w, int h, const char *label=0):Fl_Group(x,y,w,h,label)} {} {
200    code {nvoice = 0; pars = NULL;} {}
201  }
202  Function {init(ADnoteParameters *parameters, int npart_, int kititem_, int nvoice_)} {} {
203    code {//
204    synth = parameters->getSynthEngine();
205    pars = parameters;
206    npart = npart_;
207    kititem = kititem_;
208    nvoice = nvoice_;
209    fft = new FFTwrapper(synth->oscilsize);
210    oscil = new OscilGen(fft, NULL, synth, parameters->VoicePar[nvoice].POscil);
211    oscilFM = new OscilGen(fft, NULL, synth, parameters->VoicePar[nvoice].POscilFM);
212    make_window();
213    if (pars->VoicePar[nvoice].PFreqLfoEnabled > 0)
214        voicelistvibratto->activate();
215    else
216        voicelistvibratto->deactivate();
217    ADnoteVoiceListItem->show();
218    end();} {}
219  }
220  Function {refreshlist()} {} {
221    code {//
222        voiceenabled->value(pars->VoicePar[nvoice].Enabled);
223        voiceresonanceenabled->value(pars->VoicePar[nvoice].Presonance);
224        voicevolume->value(pars->VoicePar[nvoice].PVolume);
225        voicedetune->value(pars->VoicePar[nvoice].PDetune - 8192);
226        voicepanning->value(pars->VoicePar[nvoice].PPanning);
227        voicelistvibratto->value(pars->VoicePar[nvoice].FreqLfo->Pintensity);
228        int nvs = nvoice, nvp = nvoice;
229        if (pars->VoicePar[nvoice].PVoice != -1)
230            while (pars->VoicePar[nvs].PVoice != -1)
231                nvp = nvs = pars->VoicePar[nvs].PVoice;
232        else if (pars->VoicePar[nvoice].Pextoscil != -1)
233            nvs = pars->VoicePar[nvoice].Pextoscil;
234        oscil->changeParams(pars->VoicePar[nvs].POscil);
235        osc->init(oscil, 0, pars->VoicePar[nvp].Poscilphase, synth);
236        if (pars->VoicePar[nvoice].Enabled == 0)
237            voicelistitemgroup->deactivate();
238        else
239            voicelistitemgroup->activate();
240        detunevalueoutput->do_callback();
241        voiceoscil->do_callback();
242        noiselabel->do_callback();
243        modoscil->do_callback();
244        modlabel->do_callback();
245        ADnoteVoiceListItem->redraw();} {}
246  }
247  Function {update_voiceoscil()} {} {
248    code {int nvs = nvoice, nvp = nvoice;
249if (pars->VoicePar[nvoice].PVoice != -1)
250    while (pars->VoicePar[nvs].PVoice != -1)
251        nvp = nvs = pars->VoicePar[nvs].PVoice;
252else if (pars->VoicePar[nvoice].Pextoscil != -1)
253    nvs = pars->VoicePar[nvoice].Pextoscil;
254oscil->changeParams(pars->VoicePar[nvs].POscil);
255osc->init(oscil,0,pars->VoicePar[nvp].Poscilphase, synth);
256
257if (pars->VoicePar[nvoice].PVoice >= 0 || pars->VoicePar[nvoice].Type != 0)
258    voiceoscil->deactivate();
259else
260    voiceoscil->activate();} {}
261  }
262  Function {update_noiselabel()} {} {
263    code {if (pars->VoicePar[nvoice].PVoice >= 0)
264{
265    char str[15];
266    snprintf(str, sizeof(str), "V%d", pars->VoicePar[nvoice].PVoice + 1);
267    noiselabel->copy_label(str);
268    noiselabel->labelcolor(EXTVOICE_COLOUR);
269    noiselabel->show();
270}
271else if (pars->VoicePar[nvoice].Pextoscil >= 0)
272{
273    char str[15];
274    snprintf(str, sizeof(str), "O%d", pars->VoicePar[nvoice].Pextoscil + 1);
275    noiselabel->copy_label(str);
276    noiselabel->labelcolor(EXTOSC_COLOUR);
277    noiselabel->show();
278}
279else if (pars->VoicePar[nvoice].Type == 1)
280{
281    noiselabel->copy_label("N");
282    noiselabel->labelcolor(7);
283    noiselabel->show();
284}
285else if (pars->VoicePar[nvoice].Type == 2)
286{
287    noiselabel->copy_label("N");
288    noiselabel->labelcolor(5);
289    noiselabel->show();
290}
291else if (pars->VoicePar[nvoice].Type == 3)
292{
293    noiselabel->copy_label("N");
294    noiselabel->labelcolor(6);
295    noiselabel->show();
296}
297else
298{
299    noiselabel->hide();
300}} {}
301  }
302  Function {update_modoscil()} {} {
303    code {int nvs = nvoice, nvp = nvoice;
304if (pars->VoicePar[nvoice].PFMVoice != -1) {
305    nvp = nvs = pars->VoicePar[nvs].PFMVoice;
306    while (pars->VoicePar[nvs].PVoice != -1)
307        nvp = nvs = pars->VoicePar[nvs].PVoice;
308    oscilFM->changeParams(pars->VoicePar[nvs].POscil);
309    modosc->init(oscilFM,0,pars->VoicePar[nvp].Poscilphase, synth);
310} else {
311    if (pars->VoicePar[nvoice].PextFMoscil != -1)
312        nvs = pars->VoicePar[nvoice].PextFMoscil;
313    oscilFM->changeParams(pars->VoicePar[nvs].POscilFM);
314    modosc->init(oscilFM,0,pars->VoicePar[nvp].PFMoscilphase, synth);
315}
316
317if (pars->VoicePar[nvoice].PFMEnabled == NONE || pars->VoicePar[nvoice].PFMVoice >= 0)
318    modoscil->deactivate();
319else
320    modoscil->activate();} {}
321  }
322  Function {update_modlabel()} {} {
323    code {if (pars->VoicePar[nvoice].PFMEnabled == NONE)
324{
325    modlabel->copy_label("OFF");
326    modlabel->labelcolor(MODOFF_COLOUR);
327    modlabel->deactivate();
328    modlabel->show();
329}
330else
331{
332    modlabel->activate();
333    if (pars->VoicePar[nvoice].PFMVoice >= 0)
334    {
335        char str[15];
336        snprintf(str, sizeof(str), "V%d", pars->VoicePar[nvoice].PFMVoice + 1);
337        modlabel->copy_label(str);
338        modlabel->labelcolor(EXTVOICE_COLOUR);
339        modlabel->show();
340    }
341    else if (pars->VoicePar[nvoice].PextFMoscil >= 0)
342    {
343        char str[15];
344        snprintf(str, sizeof(str), "M%d", pars->VoicePar[nvoice].PextFMoscil + 1);
345        modlabel->copy_label(str);
346        modlabel->labelcolor(EXTOSC_COLOUR);
347        modlabel->show();
348    }
349    else
350    {
351        modlabel->hide();
352    }
353}} {}
354  }
355  Function {itemRtext(float dScale)} {} {
356    code {//
357
358        int size11 = int(11 * dScale);
359        int size12 = int(12 * dScale);
360        int size14 = int(14 * dScale);
361
362        voiceresonanceenabled->labelsize(size11);
363        voiceoscil->labelsize(size14);
364        noiselabel->labelsize(size14);
365        modoscil->labelsize(size14);
366        modlabel->labelsize(size14);
367        detunevalueoutput->textsize(size11);
368        itemedit->labelsize(size12);
369        voiceenabled->labelsize(size12);
370        enabledpatch->size(34 * dScale, 18 * dScale);
371        enabledpatch->labelsize(size14);} {}
372  }
373  Function {~ADvoicelistitem()} {} {
374    code {//
375        ADnoteVoiceListItem->hide();
376        delete oscil;
377        delete oscilFM;
378        delete fft;} {}
379  }
380  decl {ADnoteParameters *pars;} {private local
381  }
382  decl {int nvoice;} {public local
383  }
384  decl {FFTwrapper *fft;} {private local
385  }
386  decl {OscilGen *oscil;} {private local
387  }
388  decl {OscilGen *oscilFM;} {private local
389  }
390  decl {Oscilloscope *osc;} {private local
391  }
392  decl {Oscilloscope *modosc;} {private local
393  }
394  decl {SynthEngine *synth;} {private local
395  }
396  decl {int npart;} {private local
397  }
398  decl {int kititem;} {private local
399  }
400}
401
402class ADvoiceUI {: {public Fl_Group}
403} {
404  Function {make_window()} {} {
405    Fl_Window ADnoteVoiceParameters {
406      label Voice
407      xywh {329 157 805 610} type Double box NO_BOX hide resizable
408      code0 {o->copy_label(synth->getGuiMaster()->setPartWindowTitle("AddSynth Voice Oscillator").c_str());}
409      class Fl_Group
410    } {
411      Fl_Box {} {
412        xywh {8 69 277 66} box PLASTIC_UP_BOX color 223
413      }
414      Fl_Group voiceparametersgroup {
415        xywh {0 0 805 615} box THIN_UP_FRAME color 48
416        code0 {if (pars->VoicePar[nvoice].Enabled==0) o->deactivate();}
417      } {
418        Fl_Group voicemodegroup {
419          xywh {0 0 805 615}
420        } {
421          Fl_Group voiceFMparametersgroup {
422            label MODULATOR
423            xywh {575 5 230 565} box THIN_UP_FRAME color 48 labelfont 1 labelsize 12 align 17
424          } {
425            Fl_Group modfrequency {
426              label {Mod FREQUENCY}
427              xywh {580 204 220 161} box THIN_UP_FRAME labelfont 1 labelsize 11 align 17
428            } {
429              Fl_Group voiceFMfreqenvgroup {
430                label {ADSynth Modulator - Frequency Envelope}
431                xywh {585 290 210 70} box FLAT_BOX color 51 align 144
432                code0 {o->init(pars->VoicePar[nvoice].FMFreqEnvelope, npart, kititem, nvoice + PART::engine::addMod1, 1);}
433                code1 {if (pars->VoicePar[nvoice].PFMFreqEnvelopeEnabled==0) o->deactivate();}
434                class EnvelopeUI
435              } {}
436              Fl_Check_Button ModFreqEn {
437                label On
438                callback {//
439                    if (o->value() == 0)
440                        voiceFMfreqenvgroup->deactivate();
441                    else
442                        voiceFMfreqenvgroup->activate();
443                    o->redraw();
444                    send_data(0, ADDVOICE::control::enableModulatorFrequencyEnvelope, o->value(), TOPLEVEL::type::Integer);}
445                tooltip {Enable Frequency Envelope} xywh {590 295 38 14} box THIN_UP_BOX down_box DOWN_BOX color 237 labelfont 1 labelsize 10
446                code0 {o->value(pars->VoicePar[nvoice].PFMFreqEnvelopeEnabled);}
447                class Fl_Check_Button2
448              }
449              Fl_Counter ModCoarseDetune {
450                label {Coarse Det.}
451                callback {//
452                    send_data(0, ADDVOICE::control::modulatorCoarseDetune, o->value(), TOPLEVEL::type::Integer);}
453                tooltip {Coarse Detune} xywh {730 270 60 15} labelsize 10 align 1 minimum -64 maximum 63 step 1 textfont 1 textsize 11
454                code0 {int k = pars->VoicePar[nvoice].PFMCoarseDetune % 1024;}
455                code1 {if (k >= 512) k-= 1024;}
456                code2 {o->value(k);}
457                code3 {o->lstep(10);}
458              }
459              Fl_Counter ModOctave {
460                label Octave
461                callback {//
462                    send_data(0, ADDVOICE::control::modulatorOctave, o->value(), TOPLEVEL::type::Integer);}
463                tooltip Octave xywh {670 270 45 15} type Simple color 237 selection_color 0 labelsize 10 align 1 minimum -8 maximum 7 step 1 textfont 1 textsize 11
464                code0 {int k = pars->VoicePar[nvoice].PFMCoarseDetune / 1024;}
465                code1 {if (k >= 8) k -= 16;}
466                code2 {o->value(k);}
467              }
468              Fl_Value_Output fmdetunevalueoutput {
469                label Detune
470                callback {o->value(getDetune((pars->VoicePar[nvoice].PFMDetuneType == 0) ? (pars->GlobalPar.PDetuneType) : (pars->VoicePar[nvoice].PFMDetuneType), 0, pars->VoicePar[nvoice].PFMDetune));}
471                xywh {587 239 36 16} box THIN_DOWN_BOX labelsize 10 align 5 minimum -5000 maximum 5000 textfont 1 textsize 10
472                code0 {o->step(0.01, 1);}
473                code1 {o->value(getDetune((pars->VoicePar[nvoice].PFMDetuneType == 0) ? (pars->GlobalPar.PDetuneType) : (pars->VoicePar[nvoice].PFMDetuneType), 0, pars->VoicePar[nvoice].PFMDetune));}
474              }
475              Fl_Slider ModDetune {
476                callback {//
477                    send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::modulatorDetuneFrequency, o->value(), TOPLEVEL::type::Integer);}
478                tooltip {Fine Detune (cents)} xywh {623 239 168 16} type {Horz Knob} box THIN_DOWN_BOX minimum -8192 maximum 8191 step 1
479                code0 {o->value(pars->VoicePar[nvoice].PFMDetune-8192);}
480                class mwheel_slider_rev
481              }
482              Fl_Choice ModDetuneType {
483                label {Detune Type}
484                callback {//
485                    send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::modulatorDetuneType, o->value(), TOPLEVEL::type::Integer);}
486                xywh {585 270 75 15} down_box BORDER_BOX selection_color 49 labelsize 10 align 5 textfont 1 textsize 10
487                code0 {o->add("Default");o->add("L35cents");o->add("L10cents");o->add("E100cents");o->add("E1200cents");}
488                code1 {o->value(pars->VoicePar[nvoice].PFMDetuneType);}
489              } {}
490              Fl_Check_Button detuneFromBaseOsc {
491                label {Follow voice}
492                callback {send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::modulatorDetuneFromBaseOsc, o->value(), TOPLEVEL::type::Integer);}
493                tooltip {Apply all detuning in the voice oscillator to the modulator as well.} xywh {630 220 95 15} down_box DOWN_BOX labelsize 11
494                code0 {o->value(pars->VoicePar[nvoice].PFMDetuneFromBaseOsc);}
495                code1 {if (pars->VoicePar[nvoice].PFMFixedFreq) o->deactivate();}
496                class Fl_Check_Button2
497              }
498              Fl_Check_Button Mod440 {
499                label 440Hz
500                callback {//
501send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::modulatorFrequencyAs440Hz, o->value(), TOPLEVEL::type::Integer);}
502                tooltip {Set the modulator base frequency to 440Hz} xywh {726 220 55 15} down_box DOWN_BOX labelfont 1 labelsize 11
503                code0 {o->value(pars->VoicePar[nvoice].PFMFixedFreq);}
504                class Fl_Check_Button2
505              }
506            }
507            Fl_Group Modampgrp {
508              label {Mod AMPLITUDE}
509              xywh {580 55 220 149} box THIN_UP_FRAME labelfont 1 labelsize 11 align 17
510            } {
511              Fl_Value_Slider ModVolume {
512                label Vol
513                callback {//
514                    send_data(0, ADDVOICE::control::modulatorAmplitude, o->value(), TOPLEVEL::type::Integer);}
515                tooltip Volume xywh {585 70 160 15} type {Horz Knob} box THIN_DOWN_BOX labelsize 11 align 8 maximum 127 step 1
516                code0 {o->value(pars->VoicePar[nvoice].PFMVolume);}
517                class mwheel_val_slider_rev
518              }
519              Fl_Value_Slider ModVsense {
520                label {V.Sns}
521                callback {//
522                    send_data(0, ADDVOICE::control::modulatorVelocitySense, o->value(), TOPLEVEL::type::Integer);}
523                tooltip {Velocity Sensing Function - rightmost/max to disable)} xywh {585 90 160 15} type {Horz Knob} box THIN_DOWN_BOX labelsize 11 align 8 maximum 127 step 1
524                code0 {o->value(pars->VoicePar[nvoice].PFMVelocityScaleFunction);}
525                class mwheel_val_slider_rev
526              }
527              Fl_Group voiceFMampenvgroup {
528                label {ADSynth Modulator - Amplitude Envelope}
529                xywh {585 129 210 70} box FLAT_BOX color 51 align 144
530                code0 {o->init(pars->VoicePar[nvoice].FMAmpEnvelope, npart, kititem, nvoice + PART::engine::addMod1, 0);}
531                code1 {if (pars->VoicePar[nvoice].PFMAmpEnvelopeEnabled==0) o->deactivate();}
532                class EnvelopeUI
533              } {}
534              Fl_Check_Button ModAmpEn {
535                label On
536                callback {//
537                    if (o->value() == 0)
538                        voiceFMampenvgroup->deactivate();
539                    else
540                        voiceFMampenvgroup->activate();
541                    o->redraw();
542                    send_data(0, ADDVOICE::control::enableModulatorAmplitudeEnvelope, o->value(), TOPLEVEL::type::Integer);}
543                tooltip {Enable Amplitude Envelope} xywh {590 134 38 14} box THIN_UP_BOX down_box DOWN_BOX color 237 labelfont 1 labelsize 10
544                code0 {o->value(pars->VoicePar[nvoice].PFMAmpEnvelopeEnabled);}
545                class Fl_Check_Button2
546              }
547              Fl_Value_Slider ModFdamp {
548                label {F.Damp}
549                callback {//
550                    send_data(0, ADDVOICE::control::modulatorHFdamping, o->value(), TOPLEVEL::type::Integer);}
551                tooltip {Modulator Damp at Higher frequency} xywh {585 110 160 15} type {Horz Knob} box THIN_DOWN_BOX labelsize 11 align 8 minimum -64 maximum 63 step 1
552                code0 {o->value(pars->VoicePar[nvoice].PFMVolumeDamp-64);}
553                class mwheel_val_slider_rev
554              }
555            }
556            Fl_Group modOscDisplay {
557              xywh {580 365 220 200}
558            } {
559              Fl_Group modoscil {
560                label {                       }
561                xywh {580 365 220 200} box THIN_UP_FRAME labelfont 1 labelsize 11 align 17
562              } {
563                Fl_Text_Display ModLocalOsc {
564                  label {Local Oscillator}
565                  xywh {598 385 95 2} box NO_BOX labelfont 1 labelsize 12
566                }
567                Fl_Button changeFMoscilbutton {
568                  label Waveform
569                  callback {//
570                    if (oscedit)
571                        delete oscedit;
572                    lastWaveW = 0;
573                    int nv = nvoice;
574                    if (pars->VoicePar[nvoice].PextFMoscil >= 0)
575                        nv = pars->VoicePar[nvoice].PextFMoscil;
576                    oscedit = new OscilEditor(pars->VoicePar[nv].POscilFM, modOscDisplay, NULL, NULL, synth, npart, kititem, nvoice + PART::engine::addMod1);
577                    if ((Fl::event_button() == 3))
578                        synth->getGuiMaster()->partui->adnoteui->ADnoteVoice->hide();}
579                  xywh {712 370 72 18} box THIN_UP_BOX labelfont 1 labelsize 10
580                  code0 {if (pars->VoicePar[nvoice].PextFMoscil>=0) o->labelcolor(FL_BLUE);}
581                }
582                Fl_Slider ModPhase {
583                  label Phase
584                  callback {//
585                    send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::modulatorOscillatorPhase, o->value(), TOPLEVEL::type::Integer);}
586                  tooltip {Phase offset} xywh {711 402 74 16} type {Horz Knob} box THIN_DOWN_BOX labelsize 10 align 1 minimum -64 maximum 63 step 1
587                  code0 {o->value(64-pars->VoicePar[nvoice].PFMoscilphase);}
588                  code1 {o->setValueType(VC_PhaseOffset); o->useCustomTip(true);}
589                  class mwheel_slider_rev
590                }
591                Fl_Choice ExtModOsc {
592                  label Use
593                  callback {//
594                    send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::modulatorOscillatorSource, o->value() - 1, TOPLEVEL::type::Integer);}
595                  tooltip {Use an earlier oscillator for this modulator. Only the base oscillator is used, not other voice parameters.} xywh {607 402 75 16} down_box BORDER_BOX selection_color 49 labelsize 10 align 1 textfont 1 textsize 10
596                  code0 {o->add("Internal");}
597                  code1 {char tmp[50]; for (int i = 0; i < nvoice; ++i) {sprintf(tmp, "Mod.%2d", i + 1); o->add(tmp);};}
598                  code3 {o->value(pars->VoicePar[nvoice].PextFMoscil + 1);}
599                } {}
600                Fl_Group fmoscil {
601                  xywh {580 425 220 140} box THIN_DOWN_BOX color 32 selection_color 71 labelcolor 179
602                  code0 {oscFM = new Oscilloscope(o->x(),o->y(),o->w(),o->h(), 125,"");}
603                  code1 {update_fmoscil();}
604                } {}
605              }
606              Fl_Box modvoicelabel {
607                label Voice
608                callback {update_modvoicelabel();}
609                xywh {600 470 190 65} labelfont 1 labelsize 40 labelcolor 7
610                code0 {update_modvoicelabel();}
611              }
612            }
613            Fl_Choice ExtMod {
614              label Source
615              callback {//
616                  send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::externalModulator, o->value() - 1, TOPLEVEL::type::Integer);}
617              tooltip {Use an earlier voice as modulator. 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 current voice will then tweak the modulator further.} xywh {692 32 104 20} down_box BORDER_BOX selection_color 49 labelsize 11 align 9 textfont 1
618              code0 {o->add("Local");}
619              code1 {char tmp[50]; for (int i = 0; i < nvoice; ++i) {sprintf(tmp, "Voice %2d", i + 1); o->add(tmp);};}
620              code2 {o->value(pars->VoicePar[nvoice].PFMVoice + 1);}
621              code3 {if (lrint(o->value())) {modoscil->deactivate();}}
622            } {}
623          }
624          Fl_Choice ModType {
625            label {Type:}
626            callback {//
627                if (o->value() == 0)
628                    voiceFMparametersgroup->deactivate();
629                else
630                    voiceFMparametersgroup->activate();
631                o->redraw();
632                send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::modulatorType, o->value(), TOPLEVEL::type::Integer);}
633            xywh {580 32 90 20} down_box BORDER_BOX color 237 selection_color 49 labelsize 11 align 5 textfont 1 textsize 11
634            code0 {o->add("Off");o->add("Morph");o->add("Ring");o->add("PM");o->add("FM");o->add("PWM");}
635            code1 {o->value(pars->VoicePar[nvoice].PFMEnabled);}
636            code2 {if (o->value() == 0) voiceFMparametersgroup->deactivate();}
637          } {}
638          Fl_Group freqencygrp {
639            label FREQUENCY
640            xywh {5 280 570 120} box THIN_UP_FRAME labelfont 1 labelsize 12 align 17
641          } {
642            Fl_Group voicefreqenvgroup {
643              label {ADSynth Voice - Frequency Envelope}
644              xywh {10 325 205 70} box FLAT_BOX color 51 align 144
645              code0 {o->init(pars->VoicePar[nvoice].FreqEnvelope, npart, kititem, nvoice + PART::engine::addVoice1, 1);}
646              code1 {if (pars->VoicePar[nvoice].PFreqEnvelopeEnabled==0) o->deactivate();}
647              class EnvelopeUI
648            } {}
649            Fl_Check_Button FreqEn {
650              label On
651              callback {//
652                  if (o->value() == 0)
653                      voicefreqenvgroup->deactivate();
654                  else
655                      voicefreqenvgroup->activate();
656                  o->redraw();
657                  send_data(0, ADDVOICE::control::enableFrequencyEnvelope, o->value(), TOPLEVEL::type::Integer);}
658              tooltip {Enable Frequency Envelope} xywh {14 330 38 14} box THIN_UP_BOX down_box DOWN_BOX color 237 labelfont 1 labelsize 10
659              code0 {o->value(pars->VoicePar[nvoice].PFreqEnvelopeEnabled);}
660              class Fl_Check_Button2
661            }
662            Fl_Group voicefreqlfogroup {
663              label {Frequency LFO     }
664              xywh {215 325 275 70} box FLAT_BOX color 47 align 144
665              code0 {o->init(pars->VoicePar[nvoice].FreqLfo, npart, kititem, PART::engine::addVoice1 + nvoice, 1);}
666              code1 {if (pars->VoicePar[nvoice].PFreqLfoEnabled==0) o->deactivate();}
667              class LFOUI
668            } {}
669            Fl_Check_Button FreqLfoEn {
670              label On
671              callback {//
672    bool enab = _SYS_::F2B(o->value());
673    if (enab)
674    {
675        voicefreqlfogroup->activate();
676        synth->getGuiMaster()->partui->adnoteui->voicelistitem[nvoice]->voicelistvibratto->activate();
677    }
678    else
679    {
680        voicefreqlfogroup->deactivate();
681        synth->getGuiMaster()->partui->adnoteui->voicelistitem[nvoice]->voicelistvibratto->deactivate();
682    }
683    o->redraw();
684
685    send_data(0, ADDVOICE::control::enableFrequencyLFO, o->value(), TOPLEVEL::type::Integer);}
686              tooltip {Enable Frequency LFO} xywh {220 330 38 14} box THIN_UP_BOX down_box DOWN_BOX color 237 labelfont 1 labelsize 10
687              code0 {o->value(pars->VoicePar[nvoice].PFreqLfoEnabled);}
688              class Fl_Check_Button2
689            }
690            Fl_Counter Octave {
691              label Octave
692              callback {//
693                  send_data(0, ADDVOICE::control::octave, o->value(), TOPLEVEL::type::Integer);}
694              tooltip Octave xywh {510 306 45 15} type Simple color 237 selection_color 0 labelsize 10 align 1 minimum -8 maximum 7 step 1 value 4 textfont 1 textsize 11
695              code0 {int k = pars->VoicePar[nvoice].PCoarseDetune / 1024;}
696              code1 {if (k >= 8) k -= 16;}
697              code2 {o->value(k);}
698            }
699            Fl_Counter CoarseDetune {
700              label {Coarse Det.}
701              callback {//
702                  send_data(0, ADDVOICE::control::coarseDetune, o->value(), TOPLEVEL::type::Integer);}
703              tooltip {Coarse Detune} xywh {496 375 68 16} labelsize 10 align 1 minimum -64 maximum 63 step 1 textfont 1 textsize 11
704              code0 {int k = pars->VoicePar[nvoice].PCoarseDetune % 1024;}
705              code1 {if (k >= 512) k -= 1024;}
706              code2 {o->value(k);}
707              code3 {o->lstep(10);}
708            }
709            Fl_Value_Output detunevalueoutput {
710              label Detune
711              callback {o->value(getDetune((pars->VoicePar[nvoice].PDetuneType==0)?(pars->GlobalPar.PDetuneType) : (pars->VoicePar[nvoice].PDetuneType),0,pars->VoicePar[nvoice].PDetune)*pars->getBandwidthDetuneMultiplier());}
712              xywh {10 306 38 16} box THIN_DOWN_BOX labelsize 10 align 5 minimum -5000 maximum 5000 textfont 1 textsize 10
713              code0 {o->step(0.01, 1);}
714              code1 {o->value(getDetune((pars->VoicePar[nvoice].PDetuneType==0)?(pars->GlobalPar.PDetuneType) : (pars->VoicePar[nvoice].PDetuneType),0,pars->VoicePar[nvoice].PDetune)*pars->getBandwidthDetuneMultiplier());}
715            }
716            Fl_Slider Detune {
717              callback {//
718                int detune = lrint(o->value());
719                send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::detuneFrequency, detune, TOPLEVEL::type::Integer);}
720              tooltip {Fine Detune (cents)} xywh {48 306 442 16} type {Horz Knob} box THIN_DOWN_BOX minimum -8192 maximum 8191 step 1
721              code0 {o->value(pars->VoicePar[nvoice].PDetune-8192);}
722              class mwheel_slider_rev
723            }
724            Fl_Choice FreqDetunetype {
725              label {Detune Type}
726              callback {//
727send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::detuneType, o->value(), TOPLEVEL::type::Integer);}
728              xywh {495 340 75 17} down_box BORDER_BOX labelsize 10 align 5 textfont 1 textsize 10
729              code0 {o->add("Default");o->add("L35cents");o->add("L10cents");o->add("E100cents");o->add("E1200cents");}
730              code1 {o->value(pars->VoicePar[nvoice].PDetuneType);}
731            } {}
732            Fl_Dial bend {
733              label Bend
734              callback {//
735send_data(0, ADDVOICE::control::pitchBendAdjustment, o->value(), TOPLEVEL::type::Integer);}
736              tooltip {Pitch bend scaling for this voice} xywh {70 284 20 20} box ROUND_UP_BOX labelsize 10 align 8 maximum 127 step 1
737              code0 {o->value(pars->VoicePar[nvoice].PBendAdjust);}
738              code1 {o->setValueType(VC_PitchBend);}
739              class WidgetPDial
740            }
741            Fl_Check_Button Freq440 {
742              label 440Hz
743              callback {//
744                  int x = lrint(o->value());
745                  if (x == 0 && Mod440->value() == 0)
746                      fixedfreqetdial->deactivate();
747                  else
748                      fixedfreqetdial->activate();
749                  send_data(0, ADDVOICE::control::baseFrequencyAs440Hz, o->value(), TOPLEVEL::type::Integer);}
750              tooltip {Set the voice base frequency to 440Hz} xywh {400 286 55 15} down_box DOWN_BOX labelfont 1 labelsize 11
751              code0 {o->value(pars->VoicePar[nvoice].Pfixedfreq);}
752              class Fl_Check_Button2
753            }
754            Fl_Dial fixedfreqetdial {
755              label {Eq.T.}
756              callback {//
757send_data(0, ADDVOICE::control::equalTemperVariation, o->value(), TOPLEVEL::type::Integer);}
758              tooltip {How the frequency varies according to the keyboard (leftmost for fixed frequency)} xywh {460 284 20 20} box ROUND_UP_BOX labelsize 10 align 8 maximum 127 step 1
759              code0 {o->value(pars->VoicePar[nvoice].PfixedfreqET);}
760              code1 {if (pars->VoicePar[nvoice].Pfixedfreq==0) o->deactivate();}
761              code2 {o->setValueType(VC_FixedFreqET);}
762              class WidgetPDial
763            }
764            Fl_Dial offset {
765              label Offset
766              callback {//
767send_data(0, ADDVOICE::control::pitchBendOffset, o->value(), TOPLEVEL::type::Integer);}
768              tooltip {Offset of the frequency in Hz.} xywh {130 284 20 20} box ROUND_UP_BOX labelsize 10 align 8 maximum 127 step 1
769              code0 {o->value(pars->VoicePar[nvoice].POffsetHz);}
770              code1 {o->setValueType(VC_FreqOffsetHz);}
771              class WidgetPDial
772            }
773          }
774          Fl_Group oscDisplay {
775            xywh {5 462 570 145}
776          } {
777            Fl_Group oscGroup {
778              xywh {5 462 570 145} labelfont 1 labelsize 13 align 17
779              code0 {if (pars->VoicePar[nvoice].PVoice >= 0) o->deactivate();}
780            } {
781              Fl_Group oscParamBox {
782                label {Local
783Oscillator}
784                xywh {5 478 80 128} box THIN_UP_FRAME labelfont 1 labelsize 12 align 17
785              } {
786                Fl_Choice UseOsc {
787                  label Use
788                  callback {//
789                send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::voiceOscillatorSource, o->value() - 1, TOPLEVEL::type::Integer);}
790                  tooltip {Use an earlier oscillator for this voice. Only the base oscillator is used, not other voice parameters.} xywh {9 526 72 18} down_box BORDER_BOX selection_color 49 labelsize 10 align 1 textfont 1 textsize 10
791                  code0 {o->add("Internal");}
792                  code1 {char tmp[50]; for (int i = 0; i < nvoice; ++i) {sprintf(tmp, "Osc. %2d", i + 1); o->add(tmp);};}
793                  code3 {o->value(pars->VoicePar[nvoice].Pextoscil + 1);}
794                } {}
795                Fl_Button changevoiceoscilbutton {
796                  label Waveform
797                  callback {//
798    if (oscedit)
799        delete oscedit;
800    lastWaveW = 0;
801    int nv = nvoice;
802    if (pars->VoicePar[nvoice].Pextoscil >= 0)
803        nv=pars->VoicePar[nvoice].Pextoscil;
804    oscedit = new OscilEditor(pars->VoicePar[nv].POscil, oscDisplay, NULL, NULL, synth, npart, kititem, nvoice + PART::engine::addVoice1);
805    if ((Fl::event_button() == 3))
806        synth->getGuiMaster()->partui->adnoteui->ADnoteVoice->hide();}
807                  xywh {9 548 72 22} box THIN_UP_BOX labelfont 1 labelsize 11
808                  code0 {if (pars->VoicePar[nvoice].Pextoscil>=0) o->labelcolor(FL_BLUE);}
809                }
810                Fl_Slider VoiceOscPhase {
811                  label Phase
812                  callback {//
813                send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::voiceOscillatorPhase, o->value(), TOPLEVEL::type::Integer);}
814                  tooltip {Phase offset} xywh {9 586 72 16} type {Horz Knob} box THIN_DOWN_BOX labelsize 10 align 1 minimum -64 maximum 63 step 1
815                  code0 {o->value(64-pars->VoicePar[nvoice].Poscilphase);}
816                  code1 {o->setValueType(VC_PhaseOffset); o->useCustomTip(true);}
817                  class mwheel_slider_rev
818                }
819              }
820              Fl_Group voiceoscil {
821                xywh {90 462 485 145} box THIN_DOWN_BOX color 32 selection_color 71 labelcolor 179
822                code0 {osc = new Oscilloscope(o->x(),o->y(),o->w(),o->h(), 130, "");}
823                code1 {update_voiceoscil();}
824              } {}
825            }
826            Fl_Box osclabel {
827              label Osc
828              callback {update_osclabels();}
829              xywh {135 502 400 65} labelfont 1 labelsize 50 labelcolor 7
830            }
831          }
832          Fl_Box {} {
833            xywh {205 35 85 33} box THIN_UP_FRAME
834          }
835          Fl_Check_Button ResonanceEn {
836            label Resonance
837            callback {//
838    bool enab = _SYS_::F2B(o->value());
839    pars->VoicePar[nvoice].Presonance = enab;
840    synth->getGuiMaster()->partui->adnoteui->voicelistitem[nvoice]->voiceresonanceenabled->value(enab);
841    send_data(0, ADDVOICE::control::enableResonance, enab, TOPLEVEL::type::Integer);}
842            tooltip {Resonance On/Off} xywh {238 49 17 19} down_box DOWN_BOX labelsize 12 align 1
843            code0 {o->value(pars->VoicePar[nvoice].Presonance);}
844            class Fl_Check_Button2
845          }
846          Fl_Group unisongroup {
847            xywh {90 402 484 56} box PLASTIC_UP_BOX color 231 deactivate
848            code0 {int tmp = pars->VoicePar[nvoice].Unison_size; if (tmp > 1) o->activate();}
849            code1 {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;}}}
850          } {
851            Fl_Spinner unisonsize {
852              label Size
853              callback {//
854send_data(0, ADDVOICE::control::unisonSize, o->value(), TOPLEVEL::type::Integer);}
855              tooltip {Number of unison sub-voices} xywh {98 434 40 16} box THIN_UP_BOX color 29 labelsize 10 align 1 minimum 2 maximum 50 value 2 textsize 11
856              code0 {int tmp = pars->VoicePar[nvoice].Unison_size;}
857              code1 {if (tmp < 2) tmp = 2;}
858              code2 {o->value(tmp);}
859              class WidgetSpinner
860            }
861            Fl_Dial UnisonStereo {
862              label Stereo
863              callback {//
864send_data(0, ADDVOICE::control::unisonStereoSpread, o->value(), TOPLEVEL::type::Integer);}
865              tooltip {Stereo Spread} xywh {356 422 28 28} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
866              code0 {o->value(pars->VoicePar[nvoice].Unison_stereo_spread);}
867              class WidgetPDial
868            }
869            Fl_Dial UnisonVib {
870              label {Vib.}
871              callback {//
872send_data(0, ADDVOICE::control::unisonVibratoDepth, o->value(), TOPLEVEL::type::Integer);}
873              tooltip Vibratto xywh {396 422 28 28} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
874              code0 {o->value(pars->VoicePar[nvoice].Unison_vibratto);}
875              class WidgetPDial
876            }
877            Fl_Choice UnisonInvert {
878              label Invert
879              callback {//
880    send_data(0, ADDVOICE::control::unisonPhaseInvert, o->value(), TOPLEVEL::type::Integer);}
881              tooltip {Phase Invert} xywh {484 426 78 18} down_box BORDER_BOX labelsize 10 align 1 textfont 1 textsize 11
882              code0 {o->add("None");o->add("Random");o->add("50%");o->add("33%");o->add("25%");o->add("20%");}
883              code1 {o->value(pars->VoicePar[nvoice].Unison_invert_phase);}
884            } {}
885            Fl_Slider UnisonFreqSpread {
886              label {Frequency Spread}
887              callback {//
888                  unisonspreadoutput->do_callback();
889                  send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::unisonFrequencySpread, o->value(), TOPLEVEL::type::Integer);}
890              tooltip {Frequency Spread of the Unison} xywh {181 434 120 16} type {Horz Knob} box THIN_DOWN_BOX labelsize 10 align 1 maximum 127 step 1 value 64
891              code0 {o->value(pars->VoicePar[nvoice].Unison_frequency_spread);}
892              class mwheel_slider_rev
893            }
894            Fl_Value_Output unisonspreadoutput {
895              label {(cents)}
896              callback {o->value(pars->getUnisonFrequencySpreadCents(nvoice));}
897              xywh {145 434 38 16} box THIN_DOWN_BOX labelsize 10 align 5 maximum 1000 textsize 10
898              code0 {o->step(0.1, 1);}
899              code1 {o->value(pars->getUnisonFrequencySpreadCents(nvoice));}
900            }
901            Fl_Dial UnisonVspeed {
902              label {V.speed}
903              callback {//
904send_data(0, ADDVOICE::control::unisonVibratoSpeed, o->value(), TOPLEVEL::type::Integer);}
905              tooltip {Vibratto Average Speed} xywh {436 422 28 28} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
906              code0 {o->value(pars->VoicePar[nvoice].Unison_vibratto_speed);}
907              class WidgetPDial
908            }
909            Fl_Dial UnisonPhRnd {
910              label {Ph.rnd}
911              callback {//
912send_data(0, ADDVOICE::control::unisonPhaseRandomise, o->value(), TOPLEVEL::type::Integer);}
913              tooltip {Phase randomness} xywh {316 422 28 28} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
914              code0 {o->value(pars->VoicePar[nvoice].Unison_phase_randomness);}
915              class WidgetPDial
916            }
917            Fl_Box unisName {
918              label UNISON
919              callback {//}
920              xywh {186 402 73 25} labelfont 1 labelsize 12
921            }
922          }
923          Fl_Check_Button UnisonEn {
924            label On
925            callback {//
926send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::enableUnison, o->value(), TOPLEVEL::type::Integer);}
927            xywh {94 408 38 14} box THIN_UP_BOX down_box DOWN_BOX color 237 labelfont 1 labelsize 10
928            code0 {int tmp = (pars->VoicePar[nvoice].Unison_size);}
929            code1 {o->value(tmp > 1);}
930            class Fl_Check_Button2
931          }
932        }
933        Fl_Group amplitudegroup {
934          label AMPLITUDE
935          xywh {5 68 285 212} box UP_FRAME labelfont 1 labelsize 12 align 17
936        } {
937          Fl_Dial voicevolume {
938            label Volume
939            callback {//
940                int vol = lrint(o->value());
941                synth->getGuiMaster()->partui->adnoteui->voicelistitem[nvoice]->voicevolume->value(vol);
942                send_data(0, ADDVOICE::control::volume, vol, TOPLEVEL::type::Integer);}
943            tooltip Volume xywh {30 86 33 33} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
944            code0 {o->setValueType(VC_ADDVoiceVolume);}
945            code1 {o->value(pars->VoicePar[nvoice].PVolume);}
946            class WidgetPDial
947          }
948          Fl_Dial voicevsns {
949            label {Vel Sens}
950            callback {//
951                send_data(0, ADDVOICE::control::velocitySense, o->value(), TOPLEVEL::type::Integer);}
952            tooltip {Velocity Sensing Function - rightmost/max disables)} xywh {86 87 33 33} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
953            code0 {o->value(pars->VoicePar[nvoice].PAmpVelocityScaleFunction);}
954            code1 {o->setValueType(VC_AmpVelocitySense);}
955            class WidgetPDial
956          }
957          Fl_Dial voicepan {
958            label Pan
959            callback {//
960    int pan = lrint(o->value());
961    send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::panning, pan, TOPLEVEL::type::Integer);}
962            tooltip {Voice panning} xywh {160 86 33 33} box ROUND_UP_BOX labelsize 10 align 6 maximum 127 step 1
963            code0 {o->setValueType(VC_PanningStd);}
964            code1 {o->value(pars->VoicePar[nvoice].PPanning);}
965            class WidgetPDial
966          }
967          Fl_Dial voicewidth {
968            label Width
969            callback {//
970    send_data(0, ADDVOICE::control::randomWidth, o->value(), TOPLEVEL::type::Integer);}
971            tooltip {Voice random width} xywh {235 86 33 33} box ROUND_UP_BOX labelsize 10 maximum 63 step 1 value 63
972            code0 {o->setValueType(VC_PanningRandom);}
973            code1 {o->value(pars->VoicePar[nvoice].PWidth);}
974            class WidgetPDial
975          }
976          Fl_Check_Button voicerandompan {
977            label Rand
978            callback {//
979        int tmp = o->value();
980        if (tmp == 0)
981            voicewidth->deactivate();
982        else
983            voicewidth->activate();
984        send_data(0, ADDVOICE::control::enableRandomPan, tmp, TOPLEVEL::type::Integer);}
985            tooltip {Enable random panning} xywh {205 94 15 15} down_box DOWN_BOX color 48 labelsize 11 align 1
986            code0 {o->value(pars->VoicePar[nvoice].PRandom);}
987            code1 {if (o->value() == 0) voicewidth->deactivate(); else voicewidth->activate();}
988            class Fl_Check_Button2
989          }
990          Fl_Group voiceampenvgroup {
991            label {ADSynth Voice - Amplitude Envelope}
992            xywh {10 135 205 70} box FLAT_BOX color 51 align 144
993            code0 {o->init(pars->VoicePar[nvoice].AmpEnvelope, npart, kititem, nvoice + PART::engine::addVoice1, 0);}
994            code1 {if (!pars->VoicePar[nvoice].PAmpEnvelopeEnabled) o->deactivate();}
995            class EnvelopeUI
996          } {}
997          Fl_Check_Button AmpEnvEn {
998            label On
999            callback {//
1000                if (o->value() == 0)
1001                    voiceampenvgroup->deactivate();
1002                else
1003                    voiceampenvgroup->activate();
1004                o->redraw();
1005                send_data(0, ADDVOICE::control::enableAmplitudeEnvelope, o->value(), TOPLEVEL::type::Integer);}
1006            tooltip {Enable Amplitude Envelope} xywh {14 139 38 14} box THIN_UP_BOX down_box DOWN_BOX color 237 labelfont 1 labelsize 10
1007            code0 {o->value(pars->VoicePar[nvoice].PAmpEnvelopeEnabled);}
1008            class Fl_Check_Button2
1009          }
1010          Fl_Group voiceamplfogroup {
1011            label {Amplitude LFO     }
1012            xywh {10 205 275 70} box FLAT_BOX color 47 align 144
1013            code0 {o->init(pars->VoicePar[nvoice].AmpLfo, npart, kititem, PART::engine::addVoice1 + nvoice, 0);}
1014            code1 {if (pars->VoicePar[nvoice].PAmpLfoEnabled==0) o->deactivate();}
1015            class LFOUI
1016          } {}
1017          Fl_Check_Button AmpLfoEn {
1018            label On
1019            callback {//
1020                if (o->value() == 0)
1021                    voiceamplfogroup->deactivate();
1022                else
1023                    voiceamplfogroup->activate();
1024                o->redraw();
1025                send_data(0, ADDVOICE::control::enableAmplitudeLFO, o->value(), TOPLEVEL::type::Integer);}
1026            tooltip {Enable Amplitude LFO} xywh {14 210 38 14} box THIN_UP_BOX down_box DOWN_BOX color 237 labelfont 1 labelsize 10
1027            code0 {o->value(pars->VoicePar[nvoice].PAmpLfoEnabled);}
1028            class Fl_Check_Button2
1029          }
1030          Fl_Check_Button VolumeMinus {
1031            label Minus
1032            callback {//
1033send_data(0, ADDVOICE::control::invertPhase, o->value(), TOPLEVEL::type::Integer);}
1034            tooltip {Reverse phase relative to other voices} xywh {10 75 50 10} down_box DOWN_BOX labelsize 12
1035            code0 {o->value(pars->VoicePar[nvoice].PVolumeminus);}
1036            class Fl_Check_Button2
1037          }
1038          Fl_Box {} {
1039            xywh {140 85 4 44} box THIN_DOWN_FRAME
1040          }
1041        }
1042        Fl_Group voicefiltergroup {
1043          label {FILTER      }
1044          xywh {290 35 285 245} box UP_FRAME labelfont 1 labelsize 12 align 17
1045          code0 {if (pars->VoicePar[nvoice].PFilterEnabled==0) o->deactivate();}
1046        } {
1047          Fl_Group voicefilter {
1048            label {ADsynth Voice - Filter}
1049            xywh {295 60 275 75} box FLAT_BOX color 50 align 144
1050            code0 {o->init(pars->VoicePar[nvoice].VoiceFilter,&pars->VoicePar[nvoice].PFilterVelocityScale, &pars->VoicePar[nvoice].PFilterVelocityScaleFunction, npart, kititem, PART::engine::addVoice1 + nvoice);}
1051            class FilterUI
1052          } {}
1053          Fl_Group voicefilterenvgroup {
1054            label {ADSynth Voice - Filter Envelope}
1055            xywh {295 135 275 70} box FLAT_BOX color 51 align 144
1056            code0 {o->init(pars->VoicePar[nvoice].FilterEnvelope, npart, kititem, nvoice + PART::engine::addVoice1, 2);}
1057            code1 {if (pars->VoicePar[nvoice].PFilterEnvelopeEnabled==0) o->deactivate();}
1058            class EnvelopeUI
1059          } {}
1060          Fl_Check_Button FilterEnvEn {
1061            label On
1062            callback {//
1063                send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::enableFilterEnvelope, o->value(), TOPLEVEL::type::Integer);}
1064            tooltip {Enable Filter Envelope} xywh {300 140 38 14} box THIN_UP_BOX down_box DOWN_BOX color 237 labelfont 1 labelsize 10
1065            code0 {o->value(pars->VoicePar[nvoice].PFilterEnvelopeEnabled);}
1066            class Fl_Check_Button2
1067          }
1068          Fl_Group voicefilterlfogroup {
1069            label {Filter LFO     }
1070            xywh {295 205 275 70} box FLAT_BOX color 47 align 144
1071            code0 {o->init(pars->VoicePar[nvoice].FilterLfo, npart, kititem, PART::engine::addVoice1 + nvoice, 2);}
1072            code1 {if (pars->VoicePar[nvoice].PFilterLfoEnabled==0) o->deactivate();}
1073            class LFOUI
1074          } {}
1075          Fl_Check_Button FilterLfoEn {
1076            label On
1077            callback {//
1078                send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::enableFilterLFO, o->value(), TOPLEVEL::type::Integer);}
1079            tooltip {Enable Filter LFO} xywh {300 210 38 14} box THIN_UP_BOX down_box DOWN_BOX color 237 labelfont 1 labelsize 10
1080            code0 {o->value(pars->VoicePar[nvoice].PFilterLfoEnabled);}
1081            class Fl_Check_Button2
1082          }
1083        }
1084        Fl_Box {} {
1085          xywh {5 35 64 33} box THIN_UP_FRAME
1086        }
1087        Fl_Group {} {
1088          xywh {69 35 136 33} box THIN_UP_FRAME
1089        } {
1090          Fl_Value_Slider Delay {
1091            label Delay
1092            callback {//
1093                send_data(0, ADDVOICE::control::delay, o->value(), TOPLEVEL::type::Integer);}
1094            tooltip {Time before the voice activates} xywh {76 50 124 12} type {Horz Knob} box THIN_DOWN_BOX labelsize 11 align 1 maximum 127 step 1
1095            code0 {o->value(pars->VoicePar[nvoice].PDelay);}
1096            code1 {o->setValueType(VC_ADDVoiceDelay);o->useCustomTip(true);}
1097            class mwheel_slider_rev
1098          }
1099        }
1100        Fl_Check_Button bypassfiltercheckbutton {
1101          label {Bypass Global}
1102          callback {//
1103send_data(0, ADDVOICE::control::bypassGlobalFilter, o->value(), TOPLEVEL::type::Integer);}
1104          xywh {450 41 14 14} down_box DOWN_BOX labelsize 12 align 8
1105          code0 {o->value(pars->VoicePar[nvoice].Pfilterbypass);}
1106          class Fl_Check_Button2
1107        }
1108        Fl_Check_Button FilterEn {
1109          label On
1110          callback {//
1111              bypassfiltercheckbutton->redraw();
1112              send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::enableFilter, o->value(), TOPLEVEL::type::Integer);}
1113          tooltip {Enable Filter} xywh {294 41 38 14} box THIN_UP_BOX down_box DOWN_BOX color 237 labelfont 1 labelsize 10
1114          code0 {o->value(pars->VoicePar[nvoice].PFilterEnabled);}
1115          class Fl_Check_Button2
1116        }
1117        Fl_Group extvoicegroup {
1118          label Voice
1119          xywh {5 400 80 76} box THIN_UP_FRAME labelfont 1 labelsize 12 align 17
1120        } {
1121          Fl_Choice ExtOsc {
1122            label Source
1123            callback {//
1124                  if (nvoice == 0)
1125                      o->deactivate();
1126                  if (_SYS_::F2B(o->value())) {
1127                      oscGroup->deactivate();
1128                      SoundType->deactivate();
1129                  } else {
1130                      oscGroup->activate();
1131                      SoundType->activate();
1132                  }
1133                  send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::soundType, 0, TOPLEVEL::type::Integer);
1134                  send_data(0, ADDVOICE::control::externalOscillator, o->value() - 1, TOPLEVEL::type::Integer);}
1135            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 current voice will then tweak the signal further.} xywh {8 430 74 18} down_box BORDER_BOX selection_color 49 labelsize 10 align 5 textfont 1 textsize 10
1136            code0 {o->add("Local");}
1137            code1 {char tmp[50]; for (int i = 0; i < nvoice; ++i) {sprintf(tmp, "Voice %2d", i + 1); o->add(tmp);};}
1138            code2 {o->value(pars->VoicePar[nvoice].PVoice + 1);}
1139            code3 {if (nvoice == 0) o->deactivate();}
1140          } {}
1141          Fl_Choice SoundType {
1142            callback {//
1143              int x = int(o->value());
1144              send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::soundType, x, TOPLEVEL::type::Integer);}
1145            tooltip {Oscillator Type (sound/noise)} xywh {8 454 74 18} down_box BORDER_BOX selection_color 49 labelsize 10 when 6 textfont 1 textsize 10
1146            code0 {o->add("Sound");o->add("Whit Ns");o->add("Pink Ns");;o->add("Spot Ns");}
1147            code1 {o->value(pars->VoicePar[nvoice].Type);}
1148            code2 {if (pars->VoicePar[nvoice].Type!=0) voicemodegroup->deactivate();}
1149            code3 {if (pars->VoicePar[nvoice].PVoice >= 0) o->deactivate();}
1150          } {}
1151        }
1152        Fl_Box noiselabel {
1153          label Noise
1154          callback {//
1155                update_osclabels();}
1156          xywh {130 500 400 65} labelfont 1 labelsize 50 labelcolor 7
1157          code0 {update_osclabels();}
1158        }
1159      }
1160      Fl_Check_Button voiceonbutton {
1161        label On
1162        callback {//
1163    send_data(TOPLEVEL::action::forceUpdate, ADDVOICE::control::enableVoice, o->value(), TOPLEVEL::type::Integer);}
1164        xywh {12 41 50 20} box THIN_UP_BOX down_box DOWN_BOX color 237 labelfont 1
1165        code0 {o->value(pars->VoicePar[nvoice].Enabled);}
1166        class Fl_Check_Button2
1167      }
1168      Fl_Group Vname {
1169        label VOICE
1170        xywh {476 10 63 16} labelfont 1 align 0
1171      } {}
1172    }
1173  }
1174  Function {ADvoiceUI(int x,int y, int w, int h, const char *label=0):Fl_Group(x,y,w,h,label)} {} {
1175    code {//
1176        nvoice = 0;
1177        pars = NULL;
1178        oscedit = NULL;
1179        lastWaveW = 0;} {}
1180  }
1181  Function {send_data(int action, int control, float value, int type)} {} {
1182    code {//
1183    type |= TOPLEVEL::type::Write;
1184    collect_data(synth, value, action, type, control, npart, kititem, nvoice + PART::engine::addVoice1);} {}
1185  }
1186  Function {returns_update(CommandBlock *getData)} {} {
1187    code {//
1188    float value = getData->data.value;
1189    unsigned char control = getData->data.control;
1190    unsigned char voice = getData->data.engine;
1191    //std::cout << "voice " << int(voice) << "   nvoice " << int(nvoice) << std::endl;
1192    if (voice >= PART::engine::addMod1)
1193        voice -= PART::engine::addMod1;
1194    else if (voice >= PART::engine::addVoice1)
1195        voice -= PART::engine::addVoice1;
1196    int tmp;
1197    bool val_bool = _SYS_::F2B(value);
1198    if (control != ADDVOICE::control::enableVoice &&  voice != nvoice)
1199        return;
1200
1201    switch(control)
1202    {
1203        case ADDVOICE::control::volume:
1204            voicevolume->value(value);
1205            synth->getGuiMaster()->partui->adnoteui->voicelistitem[voice]->voicevolume->value(value);
1206            break;
1207
1208        case ADDVOICE::control::velocitySense:
1209            voicevsns->value(value);
1210            break;
1211
1212        case ADDVOICE::control::panning:
1213            voicepan->value(value);
1214            synth->getGuiMaster()->partui->adnoteui->voicelistitem[voice]->voicepanning->value(value);
1215            break;
1216
1217        case ADDVOICE::control::enableRandomPan:
1218            voicerandompan->value(val_bool);
1219            if (val_bool)
1220                voicewidth->activate();
1221            else
1222                voicewidth->deactivate();
1223            break;
1224
1225        case ADDVOICE::control::randomWidth:
1226            voicewidth->value(value);
1227            break;
1228
1229        case ADDVOICE::control::invertPhase:
1230            VolumeMinus->value(val_bool);
1231            break;
1232
1233        case ADDVOICE::control::enableAmplitudeEnvelope:
1234            AmpEnvEn->value(val_bool);
1235            if (val_bool == 0)
1236                    voiceampenvgroup->deactivate();
1237                else
1238                    voiceampenvgroup->activate();
1239            break;
1240
1241        case ADDVOICE::control::enableAmplitudeLFO:
1242            AmpLfoEn->value(val_bool);
1243            if (val_bool == 0)
1244                    voiceamplfogroup->deactivate();
1245                else
1246                    voiceamplfogroup->activate();
1247            break;
1248
1249        case ADDVOICE::control::modulatorType:
1250            ModType->value((int)value);
1251            synth->getGuiMaster()->partui->adnoteui->voicelistitem[voice]->update_modlabel();
1252            if (value == 0)
1253                    voiceFMparametersgroup->deactivate();
1254                else
1255                    voiceFMparametersgroup->activate();
1256            break;
1257
1258        case ADDVOICE::control::externalModulator:
1259            tmp = (int) value;
1260            ExtMod->value(tmp + 1);
1261            if (tmp >= 0)
1262            {
1263                modoscil->deactivate();
1264            }
1265            else
1266            {
1267                modoscil->activate();
1268            }
1269            voiceFMparametersgroup->redraw();
1270            update_fmoscil();
1271            oscFM->redraw();
1272            modoscil->redraw();
1273            modvoicelabel->do_callback();
1274            break;
1275
1276        case ADDVOICE::control::detuneFrequency:
1277            if (voice == nvoice)
1278                Detune->value(value);
1279            detunevalueoutput->do_callback();
1280            synth->getGuiMaster()->partui->adnoteui->voicelistitem[voice]->voicedetune->value(value);
1281            synth->getGuiMaster()->partui->adnoteui->voicelistitem[voice]->detunevalueoutput->do_callback();
1282            break;
1283
1284        case ADDVOICE::control::equalTemperVariation:
1285            fixedfreqetdial->value(value);
1286            break;
1287
1288        case ADDVOICE::control::baseFrequencyAs440Hz:
1289            Freq440->value(val_bool);
1290            if (value == 0 && Mod440->value() == 0)
1291                fixedfreqetdial->deactivate();
1292            else
1293                fixedfreqetdial->activate();
1294            break;
1295
1296        case ADDVOICE::control::octave:
1297            Octave->value((int) value);
1298            break;
1299
1300        case ADDVOICE::control::detuneType:
1301            FreqDetunetype->value((int) value);
1302            detunevalueoutput->do_callback();
1303            break;
1304
1305        case ADDVOICE::control::coarseDetune:
1306            CoarseDetune->value((int) value);
1307            break;
1308
1309        case ADDVOICE::control::pitchBendAdjustment:
1310            bend->value(value);
1311            break;
1312
1313        case ADDVOICE::control::pitchBendOffset:
1314            offset->value(value);
1315            break;
1316
1317        case ADDVOICE::control::enableFrequencyEnvelope:
1318            FreqEn->value(val_bool);
1319            if (val_bool == 0)
1320                voicefreqenvgroup->deactivate();
1321            else
1322                voicefreqenvgroup->activate();
1323            break;
1324
1325        case ADDVOICE::control::enableFrequencyLFO:
1326            FreqLfoEn->value(val_bool);
1327             if (val_bool == 0)
1328                 voicefreqlfogroup->deactivate();
1329             else
1330                 voicefreqlfogroup->activate();
1331            break;
1332
1333        case ADDVOICE::control::unisonFrequencySpread:
1334            UnisonFreqSpread->value(value);
1335            unisonspreadoutput->do_callback();
1336            break;
1337
1338        case ADDVOICE::control::unisonPhaseRandomise:
1339            UnisonPhRnd->value(value);
1340            break;
1341
1342        case ADDVOICE::control::unisonStereoSpread:
1343            UnisonStereo->value(value);
1344            break;
1345
1346        case ADDVOICE::control::unisonVibratoDepth:
1347            UnisonVib->value(value);
1348            break;
1349
1350        case ADDVOICE::control::unisonVibratoSpeed:
1351            UnisonVspeed->value(value);
1352            break;
1353
1354        case ADDVOICE::control::unisonSize:
1355            {
1356                tmp = int(value);
1357                unisonsize->value(tmp);
1358                int colr = FL_BLACK;
1359                int i = 0;
1360                while (pars->ADnote_unison_sizes[i] != 0)
1361                {
1362                    if (pars->ADnote_unison_sizes[i] == tmp)
1363                    {
1364                        colr = FL_RED;
1365                        break;
1366                    }
1367                    ++ i;
1368                }
1369                unisonsize->labelcolor(colr);
1370                unisongroup->redraw();
1371                UnisonEn->redraw();
1372            }
1373            break;
1374
1375        case ADDVOICE::control::unisonPhaseInvert:
1376            UnisonInvert->value(value);
1377            break;
1378
1379        case ADDVOICE::control::enableUnison:
1380            UnisonEn->value(val_bool);
1381            if (val_bool == 0)
1382            {
1383                unisonsize->value(2);
1384                unisongroup->deactivate();
1385            }
1386            else
1387            {
1388                unisongroup->activate();
1389                int colr = FL_BLACK;
1390                int i = -1;
1391                while (true)
1392                {
1393                    ++i;
1394                    if (pars->ADnote_unison_sizes[i] == 0)
1395                        break;
1396                    if (pars->ADnote_unison_sizes[i] == int(unisonsize->value()))
1397                    {
1398                        colr = FL_RED;
1399                        break;
1400                    }
1401                }
1402                unisonsize->labelcolor(colr);
1403                unisongroup->redraw();
1404                 UnisonEn->redraw();
1405            }
1406            break;
1407
1408        case ADDVOICE::control::enableFilter:
1409            FilterEn->value(val_bool);
1410            if (val_bool)
1411                  voicefiltergroup->activate();
1412              else
1413                  voicefiltergroup->deactivate();
1414              bypassfiltercheckbutton->redraw(); // yes it's needed!
1415            break;
1416
1417        case ADDVOICE::control::bypassGlobalFilter:
1418            bypassfiltercheckbutton->value(val_bool);
1419            break;
1420        case ADDVOICE::control::enableFilterEnvelope:
1421            FilterEnvEn->value(val_bool);
1422            if (val_bool)
1423                voicefilterenvgroup->activate();
1424            else
1425                voicefilterenvgroup->deactivate();
1426            FilterEnvEn->redraw(); // yes it's needed!
1427            break;
1428
1429        case ADDVOICE::control::enableFilterLFO:
1430            FilterLfoEn->value(val_bool);
1431            if (val_bool)
1432                voicefilterlfogroup->activate();
1433            else
1434                voicefilterlfogroup->deactivate();
1435            FilterLfoEn->redraw(); // yes it's needed!
1436            break;
1437
1438        case ADDVOICE::control::modulatorAmplitude:
1439            ModVolume->value(value);
1440            break;
1441
1442        case ADDVOICE::control::modulatorVelocitySense:
1443            ModVsense->value(value);
1444            break;
1445
1446        case ADDVOICE::control::modulatorHFdamping:
1447            ModFdamp->value(value);
1448            break;
1449
1450        case ADDVOICE::control::enableModulatorAmplitudeEnvelope:
1451            ModAmpEn->value(val_bool);
1452            if (val_bool)
1453                voiceFMampenvgroup->activate();
1454            else
1455                voiceFMampenvgroup->deactivate();
1456            break;
1457
1458        case ADDVOICE::control::modulatorDetuneFrequency:
1459            ModDetune->value(value);
1460            fmdetunevalueoutput->do_callback();
1461            break;
1462
1463        case ADDVOICE::control::modulatorDetuneFromBaseOsc:
1464            detuneFromBaseOsc->value(value);
1465            break;
1466
1467
1468        case ADDVOICE::control::modulatorFrequencyAs440Hz:
1469            tmp = (val_bool);
1470            Mod440->value(tmp);
1471            if (tmp == 0 && lrint(Freq440->value() == 0))
1472                fixedfreqetdial->deactivate();
1473            else
1474                fixedfreqetdial->activate();
1475            if (tmp != 0)
1476                detuneFromBaseOsc->deactivate();
1477            else
1478                detuneFromBaseOsc->activate();
1479            break;
1480        case ADDVOICE::control::modulatorOctave:
1481            ModOctave->value((int) value);
1482            break;
1483
1484        case ADDVOICE::control::modulatorDetuneType:
1485            ModDetuneType->value((int) value);
1486            fmdetunevalueoutput->do_callback();
1487            break;
1488
1489        case ADDVOICE::control::modulatorCoarseDetune:
1490            ModCoarseDetune->value((int) value);
1491            break;
1492
1493        case ADDVOICE::control::enableModulatorFrequencyEnvelope:
1494            ModFreqEn->value(val_bool);
1495            if (val_bool == 0)
1496                voiceFMfreqenvgroup->deactivate();
1497            else
1498                voiceFMfreqenvgroup->activate();
1499            break;
1500
1501        case ADDVOICE::control::modulatorOscillatorPhase:
1502            ModPhase->value(value);
1503            oscFM->phase = 64 - lrint(value);
1504            update_fmoscil();
1505            oscFM->redraw();
1506            modoscil->redraw();
1507            modvoicelabel->do_callback();
1508            break;
1509
1510        case ADDVOICE::control::modulatorOscillatorSource:
1511            tmp = int(value);
1512            ExtModOsc->value(tmp + 1);
1513            if (tmp < 0)
1514            {
1515                tmp = voice;
1516                changeFMoscilbutton->labelcolor(FL_BLACK);
1517            }
1518            else
1519                changeFMoscilbutton->labelcolor(FL_BLUE);
1520            update_fmoscil();
1521            voiceFMparametersgroup->redraw();
1522            oscFM->redraw();
1523            modoscil->redraw();
1524            modvoicelabel->do_callback();
1525            break;
1526
1527        case ADDVOICE::control::delay:
1528            Delay->value(value);
1529            break;
1530
1531        case ADDVOICE::control::enableVoice:
1532            tmp = (val_bool);
1533            voiceonbutton->value(tmp);
1534            synth->getGuiMaster()->partui->adnoteui->voicelistitem[voice]->voiceenabled->value(tmp);
1535            synth->getGuiMaster()->partui->adnoteui->setVoiceTabs(voice, false);
1536            synth->getGuiMaster()->partui->adnoteui->setTabColour(voice);
1537            if (tmp)
1538            {
1539                nvoice = voice;
1540                voiceparametersgroup->activate();
1541                synth->getGuiMaster()->partui->adnoteui->voicelistitem[voice]->voicelistitemgroup->activate();
1542            }
1543            else
1544            {
1545                voiceparametersgroup->deactivate();
1546                synth->getGuiMaster()->partui->adnoteui->voicelistitem[voice]->voicelistitemgroup->deactivate();
1547            }
1548            voiceonbutton->redraw();
1549            synth->getGuiMaster()->partui->adnoteui->voiceTabBar->redraw();
1550            break;
1551
1552        case ADDVOICE::control::enableResonance:
1553            tmp = (val_bool);
1554            if (voice == nvoice)
1555                ResonanceEn->value(tmp);
1556            synth->getGuiMaster()->partui->adnoteui->voicelistitem[voice]->voiceresonanceenabled->value(tmp);
1557            break;
1558
1559        case ADDVOICE::control::voiceOscillatorPhase:
1560            tmp = (int)value;
1561            VoiceOscPhase->value(tmp);
1562            osc->phase = 64 - tmp;
1563            update_voiceoscil();
1564            voiceoscil->redraw();
1565            osclabel->redraw();
1566            break;
1567
1568        case ADDVOICE::control::voiceOscillatorSource:
1569            tmp = int(value);
1570            UseOsc->value(tmp + 1);
1571            if (tmp < 0)
1572            {
1573                tmp = voice;
1574                changevoiceoscilbutton->labelcolor(FL_BLACK);
1575            }
1576            else
1577                changevoiceoscilbutton->labelcolor(FL_BLUE);
1578            changevoiceoscilbutton->redraw();
1579            update_voiceoscil();
1580            voiceoscil->redraw();
1581            update_osclabels();
1582            break;
1583
1584        case ADDVOICE::control::soundType:
1585            tmp = lrint(value);
1586            SoundType->value(tmp);
1587            if (tmp)
1588                voicemodegroup->deactivate();
1589            else
1590                voicemodegroup->activate();
1591            update_osclabels();
1592            break;
1593
1594        case ADDVOICE::control::externalOscillator:
1595            tmp = int(value);
1596            ExtOsc->value(tmp + 1);
1597            update_voiceoscil();
1598            voiceoscil->redraw();
1599            update_osclabels();
1600            break;
1601    }} {}
1602  }
1603  Function {update_osclabels()} {} {
1604    code {//
1605    if (pars->VoicePar[nvoice].PVoice >= 0)
1606{
1607    char str[15];
1608    snprintf(str, sizeof(str), "Voice %d", pars->VoicePar[nvoice].PVoice + 1);
1609    osclabel->copy_label(str);
1610    osclabel->labelcolor(EXTVOICE_COLOUR);
1611    osclabel->show();
1612    noiselabel->hide();
1613}
1614else if (pars->VoicePar[nvoice].Type == 0 && pars->VoicePar[nvoice].Pextoscil >= 0)
1615{
1616    char str[15];
1617    snprintf(str, sizeof(str), "Osc. %d", pars->VoicePar[nvoice].Pextoscil + 1);
1618    osclabel->copy_label(str);
1619    osclabel->labelcolor(EXTOSC_COLOUR);
1620    osclabel->show();
1621    noiselabel->hide();
1622}
1623else if (pars->VoicePar[nvoice].Type == 1)
1624{
1625    noiselabel->copy_label("White Noise");
1626    noiselabel->labelcolor(7);
1627    noiselabel->show();
1628    osclabel->hide();
1629}
1630else if (pars->VoicePar[nvoice].Type == 2)
1631{
1632    noiselabel->copy_label("Pink Noise");
1633    noiselabel->labelcolor(5);
1634    noiselabel->show();
1635    osclabel->hide();
1636}
1637else if (pars->VoicePar[nvoice].Type == 3)
1638{
1639    noiselabel->copy_label("Spot Noise");
1640    noiselabel->labelcolor(6);
1641    noiselabel->show();
1642    osclabel->hide();
1643}
1644else
1645{
1646    noiselabel->hide();
1647    osclabel->hide();
1648}} {}
1649  }
1650  Function {update_modvoicelabel()} {} {
1651    code {if (pars->VoicePar[nvoice].PFMVoice >= 0)
1652{
1653    char str[15];
1654    snprintf(str, sizeof(str), "Voice %d", pars->VoicePar[nvoice].PFMVoice + 1);
1655    modvoicelabel->copy_label(str);
1656    modvoicelabel->labelcolor(EXTVOICE_COLOUR);
1657    modvoicelabel->show();
1658}
1659else if (pars->VoicePar[nvoice].PextFMoscil >= 0)
1660{
1661    char str[15];
1662    snprintf(str, sizeof(str), "Mod. %d", pars->VoicePar[nvoice].PextFMoscil + 1);
1663    modvoicelabel->copy_label(str);
1664    modvoicelabel->labelcolor(EXTOSC_COLOUR);
1665    modvoicelabel->show();
1666}
1667else
1668{
1669    modvoicelabel->hide();
1670}} {}
1671  }
1672  Function {update_voiceoscil()} {} {
1673    code {int nvs = nvoice, nvp = nvoice;
1674if (pars->VoicePar[nvoice].PVoice != -1)
1675    while (pars->VoicePar[nvs].PVoice != -1)
1676        nvp = nvs = pars->VoicePar[nvs].PVoice;
1677else if (pars->VoicePar[nvoice].Pextoscil != -1)
1678    nvs = pars->VoicePar[nvoice].Pextoscil;
1679oscil->changeParams(pars->VoicePar[nvs].POscil);
1680osc->init(oscil,0,pars->VoicePar[nvp].Poscilphase, synth);} {}
1681  }
1682  Function {update_fmoscil()} {} {
1683    code {int nv=nvoice;
1684if (pars->VoicePar[nvoice].PFMVoice >= 0) {
1685    nv = pars->VoicePar[nvoice].PFMVoice;
1686    while (pars->VoicePar[nv].PVoice >= 0) {
1687        nv = pars->VoicePar[nv].PVoice;
1688    }
1689    oscilFM->changeParams(pars->VoicePar[nv].POscil);
1690    oscFM->init(oscilFM,0,pars->VoicePar[nv].Poscilphase, synth);
1691} else {
1692    if (pars->VoicePar[nvoice].PextFMoscil >= 0) {
1693        nv = pars->VoicePar[nvoice].PextFMoscil;
1694    }
1695    oscilFM->changeParams(pars->VoicePar[nv].POscilFM);
1696    oscFM->init(oscilFM,0,pars->VoicePar[nvoice].PFMoscilphase, synth);
1697}} {}
1698  }
1699  Function {voiceRtext(float dScale)} {} {
1700    code {//
1701   if (oscedit)
1702   {
1703       if (oscedit->osceditUI->visible() && lastWaveW != oscedit->osceditUI->w())
1704       {
1705           lastWaveW = oscedit->osceditUI->w();
1706           oscedit->waveRtext();
1707       }
1708   }
1709   voiceampenvgroup->wincheck();
1710   voicefilterenvgroup->wincheck();
1711   voicefreqenvgroup->wincheck();
1712
1713   voiceFMampenvgroup->wincheck();
1714   voiceFMfreqenvgroup->wincheck();
1715
1716   if (!ADnoteVoiceParameters->visible())
1717       return;
1718
1719   if (dScale == lastdScale)
1720       return;
1721
1722   voiceamplfogroup->lfoRtext(dScale);
1723   voiceampenvgroup->envRtext(dScale);
1724
1725   voicefilterlfogroup->lfoRtext(dScale);
1726   voicefilterenvgroup->envRtext(dScale);
1727
1728   voicefreqlfogroup->lfoRtext(dScale);
1729   voicefreqenvgroup->envRtext(dScale);
1730
1731   voicefilter->filterRtext(dScale);
1732
1733   lastdScale = dScale;
1734
1735   int size = int(10 * dScale);
1736   int size11 = int(11 * dScale);
1737   int size12 = int(12 * dScale);
1738   int size14 = int(14 * dScale);
1739
1740   voiceonbutton->labelsize(size14);
1741   Vname->labelsize(size14);
1742
1743   ResonanceEn->labelsize(size11);
1744   amplitudegroup->labelsize(size12);
1745   voicevolume->labelsize(size);
1746   voicevsns->labelsize(size);
1747   voicepan->labelsize(size);
1748   voicewidth->labelsize(size);
1749   voicerandompan->labelsize(size11);
1750   AmpEnvEn->labelsize(size);
1751   AmpLfoEn->labelsize(size);
1752   VolumeMinus->labelsize(size);
1753
1754   voicefiltergroup->labelsize(size12);
1755   FilterEnvEn->labelsize(size);
1756   FilterLfoEn->labelsize(size);
1757
1758   Delay->labelsize(size11);
1759   bypassfiltercheckbutton->labelsize(size12);
1760   FilterEn->labelsize(size);
1761
1762   freqencygrp->labelsize(size12);
1763   FreqEn->labelsize(size);
1764   FreqLfoEn->labelsize(size);
1765   Octave->labelsize(size);
1766   	Octave->textsize(size11);
1767   CoarseDetune->labelsize(size);
1768       CoarseDetune->textsize(size11);
1769   detunevalueoutput->labelsize(size);
1770   	detunevalueoutput->textsize(size);
1771   FreqDetunetype->labelsize(size);
1772       FreqDetunetype->textsize(size11);
1773   bend->labelsize(size);
1774   Freq440->labelsize(size11);
1775   fixedfreqetdial->labelsize(size);
1776   offset->labelsize(size);
1777
1778   unisonsize->labelsize(size);
1779        unisonsize->textsize(size11);
1780   UnisonStereo->labelsize(size);
1781   UnisonVib->labelsize(size);
1782   UnisonFreqSpread->labelsize(size);
1783   unisonspreadoutput->labelsize(size);
1784        unisonspreadoutput->textsize(size11);
1785   UnisonVspeed->labelsize(size);
1786   UnisonPhRnd->labelsize(size);
1787   UnisonInvert->labelsize(size);
1788       UnisonInvert->textsize(size11);
1789   UnisonEn->labelsize(size);
1790   unisName->labelsize(size12);
1791
1792   extvoicegroup->labelsize(size12);
1793   ExtOsc->labelsize(size);
1794       ExtOsc->textsize(size);
1795   SoundType->labelsize(size);
1796       SoundType->textsize(size);
1797
1798   oscParamBox->labelsize(size12);
1799   UseOsc->labelsize(size);
1800       UseOsc->textsize(size);
1801   changevoiceoscilbutton->labelsize(size);
1802   VoiceOscPhase->labelsize(size);
1803
1804   noiselabel->labelsize(int(50 * dScale));
1805   osclabel->labelsize(int(50 * dScale));
1806
1807   voiceFMparametersgroup->labelsize(size12);
1808   voiceFMampenvgroup->envRtext(dScale);
1809   voiceFMfreqenvgroup->envRtext(dScale);
1810
1811   ExtMod->labelsize(size11);
1812       ExtMod->textsize(size14);
1813
1814   Modampgrp->labelsize(size11);
1815   ModVolume->labelsize(size11);
1816       ModVolume->textsize(size);
1817   ModVsense->labelsize(size11);
1818       ModVsense->textsize(size);
1819   ModFdamp->labelsize(size11);
1820       ModFdamp->textsize(size);
1821   ModAmpEn->labelsize(size);
1822
1823   modfrequency->labelsize(size11);
1824   ModCoarseDetune->labelsize(size);
1825       ModCoarseDetune->textsize(size);
1826   ModOctave->labelsize(size);
1827       ModOctave->textsize(size);
1828   fmdetunevalueoutput->labelsize(size);
1829       fmdetunevalueoutput->textsize(size);
1830   detuneFromBaseOsc->labelsize(size11);
1831   Mod440->labelsize(size11);
1832   ModDetuneType->labelsize(size);
1833       ModDetuneType->textsize(size11);
1834
1835   ModFreqEn->labelsize(size);
1836
1837   ModType->labelsize(size11);
1838       ModType->textsize(size14);
1839
1840  ModLocalOsc->labelsize(size12);
1841  changeFMoscilbutton->labelsize(size);
1842  ModPhase->labelsize(size);
1843  ExtModOsc->labelsize(size);
1844      ExtModOsc->textsize(size);
1845
1846  modvoicelabel->labelsize(int(40 * dScale));} {}
1847  }
1848  Function {init(ADnoteParameters *parameters,int npart_, int kititem_, int nvoice_)} {} {
1849    code {//
1850        synth = parameters->getSynthEngine();
1851        pars = parameters;
1852        npart = npart_;
1853        kititem = kititem_;
1854        nvoice = nvoice_;
1855        lastdScale = 0;
1856        fft = new FFTwrapper(synth->oscilsize);
1857        oscil = new OscilGen(fft, NULL, synth, parameters->VoicePar[nvoice].POscil);
1858        oscilFM = new OscilGen(fft, NULL, synth, parameters->VoicePar[nvoice].POscilFM);
1859        make_window();
1860        end();
1861        if (nvoice == 0)
1862        {
1863            UseOsc->deactivate();
1864            ExtMod->deactivate();
1865            ExtModOsc->deactivate();
1866        }
1867
1868        ADnoteVoiceParameters->show();} {}
1869  }
1870  Function {~ADvoiceUI()} {} {
1871    code {//
1872        ADnoteVoiceParameters->hide();
1873        hide();
1874        if (oscedit)
1875            delete oscedit;
1876        delete oscil;
1877        delete oscilFM;
1878        delete fft;} {}
1879  }
1880  decl {int nvoice;} {public local
1881  }
1882  decl {int npart;} {private local
1883  }
1884  decl {int kititem;} {private local
1885  }
1886  decl {ADnoteParameters *pars;} {private local
1887  }
1888  decl {OscilEditor *oscedit;} {public local
1889  }
1890  decl {FFTwrapper *fft;} {private local
1891  }
1892  decl {OscilGen *oscil;} {private local
1893  }
1894  decl {OscilGen *oscilFM;} {private local
1895  }
1896  decl {Oscilloscope *osc;} {private local
1897  }
1898  decl {Oscilloscope *oscFM;} {private local
1899  }
1900  decl {SynthEngine *synth;} {private local
1901  }
1902  decl {float lastdScale;} {private local
1903  }
1904  decl {int lastWaveW;} {private local
1905  }
1906}
1907
1908class ADnoteUI {: {public PresetsUI_}
1909} {
1910  Function {make_window()} {private
1911  } {
1912    comment {globalrandompan MUST be after globalwidth} {in_source in_header
1913    }
1914    Fl_Window ADnoteGlobalParameters {
1915      label {ADsynth Global Parameters of the Instrument}
1916      callback {//
1917    saveWin(synth,  ADnoteGlobalParameters->w(),  ADnoteGlobalParameters->h(), ADnoteGlobalParameters->x(), ADnoteGlobalParameters->y(), false, "AddSynth");
1918    globalSeen = false;
1919    resui->resonancewindow->hide();
1920    o->hide();}
1921      xywh {890 430 575 405} type Double hide resizable
1922      code0 {o->copy_label(synth->getGuiMaster()->setPartWindowTitle("AddSynth Global").c_str());}
1923      code1 {addDW = 535; addDH = 405;}
1924      code2 {o->size_range(addDW, addDH, 0, 0, 0, 0, 1);}
1925    } {
1926      Fl_Group globalfreq {
1927        label FREQUENCY
1928        xywh {5 255 570 115} box THIN_UP_BOX labelfont 1 labelsize 12 align 17
1929      } {
1930        Fl_Group freqenv {
1931          label {ADSynth Global - Frequency Envelope}
1932          xywh {10 295 205 70} box FLAT_BOX color 51 labelsize 12 align 144
1933          code0 {o->init(pars->GlobalPar.FreqEnvelope, npart, kititem, 0, 1);}
1934          class EnvelopeUI
1935        } {}
1936        Fl_Counter octave {
1937          label Octave
1938          callback {//
1939    send_data(0, ADDSYNTH::control::octave, o->value(), TOPLEVEL::type::Integer);}
1940          tooltip Octave xywh {495 275 45 15} type Simple color 237 selection_color 0 labelsize 10 align 1 minimum -8 maximum 7 step 1 textfont 1 textsize 11
1941          code0 {int k = pars->GlobalPar.PCoarseDetune / 1024; if (k >= 8) k -= 16;}
1942          code2 {o->value(k);}
1943        }
1944        Fl_Counter coarsedet {
1945          label {Coarse det.}
1946          callback {//
1947    send_data(0, ADDSYNTH::control::coarseDetune, o->value(), TOPLEVEL::type::Integer);}
1948          tooltip {Coarse Detune} xywh {500 345 60 20} labelsize 10 align 5 minimum -64 maximum 63 step 1 textfont 1 textsize 11
1949          code0 {int k = pars->GlobalPar.PCoarseDetune % 1024; if (k >= 512) k -= 1024;}
1950          code2 {o->value(k);}
1951          code3 {o->lstep(10);}
1952        }
1953        Fl_Group freqlfo {
1954          label {Frequency LFO}
1955          xywh {215 295 275 70} box FLAT_BOX color 47 labelsize 12 align 144
1956          code0 {o->init(pars->GlobalPar.FreqLfo, npart, kititem, 0, 1);}
1957          class LFOUI
1958        } {}
1959        Fl_Slider freq {
1960          callback {//
1961            detunevalueoutput->do_callback();
1962            send_data(0, ADDSYNTH::control::detuneFrequency, o->value(), TOPLEVEL::type::Integer);}
1963          tooltip {Fine Detune (cents)} xywh {57 275 433 15} type {Horz Knob} box THIN_DOWN_BOX minimum -8192 maximum 8191 step 1
1964          code0 {o->value(pars->GlobalPar.PDetune - 8192);}
1965          class mwheel_slider_rev
1966        }
1967        Fl_Value_Output detunevalueoutput {
1968          label Detune
1969          callback {o->value(getDetune(pars->GlobalPar.PDetuneType,0,pars->GlobalPar.PDetune));}
1970          xywh {12 275 45 15} labelsize 10 align 5 minimum -5000 maximum 5000 textfont 1 textsize 10
1971          code0 {o->step(0.01, 1);}
1972          code1 {o->value(getDetune(pars->GlobalPar.PDetuneType, 0, pars->GlobalPar.PDetune));}
1973        }
1974        Fl_Choice detunetype {
1975          label {Detune Type}
1976          callback {//
1977    send_data(0, ADDSYNTH::control::detuneType, o->value() + 1, TOPLEVEL::type::Integer);}
1978          xywh {495 313 75 17} down_box BORDER_BOX labelsize 10 align 5 textfont 1 textsize 11
1979          code0 {o->add("L35 cents");o->add("L10cents");o->add("E100cents");o->add("E1200cents");}
1980          code1 {o->value(pars->GlobalPar.PDetuneType-1);}
1981        } {}
1982        Fl_Dial relBwidth {
1983          label relBW
1984          callback {//
1985    send_data(0, ADDSYNTH::control::relativeBandwidth, o->value(), TOPLEVEL::type::Integer);}
1986          tooltip {Bandwidth - modify the relative fine detune of the voices} xywh {545 270 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
1987          code0 {o->value(pars->GlobalPar.PBandwidth);}
1988          class WidgetPDial
1989        }
1990      }
1991      Fl_Box {} {
1992        xywh {10 7 275 68} box PLASTIC_UP_BOX color 223
1993      }
1994      Fl_Group amplitudegrp {
1995        label AMPLITUDE
1996        xywh {5 7 285 250} box THIN_UP_FRAME labelfont 1 labelsize 12 align 17
1997      } {
1998        Fl_Dial globalvolume {
1999          label Volume
2000          callback {//
2001send_data(0, ADDSYNTH::control::volume, o->value(), TOPLEVEL::type::Integer);}
2002          tooltip Volume xywh {30 23 35 35} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
2003          code0 {o->setValueType(VC_InstrumentVolume);}
2004          code1 {o->value(pars->GlobalPar.PVolume);}
2005          class WidgetPDial
2006        }
2007        Fl_Dial vsns {
2008          label {Vel Sens}
2009          callback {send_data(0, ADDSYNTH::control::velocitySense, o->value(), TOPLEVEL::type::Integer);}
2010          tooltip {Velocity Sensing Function - rightmost/max to disable} xywh {85 23 35 35} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
2011          code0 {o->value(pars->GlobalPar.PAmpVelocityScaleFunction);}
2012          code2 {o->setValueType(VC_AmpVelocitySense);}
2013          class WidgetPDial
2014        }
2015        Fl_Dial globalpan {
2016          label Pan
2017          callback {//
2018    send_data(0, ADDSYNTH::control::panning, o->value(), TOPLEVEL::type::Integer);}
2019          tooltip {Global panning} xywh {155 23 35 35} box ROUND_UP_BOX labelsize 10 maximum 127 step 1
2020          code0 {o->setValueType(VC_PanningStd);}
2021          code1 {o->value(pars->GlobalPar.PPanning);}
2022          class WidgetPDial
2023        }
2024        Fl_Dial globalwidth {
2025          label Width
2026          callback {//
2027    send_data(0, ADDSYNTH::control::randomWidth, o->value(), TOPLEVEL::type::Integer);}
2028          tooltip {Global random width} xywh {235 23 35 35} box ROUND_UP_BOX labelsize 10 maximum 63 step 1 value 63
2029          code0 {o->setValueType(VC_PanningRandom);}
2030          code1 {o->value(pars->GlobalPar.PWidth);}
2031          class WidgetPDial
2032        }
2033        Fl_Check_Button globalrandompan {
2034          label Rand
2035          callback {//
2036        int tmp = o->value();
2037        if (tmp == 0)
2038            globalwidth->deactivate();
2039        else
2040            globalwidth->activate();
2041        send_data(0, ADDSYNTH::control::enableRandomPan, tmp, TOPLEVEL::type::Integer);}
2042          tooltip {Enable random panning} xywh {205 32 15 15} down_box DOWN_BOX color 48 labelsize 11 align 1
2043          code0 {o->value(pars->GlobalPar.PRandom);}
2044          code1 {if (o->value() == 0) globalwidth->deactivate(); else globalwidth->activate();}
2045          class Fl_Check_Button2
2046        }
2047        Fl_Dial depop {
2048          label {D.Pop}
2049          callback {//
2050send_data(0, ADDSYNTH::control::dePop, o->value(), TOPLEVEL::type::Integer);}
2051          tooltip {Pop Suppression} xywh {130 227 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
2052          code0 {o->value(pars->GlobalPar.Fadein_adjustment);}
2053          class WidgetPDial
2054        }
2055        Fl_Dial pstr {
2056          label {P.Str.}
2057          callback {//
2058send_data(0, ADDSYNTH::control::punchStrength, o->value(), TOPLEVEL::type::Integer);}
2059          tooltip {Punch Strength} xywh {170 227 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
2060          code0 {o->value(pars->GlobalPar.PPunchStrength);}
2061          class WidgetPDial
2062        }
2063        Fl_Dial pt {
2064          label {P.t.}
2065          callback {//
2066send_data(0, ADDSYNTH::control::punchDuration, o->value(), TOPLEVEL::type::Integer);}
2067          tooltip {Punch Time (duration)} xywh {200 227 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
2068          code0 {o->value(pars->GlobalPar.PPunchTime);}
2069          class WidgetPDial
2070        }
2071        Fl_Dial pstc {
2072          label {P.Stc.}
2073          callback {//
2074send_data(0, ADDSYNTH::control::punchStretch, o->value(), TOPLEVEL::type::Integer);}
2075          tooltip {Punch Stretch} xywh {230 227 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
2076          code0 {o->value(pars->GlobalPar.PPunchStretch);}
2077          class WidgetPDial
2078        }
2079        Fl_Dial pvel {
2080          label {P.Vel.}
2081          callback {//
2082send_data(0, ADDSYNTH::control::punchVelocity, o->value(), TOPLEVEL::type::Integer);}
2083          tooltip {Punch Velocity Sensing} xywh {260 227 25 25} box ROUND_UP_BOX labelsize 10 align 1 maximum 127 step 1
2084          code0 {o->value(pars->GlobalPar.PPunchVelocitySensing);}
2085          class WidgetPDial
2086        }
2087        Fl_Group ampenv {
2088          label {ADSynth Global - Amplitude Envelope}
2089          xywh {10 75 205 70} box FLAT_BOX color 51 labelsize 12 align 144
2090          code0 {o->init(pars->GlobalPar.AmpEnvelope, npart, kititem, 0, 0);}
2091          class EnvelopeUI
2092        } {}
2093        Fl_Group amplfo {
2094          label {Amplitude LFO}
2095          xywh {10 145 275 70} box FLAT_BOX color 47 labelsize 12 align 144
2096          code0 {o->init(pars->GlobalPar.AmpLfo, npart, kititem, 0, 0);}
2097          class LFOUI
2098        } {}
2099        Fl_Check_Button rndgrp {
2100          label {Rnd Grp}
2101          callback {pars->GlobalPar.Hrandgrouping = lrint(o->value());
2102send_data(0, ADDSYNTH::control::randomGroup, o->value(), TOPLEVEL::type::Integer);}
2103          tooltip {Disable individual Harmonic Amplitude randomisation for voices that use the same oscillator} xywh {8 234 63 18} down_box DOWN_BOX labelsize 11
2104          code0 {o->value(pars->GlobalPar.Hrandgrouping);}
2105          class Fl_Check_Button2
2106        }
2107        Fl_Box {} {
2108          xywh {135 21 4 47} box THIN_DOWN_FRAME
2109        }
2110      }
2111      Fl_Group filtergrp {
2112        label FILTER
2113        xywh {290 5 285 250} box THIN_UP_BOX labelfont 1 labelsize 12 align 17
2114      } {
2115        Fl_Group filterenv {
2116          label {ADSynth Global - Filter Envelope}
2117          xywh {295 110 275 70} box FLAT_BOX color 51 labelsize 12 align 144
2118          code0 {o->init(pars->GlobalPar.FilterEnvelope, npart, kititem, 0, 2);}
2119          class EnvelopeUI
2120        } {}
2121        Fl_Group filterlfo {
2122          label {Filter LFO}
2123          xywh {295 180 275 70} box FLAT_BOX color 47 labelsize 12 align 144
2124          code0 {o->init(pars->GlobalPar.FilterLfo, npart, kititem, 0, 2);}
2125          class LFOUI
2126        } {}
2127        Fl_Group filterui {
2128          label {ADsynth Global - Filter}
2129          xywh {295 35 275 75} box FLAT_BOX color 50 labelsize 12 align 144
2130          code0 {o->init(pars->GlobalPar.GlobalFilter, &pars->GlobalPar.PFilterVelocityScale, &pars->GlobalPar.PFilterVelocityScaleFunction, npart, kititem, 0);}
2131          class FilterUI
2132        } {}
2133      }
2134      Fl_Box {} {
2135        xywh {6 218 18 18} box THIN_UP_BOX color 237
2136      }
2137      Fl_Check_Button stereo {
2138        label { Stereo}
2139        callback {//
2140send_data(0, ADDSYNTH::control::stereo, o->value(), TOPLEVEL::type::Integer);}
2141        xywh {8 220 61 15} down_box DOWN_BOX color 237 labelsize 11
2142        code0 {o->value(pars->GlobalPar.PStereo);}
2143        class Fl_Check_Button2
2144      }
2145      Fl_Button showvoicelist {
2146        label {Show Voice List}
2147        callback {//
2148            for (int i = 0; i < NUM_VOICES; ++i)
2149                voicelistitem[i]->refreshlist();
2150            int fetchW, fetchH, fetchX, fetchY, fetchO;
2151            loadWin(synth, fetchW, fetchH, fetchX, fetchY, fetchO, "AddSynth-list");
2152
2153            if (fetchW < listDW || fetchH < listDH)
2154            {
2155                fetchW = listDW;
2156                fetchH = listDH;
2157            }
2158            checkSane(fetchX, fetchY,fetchW, fetchH, listDW, listDH);
2159            ADnoteVoiceList->resize(fetchX, fetchY,fetchW, fetchH);
2160            lastlistW = 0;
2161            ADnoteVoiceList->show();
2162            listSeen = true;
2163
2164
2165            if (Fl::event_button() == 3)
2166                ADnoteGlobalParameters->hide();}
2167        tooltip {Right click: also close this} xywh {191 375 121 25} labelfont 1 labelsize 12
2168      }
2169      Fl_Button showvoicepars {
2170        label {Show Voice Parameters}
2171        callback {//
2172    set_voice(false);
2173    if ((Fl::event_button() == 3))
2174        ADnoteGlobalParameters->hide();}
2175        tooltip {Right click: also close this} xywh {5 375 180 25} labelfont 1 labelsize 12
2176      }
2177      Fl_Button globalclose {
2178        label Close
2179        callback {//
2180            saveWin(synth,  ADnoteGlobalParameters->w(),  ADnoteGlobalParameters->h(), ADnoteGlobalParameters->x(), ADnoteGlobalParameters->y(), false, "AddSynth");
2181            globalSeen = false;
2182            resui->resonancewindow->hide();
2183            ADnoteGlobalParameters->hide();
2184            if (Fl::event_button() == 3)
2185            {
2186                if (synth->getGuiMaster()->partui->partKitOn)
2187                    synth->getGuiMaster()->partui->instrumentkitlist->show();
2188                else
2189                    synth->getGuiMaster()->partui->instrumenteditwindow->show();
2190            }}
2191        tooltip {Right click: also reopen previous} xywh {517 375 54 25} box THIN_UP_BOX labelfont 1 labelsize 12
2192      }
2193      Fl_Button resonance {
2194        label Resonance
2195        callback {//
2196    resui->resonancewindow->redraw();
2197    resui->Show();
2198    if ((Fl::event_button() == 3))
2199        ADnoteGlobalParameters->hide();}
2200        tooltip {Resonance. Right click: also close this} xywh {318 375 90 25} labelfont 1 labelsize 12
2201      }
2202      Fl_Button globalcopy {
2203        label C
2204        callback {synth->getGuiMaster()->getPresetsUi()->copy(pars);}
2205        xywh {455 380 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 7
2206      }
2207      Fl_Button globalpaste {
2208        label P
2209        callback {synth->getGuiMaster()->getPresetsUi()->paste(pars,this);}
2210        xywh {485 380 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 7
2211      }
2212    }
2213    Fl_Window ADnoteVoice {
2214      label {ADsynth Voice Parameters}
2215      callback {saveWin(synth, o->w(), o->h(), o->x(), o->y(), false,"AddSynth-voice");
2216o->hide();}
2217      xywh {618 93 805 610} type Double hide resizable
2218      code0 {o->copy_label(synth->getGuiMaster()->setPartWindowTitle("AddSynth Voice").c_str());}
2219      code1 {voiceDW = int(760 * 9 / 10); voiceDH = int(610 * 9 / 10);}
2220      code2 {o->size_range(voiceDW, voiceDH, 0, 0, 0, 0, 1);}
2221    } {
2222      Fl_Group advoice {
2223        xywh {0 0 809 615} box BORDER_BOX
2224        code0 {o->init(pars, npart, kititem, nvoice);}
2225        code1 {o->show();}
2226        class ADvoiceUI
2227      } {}
2228      Fl_Button Vclose {
2229        label Close
2230        callback {//
2231            ADnoteVoice->hide();
2232            saveWin(synth, ADnoteVoice->w(), ADnoteVoice->h(), ADnoteVoice->x(), ADnoteVoice->y(), false, "AddSynth-voice");
2233            voiceSeen = false;
2234            if (Fl::event_button() == 3)
2235            {
2236                if (fromVoiceList)
2237                    ADnoteVoiceList->show();
2238                else
2239                    ShowGlobal();
2240            }}
2241        tooltip {Right click: also reopen previous} xywh {695 575 90 25} box THIN_UP_BOX labelfont 1 labelsize 12
2242      }
2243      Fl_Button Vcopy {
2244        label C
2245        callback {synth->getGuiMaster()->getPresetsUi()->copy(pars,nvoice);}
2246        xywh {600 580 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 7
2247      }
2248      Fl_Button Vpaste {
2249        label P
2250        callback {synth->getGuiMaster()->getPresetsUi()->paste(pars,this,nvoice);}
2251        xywh {630 580 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 11 labelcolor 7
2252      }
2253      Fl_Button g1 {
2254        label 1
2255        callback {setVoiceTabs(0, !o->value());}
2256        xywh {8 3 50 32} box PLASTIC_THIN_UP_BOX down_box PLASTIC_THIN_UP_BOX selection_color 231 labelfont 1
2257        code0 {o->value(1);}
2258      }
2259      Fl_Button g2 {
2260        label 2
2261        callback {setVoiceTabs(1, !o->value());}
2262        xywh {60 3 50 32} box PLASTIC_THIN_UP_BOX down_box PLASTIC_THIN_UP_BOX selection_color 231 labelfont 1
2263        code0 {o->value(0);}
2264      }
2265      Fl_Button g3 {
2266        label 3
2267        callback {setVoiceTabs(2, !o->value());}
2268        xywh {112 3 50 32} box PLASTIC_THIN_UP_BOX down_box PLASTIC_THIN_UP_BOX selection_color 231 labelfont 1
2269        code0 {o->value(0);}
2270      }
2271      Fl_Button g4 {
2272        label {4 }
2273        callback {setVoiceTabs(3, !o->value());}
2274        xywh {164 3 50 32} box PLASTIC_THIN_UP_BOX down_box PLASTIC_THIN_UP_BOX selection_color 231 labelfont 1
2275        code0 {o->value(0);}
2276      }
2277      Fl_Button g5 {
2278        label 5
2279        callback {setVoiceTabs(4, !o->value());}
2280        xywh {216 3 50 32} box PLASTIC_THIN_UP_BOX down_box PLASTIC_THIN_UP_BOX selection_color 231 labelfont 1
2281        code0 {o->value(0);}
2282      }
2283      Fl_Button g6 {
2284        label 6
2285        callback {setVoiceTabs(5, !o->value());}
2286        xywh {268 3 50 32} box PLASTIC_THIN_UP_BOX down_box PLASTIC_THIN_UP_BOX selection_color 231 labelfont 1
2287        code0 {o->value(0);}
2288      }
2289      Fl_Button g7 {
2290        label 7
2291        callback {setVoiceTabs(6, !o->value());}
2292        xywh {320 3 50 32} box PLASTIC_THIN_UP_BOX down_box PLASTIC_THIN_UP_BOX selection_color 231 labelfont 1
2293        code0 {o->value(0);}
2294      }
2295      Fl_Button g8 {
2296        label 8
2297        callback {setVoiceTabs(7, !o->value());}
2298        xywh {372 3 50 32} box PLASTIC_THIN_UP_BOX down_box PLASTIC_THIN_UP_BOX selection_color 231 labelfont 1
2299        code0 {o->value(0);}
2300      }
2301      Fl_Group voiceTabBar {
2302        xywh {4 30 524 5} box PLASTIC_THIN_DOWN_BOX color 223
2303      } {}
2304    }
2305    Fl_Window ADnoteVoiceList {
2306      label {ADsynth Voices list}
2307      callback {if (listSeen)
2308    saveWin(synth, o->w(), o->h(), o->x(), o->y(), false,"AddSynth-list");
2309listSeen = false;
2310o->hide();}
2311      xywh {101 233 705 260} type Double hide resizable
2312      code0 {o->copy_label(synth->getGuiMaster()->setPartWindowTitle("AddSynth Voice List").c_str());}
2313      code1 {listDW = 705; listDH = 260;}
2314      code2 {o->size_range(listDW,listDH,0,0,0,0,1);}
2315    } {
2316      Fl_Text_Display listNo {
2317        label {No.}
2318        xywh {24 15 30 10} box NO_BOX labelfont 1 labelsize 11
2319      }
2320      Fl_Text_Display listVolume {
2321        label Volume
2322        xywh {230 15 30 10} box NO_BOX labelfont 1 labelsize 11
2323      }
2324      Fl_Text_Display listDetune {
2325        label Detune
2326        xywh {458 15 25 10} box NO_BOX labelfont 1 labelsize 11
2327      }
2328      Fl_Text_Display listPan {
2329        label Pan
2330        xywh {298 15 30 10} box NO_BOX labelfont 1 labelsize 11
2331      }
2332      Fl_Text_Display listVibrato {
2333        label {Vibrato Depth}
2334        xywh {618 15 30 10} box NO_BOX labelfont 1 labelsize 11
2335      }
2336      Fl_Text_Display listResonance {
2337        label Res
2338        xywh {329 15 25 10} box NO_BOX labelfont 1 labelsize 11
2339      }
2340      Fl_Button listClose {
2341        label Close
2342        callback {//
2343            ADnoteVoiceList->hide();
2344            listSeen = false;
2345            saveWin(synth, ADnoteVoiceList->w(), ADnoteVoiceList->h(), ADnoteVoiceList->x(), ADnoteVoiceList->y(), false, "AddSynth-list");
2346
2347            if (Fl::event_button() == 3)
2348                ShowGlobal();}
2349        tooltip {Right click: also reopen previous} xywh {582 235 62 20} labelfont 1 labelsize 12
2350      }
2351      Fl_Group {} {
2352        xywh {5 15 695 214} box THIN_UP_BOX
2353      } {
2354        Fl_Group {} {
2355          xywh {17 27 668 200}
2356          code0 {//
2357              for (int i = 0; i < NUM_VOICES; ++i)
2358              {
2359                  voicelistitem[i] = new ADvoicelistitem(4, 8, 620, 25, "");
2360                  voicelistitem[i]->init(pars, npart, kititem, i);
2361              }}
2362        } {}
2363      }
2364      Fl_Text_Display listWave {
2365        label Wave
2366        xywh {105 15 30 10} box NO_BOX labelfont 1 labelsize 11
2367      }
2368      Fl_Text_Display listModulator {
2369        label Mod
2370        xywh {145 15 30 10} box NO_BOX labelfont 1 labelsize 11
2371      }
2372    }
2373  }
2374  Function {setVoiceTabs(int num, bool edit = true)} {} {
2375    code {//
2376    g1->value(0);
2377    g2->value(0);
2378    g3->value(0);
2379    g4->value(0);
2380    g5->value(0);
2381    g6->value(0);
2382    g7->value(0);
2383    g8->value(0);
2384    switch (num)
2385    {
2386        case 0:
2387            g1->value(1);
2388            if (edit)
2389                editVoice(0);
2390            break;
2391        case 1:
2392            g2->value(1);
2393            if (edit)
2394                editVoice(1);
2395            break;
2396        case 2:
2397            g3->value(1);
2398            if (edit)
2399                editVoice(2);
2400            break;
2401        case 3:
2402            g4->value(1);
2403            if (edit)
2404                editVoice(3);
2405            break;
2406        case 4:
2407            g5->value(1);
2408            if (edit)
2409                editVoice(4);
2410            break;
2411        case 5:
2412            g6->value(1);
2413            if (edit)
2414                editVoice(5);
2415            break;
2416        case 6:
2417            g7->value(1);
2418            if (edit)
2419                editVoice(6);
2420            break;
2421        case 7:
2422            g8->value(1);
2423            if (edit)
2424                editVoice(7);
2425            break;
2426    }} {}
2427  }
2428  Function {setTabColour(int num)} {} {
2429    code {//
2430    int set = 16;
2431    if (pars->VoicePar[num].Enabled)
2432        set = 0;
2433
2434    switch (num)
2435    {
2436        case 0:
2437            g1->labelcolor(set);
2438            break;
2439        case 1:
2440            g2->labelcolor(set);
2441            break;
2442        case 2:
2443            g3->labelcolor(set);
2444            break;
2445        case 3:
2446            g4->labelcolor(set);
2447            break;
2448        case 4:
2449            g5->labelcolor(set);
2450            break;
2451        case 5:
2452            g6->labelcolor(set);
2453            break;
2454        case 6:
2455            g7->labelcolor(set);
2456            break;
2457        case 7:
2458            g8->labelcolor(set);
2459            break;
2460    }} {}
2461  }
2462  Function {send_data(int action, int control, float value, int type)} {} {
2463    code {//
2464    type |= TOPLEVEL::type::Write;
2465    collect_data(synth, value, action, type, control, npart, kititem, 0);} {}
2466  }
2467  Function {returns_update(CommandBlock *getData)} {} {
2468    code {//
2469    float value = getData->data.value;
2470    unsigned char control = getData->data.control;
2471    bool val_bool = _SYS_::F2B(value);
2472    switch(control)
2473    {
2474        case ADDSYNTH::control::volume:
2475            globalvolume->value(value);
2476            break;
2477
2478        case ADDSYNTH::control::velocitySense:
2479            vsns->value(value);
2480            break;
2481
2482        case ADDSYNTH::control::panning:
2483            globalpan->value(value);
2484            amplitudegrp->changed();
2485            break;
2486
2487        case ADDSYNTH::control::enableRandomPan:
2488            globalrandompan->value(val_bool);
2489            if (val_bool)
2490                globalwidth->activate();
2491            else
2492                globalwidth->deactivate();
2493            amplitudegrp->changed();
2494            break;
2495
2496        case ADDSYNTH::control::randomWidth:
2497            globalwidth->value(value);
2498            amplitudegrp->changed();
2499            break;
2500
2501        case ADDSYNTH::control::detuneFrequency:
2502            freq->value(value);
2503            detunevalueoutput->do_callback();
2504            break;
2505
2506        case ADDSYNTH::control::octave:
2507            octave->value((int) value);
2508            break;
2509
2510        case ADDSYNTH::control::detuneType:
2511            detunetype->value(int(value) -1);
2512            break;
2513
2514        case ADDSYNTH::control::coarseDetune:
2515            coarsedet->value((int) value);
2516            break;
2517
2518        case ADDSYNTH::control::relativeBandwidth:
2519            relBwidth->value(value);
2520            break;
2521
2522        case ADDSYNTH::control::stereo:
2523            stereo->value(val_bool);
2524            break;
2525
2526        case ADDSYNTH::control::randomGroup:
2527            rndgrp->value(val_bool);
2528            break;
2529
2530        case ADDSYNTH::control::dePop:
2531            depop->value(value);
2532            break;
2533
2534        case ADDSYNTH::control::punchStrength:
2535            pstr->value(value);
2536            break;
2537
2538        case ADDSYNTH::control::punchDuration:
2539            pt->value(value);
2540            break;
2541
2542        case ADDSYNTH::control::punchStretch:
2543            pstc->value(value);
2544            break;
2545
2546        case ADDSYNTH::control::punchVelocity:
2547            pvel->value(value);
2548            break;
2549
2550    }} {}
2551  }
2552  Function {ADnoteUI(ADnoteParameters *parameters, int npart_, int kititem_)} {} {
2553    code {//
2554        synth = parameters->getSynthEngine();
2555        pars = parameters;
2556        npart = npart_;
2557        kititem = kititem_;
2558        globalSeen = false;
2559        lastglobalW = 0;
2560        voiceSeen = false;
2561        lastvoiceW = 0;
2562        nvoice = 0;
2563        resui = new ResonanceUI(pars->GlobalPar.Reson, npart, kititem, 0);
2564        lastlistW = 0;
2565        listSeen = false;
2566        lastResuiW = 0;
2567        make_window();
2568        for (int i = 0; i < 8; ++i)
2569        {
2570            setTabColour(i);
2571        }} {}
2572  }
2573  Function {~ADnoteUI()} {return_type virtual
2574  } {
2575    code {//
2576        if(listSeen)
2577            saveWin(synth, ADnoteVoiceList->w(), ADnoteVoiceList->h(), ADnoteVoiceList->x(), ADnoteVoiceList->y(), listSeen, "AddSynth-list");
2578        ADnoteVoiceList->hide();
2579        listSeen = false;
2580        if (globalSeen)
2581            saveWin(synth,  ADnoteGlobalParameters->w(),  ADnoteGlobalParameters->h(), ADnoteGlobalParameters->x(), ADnoteGlobalParameters->y(), globalSeen, "AddSynth");
2582        ADnoteGlobalParameters->hide();
2583        globalSeen = false;
2584        if (voiceSeen)
2585            saveWin(synth, ADnoteVoice->w(), ADnoteVoice->h(), ADnoteVoice->x(), ADnoteVoice->y(), voiceSeen, "AddSynth-voice");
2586        voiceSeen = false;
2587        ADnoteVoice->hide();
2588        resui->resonancewindow->hide();
2589        delete ADnoteVoiceList;
2590        delete ADnoteGlobalParameters;
2591        delete ADnoteVoice;
2592        delete resui;} {}
2593  }
2594  Function {refresh()} {} {
2595    code {//
2596        globalvolume->value(pars->GlobalPar.PVolume);
2597        vsns->value(pars->GlobalPar.PAmpVelocityScaleFunction);
2598        globalpan->value(pars->GlobalPar.PPanning);
2599
2600        stereo->value(pars->GlobalPar.PStereo);
2601        rndgrp->value(pars->GlobalPar.Hrandgrouping);
2602        pstr->value(pars->GlobalPar.PPunchStrength);
2603        pt->value(pars->GlobalPar.PPunchTime);
2604        pstc->value(pars->GlobalPar.PPunchStretch);
2605        pvel->value(pars->GlobalPar.PPunchVelocitySensing);
2606        detunevalueoutput->value(getDetune(pars->GlobalPar.PDetuneType, 0, pars->GlobalPar.PDetune));
2607        freq->value(pars->GlobalPar.PDetune - 8192);
2608
2609        int k = pars->GlobalPar.PCoarseDetune / 1024;
2610        if (k >= 8)
2611            k -= 16;
2612        octave->value(k);
2613
2614        detunetype->value(pars->GlobalPar.PDetuneType - 1);
2615        k = pars->GlobalPar.PCoarseDetune % 1024;
2616        if (k >= 512)
2617            k -= 1024;
2618        coarsedet->value(k);
2619        amplfo->refresh();
2620        freqlfo->refresh();
2621        filterlfo->refresh();
2622
2623        ampenv->refresh();
2624        freqenv->refresh();
2625        filterenv->refresh();
2626        filterui->refresh();
2627        for (int i = 0; i < NUM_VOICES; ++i)
2628            voicelistitem[i]->refreshlist();
2629
2630        resui->refresh();
2631        editVoice(nvoice);} {}
2632  }
2633  Function {ShowGlobal()} {} {
2634    code {//
2635    int fetchW, fetchH, fetchX, fetchY, fetchO;
2636    loadWin(synth, fetchW, fetchH, fetchX, fetchY, fetchO, "AddSynth");
2637
2638    if (fetchW < addDW || fetchH < addDH)
2639    {
2640        fetchW = addDW;
2641        fetchH = addDH;
2642    }
2643    checkSane(fetchX, fetchY, fetchW, fetchH, addDW, addDH);
2644
2645
2646    lastglobalW = 0;
2647    ADnoteGlobalParameters->resize(fetchX, fetchY, fetchW, fetchH);
2648    ADnoteGlobalParameters->show();
2649    globalSeen = true;} {}
2650  }
2651  Function {set_voice(bool type)} {} {
2652    code {//
2653
2654    voicelistitem[nvoice]->refreshlist();
2655    int fetchW, fetchH, fetchX, fetchY, fetchO;
2656
2657    if (!voiceSeen)
2658    {
2659        loadWin(synth, fetchW, fetchH, fetchX, fetchY, fetchO, "AddSynth-voice");
2660        if (fetchW < voiceDW || fetchH < voiceDH)
2661        {
2662            fetchW = voiceDW;
2663            fetchH = voiceDH;
2664        }
2665        ADnoteVoice->resize(fetchX, fetchY, fetchW, fetchH);
2666        checkSane(fetchX, fetchY, fetchW, fetchH, voiceDW, voiceDH);
2667    }
2668
2669    ADnoteVoice->redraw();
2670    ADnoteVoice->show();
2671    lastvoiceW = 0;
2672    voiceSeen = true;
2673    fromVoiceList = type;} {}
2674  }
2675  Function {wincheck()} {} {
2676    code {//
2677    addRtext();
2678    addVoiceRtext();
2679
2680    if (ADnoteVoiceList->visible())
2681        addVoiceListRtext();
2682
2683    if (resui->resonancewindow->visible() && lastResuiW != resui->resonancewindow->w())
2684    {
2685        resui->resonanceRtext();
2686        lastResuiW = resui->resonancewindow->w();
2687    }
2688
2689    if (ampenv)
2690        ampenv->wincheck();
2691    if (filterenv)
2692        filterenv->wincheck();
2693    if (freqenv)
2694        freqenv->wincheck();} {}
2695  }
2696  Function {addRtext()} {} {
2697    code {//
2698    ampenv->wincheck();
2699    freqenv->wincheck();
2700    filterenv->wincheck();
2701
2702    if (lastglobalW < 3)
2703    {
2704       ++lastglobalW;
2705       return; // in case it is  called before completely redrawn
2706    }
2707
2708    if (lastglobalW == ADnoteGlobalParameters->w())
2709        return;
2710    lastglobalW = ADnoteGlobalParameters->w();
2711
2712    float dScale = ADnoteGlobalParameters->w() / float(addDW);
2713    if (dScale < 0.2f)
2714        dScale = 0.2f;
2715
2716    amplfo->lfoRtext(dScale);
2717    ampenv->envRtext(dScale);
2718
2719    freqlfo->lfoRtext(dScale);
2720    freqenv->envRtext(dScale);
2721
2722    filterlfo->lfoRtext(dScale);
2723    filterenv->envRtext(dScale);
2724
2725    filterui->filterRtext(dScale);
2726
2727    int size = int(10 * dScale);
2728    int size11 = int(11 * dScale);
2729    int size12 = int(12 * dScale);
2730
2731    amplitudegrp->labelsize(size12);
2732    globalvolume->labelsize(size);
2733    vsns->labelsize(size);
2734    globalpan->labelsize(size);
2735    globalwidth->labelsize(size);
2736    globalrandompan->labelsize(size);
2737    depop->labelsize(size);
2738    pstr->labelsize(size);
2739    pt->labelsize(size);
2740    pstc->labelsize(size);
2741    pvel->labelsize(size);
2742    rndgrp->labelsize(size);
2743
2744    stereo->labelsize(size11);
2745
2746    filtergrp->labelsize(size12);
2747
2748    globalfreq->labelsize(size12);
2749    detunevalueoutput->labelsize(size);
2750        detunevalueoutput->textsize(size);
2751    octave->labelsize(size);
2752        octave->textsize(size11);
2753    relBwidth->labelsize(size);
2754    detunetype->labelsize(size);
2755        detunetype->textsize(size11);
2756
2757    coarsedet->labelsize(size);
2758        coarsedet->textsize(size11);
2759
2760    showvoicepars->labelsize(size12);
2761    showvoicelist->labelsize(size12);
2762    resonance->labelsize(size12);
2763    globalcopy->labelsize(size11);
2764    globalpaste->labelsize(size11);
2765    globalclose->labelsize(size11);
2766
2767    ADnoteGlobalParameters->redraw();} {}
2768  }
2769  Function {addVoiceRtext()} {} {
2770    code {// this is just for the outer skin
2771
2772    float dScale = ADnoteVoice->w() / float(voiceDW);
2773    if (dScale < 0.2f)
2774        dScale = 0.2f;
2775
2776    advoice->voiceRtext(dScale); // must be entered (for waveform)
2777
2778    if (!ADnoteVoice->visible())
2779        return;
2780
2781    if (lastvoiceW < 2) // extra time to settle
2782    {
2783        ++lastvoiceW;
2784        return;
2785    }
2786
2787    if (ADnoteVoice->w() == lastvoiceW)
2788        return;
2789
2790    lastvoiceW = ADnoteVoice->w();
2791
2792    Vclose->labelsize(int(12 * dScale));
2793
2794    Vcopy->labelsize(int(11 * dScale));
2795    Vpaste->labelsize(int(11 * dScale));
2796
2797    /*
2798     * scaling of tabs is in near tab size jumps so we
2799     * have to try to get the best overall size/position
2800    */
2801    int size = int((12 * dScale) + (1.85f * dScale * dScale));
2802    g1->labelsize(size);
2803    g2->labelsize(size);
2804    g3->labelsize(size);
2805    g4->labelsize(size);
2806    g5->labelsize(size);
2807    g6->labelsize(size);
2808    g7->labelsize(size);
2809    g8->labelsize(size);
2810
2811   ADnoteVoice->redraw();} {}
2812  }
2813  Function {addVoiceListRtext()} {} {
2814    code {//
2815
2816    if (lastlistW < 3)
2817    {
2818        ++lastlistW;
2819        return;
2820    }
2821    if (lastlistW == ADnoteVoiceList->w())
2822        return;
2823
2824    lastlistW = ADnoteVoiceList->w();
2825
2826    float dScale = ADnoteVoiceList->w() / float(listDW);
2827    if (dScale < 0.2f)
2828        dScale = 0.2f;;
2829
2830    for (int i = 0; i < NUM_VOICES; ++i)
2831    {
2832        voicelistitem[i]->resize(15 * dScale, (27 + (25 * i)) * dScale, 670 * dScale, 25 * dScale);
2833        voicelistitem[i]->itemRtext(dScale);
2834    }
2835
2836    int size11 = int(11 * dScale);
2837    listNo->labelsize(size11);
2838    listVolume->labelsize(size11);
2839    listDetune->labelsize(size11);
2840    listPan->labelsize(size11);
2841    listVibrato->labelsize(size11);
2842    listResonance->labelsize(size11);
2843    listWave->labelsize(size11);
2844    listModulator->labelsize(size11);
2845    listClose->labelsize(int(14 * dScale));
2846
2847    ADnoteVoiceList->redraw();} {}
2848  }
2849  Function {editVoice(int nvoice_)} {return_type void
2850  } {
2851    code {//
2852        nvoice = nvoice_;
2853
2854        int adW = advoice->ADnoteVoiceParameters->w();
2855        int adH = advoice->ADnoteVoiceParameters->h();
2856        advoice->hide();
2857        ADnoteVoice->remove(advoice);
2858        delete advoice;
2859
2860        advoice = new ADvoiceUI(0, 0, adW, adH);
2861        ADnoteVoice->add(advoice);
2862        advoice->init(pars, npart, kititem, nvoice);
2863        advoice->ADnoteVoiceParameters->size(adW, adH);
2864        advoice->show();
2865        addVoiceRtext();} {}
2866  }
2867  decl {ADnoteParameters *pars;} {private local
2868  }
2869  decl {int addDW;} {private local
2870  }
2871  decl {int addDH;} {private local
2872  }
2873  decl {int lastglobalW;} {private local
2874  }
2875  decl {bool globalSeen;} {private local
2876  }
2877  decl {int voiceDW;} {private local
2878  }
2879  decl {int voiceDH;} {private local
2880  }
2881  decl {int lastvoiceW;} {private local
2882  }
2883  decl {bool voiceSeen;} {public local
2884  }
2885  decl {int listDW;} {private local
2886  }
2887  decl {int listDH;} {private local
2888  }
2889  decl {int lastlistW;} {private local
2890  }
2891  decl {bool listSeen;} {public local
2892  }
2893  decl {ResonanceUI *resui;} {public local
2894  }
2895  decl {int lastResuiW;} {private local
2896  }
2897  decl {int nvoice;} {public local
2898  }
2899  decl {ADvoicelistitem *voicelistitem[NUM_VOICES];} {public local
2900  }
2901  decl {SynthEngine *synth;} {private local
2902  }
2903  decl {int npart;} {private local
2904  }
2905  decl {int kititem;} {private local
2906  }
2907  decl {bool fromVoiceList;} {public local
2908  }
2909}
2910