/[svn]/gigedit/trunk/src/gigedit/dimregionedit.cpp
ViewVC logotype

Diff of /gigedit/trunk/src/gigedit/dimregionedit.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1261 by persson, Thu Jul 5 17:12:20 2007 UTC revision 3643 by schoenebeck, Sat Dec 7 15:04:51 2019 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006, 2007 Andreas Persson   * Copyright (C) 2006-2019 Andreas Persson
3   *   *
4   * This program is free software; you can redistribute it and/or   * This program is free software; you can redistribute it and/or
5   * modify it under the terms of the GNU General Public License as   * modify it under the terms of the GNU General Public License as
# Line 17  Line 17 
17   * 02110-1301 USA.   * 02110-1301 USA.
18   */   */
19    
20    #include "global.h"
21  #include "dimregionedit.h"  #include "dimregionedit.h"
22    
23  #include <libintl.h>  #include "compat.h"
24  #define _(String) gettext(String)  
25    #if USE_GTKMM_GRID
26    # include <gtkmm/grid.h>
27    #else
28    # include <gtkmm/table.h>
29    #endif
30    
31    #include "Settings.h"
32    
33    VelocityCurve::VelocityCurve(double (gig::DimensionRegion::*getter)(uint8_t)) :
34        getter(getter), dimreg(0) {
35        set_size_request(80, 80);
36    }
37    
38    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
39    bool VelocityCurve::on_expose_event(GdkEventExpose* e) {
40        const Cairo::RefPtr<Cairo::Context>& cr =
41            get_window()->create_cairo_context();
42    #else
43    bool VelocityCurve::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
44    #endif
45        if (dimreg) {
46            int w = get_width();
47            int h = get_height();
48    
49            for (int pass = 0 ; pass < 2 ; pass++) {
50                for (double x = 0 ; x <= w ; x++) {
51                    int vel = int(x * (127 - 1e-10) / w + 1);
52                    double y = (1 - (dimreg->*getter)(vel)) * (h - 3) + 1.5;
53    
54                    if (x < 1e-10) {
55                        cr->move_to(x, y);
56                    } else {
57                        cr->line_to(x, y);
58                    }
59                }
60                if (pass == 0) {
61                    cr->line_to(w, h);
62                    cr->line_to(0, h);
63                    cr->set_source_rgba(0.5, 0.44, 1.0, is_sensitive() ? 0.2 : 0.1);
64                    cr->fill();
65                } else {
66                    cr->set_line_width(3);
67                    cr->set_source_rgba(0.5, 0.44, 1.0, is_sensitive() ? 1.0 : 0.3);
68                    cr->stroke();
69                }
70            }
71        }
72        return true;
73    }
74    
75    
76    CrossfadeCurve::CrossfadeCurve() : dimreg(0) {
77        set_size_request(500, 100);
78    }
79    
80    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
81    bool CrossfadeCurve::on_expose_event(GdkEventExpose* e) {
82        const Cairo::RefPtr<Cairo::Context>& cr =
83            get_window()->create_cairo_context();
84    #else
85    bool CrossfadeCurve::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
86    #endif
87        if (dimreg) {
88            cr->translate(1.5, 0);
89    
90            // first, draw curves for the other layers
91            gig::Region* region = dimreg->GetParent();
92            int dimregno;
93            for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
94                if (region->pDimensionRegions[dimregno] == dimreg) {
95                    break;
96                }
97            }
98            int bitcount = 0;
99            for (int dim = 0 ; dim < region->Dimensions ; dim++) {
100                if (region->pDimensionDefinitions[dim].dimension ==
101                    gig::dimension_layer) {
102                    int mask =
103                        ~(((1 << region->pDimensionDefinitions[dim].bits) - 1) <<
104                          bitcount);
105                    int c = dimregno & mask; // mask away the layer dimension
106    
107                    for (int i = 0 ; i < region->pDimensionDefinitions[dim].zones ;
108                         i++) {
109                        gig::DimensionRegion* d =
110                            region->pDimensionRegions[c + (i << bitcount)];
111                        if (d != dimreg) {
112                            draw_one_curve(cr, d, false);
113                        }
114                    }
115                    break;
116                }
117                bitcount += region->pDimensionDefinitions[dim].bits;
118            }
119    
120            // then, draw the currently selected layer
121            draw_one_curve(cr, dimreg, is_sensitive());
122        }
123        return true;
124    }
125    
126    void CrossfadeCurve::draw_one_curve(const Cairo::RefPtr<Cairo::Context>& cr,
127                                        const gig::DimensionRegion* d,
128                                        bool sensitive) {
129        int w = get_width();
130        int h = get_height();
131    
132        if (d->Crossfade.out_end) {
133            for (int pass = 0 ; pass < 2 ; pass++) {
134                cr->move_to(d->Crossfade.in_start / 127.0 * (w - 3), h);
135                cr->line_to(d->Crossfade.in_end / 127.0 * (w - 3), 1.5);
136                cr->line_to(d->Crossfade.out_start / 127.0 * (w - 3), 1.5);
137                cr->line_to(d->Crossfade.out_end / 127.0 * (w - 3), h);
138    
139                if (pass == 0) {
140                    cr->set_source_rgba(0.5, 0.44, 1.0, sensitive ? 0.2 : 0.1);
141                    cr->fill();
142                } else {
143                    cr->set_line_width(3);
144                    cr->set_source_rgba(0.5, 0.44, 1.0, sensitive ? 1.0 : 0.3);
145                    cr->stroke();
146                }
147            }
148        }
149    }
150    
151    
152    LFOGraph::LFOGraph() : dimreg(0) {
153        set_size_request(500, 100);
154    }
155    
156    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
157    bool LFOGraph::on_expose_event(GdkEventExpose* e) {
158        const Cairo::RefPtr<Cairo::Context>& cr =
159            get_window()->create_cairo_context();
160    #else
161    bool LFOGraph::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
162    #endif
163        if (dimreg) {
164            const int w = get_width();
165            const int h = get_height();
166            const bool sensitive = is_sensitive();
167            const bool signedRange = this->signedRange();
168            const float visiblePeriods = 5.f; // such that minimum LFO frequency 0.1 Hz draws exactly a half period
169    
170            // short-hand functions for setting colors
171            auto setGrayColor = [&] {
172                cr->set_source_rgba(0.88, 0.88, 0.88, sensitive ? 1.0 : 0.3);
173            };
174            auto setBlackColor = [&] {
175                cr->set_source_rgba(0, 0, 0, sensitive ? 1.0 : 0.3);
176            };
177            auto setGreenColor = [&] {
178                cr->set_source_rgba(94/255.f, 219/255.f, 80/255.f, sensitive ? 1.0 : 0.3);
179            };
180            auto setRedColor = [&] {
181                cr->set_source_rgba(255.f, 44/255.f, 44/255.f, sensitive ? 1.0 : 0.3);
182            };
183            /*auto setBlueColor = [&] {
184                cr->set_source_rgba(53/255.f, 167/255.f, 255.f, sensitive ? 1.0 : 0.3);
185            };*/
186            auto setOrangeColor = [&] {
187                cr->set_source_rgba(255.f, 177/255.f, 82/255.f, sensitive ? 1.0 : 0.3);
188            };
189            auto setWhiteColor = [&] {
190                cr->set_source_rgba(255.f, 255.f, 255.f, sensitive ? 1.0 : 0.3);
191            };
192    
193            // fill background white
194            cr->rectangle(0, 0, w, h);
195            setWhiteColor();
196            cr->fill();
197    
198            // draw horizontal center line (dashed gray) if LFO range is signed
199            if (signedRange) {
200                cr->move_to(0, h/2);
201                cr->line_to(w, h/2);
202                cr->set_line_width(2);
203                setGrayColor();
204                cr->set_dash(std::vector<double>{ 7, 5 }, 0 /*offset*/);
205                cr->stroke();
206            }
207    
208            // draw a vertical line for each second
209            for (int period = 1; period < visiblePeriods; ++period) {
210                int x = float(w) / float(visiblePeriods) * period;
211                cr->move_to(x, 0);
212                cr->line_to(x, h);
213                cr->set_line_width(2);
214                setGrayColor();
215                cr->set_dash(std::vector<double>{ 5, 3 }, 0 /*offset*/);
216                cr->stroke();
217            }
218    
219            // how many curves shall we draw, two or one?
220            const int runs = (hasControllerAssigned()) ? 2 : 1;
221            // only draw the two curves in dashed style if they're very close to each other
222            const bool dashedCurves = (runs == 2 && controllerDepth() < 63);
223            // draw the required amount of curves
224            for (int run = 0; run < runs; ++run) {
225                // setup the LFO generator with the relevant parameters
226                lfo.setup({
227                    .waveType = waveType(),
228                    .rangeType = (signedRange) ? LinuxSampler::LFO::range_signed : LinuxSampler::LFO::range_unsigned,
229                    .frequency = frequency(),
230                    .phase = phase(),
231                    .startLevel = startLevel(),
232                    .internalDepth = internalDepth(),
233                    .midiControllerDepth = controllerDepth(),
234                    .flipPolarity = flipPolarity(),
235                    .samplerate = w / visiblePeriods,
236                    .maxValue = (signedRange) ? h/2 : h,
237                });
238                // 1st curve reflects min. CC value, 2nd curve max. CC value
239                lfo.setMIDICtrlValue( (run == 0) ? 0 : 127 );
240    
241                // the actual render/draw loop
242                for (int x = 0; x < w ; ++x) {
243                    const float y =
244                        (signedRange) ?
245                            h/2 - lfo.render() :
246                            h   - lfo.render();
247                    if (x == 0)
248                        cr->move_to(x, y);
249                    else
250                        cr->line_to(x, y);
251                }
252                cr->set_line_width( (frequency() <= 4.f) ? 2 : 1 );
253                if (runs == 1)
254                    setOrangeColor();
255                else if (run == 0)
256                    setGreenColor();
257                else
258                    setRedColor();
259                if (dashedCurves)
260                    cr->set_dash(std::vector<double>{ 3, 3 }, (run == 0) ? 0 : 3 /*offset*/);
261                else
262                    cr->set_dash(std::vector<double>(), 0 /*offset*/);
263                cr->stroke();
264            }
265    
266            // draw text legend
267            if (runs == 2) {
268                setRedColor();
269                cr->move_to(2, 10);
270                cr->show_text("CC Max.");
271    
272                setGreenColor();
273                cr->move_to(2, 23);
274                cr->show_text("CC Min.");
275            } else { // no controller assigned, internal depth only ...
276                setOrangeColor();
277                cr->move_to(2, 10);
278                cr->show_text("Const. Depth");
279            }
280            // draw text legend for each second ("1s", "2s", ...)
281            for (int period = 1; period < visiblePeriods; ++period) {
282                int x = float(w) / float(visiblePeriods) * period;
283                setBlackColor();
284                cr->move_to(x - 13, h - 3);
285                cr->show_text(ToString(period) + "s");
286            }
287        }
288        return true;
289    }
290    
291    
292    EGStateOptions::EGStateOptions() : HBox(),
293        label(_("May be cancelled: ")),
294        checkBoxAttack(_("Attack")),
295        checkBoxAttackHold(_("Attack Hold")),
296        checkBoxDecay1(_("Decay 1")),
297        checkBoxDecay2(_("Decay 2")),
298        checkBoxRelease(_("Release"))
299    {
300        set_spacing(6);
301    
302        pack_start(label);
303        pack_start(checkBoxAttack, Gtk::PACK_SHRINK);
304        pack_start(checkBoxAttackHold, Gtk::PACK_SHRINK);
305        pack_start(checkBoxDecay1, Gtk::PACK_SHRINK);
306        pack_start(checkBoxDecay2, Gtk::PACK_SHRINK);
307        pack_start(checkBoxRelease, Gtk::PACK_SHRINK);
308    
309        checkBoxAttack.set_tooltip_text(_(
310            "If checked: a note-off aborts the 'attack' stage."
311        ));
312        checkBoxAttackHold.set_tooltip_text(_(
313            "If checked: a note-off aborts the 'attack hold' stage."
314        ));
315        checkBoxDecay1.set_tooltip_text(_(
316            "If checked: a note-off aborts the 'decay 1' stage."
317        ));
318        checkBoxDecay2.set_tooltip_text(_(
319            "If checked: a note-off aborts the 'decay 2' stage."
320        ));
321        checkBoxRelease.set_tooltip_text(_(
322            "If checked: a note-on reverts back from the 'release' stage."
323        ));
324    }
325    
326    void EGStateOptions::on_show_tooltips_changed() {
327        const bool b = Settings::singleton()->showTooltips;
328    
329        checkBoxAttack.set_has_tooltip(b);
330        checkBoxAttackHold.set_has_tooltip(b);
331        checkBoxDecay1.set_has_tooltip(b);
332        checkBoxDecay2.set_has_tooltip(b);
333        checkBoxRelease.set_has_tooltip(b);
334    }
335    
336    
337  DimRegionEdit::DimRegionEdit() :  DimRegionEdit::DimRegionEdit() :
338      eEG1PreAttack("Pre-attack", 0, 100, 2),      velocity_curve(&gig::DimensionRegion::GetVelocityAttenuation),
339      eEG1Attack("Attack", 0, 60, 3),      release_curve(&gig::DimensionRegion::GetVelocityRelease),
340      eEG1Decay1("Decay 1", 0.005, 60, 3),      cutoff_curve(&gig::DimensionRegion::GetVelocityCutoff),
341      eEG1Decay2("Decay 2", 0, 60, 3),      eEG1PreAttack(_("Pre-attack Level (%)"), 0, 100, 2),
342      eEG1InfiniteSustain("Infinite sustain"),      eEG1Attack(_("Attack Time (seconds)"), 0, 60, 3),
343      eEG1Sustain("Sustain", 0, 100, 2),      eEG1Decay1(_("Decay 1 Time (seconds)"), 0.005, 60, 3),
344      eEG1Release("Release", 0, 60, 3),      eEG1Decay2(_("Decay 2 Time (seconds)"), 0, 60, 3),
345      eEG1Hold("Hold"),      eEG1InfiniteSustain(_("Infinite sustain")),
346      eEG1Controller("Controller"),      eEG1Sustain(_("Sustain Level (%)"), 0, 100, 2),
347      eEG1ControllerInvert("Controller invert"),      eEG1Release(_("Release Time (seconds)"), 0, 60, 3),
348      eEG1ControllerAttackInfluence("Controller attack influence", 0, 3),      eEG1Hold(_("Hold Attack Stage until Loop End")),
349      eEG1ControllerDecayInfluence("Controller decay influence", 0, 3),      eEG1Controller(_("Controller")),
350      eEG1ControllerReleaseInfluence("Controller release influence", 0, 3),      eEG1ControllerInvert(_("Controller invert")),
351      eLFO1Frequency("Frequency", 0.1, 10, 2),      eEG1ControllerAttackInfluence(_("Controller attack influence"), 0, 3),
352      eLFO1InternalDepth("Internal depth", 0, 1200),      eEG1ControllerDecayInfluence(_("Controller decay influence"), 0, 3),
353      eLFO1ControlDepth("Control depth", 0, 1200),      eEG1ControllerReleaseInfluence(_("Controller release influence"), 0, 3),
354      eLFO1Controller("Controller"),      eLFO1Wave(_("Wave Form")),
355      eLFO1FlipPhase("Flip phase"),      eLFO1Frequency(_("Frequency"), 0.1, 10, 2),
356      eLFO1Sync("Sync"),      eLFO1Phase(_("Phase"), 0.0, 360.0, 2),
357      eEG2PreAttack("Pre-attack", 0, 100, 2),      eLFO1InternalDepth(_("Internal depth"), 0, 1200),
358      eEG2Attack("Attack", 0, 60, 3),      eLFO1ControlDepth(_("Control depth"), 0, 1200),
359      eEG2Decay1("Decay 1", 0.005, 60, 3),      eLFO1Controller(_("Controller")),
360      eEG2Decay2("Decay 2", 0, 60, 3),      eLFO1FlipPhase(_("Flip phase")),
361      eEG2InfiniteSustain("Infinite sustain"),      eLFO1Sync(_("Sync")),
362      eEG2Sustain("Sustain", 0, 100, 2),      eEG2PreAttack(_("Pre-attack Level (%)"), 0, 100, 2),
363      eEG2Release("Release", 0, 60, 3),      eEG2Attack(_("Attack Time (seconds)"), 0, 60, 3),
364      eEG2Controller("Controller"),      eEG2Decay1(_("Decay 1 Time (seconds)"), 0.005, 60, 3),
365      eEG2ControllerInvert("Controller invert"),      eEG2Decay2(_("Decay 2 Time (seconds)"), 0, 60, 3),
366      eEG2ControllerAttackInfluence("Controller attack influence", 0, 3),      eEG2InfiniteSustain(_("Infinite sustain")),
367      eEG2ControllerDecayInfluence("Controller decay influence", 0, 3),      eEG2Sustain(_("Sustain Level (%)"), 0, 100, 2),
368      eEG2ControllerReleaseInfluence("Controller release influence", 0, 3),      eEG2Release(_("Release Time (seconds)"), 0, 60, 3),
369      eLFO2Frequency("Frequency", 0.1, 10, 2),      eEG2Controller(_("Controller")),
370      eLFO2InternalDepth("Internal depth", 0, 1200),      eEG2ControllerInvert(_("Controller invert")),
371      eLFO2ControlDepth("Control depth", 0, 1200),      eEG2ControllerAttackInfluence(_("Controller attack influence"), 0, 3),
372      eLFO2Controller("Controller"),      eEG2ControllerDecayInfluence(_("Controller decay influence"), 0, 3),
373      eLFO2FlipPhase("Flip phase"),      eEG2ControllerReleaseInfluence(_("Controller release influence"), 0, 3),
374      eLFO2Sync("Sync"),      eLFO2Wave(_("Wave Form")),
375      eEG3Attack("Attack", 0, 10, 3),      eLFO2Frequency(_("Frequency"), 0.1, 10, 2),
376      eEG3Depth("Depth", -1200, 1200),      eLFO2Phase(_("Phase"), 0.0, 360.0, 2),
377      eLFO3Frequency("Frequency", 0.1, 10, 2),      eLFO2InternalDepth(_("Internal depth"), 0, 1200),
378      eLFO3InternalDepth("Internal depth", 0, 1200),      eLFO2ControlDepth(_("Control depth"), 0, 1200),
379      eLFO3ControlDepth("Control depth", 0, 1200),      eLFO2Controller(_("Controller")),
380      eLFO3Controller("Controller"),      eLFO2FlipPhase(_("Flip phase")),
381      eLFO3Sync("Sync"),      eLFO2Sync(_("Sync")),
382      eVCFEnabled("Enabled"),      eEG3Attack(_("Attack"), 0, 10, 3),
383      eVCFType("Type"),      eEG3Depth(_("Depth"), -1200, 1200),
384      eVCFCutoffController("Cutoff controller"),      eLFO3Wave(_("Wave Form")),
385      eVCFCutoffControllerInvert("Cutoff controller invert"),      eLFO3Frequency(_("Frequency"), 0.1, 10, 2),
386      eVCFCutoff("Cutoff"),      eLFO3Phase(_("Phase"), 0.0, 360.0, 2),
387      eVCFVelocityCurve("Velocity curve"),      eLFO3InternalDepth(_("Internal depth"), 0, 1200),
388      eVCFVelocityScale("Velocity scale"),      eLFO3ControlDepth(_("Control depth"), 0, 1200),
389      eVCFVelocityDynamicRange("Velocity dynamic range", 0, 4),      eLFO3Controller(_("Controller")),
390      eVCFResonance("Resonance"),      eLFO3FlipPhase(_("Flip phase")),
391      eVCFResonanceDynamic("Resonance dynamic"),      eLFO3Sync(_("Sync")),
392      eVCFResonanceController("Resonance controller"),      eVCFEnabled(_("Enabled")),
393      eVCFKeyboardTracking("Keyboard tracking"),      eVCFType(_("Type")),
394      eVCFKeyboardTrackingBreakpoint("Keyboard tracking breakpoint"),      eVCFCutoffController(_("Cutoff controller")),
395      eVelocityResponseCurve("Velocity response curve"),      eVCFCutoffControllerInvert(_("Cutoff controller invert")),
396      eVelocityResponseDepth("Velocity response depth", 0, 4),      eVCFCutoff(_("Cutoff")),
397      eVelocityResponseCurveScaling("Velocity response curve scaling"),      eVCFVelocityCurve(_("Velocity curve")),
398      eReleaseVelocityResponseCurve("Release velocity response curve"),      eVCFVelocityScale(_("Velocity scale")),
399      eReleaseVelocityResponseDepth("Release velocity response depth", 0, 4),      eVCFVelocityDynamicRange(_("Velocity dynamic range"), 0, 4),
400      eReleaseTriggerDecay("Release trigger decay", 0, 8),      eVCFResonance(_("Resonance")),
401      eCrossfade_in_start("Crossfade-in start"),      eVCFResonanceDynamic(_("Resonance dynamic")),
402      eCrossfade_in_end("Crossfade-in end"),      eVCFResonanceController(_("Resonance controller")),
403      eCrossfade_out_start("Crossfade-out start"),      eVCFKeyboardTracking(_("Keyboard tracking")),
404      eCrossfade_out_end("Crossfade-out end"),      eVCFKeyboardTrackingBreakpoint(_("Keyboard tracking breakpoint")),
405      ePitchTrack("Pitch track"),      eVelocityResponseCurve(_("Velocity response curve")),
406      eDimensionBypass("Dimension bypass"),      eVelocityResponseDepth(_("Velocity response depth"), 0, 4),
407      ePan("Pan", -64, 63),      eVelocityResponseCurveScaling(_("Velocity response curve scaling")),
408      eSelfMask("Self mask"),      eReleaseVelocityResponseCurve(_("Release velocity response curve")),
409      eAttenuationController("Attenuation controller"),      eReleaseVelocityResponseDepth(_("Release velocity response depth"), 0, 4),
410      eInvertAttenuationController("Invert attenuation controller"),      eReleaseTriggerDecay(_("Release trigger decay"), 0, 8),
411      eAttenuationControllerThreshold("Attenuation controller threshold"),      eCrossfade_in_start(_("Crossfade-in start")),
412      eChannelOffset("Channel offset", 0, 9),      eCrossfade_in_end(_("Crossfade-in end")),
413      eSustainDefeat("Sustain defeat"),      eCrossfade_out_start(_("Crossfade-out start")),
414      eMSDecode("MS decode"),      eCrossfade_out_end(_("Crossfade-out end")),
415      eSampleStartOffset("Sample start offset", 0, 2000),      ePitchTrack(_("Pitch track")),
416      eUnityNote("Unity note"),      eSustainReleaseTrigger(_("Sustain Release Trigger")),
417      eFineTune("Fine tune", -49, 50),      eNoNoteOffReleaseTrigger(_("No note-off release trigger")),
418      eGain("Gain", -96, 0, 2, -655360),      eDimensionBypass(_("Dimension bypass")),
419      eGainPlus6("Gain +6dB", eGain, 6 * -655360),      ePan(_("Pan"), -64, 63),
420      eSampleLoopEnabled("Enabled"),      eSelfMask(_("Kill lower velocity voices (a.k.a \"Self mask\")")),
421      eSampleLoopStart("Loop start positon"),      eAttenuationController(_("Attenuation controller")),
422      eSampleLoopLength("Loop size"),      eInvertAttenuationController(_("Invert attenuation controller")),
423      eSampleLoopType("Loop type"),      eAttenuationControllerThreshold(_("Attenuation controller threshold")),
424      eSampleLoopInfinite("Infinite loop"),      eChannelOffset(_("Channel offset"), 0, 9),
425      eSampleLoopPlayCount("Playback count")      eSustainDefeat(_("Ignore Hold Pedal (a.k.a. \"Sustain defeat\")")),
426  {      eMSDecode(_("Decode Mid/Side Recordings")),
427      for (int i = 0 ; i < 7 ; i++) {      eSampleStartOffset(_("Sample start offset"), 0, 2000),
428        eUnityNote(_("Unity note")),
429        eSampleGroup(_("Sample Group")),
430        eSampleFormatInfo(_("Sample Format")),
431        eSampleID("Sample ID"),
432        eChecksum("Wave Data CRC-32"),
433        eFineTune(_("Fine tune"), -49, 50),
434        eGain(_("Gain (dB)"), -96, +96, 2, -655360),
435        eSampleLoopEnabled(_("Enabled")),
436        eSampleLoopStart(_("Loop start position")),
437        eSampleLoopLength(_("Loop size")),
438        eSampleLoopType(_("Loop type")),
439        eSampleLoopInfinite(_("Infinite loop")),
440        eSampleLoopPlayCount(_("Playback count"), 1),
441        buttonSelectSample(UNICODE_LEFT_ARROW + "  " + _("Select Sample")),
442        update_model(0)
443    {
444        // make synthesis parameter page tabs scrollable
445        // (workaround for GTK3: default theme uses huge tabs which breaks layout)
446        set_scrollable();
447    
448        connect(eEG1PreAttack, &gig::DimensionRegion::EG1PreAttack);
449        connect(eEG1Attack, &gig::DimensionRegion::EG1Attack);
450        connect(eEG1Decay1, &gig::DimensionRegion::EG1Decay1);
451        connect(eEG1Decay2, &gig::DimensionRegion::EG1Decay2);
452        connect(eEG1InfiniteSustain, &gig::DimensionRegion::EG1InfiniteSustain);
453        connect(eEG1Sustain, &gig::DimensionRegion::EG1Sustain);
454        connect(eEG1Release, &gig::DimensionRegion::EG1Release);
455        connect(eEG1Hold, &gig::DimensionRegion::EG1Hold);
456        connect(eEG1Controller, &gig::DimensionRegion::EG1Controller);
457        connect(eEG1ControllerInvert, &gig::DimensionRegion::EG1ControllerInvert);
458        connect(eEG1ControllerAttackInfluence,
459                &gig::DimensionRegion::EG1ControllerAttackInfluence);
460        connect(eEG1ControllerDecayInfluence,
461                &gig::DimensionRegion::EG1ControllerDecayInfluence);
462        connect(eEG1ControllerReleaseInfluence,
463                &gig::DimensionRegion::EG1ControllerReleaseInfluence);
464        connect(eEG1StateOptions.checkBoxAttack, &gig::DimensionRegion::EG1Options,
465                &gig::eg_opt_t::AttackCancel);
466        connect(eEG1StateOptions.checkBoxAttackHold, &gig::DimensionRegion::EG1Options,
467                &gig::eg_opt_t::AttackHoldCancel);
468        connect(eEG1StateOptions.checkBoxDecay1, &gig::DimensionRegion::EG1Options,
469                &gig::eg_opt_t::Decay1Cancel);
470        connect(eEG1StateOptions.checkBoxDecay2, &gig::DimensionRegion::EG1Options,
471                &gig::eg_opt_t::Decay2Cancel);
472        connect(eEG1StateOptions.checkBoxRelease, &gig::DimensionRegion::EG1Options,
473                &gig::eg_opt_t::ReleaseCancel);
474        connect(eLFO1Wave, &gig::DimensionRegion::LFO1WaveForm);
475        connect(eLFO1Frequency, &gig::DimensionRegion::LFO1Frequency);
476        connect(eLFO1Phase, &gig::DimensionRegion::LFO1Phase);
477        connect(eLFO1InternalDepth, &gig::DimensionRegion::LFO1InternalDepth);
478        connect(eLFO1ControlDepth, &gig::DimensionRegion::LFO1ControlDepth);
479        connect(eLFO1Controller, &gig::DimensionRegion::LFO1Controller);
480        connect(eLFO1FlipPhase, &gig::DimensionRegion::LFO1FlipPhase);
481        connect(eLFO1Sync, &gig::DimensionRegion::LFO1Sync);
482        connect(eEG2PreAttack, &gig::DimensionRegion::EG2PreAttack);
483        connect(eEG2Attack, &gig::DimensionRegion::EG2Attack);
484        connect(eEG2Decay1, &gig::DimensionRegion::EG2Decay1);
485        connect(eEG2Decay2, &gig::DimensionRegion::EG2Decay2);
486        connect(eEG2InfiniteSustain, &gig::DimensionRegion::EG2InfiniteSustain);
487        connect(eEG2Sustain, &gig::DimensionRegion::EG2Sustain);
488        connect(eEG2Release, &gig::DimensionRegion::EG2Release);
489        connect(eEG2Controller, &gig::DimensionRegion::EG2Controller);
490        connect(eEG2ControllerInvert, &gig::DimensionRegion::EG2ControllerInvert);
491        connect(eEG2ControllerAttackInfluence,
492                &gig::DimensionRegion::EG2ControllerAttackInfluence);
493        connect(eEG2ControllerDecayInfluence,
494                &gig::DimensionRegion::EG2ControllerDecayInfluence);
495        connect(eEG2ControllerReleaseInfluence,
496                &gig::DimensionRegion::EG2ControllerReleaseInfluence);
497        connect(eEG2StateOptions.checkBoxAttack, &gig::DimensionRegion::EG2Options,
498                &gig::eg_opt_t::AttackCancel);
499        connect(eEG2StateOptions.checkBoxAttackHold, &gig::DimensionRegion::EG2Options,
500                &gig::eg_opt_t::AttackHoldCancel);
501        connect(eEG2StateOptions.checkBoxDecay1, &gig::DimensionRegion::EG2Options,
502                &gig::eg_opt_t::Decay1Cancel);
503        connect(eEG2StateOptions.checkBoxDecay2, &gig::DimensionRegion::EG2Options,
504                &gig::eg_opt_t::Decay2Cancel);
505        connect(eEG2StateOptions.checkBoxRelease, &gig::DimensionRegion::EG2Options,
506                &gig::eg_opt_t::ReleaseCancel);
507        connect(eLFO2Wave, &gig::DimensionRegion::LFO2WaveForm);
508        connect(eLFO2Frequency, &gig::DimensionRegion::LFO2Frequency);
509        connect(eLFO2Phase, &gig::DimensionRegion::LFO2Phase);
510        connect(eLFO2InternalDepth, &gig::DimensionRegion::LFO2InternalDepth);
511        connect(eLFO2ControlDepth, &gig::DimensionRegion::LFO2ControlDepth);
512        connect(eLFO2Controller, &gig::DimensionRegion::LFO2Controller);
513        connect(eLFO2FlipPhase, &gig::DimensionRegion::LFO2FlipPhase);
514        connect(eLFO2Sync, &gig::DimensionRegion::LFO2Sync);
515        connect(eEG3Attack, &gig::DimensionRegion::EG3Attack);
516        connect(eEG3Depth, &gig::DimensionRegion::EG3Depth);
517        connect(eLFO3Wave, &gig::DimensionRegion::LFO3WaveForm);
518        connect(eLFO3Frequency, &gig::DimensionRegion::LFO3Frequency);
519        connect(eLFO3Phase, &gig::DimensionRegion::LFO3Phase);
520        connect(eLFO3InternalDepth, &gig::DimensionRegion::LFO3InternalDepth);
521        connect(eLFO3ControlDepth, &gig::DimensionRegion::LFO3ControlDepth);
522        connect(eLFO3Controller, &gig::DimensionRegion::LFO3Controller);
523        connect(eLFO3FlipPhase, &gig::DimensionRegion::LFO3FlipPhase);
524        connect(eLFO3Sync, &gig::DimensionRegion::LFO3Sync);
525        connect(eVCFEnabled, &gig::DimensionRegion::VCFEnabled);
526        connect(eVCFType, &gig::DimensionRegion::VCFType);
527        connect(eVCFCutoffController,
528                &gig::DimensionRegion::SetVCFCutoffController);
529        connect(eVCFCutoffControllerInvert,
530                &gig::DimensionRegion::VCFCutoffControllerInvert);
531        connect(eVCFCutoff, &gig::DimensionRegion::VCFCutoff);
532        connect(eVCFVelocityCurve, &gig::DimensionRegion::SetVCFVelocityCurve);
533        connect(eVCFVelocityScale, &gig::DimensionRegion::SetVCFVelocityScale);
534        connect(eVCFVelocityDynamicRange,
535                &gig::DimensionRegion::SetVCFVelocityDynamicRange);
536        connect(eVCFResonance, &gig::DimensionRegion::VCFResonance);
537        connect(eVCFResonanceDynamic, &gig::DimensionRegion::VCFResonanceDynamic);
538        connect(eVCFResonanceController,
539                &gig::DimensionRegion::VCFResonanceController);
540        connect(eVCFKeyboardTracking, &gig::DimensionRegion::VCFKeyboardTracking);
541        connect(eVCFKeyboardTrackingBreakpoint,
542                &gig::DimensionRegion::VCFKeyboardTrackingBreakpoint);
543        connect(eVelocityResponseCurve,
544                &gig::DimensionRegion::SetVelocityResponseCurve);
545        connect(eVelocityResponseDepth,
546                &gig::DimensionRegion::SetVelocityResponseDepth);
547        connect(eVelocityResponseCurveScaling,
548                &gig::DimensionRegion::SetVelocityResponseCurveScaling);
549        connect(eReleaseVelocityResponseCurve,
550                &gig::DimensionRegion::SetReleaseVelocityResponseCurve);
551        connect(eReleaseVelocityResponseDepth,
552                &gig::DimensionRegion::SetReleaseVelocityResponseDepth);
553        connect(eReleaseTriggerDecay, &gig::DimensionRegion::ReleaseTriggerDecay);
554        connect(eCrossfade_in_start, &DimRegionEdit::set_Crossfade_in_start);
555        connect(eCrossfade_in_end, &DimRegionEdit::set_Crossfade_in_end);
556        connect(eCrossfade_out_start, &DimRegionEdit::set_Crossfade_out_start);
557        connect(eCrossfade_out_end, &DimRegionEdit::set_Crossfade_out_end);
558        connect(ePitchTrack, &gig::DimensionRegion::PitchTrack);
559        connect(eSustainReleaseTrigger, &gig::DimensionRegion::SustainReleaseTrigger);
560        connect(eNoNoteOffReleaseTrigger, &gig::DimensionRegion::NoNoteOffReleaseTrigger);
561        connect(eDimensionBypass, &gig::DimensionRegion::DimensionBypass);
562        connect(ePan, &gig::DimensionRegion::Pan);
563        connect(eSelfMask, &gig::DimensionRegion::SelfMask);
564        connect(eAttenuationController,
565                &gig::DimensionRegion::AttenuationController);
566        connect(eInvertAttenuationController,
567                &gig::DimensionRegion::InvertAttenuationController);
568        connect(eAttenuationControllerThreshold,
569                &gig::DimensionRegion::AttenuationControllerThreshold);
570        connect(eChannelOffset, &gig::DimensionRegion::ChannelOffset);
571        connect(eSustainDefeat, &gig::DimensionRegion::SustainDefeat);
572        connect(eMSDecode, &gig::DimensionRegion::MSDecode);
573        connect(eSampleStartOffset, &gig::DimensionRegion::SampleStartOffset);
574        connect(eUnityNote, &DimRegionEdit::set_UnityNote);
575        connect(eFineTune, &DimRegionEdit::set_FineTune);
576        connect(eGain, &DimRegionEdit::set_Gain);
577        connect(eSampleLoopEnabled, &DimRegionEdit::set_LoopEnabled);
578        connect(eSampleLoopType, &DimRegionEdit::set_LoopType);
579        connect(eSampleLoopStart, &DimRegionEdit::set_LoopStart);
580        connect(eSampleLoopLength, &DimRegionEdit::set_LoopLength);
581        connect(eSampleLoopInfinite, &DimRegionEdit::set_LoopInfinite);
582        connect(eSampleLoopPlayCount, &DimRegionEdit::set_LoopPlayCount);
583        buttonSelectSample.signal_clicked().connect(
584            sigc::mem_fun(*this, &DimRegionEdit::onButtonSelectSamplePressed)
585        );
586    
587        for (int i = 0 ; i < 9 ; i++) {
588    #if USE_GTKMM_GRID
589            table[i] = new Gtk::Grid;
590            table[i]->set_column_spacing(7);
591    #else
592          table[i] = new Gtk::Table(3, 1);          table[i] = new Gtk::Table(3, 1);
593          table[i]->set_col_spacings(7);          table[i]->set_col_spacings(7);
594    #endif
595    
596    // on Gtk 3 there is absolutely no margin by default
597    #if GTKMM_MAJOR_VERSION >= 3
598    # if GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION < 12
599            table[i]->set_margin_left(12);
600            table[i]->set_margin_right(12);
601    # else
602            table[i]->set_margin_start(12);
603            table[i]->set_margin_end(12);
604    # endif
605    #endif
606      }      }
607    
608      // set tooltips      // set tooltips
609      eUnityNote.set_tip(      eUnityNote.set_tip(
610          _("Note this sample is associated with (a.k.a. 'root note')")          _("Note this sample is associated with (a.k.a. 'root note')")
611      );      );
612        buttonSelectSample.set_tooltip_text(
613            _("Selects the sample of this dimension region on the left hand side's sample tree view.")
614        );
615      eSampleStartOffset.set_tip(_("Sample position at which playback should be started"));      eSampleStartOffset.set_tip(_("Sample position at which playback should be started"));
616      ePan.set_tip(_("Stereo balance (left/right)"));      ePan.set_tip(_("Stereo balance (left/right)"));
617      eChannelOffset.set_tip(      eChannelOffset.set_tip(
# Line 151  DimRegionEdit::DimRegionEdit() : Line 642  DimRegionEdit::DimRegionEdit() :
642            "Caution: this setting is stored on Sample side, thus is shared "            "Caution: this setting is stored on Sample side, thus is shared "
643            "among all dimension regions that use this sample!")            "among all dimension regions that use this sample!")
644      );      );
645        
646        eEG1PreAttack.set_tip(
647            "Very first level this EG starts with. It rises then in Attack Time "
648            "seconds from this initial level to 100%."
649        );
650        eEG1Attack.set_tip(
651            "Duration of the EG's Attack stage, which raises its level from "
652            "Pre-Attack Level to 100%."
653        );
654        eEG1Hold.set_tip(
655           "On looped sounds, enabling this will cause the Decay 1 stage not to "
656           "enter before the loop has been passed one time."
657        );
658        eAttenuationController.set_tip(_(
659            "If you are not using the 'Layer' dimension, then this controller "
660            "simply alters the volume. If you are using the 'Layer' dimension, "
661            "then this controller is controlling the crossfade between Layers in "
662            "real-time."
663        ));
664    
665        eLFO1Sync.set_tip(
666            "If not checked, every voice will use its own LFO instance, which "
667            "causes voices triggered at different points in time to have different "
668            "LFO levels. By enabling 'Sync' here the voices will instead use and "
669            "share one single LFO, causing all voices to have the same LFO level, "
670            "no matter when the individual notes have been triggered."
671        );
672        eLFO2Sync.set_tip(
673            "If not checked, every voice will use its own LFO instance, which "
674            "causes voices triggered at different points in time to have different "
675            "LFO levels. By enabling 'Sync' here the voices will instead use and "
676            "share one single LFO, causing all voices to have the same LFO level, "
677            "no matter when the individual notes have been triggered."
678        );
679        eLFO3Sync.set_tip(
680            "If not checked, every voice will use its own LFO instance, which "
681            "causes voices triggered at different points in time to have different "
682            "LFO levels. By enabling 'Sync' here the voices will instead use and "
683            "share one single LFO, causing all voices to have the same LFO level, "
684            "no matter when the individual notes have been triggered."
685        );
686        eLFO1FlipPhase.set_tip(
687           "Inverts the LFO's generated wave vertically."
688        );
689        eLFO2FlipPhase.set_tip(
690           "Inverts the LFO's generated wave vertically."
691        );
692        eLFO3FlipPhase.set_tip(
693           "Inverts the LFO's generated wave vertically."
694        );
695    
696      pageno = 0;      pageno = 0;
697      rowno = 0;      rowno = 0;
698      firstRowInBlock = 0;      firstRowInBlock = 0;
699    
700      addHeader(_("Mandatory Settings"));      addHeader(_("Mandatory Settings"));
701      addString("Sample", lSample, wSample);      addString(_("Sample"), lSample, wSample, buttonNullSampleReference);
702        buttonNullSampleReference->set_label("X");
703        buttonNullSampleReference->set_tooltip_text(_("Remove current sample reference (NULL reference). This can be used to define a \"silent\" case where no sample shall be played."));
704        buttonNullSampleReference->signal_clicked().connect(
705            sigc::mem_fun(*this, &DimRegionEdit::nullOutSampleReference)
706        );
707      //TODO: the following would break drag&drop:   wSample->property_editable().set_value(false);  or this:    wSample->set_editable(false);      //TODO: the following would break drag&drop:   wSample->property_editable().set_value(false);  or this:    wSample->set_editable(false);
708      tooltips.set_tip(*wSample, _("Drop a sample here"));  #ifdef OLD_TOOLTIPS
709        tooltips.set_tip(*wSample, _("Drag & drop a sample here"));
710    #else
711        wSample->set_tooltip_text(_("Drag & drop a sample here"));
712    #endif
713      addProp(eUnityNote);      addProp(eUnityNote);
714        addProp(eSampleGroup);
715        addProp(eSampleFormatInfo);
716        addProp(eSampleID);
717        addProp(eChecksum);
718        addRightHandSide(buttonSelectSample);
719      addHeader(_("Optional Settings"));      addHeader(_("Optional Settings"));
720      addProp(eSampleStartOffset);      addProp(eSampleStartOffset);
721      addProp(eChannelOffset);      addProp(eChannelOffset);
722      addHeader("Loops");      addHeader(_("Loops"));
723      addProp(eSampleLoopEnabled);      addProp(eSampleLoopEnabled);
724      addProp(eSampleLoopStart);      addProp(eSampleLoopStart);
725      addProp(eSampleLoopLength);      addProp(eSampleLoopLength);
726      {      {
727          const char* choices[] = { "normal", "bidirectional", "backward", 0 };          const char* choices[] = { _("normal"), _("bidirectional"), _("backward"), 0 };
728          static const uint32_t values[] = {          static const uint32_t values[] = {
729              gig::loop_type_normal,              gig::loop_type_normal,
730              gig::loop_type_bidirectional,              gig::loop_type_bidirectional,
# Line 185  DimRegionEdit::DimRegionEdit() : Line 740  DimRegionEdit::DimRegionEdit() :
740    
741      addHeader(_("General Amplitude Settings"));      addHeader(_("General Amplitude Settings"));
742      addProp(eGain);      addProp(eGain);
     addProp(eGainPlus6);  
743      addProp(ePan);      addProp(ePan);
744      addHeader(_("Amplitude Envelope (EG1)"));      addHeader(_("Amplitude Envelope (EG1)"));
745      addProp(eEG1PreAttack);      addProp(eEG1PreAttack);
746      addProp(eEG1Attack);      addProp(eEG1Attack);
747        addProp(eEG1Hold);
748      addProp(eEG1Decay1);      addProp(eEG1Decay1);
749      addProp(eEG1Decay2);      addProp(eEG1Decay2);
750      addProp(eEG1InfiniteSustain);      addProp(eEG1InfiniteSustain);
751      addProp(eEG1Sustain);      addProp(eEG1Sustain);
752      addProp(eEG1Release);      addProp(eEG1Release);
     addProp(eEG1Hold);  
753      addProp(eEG1Controller);      addProp(eEG1Controller);
754      addProp(eEG1ControllerInvert);      addProp(eEG1ControllerInvert);
755      addProp(eEG1ControllerAttackInfluence);      addProp(eEG1ControllerAttackInfluence);
756      addProp(eEG1ControllerDecayInfluence);      addProp(eEG1ControllerDecayInfluence);
757      addProp(eEG1ControllerReleaseInfluence);      addProp(eEG1ControllerReleaseInfluence);
758        addLine(eEG1StateOptions);
759    
760      nextPage();      nextPage();
761    
762      addHeader(_("Amplitude Oscillator (LFO1)"));      addHeader(_("Amplitude Oscillator (LFO1)"));
763        addProp(eLFO1Wave);
764      addProp(eLFO1Frequency);      addProp(eLFO1Frequency);
765        addProp(eLFO1Phase);
766      addProp(eLFO1InternalDepth);      addProp(eLFO1InternalDepth);
767      addProp(eLFO1ControlDepth);      addProp(eLFO1ControlDepth);
768      {      {
769          const char* choices[] = { "internal", "modwheel", "breath",          const char* choices[] = { _("internal"), _("modwheel"), _("breath"),
770                                    "internal+modwheel", "internal+breath", 0 };                                    _("internal+modwheel"), _("internal+breath"), 0 };
771          static const gig::lfo1_ctrl_t values[] = {          static const gig::lfo1_ctrl_t values[] = {
772              gig::lfo1_ctrl_internal,              gig::lfo1_ctrl_internal,
773              gig::lfo1_ctrl_modwheel,              gig::lfo1_ctrl_modwheel,
# Line 223  DimRegionEdit::DimRegionEdit() : Line 780  DimRegionEdit::DimRegionEdit() :
780      addProp(eLFO1Controller);      addProp(eLFO1Controller);
781      addProp(eLFO1FlipPhase);      addProp(eLFO1FlipPhase);
782      addProp(eLFO1Sync);      addProp(eLFO1Sync);
783      addHeader("Crossfade");      {
784            Gtk::Frame* frame = new Gtk::Frame;
785            frame->add(lfo1Graph);
786            // on Gtk 3 there is no margin at all by default
787    #if GTKMM_MAJOR_VERSION >= 3
788            frame->set_margin_top(12);
789            frame->set_margin_bottom(12);
790    #endif
791    #if USE_GTKMM_GRID
792            table[pageno]->attach(*frame, 1, rowno, 2);
793    #else
794            table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
795                                  Gtk::SHRINK, Gtk::SHRINK);
796    #endif
797            rowno++;
798        }
799        eLFO1Wave.signal_value_changed().connect(
800            sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw)
801        );
802        eLFO1Frequency.signal_value_changed().connect(
803            sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw)
804        );
805        eLFO1Phase.signal_value_changed().connect(
806            sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw)
807        );
808        eLFO1InternalDepth.signal_value_changed().connect(
809            sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw)
810        );
811        eLFO1ControlDepth.signal_value_changed().connect(
812            sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw)
813        );
814        eLFO1Controller.signal_value_changed().connect(
815            sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw)
816        );
817        eLFO1FlipPhase.signal_value_changed().connect(
818            sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw)
819        );
820        eLFO1Sync.signal_value_changed().connect(
821            sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw)
822        );
823    
824        nextPage();
825    
826        addHeader(_("Crossfade"));
827      addProp(eAttenuationController);      addProp(eAttenuationController);
828      addProp(eInvertAttenuationController);      addProp(eInvertAttenuationController);
829      addProp(eAttenuationControllerThreshold);      addProp(eAttenuationControllerThreshold);
# Line 232  DimRegionEdit::DimRegionEdit() : Line 832  DimRegionEdit::DimRegionEdit() :
832      addProp(eCrossfade_out_start);      addProp(eCrossfade_out_start);
833      addProp(eCrossfade_out_end);      addProp(eCrossfade_out_end);
834    
835        Gtk::Frame* frame = new Gtk::Frame;
836        frame->add(crossfade_curve);
837        // on Gtk 3 there is no margin at all by default
838    #if GTKMM_MAJOR_VERSION >= 3
839        frame->set_margin_top(12);
840        frame->set_margin_bottom(12);
841    #endif
842    #if USE_GTKMM_GRID
843        table[pageno]->attach(*frame, 1, rowno, 2);
844    #else
845        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
846                              Gtk::SHRINK, Gtk::SHRINK);
847    #endif
848        rowno++;
849    
850        eCrossfade_in_start.signal_value_changed().connect(
851            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
852        eCrossfade_in_end.signal_value_changed().connect(
853            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
854        eCrossfade_out_start.signal_value_changed().connect(
855            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
856        eCrossfade_out_end.signal_value_changed().connect(
857            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
858    
859      nextPage();      nextPage();
860    
861      addHeader(_("General Filter Settings"));      addHeader(_("General Filter Settings"));
862      addProp(eVCFEnabled);      addProp(eVCFEnabled);
863      {      {
864          const char* choices[] = { "lowpass", "lowpassturbo", "bandpass",          const char* choices[] = { _("lowpass"), _("lowpassturbo"), _("bandpass"),
865                                    "highpass", "bandreject", 0 };                                    _("highpass"), _("bandreject"), 0 };
866          static const gig::vcf_type_t values[] = {          static const gig::vcf_type_t values[] = {
867              gig::vcf_type_lowpass,              gig::vcf_type_lowpass,
868              gig::vcf_type_lowpassturbo,              gig::vcf_type_lowpassturbo,
# Line 250  DimRegionEdit::DimRegionEdit() : Line 874  DimRegionEdit::DimRegionEdit() :
874      }      }
875      addProp(eVCFType);      addProp(eVCFType);
876      {      {
877          const char* choices[] = { "none", "none2", "modwheel", "effect1", "effect2",          const char* choices[] = { _("none"), _("none2"), _("modwheel"), _("effect1"), _("effect2"),
878                                    "breath", "foot", "sustainpedal", "softpedal",                                    _("breath"), _("foot"), _("sustainpedal"), _("softpedal"),
879                                    "genpurpose7", "genpurpose8", "aftertouch", 0 };                                    _("genpurpose7"), _("genpurpose8"), _("aftertouch"), 0 };
880          static const gig::vcf_cutoff_ctrl_t values[] = {          static const gig::vcf_cutoff_ctrl_t values[] = {
881              gig::vcf_cutoff_ctrl_none,              gig::vcf_cutoff_ctrl_none,
882              gig::vcf_cutoff_ctrl_none2,              gig::vcf_cutoff_ctrl_none2,
# Line 272  DimRegionEdit::DimRegionEdit() : Line 896  DimRegionEdit::DimRegionEdit() :
896      addProp(eVCFCutoffController);      addProp(eVCFCutoffController);
897      addProp(eVCFCutoffControllerInvert);      addProp(eVCFCutoffControllerInvert);
898      addProp(eVCFCutoff);      addProp(eVCFCutoff);
899      const char* curve_type_texts[] = { "nonlinear", "linear", "special", 0 };      const char* curve_type_texts[] = { _("nonlinear"), _("linear"), _("special"), 0 };
900      static const gig::curve_type_t curve_type_values[] = {      static const gig::curve_type_t curve_type_values[] = {
901          gig::curve_type_nonlinear,          gig::curve_type_nonlinear,
902          gig::curve_type_linear,          gig::curve_type_linear,
# Line 282  DimRegionEdit::DimRegionEdit() : Line 906  DimRegionEdit::DimRegionEdit() :
906      addProp(eVCFVelocityCurve);      addProp(eVCFVelocityCurve);
907      addProp(eVCFVelocityScale);      addProp(eVCFVelocityScale);
908      addProp(eVCFVelocityDynamicRange);      addProp(eVCFVelocityDynamicRange);
909    
910        eVCFCutoffController.signal_value_changed().connect(
911            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
912        eVCFVelocityCurve.signal_value_changed().connect(
913            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
914        eVCFVelocityScale.signal_value_changed().connect(
915            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
916        eVCFVelocityDynamicRange.signal_value_changed().connect(
917            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
918    
919        frame = new Gtk::Frame;
920        frame->add(cutoff_curve);
921        // on Gtk 3 there is no margin at all by default
922    #if GTKMM_MAJOR_VERSION >= 3
923        frame->set_margin_top(12);
924        frame->set_margin_bottom(12);
925    #endif
926    #if USE_GTKMM_GRID
927        table[pageno]->attach(*frame, 1, rowno, 2);
928    #else
929        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
930                              Gtk::SHRINK, Gtk::SHRINK);
931    #endif
932        rowno++;
933    
934      addProp(eVCFResonance);      addProp(eVCFResonance);
935      addProp(eVCFResonanceDynamic);      addProp(eVCFResonanceDynamic);
936      {      {
937          const char* choices[] = { "none", "genpurpose3", "genpurpose4",          const char* choices[] = { _("none"), _("genpurpose3"), _("genpurpose4"),
938                                    "genpurpose5", "genpurpose6", 0 };                                    _("genpurpose5"), _("genpurpose6"), 0 };
939          static const gig::vcf_res_ctrl_t values[] = {          static const gig::vcf_res_ctrl_t values[] = {
940              gig::vcf_res_ctrl_none,              gig::vcf_res_ctrl_none,
941              gig::vcf_res_ctrl_genpurpose3,              gig::vcf_res_ctrl_genpurpose3,
# Line 302  DimRegionEdit::DimRegionEdit() : Line 951  DimRegionEdit::DimRegionEdit() :
951    
952      nextPage();      nextPage();
953    
954      addHeader(_("Filter Cutoff Envelope (EG2)"));      lEG2 = addHeader(_("Filter Cutoff Envelope (EG2)"));
955      addProp(eEG2PreAttack);      addProp(eEG2PreAttack);
956      addProp(eEG2Attack);      addProp(eEG2Attack);
957      addProp(eEG2Decay1);      addProp(eEG2Decay1);
# Line 315  DimRegionEdit::DimRegionEdit() : Line 964  DimRegionEdit::DimRegionEdit() :
964      addProp(eEG2ControllerAttackInfluence);      addProp(eEG2ControllerAttackInfluence);
965      addProp(eEG2ControllerDecayInfluence);      addProp(eEG2ControllerDecayInfluence);
966      addProp(eEG2ControllerReleaseInfluence);      addProp(eEG2ControllerReleaseInfluence);
967      addHeader(_("Filter Cutoff Oscillator (LFO2)"));      addLine(eEG2StateOptions);
968    
969        nextPage();
970    
971        lLFO2 = addHeader(_("Filter Cutoff Oscillator (LFO2)"));
972        addProp(eLFO2Wave);
973      addProp(eLFO2Frequency);      addProp(eLFO2Frequency);
974        addProp(eLFO2Phase);
975      addProp(eLFO2InternalDepth);      addProp(eLFO2InternalDepth);
976      addProp(eLFO2ControlDepth);      addProp(eLFO2ControlDepth);
977      {      {
978          const char* choices[] = { "internal", "modwheel", "foot",          const char* choices[] = { _("internal"), _("modwheel"), _("foot"),
979                                    "internal+modwheel", "internal+foot", 0 };                                    _("internal+modwheel"), _("internal+foot"), 0 };
980          static const gig::lfo2_ctrl_t values[] = {          static const gig::lfo2_ctrl_t values[] = {
981              gig::lfo2_ctrl_internal,              gig::lfo2_ctrl_internal,
982              gig::lfo2_ctrl_modwheel,              gig::lfo2_ctrl_modwheel,
# Line 334  DimRegionEdit::DimRegionEdit() : Line 989  DimRegionEdit::DimRegionEdit() :
989      addProp(eLFO2Controller);      addProp(eLFO2Controller);
990      addProp(eLFO2FlipPhase);      addProp(eLFO2FlipPhase);
991      addProp(eLFO2Sync);      addProp(eLFO2Sync);
992        {
993            Gtk::Frame* frame = new Gtk::Frame;
994            frame->add(lfo2Graph);
995            // on Gtk 3 there is no margin at all by default
996    #if GTKMM_MAJOR_VERSION >= 3
997            frame->set_margin_top(12);
998            frame->set_margin_bottom(12);
999    #endif
1000    #if USE_GTKMM_GRID
1001            table[pageno]->attach(*frame, 1, rowno, 2);
1002    #else
1003            table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
1004                                  Gtk::SHRINK, Gtk::SHRINK);
1005    #endif
1006            rowno++;
1007        }
1008        eLFO2Wave.signal_value_changed().connect(
1009            sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw)
1010        );
1011        eLFO2Frequency.signal_value_changed().connect(
1012            sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw)
1013        );
1014        eLFO2Phase.signal_value_changed().connect(
1015            sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw)
1016        );
1017        eLFO2InternalDepth.signal_value_changed().connect(
1018            sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw)
1019        );
1020        eLFO2ControlDepth.signal_value_changed().connect(
1021            sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw)
1022        );
1023        eLFO2Controller.signal_value_changed().connect(
1024            sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw)
1025        );
1026        eLFO2FlipPhase.signal_value_changed().connect(
1027            sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw)
1028        );
1029        eLFO2Sync.signal_value_changed().connect(
1030            sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw)
1031        );
1032    
1033      nextPage();      nextPage();
1034    
# Line 344  DimRegionEdit::DimRegionEdit() : Line 1039  DimRegionEdit::DimRegionEdit() :
1039      addProp(eEG3Attack);      addProp(eEG3Attack);
1040      addProp(eEG3Depth);      addProp(eEG3Depth);
1041      addHeader(_("Pitch Oscillator (LFO3)"));      addHeader(_("Pitch Oscillator (LFO3)"));
1042        addProp(eLFO3Wave);
1043      addProp(eLFO3Frequency);      addProp(eLFO3Frequency);
1044        addProp(eLFO3Phase);
1045      addProp(eLFO3InternalDepth);      addProp(eLFO3InternalDepth);
1046      addProp(eLFO3ControlDepth);      addProp(eLFO3ControlDepth);
1047      {      {
1048          const char* choices[] = { "internal", "modwheel", "aftertouch",          const char* choices[] = { _("internal"), _("modwheel"), _("aftertouch"),
1049                                    "internal+modwheel", "internal+aftertouch", 0 };                                    _("internal+modwheel"), _("internal+aftertouch"), 0 };
1050          static const gig::lfo3_ctrl_t values[] = {          static const gig::lfo3_ctrl_t values[] = {
1051              gig::lfo3_ctrl_internal,              gig::lfo3_ctrl_internal,
1052              gig::lfo3_ctrl_modwheel,              gig::lfo3_ctrl_modwheel,
# Line 360  DimRegionEdit::DimRegionEdit() : Line 1057  DimRegionEdit::DimRegionEdit() :
1057          eLFO3Controller.set_choices(choices, values);          eLFO3Controller.set_choices(choices, values);
1058      }      }
1059      addProp(eLFO3Controller);      addProp(eLFO3Controller);
1060        addProp(eLFO3FlipPhase);
1061      addProp(eLFO3Sync);      addProp(eLFO3Sync);
1062        {
1063            Gtk::Frame* frame = new Gtk::Frame;
1064            frame->add(lfo3Graph);
1065            // on Gtk 3 there is no margin at all by default
1066    #if GTKMM_MAJOR_VERSION >= 3
1067            frame->set_margin_top(12);
1068            frame->set_margin_bottom(12);
1069    #endif
1070    #if USE_GTKMM_GRID
1071            table[pageno]->attach(*frame, 1, rowno, 2);
1072    #else
1073            table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
1074                                  Gtk::SHRINK, Gtk::SHRINK);
1075    #endif
1076            rowno++;
1077        }
1078        eLFO3Wave.signal_value_changed().connect(
1079            sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw)
1080        );
1081        eLFO3Frequency.signal_value_changed().connect(
1082            sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw)
1083        );
1084        eLFO3Phase.signal_value_changed().connect(
1085            sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw)
1086        );
1087        eLFO3InternalDepth.signal_value_changed().connect(
1088            sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw)
1089        );
1090        eLFO3ControlDepth.signal_value_changed().connect(
1091            sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw)
1092        );
1093        eLFO3Controller.signal_value_changed().connect(
1094            sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw)
1095        );
1096        eLFO3FlipPhase.signal_value_changed().connect(
1097            sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw)
1098        );
1099        eLFO3Sync.signal_value_changed().connect(
1100            sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw)
1101        );
1102    
1103      nextPage();      nextPage();
1104    
1105        addHeader(_("Velocity Response"));
1106      eVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values);      eVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values);
1107      addProp(eVelocityResponseCurve);      addProp(eVelocityResponseCurve);
1108      addProp(eVelocityResponseDepth);      addProp(eVelocityResponseDepth);
1109      addProp(eVelocityResponseCurveScaling);      addProp(eVelocityResponseCurveScaling);
1110    
1111        eVelocityResponseCurve.signal_value_changed().connect(
1112            sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
1113        eVelocityResponseDepth.signal_value_changed().connect(
1114            sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
1115        eVelocityResponseCurveScaling.signal_value_changed().connect(
1116            sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
1117    
1118        frame = new Gtk::Frame;
1119        frame->add(velocity_curve);
1120        // on Gtk 3 there is no margin at all by default
1121    #if GTKMM_MAJOR_VERSION >= 3
1122        frame->set_margin_top(12);
1123        frame->set_margin_bottom(12);
1124    #endif
1125    #if USE_GTKMM_GRID
1126        table[pageno]->attach(*frame, 1, rowno, 2);
1127    #else
1128        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
1129                              Gtk::SHRINK, Gtk::SHRINK);
1130    #endif
1131        rowno++;
1132    
1133        addHeader(_("Release Velocity Response"));
1134      eReleaseVelocityResponseCurve.set_choices(curve_type_texts,      eReleaseVelocityResponseCurve.set_choices(curve_type_texts,
1135                                                curve_type_values);                                                curve_type_values);
1136      addProp(eReleaseVelocityResponseCurve);      addProp(eReleaseVelocityResponseCurve);
1137      addProp(eReleaseVelocityResponseDepth);      addProp(eReleaseVelocityResponseDepth);
1138    
1139        eReleaseVelocityResponseCurve.signal_value_changed().connect(
1140            sigc::mem_fun(release_curve, &VelocityCurve::queue_draw));
1141        eReleaseVelocityResponseDepth.signal_value_changed().connect(
1142            sigc::mem_fun(release_curve, &VelocityCurve::queue_draw));
1143        frame = new Gtk::Frame;
1144        frame->add(release_curve);
1145        // on Gtk 3 there is no margin at all by default
1146    #if GTKMM_MAJOR_VERSION >= 3
1147        frame->set_margin_top(12);
1148        frame->set_margin_bottom(12);
1149    #endif
1150    #if USE_GTKMM_GRID
1151        table[pageno]->attach(*frame, 1, rowno, 2);
1152    #else
1153        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
1154                              Gtk::SHRINK, Gtk::SHRINK);
1155    #endif
1156        rowno++;
1157    
1158      addProp(eReleaseTriggerDecay);      addProp(eReleaseTriggerDecay);
1159      {      {
1160          const char* choices[] = { "none", "effect4depth", "effect5depth", 0 };          const char* choices[] = { _("off"), _("on (max. velocity)"), _("on (key velocity)"), 0 };
1161            static const gig::sust_rel_trg_t values[] = {
1162                gig::sust_rel_trg_none,
1163                gig::sust_rel_trg_maxvelocity,
1164                gig::sust_rel_trg_keyvelocity
1165            };
1166            eSustainReleaseTrigger.set_choices(choices, values);
1167        }
1168        eSustainReleaseTrigger.set_tip(_(
1169            "By default release trigger samples are played on note-off events only. "
1170            "This option allows to play release trigger sample on sustain pedal up "
1171            "events as well. NOTE: This is a format extension!"
1172        ));
1173        addProp(eSustainReleaseTrigger);
1174        {
1175            const char* choices[] = { _("none"), _("effect4depth"), _("effect5depth"), 0 };
1176          static const gig::dim_bypass_ctrl_t values[] = {          static const gig::dim_bypass_ctrl_t values[] = {
1177              gig::dim_bypass_ctrl_none,              gig::dim_bypass_ctrl_none,
1178              gig::dim_bypass_ctrl_94,              gig::dim_bypass_ctrl_94,
# Line 382  DimRegionEdit::DimRegionEdit() : Line 1180  DimRegionEdit::DimRegionEdit() :
1180          };          };
1181          eDimensionBypass.set_choices(choices, values);          eDimensionBypass.set_choices(choices, values);
1182      }      }
1183        eNoNoteOffReleaseTrigger.set_tip(_(
1184            "By default release trigger samples are played on note-off events only. "
1185            "If this option is checked, then no release trigger sample is played "
1186            "when releasing a note. NOTE: This is a format extension!"
1187        ));
1188        addProp(eNoNoteOffReleaseTrigger);
1189      addProp(eDimensionBypass);      addProp(eDimensionBypass);
1190        eSelfMask.widget.set_tooltip_text(_(
1191            "If enabled: new notes with higher velocity value will stop older "
1192            "notes with lower velocity values, that way you can save voices that "
1193            "would barely be audible. This is also useful for certain drum sounds."
1194        ));
1195      addProp(eSelfMask);      addProp(eSelfMask);
1196        eSustainDefeat.widget.set_tooltip_text(_(
1197            "If enabled: sustain pedal will not hold a note. This way you can use "
1198            "the sustain pedal for other purposes, for example to switch among "
1199            "dimension regions."
1200        ));
1201      addProp(eSustainDefeat);      addProp(eSustainDefeat);
1202        eMSDecode.widget.set_tooltip_text(_(
1203            "Defines if Mid/Side Recordings should be decoded. Mid/Side Recordings "
1204            "are an alternative way to record sounds in stereo. The sampler needs "
1205            "to decode such samples to actually make use of them. Note: this "
1206            "feature is currently not supported by LinuxSampler."
1207        ));
1208      addProp(eMSDecode);      addProp(eMSDecode);
1209    
1210      nextPage();      nextPage();
1211    
1212    
1213      eEG1InfiniteSustain.signal_toggled().connect(      eEG1InfiniteSustain.signal_value_changed().connect(
1214          sigc::mem_fun(*this, &DimRegionEdit::EG1InfiniteSustain_toggled) );          sigc::mem_fun(*this, &DimRegionEdit::EG1InfiniteSustain_toggled));
1215      eEG2InfiniteSustain.signal_toggled().connect(      eEG2InfiniteSustain.signal_value_changed().connect(
1216          sigc::mem_fun(*this, &DimRegionEdit::EG2InfiniteSustain_toggled) );          sigc::mem_fun(*this, &DimRegionEdit::EG2InfiniteSustain_toggled));
1217      eEG1Controller.signal_changed().connect(      eEG1Controller.signal_value_changed().connect(
1218          sigc::mem_fun(*this, &DimRegionEdit::EG1Controller_changed) );          sigc::mem_fun(*this, &DimRegionEdit::EG1Controller_changed));
1219      eEG2Controller.signal_changed().connect(      eEG2Controller.signal_value_changed().connect(
1220          sigc::mem_fun(*this, &DimRegionEdit::EG2Controller_changed) );          sigc::mem_fun(*this, &DimRegionEdit::EG2Controller_changed));
1221      eLFO1Controller.signal_changed().connect(      eLFO1Controller.signal_value_changed().connect(
1222          sigc::mem_fun(*this, &DimRegionEdit::LFO1Controller_changed) );          sigc::mem_fun(*this, &DimRegionEdit::LFO1Controller_changed));
1223      eLFO2Controller.signal_changed().connect(      eLFO2Controller.signal_value_changed().connect(
1224          sigc::mem_fun(*this, &DimRegionEdit::LFO2Controller_changed) );          sigc::mem_fun(*this, &DimRegionEdit::LFO2Controller_changed));
1225      eLFO3Controller.signal_changed().connect(      eLFO3Controller.signal_value_changed().connect(
1226          sigc::mem_fun(*this, &DimRegionEdit::LFO3Controller_changed) );          sigc::mem_fun(*this, &DimRegionEdit::LFO3Controller_changed));
1227      eAttenuationController.signal_changed().connect(      eAttenuationController.signal_value_changed().connect(
1228          sigc::mem_fun(*this, &DimRegionEdit::AttenuationController_changed) );          sigc::mem_fun(*this, &DimRegionEdit::AttenuationController_changed));
1229      eVCFEnabled.signal_toggled().connect(      eVCFEnabled.signal_value_changed().connect(
1230          sigc::mem_fun(*this, &DimRegionEdit::VCFEnabled_toggled) );          sigc::mem_fun(*this, &DimRegionEdit::VCFEnabled_toggled));
1231      eVCFCutoffController.signal_changed().connect(      eVCFCutoffController.signal_value_changed().connect(
1232          sigc::mem_fun(*this, &DimRegionEdit::VCFCutoffController_changed) );          sigc::mem_fun(*this, &DimRegionEdit::VCFCutoffController_changed));
1233      eVCFResonanceController.signal_changed().connect(      eVCFResonanceController.signal_value_changed().connect(
1234          sigc::mem_fun(*this, &DimRegionEdit::VCFResonanceController_changed) );          sigc::mem_fun(*this, &DimRegionEdit::VCFResonanceController_changed));
1235    
1236      eCrossfade_in_start.signal_changed_by_user().connect(      eCrossfade_in_start.signal_value_changed().connect(
1237          sigc::mem_fun(*this, &DimRegionEdit::crossfade1_changed));          sigc::mem_fun(*this, &DimRegionEdit::crossfade1_changed));
1238      eCrossfade_in_end.signal_changed_by_user().connect(      eCrossfade_in_end.signal_value_changed().connect(
1239          sigc::mem_fun(*this, &DimRegionEdit::crossfade2_changed));          sigc::mem_fun(*this, &DimRegionEdit::crossfade2_changed));
1240      eCrossfade_out_start.signal_changed_by_user().connect(      eCrossfade_out_start.signal_value_changed().connect(
1241          sigc::mem_fun(*this, &DimRegionEdit::crossfade3_changed));          sigc::mem_fun(*this, &DimRegionEdit::crossfade3_changed));
1242      eCrossfade_out_end.signal_changed_by_user().connect(      eCrossfade_out_end.signal_value_changed().connect(
1243          sigc::mem_fun(*this, &DimRegionEdit::crossfade4_changed));          sigc::mem_fun(*this, &DimRegionEdit::crossfade4_changed));
1244    
1245      eSampleLoopEnabled.signal_toggled().connect(      eSampleLoopEnabled.signal_value_changed().connect(
1246          sigc::mem_fun(*this, &DimRegionEdit::loop_enabled_toggled));          sigc::mem_fun(*this, &DimRegionEdit::update_loop_elements));
1247      eSampleLoopStart.signal_changed_by_user().connect(      eSampleLoopStart.signal_value_changed().connect(
1248          sigc::mem_fun(*this, &DimRegionEdit::updateLoopElements));          sigc::mem_fun(*this, &DimRegionEdit::loop_start_changed));
1249      eSampleLoopLength.signal_changed_by_user().connect(      eSampleLoopLength.signal_value_changed().connect(
1250          sigc::mem_fun(*this, &DimRegionEdit::updateLoopElements));          sigc::mem_fun(*this, &DimRegionEdit::loop_length_changed));
1251      eSampleLoopInfinite.signal_toggled().connect(      eSampleLoopInfinite.signal_value_changed().connect(
1252          sigc::mem_fun(*this, &DimRegionEdit::loop_infinite_toggled));          sigc::mem_fun(*this, &DimRegionEdit::loop_infinite_toggled));
1253    
1254      append_page(*table[0], "Sample");      append_page(*table[0], _("Sample"));
1255      append_page(*table[1], "Amplitude (1)");      append_page(*table[1], _("Amp (1)"));
1256      append_page(*table[2], "Amplitude (2)");      append_page(*table[2], _("Amp (2)"));
1257      append_page(*table[3], "Filter (1)");      append_page(*table[3], _("Amp (3)"));
1258      append_page(*table[4], "Filter (2)");      append_page(*table[4], _("Filter (1)"));
1259      append_page(*table[5], "Pitch");      append_page(*table[5], _("Filter (2)"));
1260      append_page(*table[6], "Misc");      append_page(*table[6], _("Filter (3)"));
1261        append_page(*table[7], _("Pitch"));
1262        append_page(*table[8], _("Misc"));
1263    
1264        Settings::singleton()->showTooltips.get_proxy().signal_changed().connect(
1265            sigc::mem_fun(*this, &DimRegionEdit::on_show_tooltips_changed)
1266        );
1267    
1268        on_show_tooltips_changed();
1269  }  }
1270    
1271  DimRegionEdit::~DimRegionEdit()  DimRegionEdit::~DimRegionEdit()
# Line 448  void DimRegionEdit::addString(const char Line 1276  void DimRegionEdit::addString(const char
1276                                Gtk::Entry*& widget)                                Gtk::Entry*& widget)
1277  {  {
1278      label = new Gtk::Label(Glib::ustring(labelText) + ":");      label = new Gtk::Label(Glib::ustring(labelText) + ":");
1279      label->set_alignment(Gtk::ALIGN_LEFT);  #if HAS_GTKMM_ALIGNMENT
1280        label->set_alignment(Gtk::ALIGN_START);
1281    #else
1282        label->set_halign(Gtk::Align::START);
1283    #endif
1284    
1285    #if USE_GTKMM_GRID
1286        table[pageno]->attach(*label, 1, rowno);
1287    #else
1288      table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,      table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,
1289                            Gtk::FILL, Gtk::SHRINK);                            Gtk::FILL, Gtk::SHRINK);
1290    #endif
1291    
1292      widget = new Gtk::Entry();      widget = new Gtk::Entry();
1293    
1294    #if USE_GTKMM_GRID
1295        table[pageno]->attach(*widget, 2, rowno);
1296    #else
1297      table[pageno]->attach(*widget, 2, 3, rowno, rowno + 1,      table[pageno]->attach(*widget, 2, 3, rowno, rowno + 1,
1298                            Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);                            Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
1299    #endif
1300    
1301        rowno++;
1302    }
1303    
1304    void DimRegionEdit::addString(const char* labelText, Gtk::Label*& label,
1305                                  Gtk::Entry*& widget, Gtk::Button*& button)
1306    {
1307        label = new Gtk::Label(Glib::ustring(labelText) + ":");
1308    #if HAS_GTKMM_ALIGNMENT
1309        label->set_alignment(Gtk::ALIGN_START);
1310    #else
1311        label->set_halign(Gtk::Align::START);
1312    #endif
1313    
1314    #if USE_GTKMM_GRID
1315        table[pageno]->attach(*label, 1, rowno);
1316    #else
1317        table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,
1318                              Gtk::FILL, Gtk::SHRINK);
1319    #endif
1320    
1321        widget = new Gtk::Entry();
1322        button = new Gtk::Button();
1323    
1324        HBox* hbox = new HBox;
1325        hbox->pack_start(*widget);
1326        hbox->pack_start(*button, Gtk::PACK_SHRINK);
1327    
1328    #if USE_GTKMM_GRID
1329        table[pageno]->attach(*hbox, 2, rowno);
1330    #else
1331        table[pageno]->attach(*hbox, 2, 3, rowno, rowno + 1,
1332                              Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
1333    #endif
1334    
1335      rowno++;      rowno++;
1336  }  }
1337    
1338  void DimRegionEdit::addHeader(const char* text)  Gtk::Label* DimRegionEdit::addHeader(const char* text)
1339  {  {
1340      if (firstRowInBlock < rowno - 1)      if (firstRowInBlock < rowno - 1)
1341      {      {
1342          Gtk::Label* filler = new Gtk::Label("    ");          Gtk::Label* filler = new Gtk::Label("    ");
1343    #if USE_GTKMM_GRID
1344            table[pageno]->attach(*filler, 0, firstRowInBlock);
1345    #else
1346          table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,          table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,
1347                                Gtk::FILL, Gtk::SHRINK);                                Gtk::FILL, Gtk::SHRINK);
1348    #endif
1349      }      }
1350      Glib::ustring str = "<b>";      Glib::ustring str = "<b>";
1351      str += text;      str += text;
1352      str += "</b>";      str += "</b>";
1353      Gtk::Label* label = new Gtk::Label(str);      Gtk::Label* label = new Gtk::Label(str);
1354      label->set_use_markup();      label->set_use_markup();
1355      label->set_alignment(Gtk::ALIGN_LEFT);  #if HAS_GTKMM_ALIGNMENT
1356        label->set_alignment(Gtk::ALIGN_START);
1357    #else
1358        label->set_halign(Gtk::Align::START);
1359    #endif
1360        // on GTKMM 3 there is absolutely no margin by default
1361    #if GTKMM_MAJOR_VERSION >= 3
1362        label->set_margin_top(18);
1363        label->set_margin_bottom(13);
1364    #endif
1365    #if USE_GTKMM_GRID
1366        table[pageno]->attach(*label, 0, rowno, 3);
1367    #else
1368      table[pageno]->attach(*label, 0, 3, rowno, rowno + 1,      table[pageno]->attach(*label, 0, 3, rowno, rowno + 1,
1369                            Gtk::FILL, Gtk::SHRINK);                            Gtk::FILL, Gtk::SHRINK);
1370    #endif
1371      rowno++;      rowno++;
1372      firstRowInBlock = rowno;      firstRowInBlock = rowno;
1373        return label;
1374    }
1375    
1376    void DimRegionEdit::on_show_tooltips_changed() {
1377        const bool b = Settings::singleton()->showTooltips;
1378    
1379        buttonSelectSample.set_has_tooltip(b);
1380        buttonNullSampleReference->set_has_tooltip(b);
1381        wSample->set_has_tooltip(b);
1382    
1383        eEG1StateOptions.on_show_tooltips_changed();
1384        eEG2StateOptions.on_show_tooltips_changed();
1385    
1386        set_has_tooltip(b);
1387  }  }
1388    
1389  void DimRegionEdit::nextPage()  void DimRegionEdit::nextPage()
# Line 486  void DimRegionEdit::nextPage() Line 1391  void DimRegionEdit::nextPage()
1391      if (firstRowInBlock < rowno - 1)      if (firstRowInBlock < rowno - 1)
1392      {      {
1393          Gtk::Label* filler = new Gtk::Label("    ");          Gtk::Label* filler = new Gtk::Label("    ");
1394    #if USE_GTKMM_GRID
1395            table[pageno]->attach(*filler, 0, firstRowInBlock);
1396    #else
1397          table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,          table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,
1398                                Gtk::FILL, Gtk::SHRINK);                                Gtk::FILL, Gtk::SHRINK);
1399    #endif
1400      }      }
1401      pageno++;      pageno++;
1402      rowno = 0;      rowno = 0;
# Line 496  void DimRegionEdit::nextPage() Line 1405  void DimRegionEdit::nextPage()
1405    
1406  void DimRegionEdit::addProp(BoolEntry& boolentry)  void DimRegionEdit::addProp(BoolEntry& boolentry)
1407  {  {
1408    #if USE_GTKMM_GRID
1409        table[pageno]->attach(boolentry.widget, 1, rowno, 2);
1410    #else
1411      table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1,      table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1,
1412                            Gtk::FILL, Gtk::SHRINK);                            Gtk::FILL, Gtk::SHRINK);
1413    #endif
1414      rowno++;      rowno++;
     boolentry.signal_changed_by_user().connect(dimreg_changed_signal.make_slot());  
1415  }  }
1416    
1417  void DimRegionEdit::addProp(LabelWidget& prop)  void DimRegionEdit::addProp(LabelWidget& prop)
1418  {  {
1419    #if USE_GTKMM_GRID
1420        table[pageno]->attach(prop.label, 1, rowno);
1421        table[pageno]->attach(prop.widget, 2, rowno);
1422    #else
1423      table[pageno]->attach(prop.label, 1, 2, rowno, rowno + 1,      table[pageno]->attach(prop.label, 1, 2, rowno, rowno + 1,
1424                            Gtk::FILL, Gtk::SHRINK);                            Gtk::FILL, Gtk::SHRINK);
1425      table[pageno]->attach(prop.widget, 2, 3, rowno, rowno + 1,      table[pageno]->attach(prop.widget, 2, 3, rowno, rowno + 1,
1426                            Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);                            Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
1427    #endif
1428      rowno++;      rowno++;
     prop.signal_changed_by_user().connect(dimreg_changed_signal.make_slot());  
1429  }  }
1430    
1431    void DimRegionEdit::addLine(HBox& line)
1432    {
1433    #if USE_GTKMM_GRID
1434        table[pageno]->attach(line, 1, rowno, 2);
1435    #else
1436        table[pageno]->attach(line, 1, 3, rowno, rowno + 1,
1437                              Gtk::FILL, Gtk::SHRINK);
1438    #endif
1439        rowno++;
1440    }
1441    
1442    void DimRegionEdit::addRightHandSide(Gtk::Widget& widget)
1443    {
1444    #if USE_GTKMM_GRID
1445        table[pageno]->attach(widget, 2, rowno);
1446    #else
1447        table[pageno]->attach(widget, 2, 3, rowno, rowno + 1,
1448                              Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
1449    #endif
1450        rowno++;
1451    }
1452    
1453  void DimRegionEdit::set_dim_region(gig::DimensionRegion* d)  void DimRegionEdit::set_dim_region(gig::DimensionRegion* d)
1454  {  {
1455      dimregion = d;      dimregion = d;
1456        velocity_curve.set_dim_region(d);
1457        release_curve.set_dim_region(d);
1458        cutoff_curve.set_dim_region(d);
1459        crossfade_curve.set_dim_region(d);
1460        lfo1Graph.set_dim_region(d);
1461        lfo2Graph.set_dim_region(d);
1462        lfo3Graph.set_dim_region(d);
1463    
1464      set_sensitive(d);      set_sensitive(d);
1465      if (!d) return;      if (!d) return;
1466    
1467      wSample->set_text(d->pSample ? d->pSample->pInfo->Name.c_str() : "NULL");      update_model++;
1468      eEG1PreAttack.set_ptr(&d->EG1PreAttack);      eEG1PreAttack.set_value(d->EG1PreAttack);
1469      eEG1Attack.set_ptr(&d->EG1Attack);      eEG1Attack.set_value(d->EG1Attack);
1470      eEG1Decay1.set_ptr(&d->EG1Decay1);      eEG1Decay1.set_value(d->EG1Decay1);
1471      eEG1Decay2.set_ptr(&d->EG1Decay2);      eEG1Decay2.set_value(d->EG1Decay2);
1472      eEG1InfiniteSustain.set_ptr(&d->EG1InfiniteSustain);      eEG1InfiniteSustain.set_value(d->EG1InfiniteSustain);
1473      eEG1Sustain.set_ptr(&d->EG1Sustain);      eEG1Sustain.set_value(d->EG1Sustain);
1474      eEG1Release.set_ptr(&d->EG1Release);      eEG1Release.set_value(d->EG1Release);
1475      eEG1Hold.set_ptr(&d->EG1Hold);      eEG1Hold.set_value(d->EG1Hold);
1476      eEG1Controller.set_ptr(&d->EG1Controller);      eEG1Controller.set_value(d->EG1Controller);
1477      eEG1ControllerInvert.set_ptr(&d->EG1ControllerInvert);      eEG1ControllerInvert.set_value(d->EG1ControllerInvert);
1478      eEG1ControllerAttackInfluence.set_ptr(&d->EG1ControllerAttackInfluence);      eEG1ControllerAttackInfluence.set_value(d->EG1ControllerAttackInfluence);
1479      eEG1ControllerDecayInfluence.set_ptr(&d->EG1ControllerDecayInfluence);      eEG1ControllerDecayInfluence.set_value(d->EG1ControllerDecayInfluence);
1480      eEG1ControllerReleaseInfluence.set_ptr(&d->EG1ControllerReleaseInfluence);      eEG1ControllerReleaseInfluence.set_value(d->EG1ControllerReleaseInfluence);
1481      eLFO1Frequency.set_ptr(&d->LFO1Frequency);      eEG1StateOptions.checkBoxAttack.set_value(d->EG1Options.AttackCancel);
1482      eLFO1InternalDepth.set_ptr(&d->LFO1InternalDepth);      eEG1StateOptions.checkBoxAttackHold.set_value(d->EG1Options.AttackHoldCancel);
1483      eLFO1ControlDepth.set_ptr(&d->LFO1ControlDepth);      eEG1StateOptions.checkBoxDecay1.set_value(d->EG1Options.Decay1Cancel);
1484      eLFO1Controller.set_ptr(&d->LFO1Controller);      eEG1StateOptions.checkBoxDecay2.set_value(d->EG1Options.Decay2Cancel);
1485      eLFO1FlipPhase.set_ptr(&d->LFO1FlipPhase);      eEG1StateOptions.checkBoxRelease.set_value(d->EG1Options.ReleaseCancel);
1486      eLFO1Sync.set_ptr(&d->LFO1Sync);      eLFO1Wave.set_value(d->LFO1WaveForm);
1487      eEG2PreAttack.set_ptr(&d->EG2PreAttack);      eLFO1Frequency.set_value(d->LFO1Frequency);
1488      eEG2Attack.set_ptr(&d->EG2Attack);      eLFO1Phase.set_value(d->LFO1Phase);
1489      eEG2Decay1.set_ptr(&d->EG2Decay1);      eLFO1InternalDepth.set_value(d->LFO1InternalDepth);
1490      eEG2Decay2.set_ptr(&d->EG2Decay2);      eLFO1ControlDepth.set_value(d->LFO1ControlDepth);
1491      eEG2InfiniteSustain.set_ptr(&d->EG2InfiniteSustain);      eLFO1Controller.set_value(d->LFO1Controller);
1492      eEG2Sustain.set_ptr(&d->EG2Sustain);      eLFO1FlipPhase.set_value(d->LFO1FlipPhase);
1493      eEG2Release.set_ptr(&d->EG2Release);      eLFO1Sync.set_value(d->LFO1Sync);
1494      eEG2Controller.set_ptr(&d->EG2Controller);      eEG2PreAttack.set_value(d->EG2PreAttack);
1495      eEG2ControllerInvert.set_ptr(&d->EG2ControllerInvert);      eEG2Attack.set_value(d->EG2Attack);
1496      eEG2ControllerAttackInfluence.set_ptr(&d->EG2ControllerAttackInfluence);      eEG2Decay1.set_value(d->EG2Decay1);
1497      eEG2ControllerDecayInfluence.set_ptr(&d->EG2ControllerDecayInfluence);      eEG2Decay2.set_value(d->EG2Decay2);
1498      eEG2ControllerReleaseInfluence.set_ptr(&d->EG2ControllerReleaseInfluence);      eEG2InfiniteSustain.set_value(d->EG2InfiniteSustain);
1499      eLFO2Frequency.set_ptr(&d->LFO2Frequency);      eEG2Sustain.set_value(d->EG2Sustain);
1500      eLFO2InternalDepth.set_ptr(&d->LFO2InternalDepth);      eEG2Release.set_value(d->EG2Release);
1501      eLFO2ControlDepth.set_ptr(&d->LFO2ControlDepth);      eEG2Controller.set_value(d->EG2Controller);
1502      eLFO2Controller.set_ptr(&d->LFO2Controller);      eEG2ControllerInvert.set_value(d->EG2ControllerInvert);
1503      eLFO2FlipPhase.set_ptr(&d->LFO2FlipPhase);      eEG2ControllerAttackInfluence.set_value(d->EG2ControllerAttackInfluence);
1504      eLFO2Sync.set_ptr(&d->LFO2Sync);      eEG2ControllerDecayInfluence.set_value(d->EG2ControllerDecayInfluence);
1505      eEG3Attack.set_ptr(&d->EG3Attack);      eEG2ControllerReleaseInfluence.set_value(d->EG2ControllerReleaseInfluence);
1506      eEG3Depth.set_ptr(&d->EG3Depth);      eEG2StateOptions.checkBoxAttack.set_value(d->EG2Options.AttackCancel);
1507      eLFO3Frequency.set_ptr(&d->LFO3Frequency);      eEG2StateOptions.checkBoxAttackHold.set_value(d->EG2Options.AttackHoldCancel);
1508      eLFO3InternalDepth.set_ptr(&d->LFO3InternalDepth);      eEG2StateOptions.checkBoxDecay1.set_value(d->EG2Options.Decay1Cancel);
1509      eLFO3ControlDepth.set_ptr(&d->LFO3ControlDepth);      eEG2StateOptions.checkBoxDecay2.set_value(d->EG2Options.Decay2Cancel);
1510      eLFO3Controller.set_ptr(&d->LFO3Controller);      eEG2StateOptions.checkBoxRelease.set_value(d->EG2Options.ReleaseCancel);
1511      eLFO3Sync.set_ptr(&d->LFO3Sync);      eLFO2Wave.set_value(d->LFO2WaveForm);
1512      eVCFEnabled.set_ptr(&d->VCFEnabled);      eLFO2Frequency.set_value(d->LFO2Frequency);
1513      eVCFType.set_ptr(&d->VCFType);      eLFO2Phase.set_value(d->LFO2Phase);
1514      eVCFCutoffController.set_ptr(&d->VCFCutoffController);      eLFO2InternalDepth.set_value(d->LFO2InternalDepth);
1515      eVCFCutoffControllerInvert.set_ptr(&d->VCFCutoffControllerInvert);      eLFO2ControlDepth.set_value(d->LFO2ControlDepth);
1516      eVCFCutoff.set_ptr(&d->VCFCutoff);      eLFO2Controller.set_value(d->LFO2Controller);
1517      eVCFVelocityCurve.set_ptr(&d->VCFVelocityCurve);      eLFO2FlipPhase.set_value(d->LFO2FlipPhase);
1518      eVCFVelocityScale.set_ptr(&d->VCFVelocityScale);      eLFO2Sync.set_value(d->LFO2Sync);
1519      eVCFVelocityDynamicRange.set_ptr(&d->VCFVelocityDynamicRange);      eEG3Attack.set_value(d->EG3Attack);
1520      eVCFResonance.set_ptr(&d->VCFResonance);      eEG3Depth.set_value(d->EG3Depth);
1521      eVCFResonanceDynamic.set_ptr(&d->VCFResonanceDynamic);      eLFO3Wave.set_value(d->LFO3WaveForm);
1522      eVCFResonanceController.set_ptr(&d->VCFResonanceController);      eLFO3Frequency.set_value(d->LFO3Frequency);
1523      eVCFKeyboardTracking.set_ptr(&d->VCFKeyboardTracking);      eLFO3Phase.set_value(d->LFO3Phase);
1524      eVCFKeyboardTrackingBreakpoint.set_ptr(&d->VCFKeyboardTrackingBreakpoint);      eLFO3InternalDepth.set_value(d->LFO3InternalDepth);
1525      eVelocityResponseCurve.set_ptr(&d->VelocityResponseCurve);      eLFO3ControlDepth.set_value(d->LFO3ControlDepth);
1526      eVelocityResponseDepth.set_ptr(&d->VelocityResponseDepth);      eLFO3Controller.set_value(d->LFO3Controller);
1527      eVelocityResponseCurveScaling.set_ptr(&d->VelocityResponseCurveScaling);      eLFO3FlipPhase.set_value(d->LFO3FlipPhase);
1528      eReleaseVelocityResponseCurve.set_ptr(&d->ReleaseVelocityResponseCurve);      eLFO3Sync.set_value(d->LFO3Sync);
1529      eReleaseVelocityResponseDepth.set_ptr(&d->ReleaseVelocityResponseDepth);      eVCFEnabled.set_value(d->VCFEnabled);
1530      eReleaseTriggerDecay.set_ptr(&d->ReleaseTriggerDecay);      eVCFType.set_value(d->VCFType);
1531        eVCFCutoffController.set_value(d->VCFCutoffController);
1532      eCrossfade_in_start.set_ptr(0);      eVCFCutoffControllerInvert.set_value(d->VCFCutoffControllerInvert);
1533      eCrossfade_in_end.set_ptr(0);      eVCFCutoff.set_value(d->VCFCutoff);
1534      eCrossfade_out_start.set_ptr(0);      eVCFVelocityCurve.set_value(d->VCFVelocityCurve);
1535      eCrossfade_out_end.set_ptr(0);      eVCFVelocityScale.set_value(d->VCFVelocityScale);
1536      eCrossfade_in_start.set_ptr(&d->Crossfade.in_start);      eVCFVelocityDynamicRange.set_value(d->VCFVelocityDynamicRange);
1537      eCrossfade_in_end.set_ptr(&d->Crossfade.in_end);      eVCFResonance.set_value(d->VCFResonance);
1538      eCrossfade_out_start.set_ptr(&d->Crossfade.out_start);      eVCFResonanceDynamic.set_value(d->VCFResonanceDynamic);
1539      eCrossfade_out_end.set_ptr(&d->Crossfade.out_end);      eVCFResonanceController.set_value(d->VCFResonanceController);
1540        eVCFKeyboardTracking.set_value(d->VCFKeyboardTracking);
1541      ePitchTrack.set_ptr(&d->PitchTrack);      eVCFKeyboardTrackingBreakpoint.set_value(d->VCFKeyboardTrackingBreakpoint);
1542      eDimensionBypass.set_ptr(&d->DimensionBypass);      eVelocityResponseCurve.set_value(d->VelocityResponseCurve);
1543      ePan.set_ptr(&d->Pan);      eVelocityResponseDepth.set_value(d->VelocityResponseDepth);
1544      eSelfMask.set_ptr(&d->SelfMask);      eVelocityResponseCurveScaling.set_value(d->VelocityResponseCurveScaling);
1545      eAttenuationController.set_ptr(&d->AttenuationController);      eReleaseVelocityResponseCurve.set_value(d->ReleaseVelocityResponseCurve);
1546      eInvertAttenuationController.set_ptr(&d->InvertAttenuationController);      eReleaseVelocityResponseDepth.set_value(d->ReleaseVelocityResponseDepth);
1547      eAttenuationControllerThreshold.set_ptr(&d->AttenuationControllerThreshold);      eReleaseTriggerDecay.set_value(d->ReleaseTriggerDecay);
1548      eChannelOffset.set_ptr(&d->ChannelOffset);      eCrossfade_in_start.set_value(d->Crossfade.in_start);
1549      eSustainDefeat.set_ptr(&d->SustainDefeat);      eCrossfade_in_end.set_value(d->Crossfade.in_end);
1550      eMSDecode.set_ptr(&d->MSDecode);      eCrossfade_out_start.set_value(d->Crossfade.out_start);
1551      eSampleStartOffset.set_ptr(&d->SampleStartOffset);      eCrossfade_out_end.set_value(d->Crossfade.out_end);
1552      eUnityNote.set_ptr(&d->UnityNote);      ePitchTrack.set_value(d->PitchTrack);
1553      eFineTune.set_ptr(&d->FineTune);      eSustainReleaseTrigger.set_value(d->SustainReleaseTrigger);
1554      eGain.set_ptr(&d->Gain);      eNoNoteOffReleaseTrigger.set_value(d->NoNoteOffReleaseTrigger);
1555      eGainPlus6.set_ptr(&d->Gain);      eDimensionBypass.set_value(d->DimensionBypass);
1556        ePan.set_value(d->Pan);
1557        eSelfMask.set_value(d->SelfMask);
1558        eAttenuationController.set_value(d->AttenuationController);
1559        eInvertAttenuationController.set_value(d->InvertAttenuationController);
1560        eAttenuationControllerThreshold.set_value(d->AttenuationControllerThreshold);
1561        eChannelOffset.set_value(d->ChannelOffset);
1562        eSustainDefeat.set_value(d->SustainDefeat);
1563        eMSDecode.set_value(d->MSDecode);
1564        eSampleStartOffset.set_value(d->SampleStartOffset);
1565        eUnityNote.set_value(d->UnityNote);
1566        // show sample group name
1567        {
1568            Glib::ustring s = "---";
1569            if (d->pSample && d->pSample->GetGroup())
1570                s = d->pSample->GetGroup()->Name;
1571            eSampleGroup.text.set_text(s);
1572        }
1573        // assemble sample format info string
1574        {
1575            Glib::ustring s;
1576            if (d->pSample) {
1577                switch (d->pSample->Channels) {
1578                    case 1: s = _("Mono"); break;
1579                    case 2: s = _("Stereo"); break;
1580                    default:
1581                        s = ToString(d->pSample->Channels) + _(" audio channels");
1582                        break;
1583                }
1584                s += " " + ToString(d->pSample->BitDepth) + " Bits";
1585                s += " " + ToString(d->pSample->SamplesPerSecond/1000) + "."
1586                          + ToString((d->pSample->SamplesPerSecond%1000)/100) + " kHz";
1587            } else {
1588                s = _("No sample assigned to this dimension region.");
1589            }
1590            eSampleFormatInfo.text.set_text(s);
1591        }
1592        // generate sample's memory address pointer string
1593        {
1594            Glib::ustring s;
1595            if (d->pSample) {
1596                char buf[64] = {};
1597                snprintf(buf, sizeof(buf), "%p", d->pSample);
1598                s = buf;
1599            } else {
1600                s = "---";
1601            }
1602            eSampleID.text.set_text(s);
1603        }
1604        // generate raw wave form data CRC-32 checksum string
1605        {
1606            Glib::ustring s = "---";
1607            if (d->pSample) {
1608                char buf[64] = {};
1609                snprintf(buf, sizeof(buf), "%x", d->pSample->GetWaveDataCRC32Checksum());
1610                s = buf;
1611            }
1612            eChecksum.text.set_text(s);
1613        }
1614        buttonSelectSample.set_sensitive(d && d->pSample);
1615        eFineTune.set_value(d->FineTune);
1616        eGain.set_value(d->Gain);
1617        eSampleLoopEnabled.set_value(d->SampleLoops);
1618        eSampleLoopType.set_value(
1619            d->SampleLoops ? d->pSampleLoops[0].LoopType : 0);
1620        eSampleLoopStart.set_value(
1621            d->SampleLoops ? d->pSampleLoops[0].LoopStart : 0);
1622        eSampleLoopLength.set_value(
1623            d->SampleLoops ? d->pSampleLoops[0].LoopLength : 0);
1624        eSampleLoopInfinite.set_value(
1625            d->pSample && d->pSample->LoopPlayCount == 0);
1626        eSampleLoopPlayCount.set_value(
1627            d->pSample ? d->pSample->LoopPlayCount : 0);
1628        update_model--;
1629    
1630      eSampleLoopEnabled.set_active(d->SampleLoops);      wSample->set_text(d->pSample ? gig_to_utf8(d->pSample->pInfo->Name) :
1631      updateLoopElements();                        _("NULL"));
1632    
1633        update_loop_elements();
1634      VCFEnabled_toggled();      VCFEnabled_toggled();
1635  }  }
1636    
1637    
1638  void DimRegionEdit::VCFEnabled_toggled()  void DimRegionEdit::VCFEnabled_toggled()
1639  {  {
1640      bool sensitive = eVCFEnabled.get_active();      bool sensitive = eVCFEnabled.get_value();
1641      eVCFType.set_sensitive(sensitive);      eVCFType.set_sensitive(sensitive);
1642      eVCFCutoffController.set_sensitive(sensitive);      eVCFCutoffController.set_sensitive(sensitive);
1643      eVCFVelocityCurve.set_sensitive(sensitive);      eVCFVelocityCurve.set_sensitive(sensitive);
1644      eVCFVelocityScale.set_sensitive(sensitive);      eVCFVelocityScale.set_sensitive(sensitive);
1645      eVCFVelocityDynamicRange.set_sensitive(sensitive);      eVCFVelocityDynamicRange.set_sensitive(sensitive);
1646        cutoff_curve.set_sensitive(sensitive);
1647      eVCFResonance.set_sensitive(sensitive);      eVCFResonance.set_sensitive(sensitive);
1648      eVCFResonanceController.set_sensitive(sensitive);      eVCFResonanceController.set_sensitive(sensitive);
1649      eVCFKeyboardTracking.set_sensitive(sensitive);      eVCFKeyboardTracking.set_sensitive(sensitive);
1650      eVCFKeyboardTrackingBreakpoint.set_sensitive(sensitive);      eVCFKeyboardTrackingBreakpoint.set_sensitive(sensitive);
1651        lEG2->set_sensitive(sensitive);
1652      eEG2PreAttack.set_sensitive(sensitive);      eEG2PreAttack.set_sensitive(sensitive);
1653      eEG2Attack.set_sensitive(sensitive);      eEG2Attack.set_sensitive(sensitive);
1654      eEG2Decay1.set_sensitive(sensitive);      eEG2Decay1.set_sensitive(sensitive);
# Line 638  void DimRegionEdit::VCFEnabled_toggled() Line 1659  void DimRegionEdit::VCFEnabled_toggled()
1659      eEG2ControllerAttackInfluence.set_sensitive(sensitive);      eEG2ControllerAttackInfluence.set_sensitive(sensitive);
1660      eEG2ControllerDecayInfluence.set_sensitive(sensitive);      eEG2ControllerDecayInfluence.set_sensitive(sensitive);
1661      eEG2ControllerReleaseInfluence.set_sensitive(sensitive);      eEG2ControllerReleaseInfluence.set_sensitive(sensitive);
1662        eEG2StateOptions.set_sensitive(sensitive);
1663        lLFO2->set_sensitive(sensitive);
1664        eLFO2Wave.set_sensitive(sensitive);
1665      eLFO2Frequency.set_sensitive(sensitive);      eLFO2Frequency.set_sensitive(sensitive);
1666        eLFO2Phase.set_sensitive(sensitive);
1667      eLFO2InternalDepth.set_sensitive(sensitive);      eLFO2InternalDepth.set_sensitive(sensitive);
1668      eLFO2ControlDepth.set_sensitive(sensitive);      eLFO2ControlDepth.set_sensitive(sensitive);
1669      eLFO2Controller.set_sensitive(sensitive);      eLFO2Controller.set_sensitive(sensitive);
1670      eLFO2FlipPhase.set_sensitive(sensitive);      eLFO2FlipPhase.set_sensitive(sensitive);
1671      eLFO2Sync.set_sensitive(sensitive);      eLFO2Sync.set_sensitive(sensitive);
1672        lfo2Graph.set_sensitive(sensitive);
1673      if (sensitive) {      if (sensitive) {
1674          VCFCutoffController_changed();          VCFCutoffController_changed();
1675          VCFResonanceController_changed();          VCFResonanceController_changed();
# Line 664  void DimRegionEdit::VCFEnabled_toggled() Line 1690  void DimRegionEdit::VCFEnabled_toggled()
1690    
1691  void DimRegionEdit::VCFCutoffController_changed()  void DimRegionEdit::VCFCutoffController_changed()
1692  {  {
1693      int rowno = eVCFCutoffController.get_active_row_number();      gig::vcf_cutoff_ctrl_t ctrl = eVCFCutoffController.get_value();
1694      bool hasController = rowno != 0 && rowno != 1;      bool hasController = ctrl != gig::vcf_cutoff_ctrl_none && ctrl != gig::vcf_cutoff_ctrl_none2;
1695    
1696      eVCFCutoffControllerInvert.set_sensitive(hasController);      eVCFCutoffControllerInvert.set_sensitive(hasController);
1697      eVCFCutoff.set_sensitive(!hasController);      eVCFCutoff.set_sensitive(!hasController);
1698      eVCFResonanceDynamic.set_sensitive(!hasController);      eVCFResonanceDynamic.set_sensitive(!hasController);
1699      eVCFVelocityScale.label.set_text(hasController ? "Minimum cutoff:" :      eVCFVelocityScale.label.set_text(hasController ? _("Minimum cutoff:") :
1700                                       "Velocity scale:");                                       _("Velocity scale:"));
1701  }  }
1702    
1703  void DimRegionEdit::VCFResonanceController_changed()  void DimRegionEdit::VCFResonanceController_changed()
1704  {  {
1705      bool hasController = eVCFResonanceController.get_active_row_number() != 0;      bool hasController = eVCFResonanceController.get_value() != gig::vcf_res_ctrl_none;
1706      eVCFResonance.set_sensitive(!hasController);      eVCFResonance.set_sensitive(!hasController);
1707  }  }
1708    
1709  void DimRegionEdit::EG1InfiniteSustain_toggled()  void DimRegionEdit::EG1InfiniteSustain_toggled()
1710  {  {
1711      bool infSus = eEG1InfiniteSustain.get_active();      bool infSus = eEG1InfiniteSustain.get_value();
1712      eEG1Decay2.set_sensitive(!infSus);      eEG1Decay2.set_sensitive(!infSus);
1713  }  }
1714    
1715  void DimRegionEdit::EG2InfiniteSustain_toggled()  void DimRegionEdit::EG2InfiniteSustain_toggled()
1716  {  {
1717      bool infSus = eEG2InfiniteSustain.get_active();      bool infSus = eEG2InfiniteSustain.get_value();
1718      eEG2Decay2.set_sensitive(!infSus);      eEG2Decay2.set_sensitive(!infSus);
1719  }  }
1720    
1721  void DimRegionEdit::EG1Controller_changed()  void DimRegionEdit::EG1Controller_changed()
1722  {  {
1723      bool hasController = eEG1Controller.get_active_row_number() != 0;      bool hasController = eEG1Controller.get_value().type != gig::leverage_ctrl_t::type_none;
1724      eEG1ControllerInvert.set_sensitive(hasController);      eEG1ControllerInvert.set_sensitive(hasController);
1725  }  }
1726    
1727  void DimRegionEdit::EG2Controller_changed()  void DimRegionEdit::EG2Controller_changed()
1728  {  {
1729      bool hasController = eEG2Controller.get_active_row_number() != 0;      bool hasController = eEG2Controller.get_value().type != gig::leverage_ctrl_t::type_none;
1730      eEG2ControllerInvert.set_sensitive(hasController);      eEG2ControllerInvert.set_sensitive(hasController);
1731  }  }
1732    
1733  void DimRegionEdit::AttenuationController_changed()  void DimRegionEdit::AttenuationController_changed()
1734  {  {
1735      bool hasController = eAttenuationController.get_active_row_number() != 0;      bool hasController =
1736            eAttenuationController.get_value().type != gig::leverage_ctrl_t::type_none;
1737      eInvertAttenuationController.set_sensitive(hasController);      eInvertAttenuationController.set_sensitive(hasController);
1738      eAttenuationControllerThreshold.set_sensitive(hasController);      eAttenuationControllerThreshold.set_sensitive(hasController);
1739      eCrossfade_in_start.set_sensitive(hasController);      eCrossfade_in_start.set_sensitive(hasController);
1740      eCrossfade_in_end.set_sensitive(hasController);      eCrossfade_in_end.set_sensitive(hasController);
1741      eCrossfade_out_start.set_sensitive(hasController);      eCrossfade_out_start.set_sensitive(hasController);
1742      eCrossfade_out_end.set_sensitive(hasController);      eCrossfade_out_end.set_sensitive(hasController);
1743        crossfade_curve.set_sensitive(hasController);
1744  }  }
1745    
1746  void DimRegionEdit::LFO1Controller_changed()  void DimRegionEdit::LFO1Controller_changed()
1747  {  {
1748      int rowno = eLFO1Controller.get_active_row_number();      gig::lfo1_ctrl_t ctrl = eLFO1Controller.get_value();
1749      eLFO1ControlDepth.set_sensitive(rowno != 0);      eLFO1ControlDepth.set_sensitive(ctrl != gig::lfo1_ctrl_internal);
1750      eLFO1InternalDepth.set_sensitive(rowno != 1 && rowno != 2);      eLFO1InternalDepth.set_sensitive(ctrl != gig::lfo1_ctrl_modwheel &&
1751                                         ctrl != gig::lfo1_ctrl_breath);
1752  }  }
1753    
1754  void DimRegionEdit::LFO2Controller_changed()  void DimRegionEdit::LFO2Controller_changed()
1755  {  {
1756      int rowno = eLFO2Controller.get_active_row_number();      gig::lfo2_ctrl_t ctrl = eLFO2Controller.get_value();
1757      eLFO2ControlDepth.set_sensitive(rowno != 0);      eLFO2ControlDepth.set_sensitive(ctrl != gig::lfo2_ctrl_internal);
1758      eLFO2InternalDepth.set_sensitive(rowno != 1 && rowno != 2);      eLFO2InternalDepth.set_sensitive(ctrl != gig::lfo2_ctrl_modwheel &&
1759                                         ctrl != gig::lfo2_ctrl_foot);
1760  }  }
1761    
1762  void DimRegionEdit::LFO3Controller_changed()  void DimRegionEdit::LFO3Controller_changed()
1763  {  {
1764      int rowno = eLFO3Controller.get_active_row_number();      gig::lfo3_ctrl_t ctrl = eLFO3Controller.get_value();
1765      eLFO3ControlDepth.set_sensitive(rowno != 0);      eLFO3ControlDepth.set_sensitive(ctrl != gig::lfo3_ctrl_internal);
1766      eLFO3InternalDepth.set_sensitive(rowno != 1 && rowno != 2);      eLFO3InternalDepth.set_sensitive(ctrl != gig::lfo3_ctrl_modwheel &&
1767                                         ctrl != gig::lfo3_ctrl_aftertouch);
1768  }  }
1769    
1770  void DimRegionEdit::crossfade1_changed()  void DimRegionEdit::crossfade1_changed()
1771  {  {
1772      double c1 = eCrossfade_in_start.get_value();      update_model++;
1773      double c2 = eCrossfade_in_end.get_value();      eCrossfade_in_end.set_value(dimregion->Crossfade.in_end);
1774      if (c1 > c2) eCrossfade_in_end.set_value(c1);      eCrossfade_out_start.set_value(dimregion->Crossfade.out_start);
1775        eCrossfade_out_end.set_value(dimregion->Crossfade.out_end);
1776        update_model--;
1777  }  }
1778    
1779  void DimRegionEdit::crossfade2_changed()  void DimRegionEdit::crossfade2_changed()
1780  {  {
1781      double c1 = eCrossfade_in_start.get_value();      update_model++;
1782      double c2 = eCrossfade_in_end.get_value();      eCrossfade_in_start.set_value(dimregion->Crossfade.in_start);
1783      double c3 = eCrossfade_out_start.get_value();      eCrossfade_out_start.set_value(dimregion->Crossfade.out_start);
1784        eCrossfade_out_end.set_value(dimregion->Crossfade.out_end);
1785      if (c2 < c1) eCrossfade_in_start.set_value(c2);      update_model--;
     if (c2 > c3) eCrossfade_out_start.set_value(c2);  
1786  }  }
1787    
1788  void DimRegionEdit::crossfade3_changed()  void DimRegionEdit::crossfade3_changed()
1789  {  {
1790      double c2 = eCrossfade_in_end.get_value();      update_model++;
1791      double c3 = eCrossfade_out_start.get_value();      eCrossfade_in_start.set_value(dimregion->Crossfade.in_start);
1792      double c4 = eCrossfade_out_end.get_value();      eCrossfade_in_end.set_value(dimregion->Crossfade.in_end);
1793        eCrossfade_out_end.set_value(dimregion->Crossfade.out_end);
1794      if (c3 < c2) eCrossfade_in_end.set_value(c3);      update_model--;
     if (c3 > c4) eCrossfade_out_end.set_value(c3);  
1795  }  }
1796    
1797  void DimRegionEdit::crossfade4_changed()  void DimRegionEdit::crossfade4_changed()
1798  {  {
1799      double c3 = eCrossfade_out_start.get_value();      update_model++;
1800      double c4 = eCrossfade_out_end.get_value();      eCrossfade_in_start.set_value(dimregion->Crossfade.in_start);
1801        eCrossfade_in_end.set_value(dimregion->Crossfade.in_end);
1802        eCrossfade_out_start.set_value(dimregion->Crossfade.out_start);
1803        update_model--;
1804    }
1805    
1806    void DimRegionEdit::update_loop_elements()
1807    {
1808        update_model++;
1809        const bool active = eSampleLoopEnabled.get_value();
1810        eSampleLoopStart.set_sensitive(active);
1811        eSampleLoopLength.set_sensitive(active);
1812        eSampleLoopType.set_sensitive(active);
1813        eSampleLoopInfinite.set_sensitive(active && dimregion && dimregion->pSample);
1814        // sample loop shall never be longer than the actual sample size
1815        loop_start_changed();
1816        loop_length_changed();
1817        eSampleLoopStart.set_value(
1818            dimregion->SampleLoops ? dimregion->pSampleLoops[0].LoopStart : 0);
1819        eSampleLoopLength.set_value(
1820            dimregion->SampleLoops ? dimregion->pSampleLoops[0].LoopLength : 0);
1821    
1822        eSampleLoopInfinite.set_value(
1823            dimregion->pSample && dimregion->pSample->LoopPlayCount == 0);
1824    
1825        loop_infinite_toggled();
1826        update_model--;
1827    }
1828    
1829    void DimRegionEdit::loop_start_changed() {
1830        if (dimregion && dimregion->SampleLoops) {
1831            eSampleLoopLength.set_upper(dimregion->pSample ?
1832                                        dimregion->pSample->SamplesTotal -
1833                                        dimregion->pSampleLoops[0].LoopStart : 0);
1834        }
1835    }
1836    
1837    void DimRegionEdit::loop_length_changed() {
1838        if (dimregion && dimregion->SampleLoops) {
1839            eSampleLoopStart.set_upper(dimregion->pSample ?
1840                                       dimregion->pSample->SamplesTotal -
1841                                       dimregion->pSampleLoops[0].LoopLength : 0);
1842        }
1843    }
1844    
1845    void DimRegionEdit::loop_infinite_toggled() {
1846        eSampleLoopPlayCount.set_sensitive(
1847            dimregion && dimregion->pSample &&
1848            !eSampleLoopInfinite.get_value() &&
1849            eSampleLoopEnabled.get_value()
1850        );
1851        update_model++;
1852        eSampleLoopPlayCount.set_value(
1853            dimregion->pSample ? dimregion->pSample->LoopPlayCount : 0);
1854        update_model--;
1855    }
1856    
1857    bool DimRegionEdit::set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop)
1858    {
1859        bool result = false;
1860        for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimregs.begin();
1861             itDimReg != dimregs.end(); ++itDimReg)
1862        {
1863            result |= set_sample(*itDimReg, sample, copy_sample_unity, copy_sample_tune, copy_sample_loop);
1864        }
1865        return result;
1866    }
1867    
1868    bool DimRegionEdit::set_sample(gig::DimensionRegion* dimreg, gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop)
1869    {
1870        if (dimreg) {
1871            //TODO: we should better move the code from MainWindow::on_sample_label_drop_drag_data_received() here
1872    
1873            // currently commented because we're sending a similar signal in MainWindow::on_sample_label_drop_drag_data_received()
1874            //DimRegionChangeGuard(this, dimregion);
1875    
1876            // make sure stereo samples always are the same in both
1877            // dimregs in the samplechannel dimension
1878            int nbDimregs = 1;
1879            gig::DimensionRegion* d[2] = { dimreg, 0 };
1880            if (sample->Channels == 2) {
1881                gig::Region* region = dimreg->GetParent();
1882    
1883                int bitcount = 0;
1884                int stereo_bit = 0;
1885                for (int dim = 0 ; dim < region->Dimensions ; dim++) {
1886                    if (region->pDimensionDefinitions[dim].dimension == gig::dimension_samplechannel) {
1887                        stereo_bit = 1 << bitcount;
1888                        break;
1889                    }
1890                    bitcount += region->pDimensionDefinitions[dim].bits;
1891                }
1892    
1893                if (stereo_bit) {
1894                    int dimregno;
1895                    for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
1896                        if (region->pDimensionRegions[dimregno] == dimreg) {
1897                            break;
1898                        }
1899                    }
1900                    d[0] = region->pDimensionRegions[dimregno & ~stereo_bit];
1901                    d[1] = region->pDimensionRegions[dimregno | stereo_bit];
1902                    nbDimregs = 2;
1903                }
1904            }
1905    
1906            gig::Sample* oldref = dimreg->pSample;
1907    
1908            for (int i = 0 ; i < nbDimregs ; i++) {
1909                d[i]->pSample = sample;
1910    
1911                // copy sample information from Sample to DimensionRegion
1912                if (copy_sample_unity)
1913                    d[i]->UnityNote = sample->MIDIUnityNote;
1914                if (copy_sample_tune)
1915                    d[i]->FineTune = sample->FineTune;
1916                if (copy_sample_loop) {
1917                    int loops = sample->Loops ? 1 : 0;
1918                    while (d[i]->SampleLoops > loops) {
1919                        d[i]->DeleteSampleLoop(&d[i]->pSampleLoops[0]);
1920                    }
1921                    while (d[i]->SampleLoops < sample->Loops) {
1922                        DLS::sample_loop_t loop;
1923                        d[i]->AddSampleLoop(&loop);
1924                    }
1925                    if (loops) {
1926                        d[i]->pSampleLoops[0].Size = sizeof(DLS::sample_loop_t);
1927                        d[i]->pSampleLoops[0].LoopType = sample->LoopType;
1928                        d[i]->pSampleLoops[0].LoopStart = sample->LoopStart;
1929                        d[i]->pSampleLoops[0].LoopLength = sample->LoopEnd - sample->LoopStart + 1;
1930                    }
1931                }
1932            }
1933    
1934            // update ui
1935            update_model++;
1936            wSample->set_text(gig_to_utf8(dimreg->pSample->pInfo->Name));
1937            eUnityNote.set_value(dimreg->UnityNote);
1938            eFineTune.set_value(dimreg->FineTune);
1939            eSampleLoopEnabled.set_value(dimreg->SampleLoops);
1940            update_loop_elements();
1941            update_model--;
1942    
1943            sample_ref_changed_signal.emit(oldref, sample);
1944            return true;
1945        }
1946        return false;
1947    }
1948    
1949    sigc::signal<void, gig::DimensionRegion*>& DimRegionEdit::signal_dimreg_to_be_changed() {
1950        return dimreg_to_be_changed_signal;
1951    }
1952    
1953    sigc::signal<void, gig::DimensionRegion*>& DimRegionEdit::signal_dimreg_changed() {
1954        return dimreg_changed_signal;
1955    }
1956    
1957    sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& DimRegionEdit::signal_sample_ref_changed() {
1958        return sample_ref_changed_signal;
1959    }
1960    
1961    
1962    void DimRegionEdit::set_UnityNote(gig::DimensionRegion& d, uint8_t value)
1963    {
1964        d.UnityNote = value;
1965    }
1966    
1967      if (c4 < c3) eCrossfade_out_start.set_value(c4);  void DimRegionEdit::set_FineTune(gig::DimensionRegion& d, int16_t value)
1968    {
1969        d.FineTune = value;
1970  }  }
1971    
1972  void DimRegionEdit::loop_enabled_toggled()  void DimRegionEdit::set_Crossfade_in_start(gig::DimensionRegion& d,
1973                                               uint8_t value)
1974  {  {
1975      const bool active = eSampleLoopEnabled.get_active();      d.Crossfade.in_start = value;
1976      if (active) {      if (d.Crossfade.in_end < value) set_Crossfade_in_end(d, value);
1977    }
1978    
1979    void DimRegionEdit::set_Crossfade_in_end(gig::DimensionRegion& d,
1980                                             uint8_t value)
1981    {
1982        d.Crossfade.in_end = value;
1983        if (value < d.Crossfade.in_start) set_Crossfade_in_start(d, value);
1984        if (value > d.Crossfade.out_start) set_Crossfade_out_start(d, value);
1985    }
1986    
1987    void DimRegionEdit::set_Crossfade_out_start(gig::DimensionRegion& d,
1988                                                uint8_t value)
1989    {
1990        d.Crossfade.out_start = value;
1991        if (value < d.Crossfade.in_end) set_Crossfade_in_end(d, value);
1992        if (value > d.Crossfade.out_end) set_Crossfade_out_end(d, value);
1993    }
1994    
1995    void DimRegionEdit::set_Crossfade_out_end(gig::DimensionRegion& d,
1996                                              uint8_t value)
1997    {
1998        d.Crossfade.out_end = value;
1999        if (value < d.Crossfade.out_start) set_Crossfade_out_start(d, value);
2000    }
2001    
2002    void DimRegionEdit::set_Gain(gig::DimensionRegion& d, int32_t value)
2003    {
2004        d.SetGain(value);
2005    }
2006    
2007    void DimRegionEdit::set_LoopEnabled(gig::DimensionRegion& d, bool value)
2008    {
2009        if (value) {
2010          // create a new sample loop in case there is none yet          // create a new sample loop in case there is none yet
2011          if (!dimregion->SampleLoops) {          if (!d.SampleLoops) {
2012                DimRegionChangeGuard(this, &d);
2013    
2014              DLS::sample_loop_t loop;              DLS::sample_loop_t loop;
2015              loop.LoopType   = gig::loop_type_normal;              loop.LoopType = gig::loop_type_normal;
2016              // loop the whole sample by default              // loop the whole sample by default
2017              loop.LoopStart  = 0;              loop.LoopStart  = 0;
2018              loop.LoopLength =              loop.LoopLength =
2019                  (dimregion->pSample) ? dimregion->pSample->GetSize() : 0;                  (d.pSample) ? d.pSample->SamplesTotal : 0;
2020              dimregion->AddSampleLoop(&loop);              d.AddSampleLoop(&loop);
             dimreg_changed_signal();  
2021          }          }
2022      } else {      } else {
2023          if (dimregion->SampleLoops) {          if (d.SampleLoops) {
2024                DimRegionChangeGuard(this, &d);
2025    
2026              // delete ALL existing sample loops              // delete ALL existing sample loops
2027              while (dimregion->SampleLoops) {              while (d.SampleLoops) {
2028                  dimregion->DeleteSampleLoop(&dimregion->pSampleLoops[0]);                  d.DeleteSampleLoop(&d.pSampleLoops[0]);
2029              }              }
             dimreg_changed_signal();  
2030          }          }
2031      }      }
     updateLoopElements();  
2032  }  }
2033    
2034  void DimRegionEdit::updateLoopElements()  void DimRegionEdit::set_LoopType(gig::DimensionRegion& d, uint32_t value)
2035  {  {
2036      const bool active = eSampleLoopEnabled.get_active();      if (d.SampleLoops) d.pSampleLoops[0].LoopType = value;
2037      eSampleLoopStart.set_sensitive(active);  }
     eSampleLoopLength.set_sensitive(active);  
     eSampleLoopType.set_sensitive(active);  
     eSampleLoopInfinite.set_sensitive(active);  
     eSampleLoopStart.set_ptr(0);  
     eSampleLoopLength.set_ptr(0);  
     eSampleLoopPlayCount.set_ptr(0);  
2038    
2039      if (dimregion && dimregion->SampleLoops) {  void DimRegionEdit::set_LoopStart(gig::DimensionRegion& d, uint32_t value)
2040          eSampleLoopStart.set_ptr(&dimregion->pSampleLoops[0].LoopStart);  {
2041          eSampleLoopLength.set_ptr(&dimregion->pSampleLoops[0].LoopLength);      if (d.SampleLoops) {
2042          eSampleLoopType.set_ptr(&dimregion->pSampleLoops[0].LoopType);          d.pSampleLoops[0].LoopStart =
2043          eSampleLoopInfinite.set_active(              d.pSample ?
2044              dimregion->pSample && !dimregion->pSample->LoopPlayCount              std::min(value, uint32_t(d.pSample->SamplesTotal -
2045          );                                       d.pSampleLoops[0].LoopLength)) :
2046          // updated enabled state of loop play count widget              0;
         loop_infinite_toggled();  
   
         eSampleLoopPlayCount.set_ptr(  
             (dimregion->pSample) ? &dimregion->pSample->LoopPlayCount : 0  
         );  
   
         // sample loop shall never be longer than the actual sample size  
         eSampleLoopStart.set_upper(  
             (dimregion->pSample)  
                 ? dimregion->pSample->GetSize() -  
                   dimregion->pSampleLoops[0].LoopLength  
                 : 0  
         );  
         eSampleLoopLength.set_upper(  
             (dimregion->pSample)  
                 ? dimregion->pSample->GetSize() -  
                   dimregion->pSampleLoops[0].LoopStart  
                 : 0  
         );  
     } else { // no sample loop(s)  
         eSampleLoopType.set_ptr(0);  
         // updated enabled state of loop play count widget  
         loop_infinite_toggled();  
2047      }      }
2048  }  }
2049    
2050  void DimRegionEdit::loop_infinite_toggled() {  void DimRegionEdit::set_LoopLength(gig::DimensionRegion& d, uint32_t value)
2051      eSampleLoopPlayCount.set_sensitive(  {
2052          !eSampleLoopInfinite.get_active() &&      if (d.SampleLoops) {
2053           eSampleLoopEnabled.get_active()          d.pSampleLoops[0].LoopLength =
2054      );              d.pSample ?
2055      if (eSampleLoopInfinite.get_active())              std::min(value, uint32_t(d.pSample->SamplesTotal -
2056          eSampleLoopPlayCount.set_value(0);                                       d.pSampleLoops[0].LoopStart)) :
2057      else if (!eSampleLoopPlayCount.get_value())              0;
2058          eSampleLoopPlayCount.set_value(1);      }
2059    }
2060    
2061    void DimRegionEdit::set_LoopInfinite(gig::DimensionRegion& d, bool value)
2062    {
2063        if (d.pSample) {
2064            if (value) d.pSample->LoopPlayCount = 0;
2065            else if (d.pSample->LoopPlayCount == 0) d.pSample->LoopPlayCount = 1;
2066        }
2067    }
2068    
2069    void DimRegionEdit::set_LoopPlayCount(gig::DimensionRegion& d, uint32_t value)
2070    {
2071        if (d.pSample) d.pSample->LoopPlayCount = value;
2072    }
2073    
2074    void DimRegionEdit::nullOutSampleReference() {
2075        if (!dimregion) return;
2076        gig::Sample* oldref = dimregion->pSample;
2077        if (!oldref) return;
2078    
2079        DimRegionChangeGuard(this, dimregion);
2080    
2081        // in case currently assigned sample is a stereo one, then remove both
2082        // references (expected to be due to a "stereo dimension")
2083        gig::DimensionRegion* d[2] = { dimregion, NULL };
2084        if (oldref->Channels == 2) {
2085            gig::Region* region = dimregion->GetParent();
2086            {
2087                int stereo_bit = 0;
2088                int bitcount = 0;
2089                for (int dim = 0 ; dim < region->Dimensions ; dim++) {
2090                    if (region->pDimensionDefinitions[dim].dimension == gig::dimension_samplechannel) {
2091                        stereo_bit = 1 << bitcount;
2092                        break;
2093                    }
2094                    bitcount += region->pDimensionDefinitions[dim].bits;
2095                }
2096    
2097                if (stereo_bit) {
2098                    int dimregno;
2099                    for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
2100                        if (region->pDimensionRegions[dimregno] == dimregion) {
2101                            break;
2102                        }
2103                    }
2104                    d[0] = region->pDimensionRegions[dimregno & ~stereo_bit];
2105                    d[1] = region->pDimensionRegions[dimregno | stereo_bit];
2106                }
2107            }
2108        }
2109    
2110        if (d[0]) d[0]->pSample = NULL;
2111        if (d[1]) d[1]->pSample = NULL;
2112    
2113        // update UI elements
2114        set_dim_region(dimregion);
2115    
2116        sample_ref_changed_signal.emit(oldref, NULL);
2117    }
2118    
2119    void DimRegionEdit::onButtonSelectSamplePressed() {
2120        if (!dimregion) return;
2121        if (!dimregion->pSample) return;
2122        select_sample_signal.emit(dimregion->pSample);
2123    }
2124    
2125    sigc::signal<void, gig::Sample*>& DimRegionEdit::signal_select_sample() {
2126        return select_sample_signal;
2127  }  }

Legend:
Removed from v.1261  
changed lines
  Added in v.3643

  ViewVC Help
Powered by ViewVC