/[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 3624 by schoenebeck, Wed Oct 2 17:11:30 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(280, 80);
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"), -96, 0, 2, -655360),
435        eGainPlus6(_("Gain +6dB"), eGain, 6 * -655360),
436        eSampleLoopEnabled(_("Enabled")),
437        eSampleLoopStart(_("Loop start position")),
438        eSampleLoopLength(_("Loop size")),
439        eSampleLoopType(_("Loop type")),
440        eSampleLoopInfinite(_("Infinite loop")),
441        eSampleLoopPlayCount(_("Playback count"), 1),
442        buttonSelectSample(UNICODE_LEFT_ARROW + "  " + _("Select Sample")),
443        update_model(0)
444    {
445        // make synthesis parameter page tabs scrollable
446        // (workaround for GTK3: default theme uses huge tabs which breaks layout)
447        set_scrollable();
448    
449        connect(eEG1PreAttack, &gig::DimensionRegion::EG1PreAttack);
450        connect(eEG1Attack, &gig::DimensionRegion::EG1Attack);
451        connect(eEG1Decay1, &gig::DimensionRegion::EG1Decay1);
452        connect(eEG1Decay2, &gig::DimensionRegion::EG1Decay2);
453        connect(eEG1InfiniteSustain, &gig::DimensionRegion::EG1InfiniteSustain);
454        connect(eEG1Sustain, &gig::DimensionRegion::EG1Sustain);
455        connect(eEG1Release, &gig::DimensionRegion::EG1Release);
456        connect(eEG1Hold, &gig::DimensionRegion::EG1Hold);
457        connect(eEG1Controller, &gig::DimensionRegion::EG1Controller);
458        connect(eEG1ControllerInvert, &gig::DimensionRegion::EG1ControllerInvert);
459        connect(eEG1ControllerAttackInfluence,
460                &gig::DimensionRegion::EG1ControllerAttackInfluence);
461        connect(eEG1ControllerDecayInfluence,
462                &gig::DimensionRegion::EG1ControllerDecayInfluence);
463        connect(eEG1ControllerReleaseInfluence,
464                &gig::DimensionRegion::EG1ControllerReleaseInfluence);
465        connect(eEG1StateOptions.checkBoxAttack, &gig::DimensionRegion::EG1Options,
466                &gig::eg_opt_t::AttackCancel);
467        connect(eEG1StateOptions.checkBoxAttackHold, &gig::DimensionRegion::EG1Options,
468                &gig::eg_opt_t::AttackHoldCancel);
469        connect(eEG1StateOptions.checkBoxDecay1, &gig::DimensionRegion::EG1Options,
470                &gig::eg_opt_t::Decay1Cancel);
471        connect(eEG1StateOptions.checkBoxDecay2, &gig::DimensionRegion::EG1Options,
472                &gig::eg_opt_t::Decay2Cancel);
473        connect(eEG1StateOptions.checkBoxRelease, &gig::DimensionRegion::EG1Options,
474                &gig::eg_opt_t::ReleaseCancel);
475        connect(eLFO1Wave, &gig::DimensionRegion::LFO1WaveForm);
476        connect(eLFO1Frequency, &gig::DimensionRegion::LFO1Frequency);
477        connect(eLFO1Phase, &gig::DimensionRegion::LFO1Phase);
478        connect(eLFO1InternalDepth, &gig::DimensionRegion::LFO1InternalDepth);
479        connect(eLFO1ControlDepth, &gig::DimensionRegion::LFO1ControlDepth);
480        connect(eLFO1Controller, &gig::DimensionRegion::LFO1Controller);
481        connect(eLFO1FlipPhase, &gig::DimensionRegion::LFO1FlipPhase);
482        connect(eLFO1Sync, &gig::DimensionRegion::LFO1Sync);
483        connect(eEG2PreAttack, &gig::DimensionRegion::EG2PreAttack);
484        connect(eEG2Attack, &gig::DimensionRegion::EG2Attack);
485        connect(eEG2Decay1, &gig::DimensionRegion::EG2Decay1);
486        connect(eEG2Decay2, &gig::DimensionRegion::EG2Decay2);
487        connect(eEG2InfiniteSustain, &gig::DimensionRegion::EG2InfiniteSustain);
488        connect(eEG2Sustain, &gig::DimensionRegion::EG2Sustain);
489        connect(eEG2Release, &gig::DimensionRegion::EG2Release);
490        connect(eEG2Controller, &gig::DimensionRegion::EG2Controller);
491        connect(eEG2ControllerInvert, &gig::DimensionRegion::EG2ControllerInvert);
492        connect(eEG2ControllerAttackInfluence,
493                &gig::DimensionRegion::EG2ControllerAttackInfluence);
494        connect(eEG2ControllerDecayInfluence,
495                &gig::DimensionRegion::EG2ControllerDecayInfluence);
496        connect(eEG2ControllerReleaseInfluence,
497                &gig::DimensionRegion::EG2ControllerReleaseInfluence);
498        connect(eEG2StateOptions.checkBoxAttack, &gig::DimensionRegion::EG2Options,
499                &gig::eg_opt_t::AttackCancel);
500        connect(eEG2StateOptions.checkBoxAttackHold, &gig::DimensionRegion::EG2Options,
501                &gig::eg_opt_t::AttackHoldCancel);
502        connect(eEG2StateOptions.checkBoxDecay1, &gig::DimensionRegion::EG2Options,
503                &gig::eg_opt_t::Decay1Cancel);
504        connect(eEG2StateOptions.checkBoxDecay2, &gig::DimensionRegion::EG2Options,
505                &gig::eg_opt_t::Decay2Cancel);
506        connect(eEG2StateOptions.checkBoxRelease, &gig::DimensionRegion::EG2Options,
507                &gig::eg_opt_t::ReleaseCancel);
508        connect(eLFO2Wave, &gig::DimensionRegion::LFO2WaveForm);
509        connect(eLFO2Frequency, &gig::DimensionRegion::LFO2Frequency);
510        connect(eLFO2Phase, &gig::DimensionRegion::LFO2Phase);
511        connect(eLFO2InternalDepth, &gig::DimensionRegion::LFO2InternalDepth);
512        connect(eLFO2ControlDepth, &gig::DimensionRegion::LFO2ControlDepth);
513        connect(eLFO2Controller, &gig::DimensionRegion::LFO2Controller);
514        connect(eLFO2FlipPhase, &gig::DimensionRegion::LFO2FlipPhase);
515        connect(eLFO2Sync, &gig::DimensionRegion::LFO2Sync);
516        connect(eEG3Attack, &gig::DimensionRegion::EG3Attack);
517        connect(eEG3Depth, &gig::DimensionRegion::EG3Depth);
518        connect(eLFO3Wave, &gig::DimensionRegion::LFO3WaveForm);
519        connect(eLFO3Frequency, &gig::DimensionRegion::LFO3Frequency);
520        connect(eLFO3Phase, &gig::DimensionRegion::LFO3Phase);
521        connect(eLFO3InternalDepth, &gig::DimensionRegion::LFO3InternalDepth);
522        connect(eLFO3ControlDepth, &gig::DimensionRegion::LFO3ControlDepth);
523        connect(eLFO3Controller, &gig::DimensionRegion::LFO3Controller);
524        connect(eLFO3FlipPhase, &gig::DimensionRegion::LFO3FlipPhase);
525        connect(eLFO3Sync, &gig::DimensionRegion::LFO3Sync);
526        connect(eVCFEnabled, &gig::DimensionRegion::VCFEnabled);
527        connect(eVCFType, &gig::DimensionRegion::VCFType);
528        connect(eVCFCutoffController,
529                &gig::DimensionRegion::SetVCFCutoffController);
530        connect(eVCFCutoffControllerInvert,
531                &gig::DimensionRegion::VCFCutoffControllerInvert);
532        connect(eVCFCutoff, &gig::DimensionRegion::VCFCutoff);
533        connect(eVCFVelocityCurve, &gig::DimensionRegion::SetVCFVelocityCurve);
534        connect(eVCFVelocityScale, &gig::DimensionRegion::SetVCFVelocityScale);
535        connect(eVCFVelocityDynamicRange,
536                &gig::DimensionRegion::SetVCFVelocityDynamicRange);
537        connect(eVCFResonance, &gig::DimensionRegion::VCFResonance);
538        connect(eVCFResonanceDynamic, &gig::DimensionRegion::VCFResonanceDynamic);
539        connect(eVCFResonanceController,
540                &gig::DimensionRegion::VCFResonanceController);
541        connect(eVCFKeyboardTracking, &gig::DimensionRegion::VCFKeyboardTracking);
542        connect(eVCFKeyboardTrackingBreakpoint,
543                &gig::DimensionRegion::VCFKeyboardTrackingBreakpoint);
544        connect(eVelocityResponseCurve,
545                &gig::DimensionRegion::SetVelocityResponseCurve);
546        connect(eVelocityResponseDepth,
547                &gig::DimensionRegion::SetVelocityResponseDepth);
548        connect(eVelocityResponseCurveScaling,
549                &gig::DimensionRegion::SetVelocityResponseCurveScaling);
550        connect(eReleaseVelocityResponseCurve,
551                &gig::DimensionRegion::SetReleaseVelocityResponseCurve);
552        connect(eReleaseVelocityResponseDepth,
553                &gig::DimensionRegion::SetReleaseVelocityResponseDepth);
554        connect(eReleaseTriggerDecay, &gig::DimensionRegion::ReleaseTriggerDecay);
555        connect(eCrossfade_in_start, &DimRegionEdit::set_Crossfade_in_start);
556        connect(eCrossfade_in_end, &DimRegionEdit::set_Crossfade_in_end);
557        connect(eCrossfade_out_start, &DimRegionEdit::set_Crossfade_out_start);
558        connect(eCrossfade_out_end, &DimRegionEdit::set_Crossfade_out_end);
559        connect(ePitchTrack, &gig::DimensionRegion::PitchTrack);
560        connect(eSustainReleaseTrigger, &gig::DimensionRegion::SustainReleaseTrigger);
561        connect(eNoNoteOffReleaseTrigger, &gig::DimensionRegion::NoNoteOffReleaseTrigger);
562        connect(eDimensionBypass, &gig::DimensionRegion::DimensionBypass);
563        connect(ePan, &gig::DimensionRegion::Pan);
564        connect(eSelfMask, &gig::DimensionRegion::SelfMask);
565        connect(eAttenuationController,
566                &gig::DimensionRegion::AttenuationController);
567        connect(eInvertAttenuationController,
568                &gig::DimensionRegion::InvertAttenuationController);
569        connect(eAttenuationControllerThreshold,
570                &gig::DimensionRegion::AttenuationControllerThreshold);
571        connect(eChannelOffset, &gig::DimensionRegion::ChannelOffset);
572        connect(eSustainDefeat, &gig::DimensionRegion::SustainDefeat);
573        connect(eMSDecode, &gig::DimensionRegion::MSDecode);
574        connect(eSampleStartOffset, &gig::DimensionRegion::SampleStartOffset);
575        connect(eUnityNote, &DimRegionEdit::set_UnityNote);
576        connect(eFineTune, &DimRegionEdit::set_FineTune);
577        connect(eGain, &DimRegionEdit::set_Gain);
578        connect(eGainPlus6, &DimRegionEdit::set_Gain);
579        connect(eSampleLoopEnabled, &DimRegionEdit::set_LoopEnabled);
580        connect(eSampleLoopType, &DimRegionEdit::set_LoopType);
581        connect(eSampleLoopStart, &DimRegionEdit::set_LoopStart);
582        connect(eSampleLoopLength, &DimRegionEdit::set_LoopLength);
583        connect(eSampleLoopInfinite, &DimRegionEdit::set_LoopInfinite);
584        connect(eSampleLoopPlayCount, &DimRegionEdit::set_LoopPlayCount);
585        buttonSelectSample.signal_clicked().connect(
586            sigc::mem_fun(*this, &DimRegionEdit::onButtonSelectSamplePressed)
587        );
588    
589        for (int i = 0 ; i < 9 ; i++) {
590    #if USE_GTKMM_GRID
591            table[i] = new Gtk::Grid;
592            table[i]->set_column_spacing(7);
593    #else
594          table[i] = new Gtk::Table(3, 1);          table[i] = new Gtk::Table(3, 1);
595          table[i]->set_col_spacings(7);          table[i]->set_col_spacings(7);
596    #endif
597    
598    // on Gtk 3 there is absolutely no margin by default
599    #if GTKMM_MAJOR_VERSION >= 3
600    # if GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION < 12
601            table[i]->set_margin_left(12);
602            table[i]->set_margin_right(12);
603    # else
604            table[i]->set_margin_start(12);
605            table[i]->set_margin_end(12);
606    # endif
607    #endif
608      }      }
609    
610      // set tooltips      // set tooltips
611      eUnityNote.set_tip(      eUnityNote.set_tip(
612          _("Note this sample is associated with (a.k.a. 'root note')")          _("Note this sample is associated with (a.k.a. 'root note')")
613      );      );
614        buttonSelectSample.set_tooltip_text(
615            _("Selects the sample of this dimension region on the left hand side's sample tree view.")
616        );
617      eSampleStartOffset.set_tip(_("Sample position at which playback should be started"));      eSampleStartOffset.set_tip(_("Sample position at which playback should be started"));
618      ePan.set_tip(_("Stereo balance (left/right)"));      ePan.set_tip(_("Stereo balance (left/right)"));
619      eChannelOffset.set_tip(      eChannelOffset.set_tip(
# Line 151  DimRegionEdit::DimRegionEdit() : Line 644  DimRegionEdit::DimRegionEdit() :
644            "Caution: this setting is stored on Sample side, thus is shared "            "Caution: this setting is stored on Sample side, thus is shared "
645            "among all dimension regions that use this sample!")            "among all dimension regions that use this sample!")
646      );      );
647        
648        eEG1PreAttack.set_tip(
649            "Very first level this EG starts with. It rises then in Attack Time "
650            "seconds from this initial level to 100%."
651        );
652        eEG1Attack.set_tip(
653            "Duration of the EG's Attack stage, which raises its level from "
654            "Pre-Attack Level to 100%."
655        );
656        eEG1Hold.set_tip(
657           "On looped sounds, enabling this will cause the Decay 1 stage not to "
658           "enter before the loop has been passed one time."
659        );
660        eAttenuationController.set_tip(_(
661            "If you are not using the 'Layer' dimension, then this controller "
662            "simply alters the volume. If you are using the 'Layer' dimension, "
663            "then this controller is controlling the crossfade between Layers in "
664            "real-time."
665        ));
666    
667        eLFO1Sync.set_tip(
668            "If not checked, every voice will use its own LFO instance, which "
669            "causes voices triggered at different points in time to have different "
670            "LFO levels. By enabling 'Sync' here the voices will instead use and "
671            "share one single LFO, causing all voices to have the same LFO level, "
672            "no matter when the individual notes have been triggered."
673        );
674        eLFO2Sync.set_tip(
675            "If not checked, every voice will use its own LFO instance, which "
676            "causes voices triggered at different points in time to have different "
677            "LFO levels. By enabling 'Sync' here the voices will instead use and "
678            "share one single LFO, causing all voices to have the same LFO level, "
679            "no matter when the individual notes have been triggered."
680        );
681        eLFO3Sync.set_tip(
682            "If not checked, every voice will use its own LFO instance, which "
683            "causes voices triggered at different points in time to have different "
684            "LFO levels. By enabling 'Sync' here the voices will instead use and "
685            "share one single LFO, causing all voices to have the same LFO level, "
686            "no matter when the individual notes have been triggered."
687        );
688        eLFO1FlipPhase.set_tip(
689           "Inverts the LFO's generated wave vertically."
690        );
691        eLFO2FlipPhase.set_tip(
692           "Inverts the LFO's generated wave vertically."
693        );
694        eLFO3FlipPhase.set_tip(
695           "Inverts the LFO's generated wave vertically."
696        );
697    
698      pageno = 0;      pageno = 0;
699      rowno = 0;      rowno = 0;
700      firstRowInBlock = 0;      firstRowInBlock = 0;
701    
702      addHeader(_("Mandatory Settings"));      addHeader(_("Mandatory Settings"));
703      addString("Sample", lSample, wSample);      addString(_("Sample"), lSample, wSample, buttonNullSampleReference);
704        buttonNullSampleReference->set_label("X");
705        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."));
706        buttonNullSampleReference->signal_clicked().connect(
707            sigc::mem_fun(*this, &DimRegionEdit::nullOutSampleReference)
708        );
709      //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);
710      tooltips.set_tip(*wSample, _("Drop a sample here"));  #ifdef OLD_TOOLTIPS
711        tooltips.set_tip(*wSample, _("Drag & drop a sample here"));
712    #else
713        wSample->set_tooltip_text(_("Drag & drop a sample here"));
714    #endif
715      addProp(eUnityNote);      addProp(eUnityNote);
716        addProp(eSampleGroup);
717        addProp(eSampleFormatInfo);
718        addProp(eSampleID);
719        addProp(eChecksum);
720        addRightHandSide(buttonSelectSample);
721      addHeader(_("Optional Settings"));      addHeader(_("Optional Settings"));
722      addProp(eSampleStartOffset);      addProp(eSampleStartOffset);
723      addProp(eChannelOffset);      addProp(eChannelOffset);
724      addHeader("Loops");      addHeader(_("Loops"));
725      addProp(eSampleLoopEnabled);      addProp(eSampleLoopEnabled);
726      addProp(eSampleLoopStart);      addProp(eSampleLoopStart);
727      addProp(eSampleLoopLength);      addProp(eSampleLoopLength);
728      {      {
729          const char* choices[] = { "normal", "bidirectional", "backward", 0 };          const char* choices[] = { _("normal"), _("bidirectional"), _("backward"), 0 };
730          static const uint32_t values[] = {          static const uint32_t values[] = {
731              gig::loop_type_normal,              gig::loop_type_normal,
732              gig::loop_type_bidirectional,              gig::loop_type_bidirectional,
# Line 190  DimRegionEdit::DimRegionEdit() : Line 747  DimRegionEdit::DimRegionEdit() :
747      addHeader(_("Amplitude Envelope (EG1)"));      addHeader(_("Amplitude Envelope (EG1)"));
748      addProp(eEG1PreAttack);      addProp(eEG1PreAttack);
749      addProp(eEG1Attack);      addProp(eEG1Attack);
750        addProp(eEG1Hold);
751      addProp(eEG1Decay1);      addProp(eEG1Decay1);
752      addProp(eEG1Decay2);      addProp(eEG1Decay2);
753      addProp(eEG1InfiniteSustain);      addProp(eEG1InfiniteSustain);
754      addProp(eEG1Sustain);      addProp(eEG1Sustain);
755      addProp(eEG1Release);      addProp(eEG1Release);
     addProp(eEG1Hold);  
756      addProp(eEG1Controller);      addProp(eEG1Controller);
757      addProp(eEG1ControllerInvert);      addProp(eEG1ControllerInvert);
758      addProp(eEG1ControllerAttackInfluence);      addProp(eEG1ControllerAttackInfluence);
759      addProp(eEG1ControllerDecayInfluence);      addProp(eEG1ControllerDecayInfluence);
760      addProp(eEG1ControllerReleaseInfluence);      addProp(eEG1ControllerReleaseInfluence);
761        addLine(eEG1StateOptions);
762    
763      nextPage();      nextPage();
764    
765      addHeader(_("Amplitude Oscillator (LFO1)"));      addHeader(_("Amplitude Oscillator (LFO1)"));
766        addProp(eLFO1Wave);
767      addProp(eLFO1Frequency);      addProp(eLFO1Frequency);
768        addProp(eLFO1Phase);
769      addProp(eLFO1InternalDepth);      addProp(eLFO1InternalDepth);
770      addProp(eLFO1ControlDepth);      addProp(eLFO1ControlDepth);
771      {      {
772          const char* choices[] = { "internal", "modwheel", "breath",          const char* choices[] = { _("internal"), _("modwheel"), _("breath"),
773                                    "internal+modwheel", "internal+breath", 0 };                                    _("internal+modwheel"), _("internal+breath"), 0 };
774          static const gig::lfo1_ctrl_t values[] = {          static const gig::lfo1_ctrl_t values[] = {
775              gig::lfo1_ctrl_internal,              gig::lfo1_ctrl_internal,
776              gig::lfo1_ctrl_modwheel,              gig::lfo1_ctrl_modwheel,
# Line 223  DimRegionEdit::DimRegionEdit() : Line 783  DimRegionEdit::DimRegionEdit() :
783      addProp(eLFO1Controller);      addProp(eLFO1Controller);
784      addProp(eLFO1FlipPhase);      addProp(eLFO1FlipPhase);
785      addProp(eLFO1Sync);      addProp(eLFO1Sync);
786      addHeader("Crossfade");      {
787            Gtk::Frame* frame = new Gtk::Frame;
788            frame->add(lfo1Graph);
789            // on Gtk 3 there is no margin at all by default
790    #if GTKMM_MAJOR_VERSION >= 3
791            frame->set_margin_top(12);
792            frame->set_margin_bottom(12);
793    #endif
794    #if USE_GTKMM_GRID
795            table[pageno]->attach(*frame, 1, rowno, 2);
796    #else
797            table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
798                                  Gtk::SHRINK, Gtk::SHRINK);
799    #endif
800            rowno++;
801        }
802        eLFO1FlipPhase.signal_value_changed().connect(
803            sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw)
804        );
805    
806        nextPage();
807    
808        addHeader(_("Crossfade"));
809      addProp(eAttenuationController);      addProp(eAttenuationController);
810      addProp(eInvertAttenuationController);      addProp(eInvertAttenuationController);
811      addProp(eAttenuationControllerThreshold);      addProp(eAttenuationControllerThreshold);
# Line 232  DimRegionEdit::DimRegionEdit() : Line 814  DimRegionEdit::DimRegionEdit() :
814      addProp(eCrossfade_out_start);      addProp(eCrossfade_out_start);
815      addProp(eCrossfade_out_end);      addProp(eCrossfade_out_end);
816    
817        Gtk::Frame* frame = new Gtk::Frame;
818        frame->add(crossfade_curve);
819        // on Gtk 3 there is no margin at all by default
820    #if GTKMM_MAJOR_VERSION >= 3
821        frame->set_margin_top(12);
822        frame->set_margin_bottom(12);
823    #endif
824    #if USE_GTKMM_GRID
825        table[pageno]->attach(*frame, 1, rowno, 2);
826    #else
827        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
828                              Gtk::SHRINK, Gtk::SHRINK);
829    #endif
830        rowno++;
831    
832        eCrossfade_in_start.signal_value_changed().connect(
833            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
834        eCrossfade_in_end.signal_value_changed().connect(
835            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
836        eCrossfade_out_start.signal_value_changed().connect(
837            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
838        eCrossfade_out_end.signal_value_changed().connect(
839            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
840    
841      nextPage();      nextPage();
842    
843      addHeader(_("General Filter Settings"));      addHeader(_("General Filter Settings"));
844      addProp(eVCFEnabled);      addProp(eVCFEnabled);
845      {      {
846          const char* choices[] = { "lowpass", "lowpassturbo", "bandpass",          const char* choices[] = { _("lowpass"), _("lowpassturbo"), _("bandpass"),
847                                    "highpass", "bandreject", 0 };                                    _("highpass"), _("bandreject"), 0 };
848          static const gig::vcf_type_t values[] = {          static const gig::vcf_type_t values[] = {
849              gig::vcf_type_lowpass,              gig::vcf_type_lowpass,
850              gig::vcf_type_lowpassturbo,              gig::vcf_type_lowpassturbo,
# Line 250  DimRegionEdit::DimRegionEdit() : Line 856  DimRegionEdit::DimRegionEdit() :
856      }      }
857      addProp(eVCFType);      addProp(eVCFType);
858      {      {
859          const char* choices[] = { "none", "none2", "modwheel", "effect1", "effect2",          const char* choices[] = { _("none"), _("none2"), _("modwheel"), _("effect1"), _("effect2"),
860                                    "breath", "foot", "sustainpedal", "softpedal",                                    _("breath"), _("foot"), _("sustainpedal"), _("softpedal"),
861                                    "genpurpose7", "genpurpose8", "aftertouch", 0 };                                    _("genpurpose7"), _("genpurpose8"), _("aftertouch"), 0 };
862          static const gig::vcf_cutoff_ctrl_t values[] = {          static const gig::vcf_cutoff_ctrl_t values[] = {
863              gig::vcf_cutoff_ctrl_none,              gig::vcf_cutoff_ctrl_none,
864              gig::vcf_cutoff_ctrl_none2,              gig::vcf_cutoff_ctrl_none2,
# Line 272  DimRegionEdit::DimRegionEdit() : Line 878  DimRegionEdit::DimRegionEdit() :
878      addProp(eVCFCutoffController);      addProp(eVCFCutoffController);
879      addProp(eVCFCutoffControllerInvert);      addProp(eVCFCutoffControllerInvert);
880      addProp(eVCFCutoff);      addProp(eVCFCutoff);
881      const char* curve_type_texts[] = { "nonlinear", "linear", "special", 0 };      const char* curve_type_texts[] = { _("nonlinear"), _("linear"), _("special"), 0 };
882      static const gig::curve_type_t curve_type_values[] = {      static const gig::curve_type_t curve_type_values[] = {
883          gig::curve_type_nonlinear,          gig::curve_type_nonlinear,
884          gig::curve_type_linear,          gig::curve_type_linear,
# Line 282  DimRegionEdit::DimRegionEdit() : Line 888  DimRegionEdit::DimRegionEdit() :
888      addProp(eVCFVelocityCurve);      addProp(eVCFVelocityCurve);
889      addProp(eVCFVelocityScale);      addProp(eVCFVelocityScale);
890      addProp(eVCFVelocityDynamicRange);      addProp(eVCFVelocityDynamicRange);
891    
892        eVCFCutoffController.signal_value_changed().connect(
893            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
894        eVCFVelocityCurve.signal_value_changed().connect(
895            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
896        eVCFVelocityScale.signal_value_changed().connect(
897            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
898        eVCFVelocityDynamicRange.signal_value_changed().connect(
899            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
900    
901        frame = new Gtk::Frame;
902        frame->add(cutoff_curve);
903        // on Gtk 3 there is no margin at all by default
904    #if GTKMM_MAJOR_VERSION >= 3
905        frame->set_margin_top(12);
906        frame->set_margin_bottom(12);
907    #endif
908    #if USE_GTKMM_GRID
909        table[pageno]->attach(*frame, 1, rowno, 2);
910    #else
911        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
912                              Gtk::SHRINK, Gtk::SHRINK);
913    #endif
914        rowno++;
915    
916      addProp(eVCFResonance);      addProp(eVCFResonance);
917      addProp(eVCFResonanceDynamic);      addProp(eVCFResonanceDynamic);
918      {      {
919          const char* choices[] = { "none", "genpurpose3", "genpurpose4",          const char* choices[] = { _("none"), _("genpurpose3"), _("genpurpose4"),
920                                    "genpurpose5", "genpurpose6", 0 };                                    _("genpurpose5"), _("genpurpose6"), 0 };
921          static const gig::vcf_res_ctrl_t values[] = {          static const gig::vcf_res_ctrl_t values[] = {
922              gig::vcf_res_ctrl_none,              gig::vcf_res_ctrl_none,
923              gig::vcf_res_ctrl_genpurpose3,              gig::vcf_res_ctrl_genpurpose3,
# Line 302  DimRegionEdit::DimRegionEdit() : Line 933  DimRegionEdit::DimRegionEdit() :
933    
934      nextPage();      nextPage();
935    
936      addHeader(_("Filter Cutoff Envelope (EG2)"));      lEG2 = addHeader(_("Filter Cutoff Envelope (EG2)"));
937      addProp(eEG2PreAttack);      addProp(eEG2PreAttack);
938      addProp(eEG2Attack);      addProp(eEG2Attack);
939      addProp(eEG2Decay1);      addProp(eEG2Decay1);
# Line 315  DimRegionEdit::DimRegionEdit() : Line 946  DimRegionEdit::DimRegionEdit() :
946      addProp(eEG2ControllerAttackInfluence);      addProp(eEG2ControllerAttackInfluence);
947      addProp(eEG2ControllerDecayInfluence);      addProp(eEG2ControllerDecayInfluence);
948      addProp(eEG2ControllerReleaseInfluence);      addProp(eEG2ControllerReleaseInfluence);
949      addHeader(_("Filter Cutoff Oscillator (LFO2)"));      addLine(eEG2StateOptions);
950    
951        nextPage();
952    
953        lLFO2 = addHeader(_("Filter Cutoff Oscillator (LFO2)"));
954        addProp(eLFO2Wave);
955      addProp(eLFO2Frequency);      addProp(eLFO2Frequency);
956        addProp(eLFO2Phase);
957      addProp(eLFO2InternalDepth);      addProp(eLFO2InternalDepth);
958      addProp(eLFO2ControlDepth);      addProp(eLFO2ControlDepth);
959      {      {
960          const char* choices[] = { "internal", "modwheel", "foot",          const char* choices[] = { _("internal"), _("modwheel"), _("foot"),
961                                    "internal+modwheel", "internal+foot", 0 };                                    _("internal+modwheel"), _("internal+foot"), 0 };
962          static const gig::lfo2_ctrl_t values[] = {          static const gig::lfo2_ctrl_t values[] = {
963              gig::lfo2_ctrl_internal,              gig::lfo2_ctrl_internal,
964              gig::lfo2_ctrl_modwheel,              gig::lfo2_ctrl_modwheel,
# Line 334  DimRegionEdit::DimRegionEdit() : Line 971  DimRegionEdit::DimRegionEdit() :
971      addProp(eLFO2Controller);      addProp(eLFO2Controller);
972      addProp(eLFO2FlipPhase);      addProp(eLFO2FlipPhase);
973      addProp(eLFO2Sync);      addProp(eLFO2Sync);
974        {
975            Gtk::Frame* frame = new Gtk::Frame;
976            frame->add(lfo2Graph);
977            // on Gtk 3 there is no margin at all by default
978    #if GTKMM_MAJOR_VERSION >= 3
979            frame->set_margin_top(12);
980            frame->set_margin_bottom(12);
981    #endif
982    #if USE_GTKMM_GRID
983            table[pageno]->attach(*frame, 1, rowno, 2);
984    #else
985            table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
986                                  Gtk::SHRINK, Gtk::SHRINK);
987    #endif
988            rowno++;
989        }
990        eLFO2FlipPhase.signal_value_changed().connect(
991            sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw)
992        );
993    
994      nextPage();      nextPage();
995    
# Line 344  DimRegionEdit::DimRegionEdit() : Line 1000  DimRegionEdit::DimRegionEdit() :
1000      addProp(eEG3Attack);      addProp(eEG3Attack);
1001      addProp(eEG3Depth);      addProp(eEG3Depth);
1002      addHeader(_("Pitch Oscillator (LFO3)"));      addHeader(_("Pitch Oscillator (LFO3)"));
1003        addProp(eLFO3Wave);
1004      addProp(eLFO3Frequency);      addProp(eLFO3Frequency);
1005        addProp(eLFO3Phase);
1006      addProp(eLFO3InternalDepth);      addProp(eLFO3InternalDepth);
1007      addProp(eLFO3ControlDepth);      addProp(eLFO3ControlDepth);
1008      {      {
1009          const char* choices[] = { "internal", "modwheel", "aftertouch",          const char* choices[] = { _("internal"), _("modwheel"), _("aftertouch"),
1010                                    "internal+modwheel", "internal+aftertouch", 0 };                                    _("internal+modwheel"), _("internal+aftertouch"), 0 };
1011          static const gig::lfo3_ctrl_t values[] = {          static const gig::lfo3_ctrl_t values[] = {
1012              gig::lfo3_ctrl_internal,              gig::lfo3_ctrl_internal,
1013              gig::lfo3_ctrl_modwheel,              gig::lfo3_ctrl_modwheel,
# Line 360  DimRegionEdit::DimRegionEdit() : Line 1018  DimRegionEdit::DimRegionEdit() :
1018          eLFO3Controller.set_choices(choices, values);          eLFO3Controller.set_choices(choices, values);
1019      }      }
1020      addProp(eLFO3Controller);      addProp(eLFO3Controller);
1021        addProp(eLFO3FlipPhase);
1022      addProp(eLFO3Sync);      addProp(eLFO3Sync);
1023        {
1024            Gtk::Frame* frame = new Gtk::Frame;
1025            frame->add(lfo3Graph);
1026            // on Gtk 3 there is no margin at all by default
1027    #if GTKMM_MAJOR_VERSION >= 3
1028            frame->set_margin_top(12);
1029            frame->set_margin_bottom(12);
1030    #endif
1031    #if USE_GTKMM_GRID
1032            table[pageno]->attach(*frame, 1, rowno, 2);
1033    #else
1034            table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
1035                                  Gtk::SHRINK, Gtk::SHRINK);
1036    #endif
1037            rowno++;
1038        }
1039        eLFO3FlipPhase.signal_value_changed().connect(
1040            sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw)
1041        );
1042    
1043      nextPage();      nextPage();
1044    
1045        addHeader(_("Velocity Response"));
1046      eVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values);      eVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values);
1047      addProp(eVelocityResponseCurve);      addProp(eVelocityResponseCurve);
1048      addProp(eVelocityResponseDepth);      addProp(eVelocityResponseDepth);
1049      addProp(eVelocityResponseCurveScaling);      addProp(eVelocityResponseCurveScaling);
1050    
1051        eVelocityResponseCurve.signal_value_changed().connect(
1052            sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
1053        eVelocityResponseDepth.signal_value_changed().connect(
1054            sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
1055        eVelocityResponseCurveScaling.signal_value_changed().connect(
1056            sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
1057    
1058        frame = new Gtk::Frame;
1059        frame->add(velocity_curve);
1060        // on Gtk 3 there is no margin at all by default
1061    #if GTKMM_MAJOR_VERSION >= 3
1062        frame->set_margin_top(12);
1063        frame->set_margin_bottom(12);
1064    #endif
1065    #if USE_GTKMM_GRID
1066        table[pageno]->attach(*frame, 1, rowno, 2);
1067    #else
1068        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
1069                              Gtk::SHRINK, Gtk::SHRINK);
1070    #endif
1071        rowno++;
1072    
1073        addHeader(_("Release Velocity Response"));
1074      eReleaseVelocityResponseCurve.set_choices(curve_type_texts,      eReleaseVelocityResponseCurve.set_choices(curve_type_texts,
1075                                                curve_type_values);                                                curve_type_values);
1076      addProp(eReleaseVelocityResponseCurve);      addProp(eReleaseVelocityResponseCurve);
1077      addProp(eReleaseVelocityResponseDepth);      addProp(eReleaseVelocityResponseDepth);
1078    
1079        eReleaseVelocityResponseCurve.signal_value_changed().connect(
1080            sigc::mem_fun(release_curve, &VelocityCurve::queue_draw));
1081        eReleaseVelocityResponseDepth.signal_value_changed().connect(
1082            sigc::mem_fun(release_curve, &VelocityCurve::queue_draw));
1083        frame = new Gtk::Frame;
1084        frame->add(release_curve);
1085        // on Gtk 3 there is no margin at all by default
1086    #if GTKMM_MAJOR_VERSION >= 3
1087        frame->set_margin_top(12);
1088        frame->set_margin_bottom(12);
1089    #endif
1090    #if USE_GTKMM_GRID
1091        table[pageno]->attach(*frame, 1, rowno, 2);
1092    #else
1093        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
1094                              Gtk::SHRINK, Gtk::SHRINK);
1095    #endif
1096        rowno++;
1097    
1098      addProp(eReleaseTriggerDecay);      addProp(eReleaseTriggerDecay);
1099      {      {
1100          const char* choices[] = { "none", "effect4depth", "effect5depth", 0 };          const char* choices[] = { _("off"), _("on (max. velocity)"), _("on (key velocity)"), 0 };
1101            static const gig::sust_rel_trg_t values[] = {
1102                gig::sust_rel_trg_none,
1103                gig::sust_rel_trg_maxvelocity,
1104                gig::sust_rel_trg_keyvelocity
1105            };
1106            eSustainReleaseTrigger.set_choices(choices, values);
1107        }
1108        eSustainReleaseTrigger.set_tip(_(
1109            "By default release trigger samples are played on note-off events only. "
1110            "This option allows to play release trigger sample on sustain pedal up "
1111            "events as well. NOTE: This is a format extension!"
1112        ));
1113        addProp(eSustainReleaseTrigger);
1114        {
1115            const char* choices[] = { _("none"), _("effect4depth"), _("effect5depth"), 0 };
1116          static const gig::dim_bypass_ctrl_t values[] = {          static const gig::dim_bypass_ctrl_t values[] = {
1117              gig::dim_bypass_ctrl_none,              gig::dim_bypass_ctrl_none,
1118              gig::dim_bypass_ctrl_94,              gig::dim_bypass_ctrl_94,
# Line 382  DimRegionEdit::DimRegionEdit() : Line 1120  DimRegionEdit::DimRegionEdit() :
1120          };          };
1121          eDimensionBypass.set_choices(choices, values);          eDimensionBypass.set_choices(choices, values);
1122      }      }
1123        eNoNoteOffReleaseTrigger.set_tip(_(
1124            "By default release trigger samples are played on note-off events only. "
1125            "If this option is checked, then no release trigger sample is played "
1126            "when releasing a note. NOTE: This is a format extension!"
1127        ));
1128        addProp(eNoNoteOffReleaseTrigger);
1129      addProp(eDimensionBypass);      addProp(eDimensionBypass);
1130        eSelfMask.widget.set_tooltip_text(_(
1131            "If enabled: new notes with higher velocity value will stop older "
1132            "notes with lower velocity values, that way you can save voices that "
1133            "would barely be audible. This is also useful for certain drum sounds."
1134        ));
1135      addProp(eSelfMask);      addProp(eSelfMask);
1136        eSustainDefeat.widget.set_tooltip_text(_(
1137            "If enabled: sustain pedal will not hold a note. This way you can use "
1138            "the sustain pedal for other purposes, for example to switch among "
1139            "dimension regions."
1140        ));
1141      addProp(eSustainDefeat);      addProp(eSustainDefeat);
1142        eMSDecode.widget.set_tooltip_text(_(
1143            "Defines if Mid/Side Recordings should be decoded. Mid/Side Recordings "
1144            "are an alternative way to record sounds in stereo. The sampler needs "
1145            "to decode such samples to actually make use of them. Note: this "
1146            "feature is currently not supported by LinuxSampler."
1147        ));
1148      addProp(eMSDecode);      addProp(eMSDecode);
1149    
1150      nextPage();      nextPage();
1151    
1152    
1153      eEG1InfiniteSustain.signal_toggled().connect(      eEG1InfiniteSustain.signal_value_changed().connect(
1154          sigc::mem_fun(*this, &DimRegionEdit::EG1InfiniteSustain_toggled) );          sigc::mem_fun(*this, &DimRegionEdit::EG1InfiniteSustain_toggled));
1155      eEG2InfiniteSustain.signal_toggled().connect(      eEG2InfiniteSustain.signal_value_changed().connect(
1156          sigc::mem_fun(*this, &DimRegionEdit::EG2InfiniteSustain_toggled) );          sigc::mem_fun(*this, &DimRegionEdit::EG2InfiniteSustain_toggled));
1157      eEG1Controller.signal_changed().connect(      eEG1Controller.signal_value_changed().connect(
1158          sigc::mem_fun(*this, &DimRegionEdit::EG1Controller_changed) );          sigc::mem_fun(*this, &DimRegionEdit::EG1Controller_changed));
1159      eEG2Controller.signal_changed().connect(      eEG2Controller.signal_value_changed().connect(
1160          sigc::mem_fun(*this, &DimRegionEdit::EG2Controller_changed) );          sigc::mem_fun(*this, &DimRegionEdit::EG2Controller_changed));
1161      eLFO1Controller.signal_changed().connect(      eLFO1Controller.signal_value_changed().connect(
1162          sigc::mem_fun(*this, &DimRegionEdit::LFO1Controller_changed) );          sigc::mem_fun(*this, &DimRegionEdit::LFO1Controller_changed));
1163      eLFO2Controller.signal_changed().connect(      eLFO2Controller.signal_value_changed().connect(
1164          sigc::mem_fun(*this, &DimRegionEdit::LFO2Controller_changed) );          sigc::mem_fun(*this, &DimRegionEdit::LFO2Controller_changed));
1165      eLFO3Controller.signal_changed().connect(      eLFO3Controller.signal_value_changed().connect(
1166          sigc::mem_fun(*this, &DimRegionEdit::LFO3Controller_changed) );          sigc::mem_fun(*this, &DimRegionEdit::LFO3Controller_changed));
1167      eAttenuationController.signal_changed().connect(      eAttenuationController.signal_value_changed().connect(
1168          sigc::mem_fun(*this, &DimRegionEdit::AttenuationController_changed) );          sigc::mem_fun(*this, &DimRegionEdit::AttenuationController_changed));
1169      eVCFEnabled.signal_toggled().connect(      eVCFEnabled.signal_value_changed().connect(
1170          sigc::mem_fun(*this, &DimRegionEdit::VCFEnabled_toggled) );          sigc::mem_fun(*this, &DimRegionEdit::VCFEnabled_toggled));
1171      eVCFCutoffController.signal_changed().connect(      eVCFCutoffController.signal_value_changed().connect(
1172          sigc::mem_fun(*this, &DimRegionEdit::VCFCutoffController_changed) );          sigc::mem_fun(*this, &DimRegionEdit::VCFCutoffController_changed));
1173      eVCFResonanceController.signal_changed().connect(      eVCFResonanceController.signal_value_changed().connect(
1174          sigc::mem_fun(*this, &DimRegionEdit::VCFResonanceController_changed) );          sigc::mem_fun(*this, &DimRegionEdit::VCFResonanceController_changed));
1175    
1176      eCrossfade_in_start.signal_changed_by_user().connect(      eCrossfade_in_start.signal_value_changed().connect(
1177          sigc::mem_fun(*this, &DimRegionEdit::crossfade1_changed));          sigc::mem_fun(*this, &DimRegionEdit::crossfade1_changed));
1178      eCrossfade_in_end.signal_changed_by_user().connect(      eCrossfade_in_end.signal_value_changed().connect(
1179          sigc::mem_fun(*this, &DimRegionEdit::crossfade2_changed));          sigc::mem_fun(*this, &DimRegionEdit::crossfade2_changed));
1180      eCrossfade_out_start.signal_changed_by_user().connect(      eCrossfade_out_start.signal_value_changed().connect(
1181          sigc::mem_fun(*this, &DimRegionEdit::crossfade3_changed));          sigc::mem_fun(*this, &DimRegionEdit::crossfade3_changed));
1182      eCrossfade_out_end.signal_changed_by_user().connect(      eCrossfade_out_end.signal_value_changed().connect(
1183          sigc::mem_fun(*this, &DimRegionEdit::crossfade4_changed));          sigc::mem_fun(*this, &DimRegionEdit::crossfade4_changed));
1184    
1185      eSampleLoopEnabled.signal_toggled().connect(      eSampleLoopEnabled.signal_value_changed().connect(
1186          sigc::mem_fun(*this, &DimRegionEdit::loop_enabled_toggled));          sigc::mem_fun(*this, &DimRegionEdit::update_loop_elements));
1187      eSampleLoopStart.signal_changed_by_user().connect(      eSampleLoopStart.signal_value_changed().connect(
1188          sigc::mem_fun(*this, &DimRegionEdit::updateLoopElements));          sigc::mem_fun(*this, &DimRegionEdit::loop_start_changed));
1189      eSampleLoopLength.signal_changed_by_user().connect(      eSampleLoopLength.signal_value_changed().connect(
1190          sigc::mem_fun(*this, &DimRegionEdit::updateLoopElements));          sigc::mem_fun(*this, &DimRegionEdit::loop_length_changed));
1191      eSampleLoopInfinite.signal_toggled().connect(      eSampleLoopInfinite.signal_value_changed().connect(
1192          sigc::mem_fun(*this, &DimRegionEdit::loop_infinite_toggled));          sigc::mem_fun(*this, &DimRegionEdit::loop_infinite_toggled));
1193    
1194      append_page(*table[0], "Sample");      append_page(*table[0], _("Sample"));
1195      append_page(*table[1], "Amplitude (1)");      append_page(*table[1], _("Amp (1)"));
1196      append_page(*table[2], "Amplitude (2)");      append_page(*table[2], _("Amp (2)"));
1197      append_page(*table[3], "Filter (1)");      append_page(*table[3], _("Amp (3)"));
1198      append_page(*table[4], "Filter (2)");      append_page(*table[4], _("Filter (1)"));
1199      append_page(*table[5], "Pitch");      append_page(*table[5], _("Filter (2)"));
1200      append_page(*table[6], "Misc");      append_page(*table[6], _("Filter (3)"));
1201        append_page(*table[7], _("Pitch"));
1202        append_page(*table[8], _("Misc"));
1203    
1204        Settings::singleton()->showTooltips.get_proxy().signal_changed().connect(
1205            sigc::mem_fun(*this, &DimRegionEdit::on_show_tooltips_changed)
1206        );
1207    
1208        on_show_tooltips_changed();
1209  }  }
1210    
1211  DimRegionEdit::~DimRegionEdit()  DimRegionEdit::~DimRegionEdit()
# Line 448  void DimRegionEdit::addString(const char Line 1216  void DimRegionEdit::addString(const char
1216                                Gtk::Entry*& widget)                                Gtk::Entry*& widget)
1217  {  {
1218      label = new Gtk::Label(Glib::ustring(labelText) + ":");      label = new Gtk::Label(Glib::ustring(labelText) + ":");
1219      label->set_alignment(Gtk::ALIGN_LEFT);  #if HAS_GTKMM_ALIGNMENT
1220        label->set_alignment(Gtk::ALIGN_START);
1221    #else
1222        label->set_halign(Gtk::Align::START);
1223    #endif
1224    
1225    #if USE_GTKMM_GRID
1226        table[pageno]->attach(*label, 1, rowno);
1227    #else
1228      table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,      table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,
1229                            Gtk::FILL, Gtk::SHRINK);                            Gtk::FILL, Gtk::SHRINK);
1230    #endif
1231    
1232      widget = new Gtk::Entry();      widget = new Gtk::Entry();
1233    
1234    #if USE_GTKMM_GRID
1235        table[pageno]->attach(*widget, 2, rowno);
1236    #else
1237      table[pageno]->attach(*widget, 2, 3, rowno, rowno + 1,      table[pageno]->attach(*widget, 2, 3, rowno, rowno + 1,
1238                            Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);                            Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
1239    #endif
1240    
1241      rowno++;      rowno++;
1242  }  }
1243    
1244  void DimRegionEdit::addHeader(const char* text)  void DimRegionEdit::addString(const char* labelText, Gtk::Label*& label,
1245                                  Gtk::Entry*& widget, Gtk::Button*& button)
1246    {
1247        label = new Gtk::Label(Glib::ustring(labelText) + ":");
1248    #if HAS_GTKMM_ALIGNMENT
1249        label->set_alignment(Gtk::ALIGN_START);
1250    #else
1251        label->set_halign(Gtk::Align::START);
1252    #endif
1253    
1254    #if USE_GTKMM_GRID
1255        table[pageno]->attach(*label, 1, rowno);
1256    #else
1257        table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,
1258                              Gtk::FILL, Gtk::SHRINK);
1259    #endif
1260    
1261        widget = new Gtk::Entry();
1262        button = new Gtk::Button();
1263    
1264        HBox* hbox = new HBox;
1265        hbox->pack_start(*widget);
1266        hbox->pack_start(*button, Gtk::PACK_SHRINK);
1267    
1268    #if USE_GTKMM_GRID
1269        table[pageno]->attach(*hbox, 2, rowno);
1270    #else
1271        table[pageno]->attach(*hbox, 2, 3, rowno, rowno + 1,
1272                              Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
1273    #endif
1274    
1275        rowno++;
1276    }
1277    
1278    Gtk::Label* DimRegionEdit::addHeader(const char* text)
1279  {  {
1280      if (firstRowInBlock < rowno - 1)      if (firstRowInBlock < rowno - 1)
1281      {      {
1282          Gtk::Label* filler = new Gtk::Label("    ");          Gtk::Label* filler = new Gtk::Label("    ");
1283    #if USE_GTKMM_GRID
1284            table[pageno]->attach(*filler, 0, firstRowInBlock);
1285    #else
1286          table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,          table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,
1287                                Gtk::FILL, Gtk::SHRINK);                                Gtk::FILL, Gtk::SHRINK);
1288    #endif
1289      }      }
1290      Glib::ustring str = "<b>";      Glib::ustring str = "<b>";
1291      str += text;      str += text;
1292      str += "</b>";      str += "</b>";
1293      Gtk::Label* label = new Gtk::Label(str);      Gtk::Label* label = new Gtk::Label(str);
1294      label->set_use_markup();      label->set_use_markup();
1295      label->set_alignment(Gtk::ALIGN_LEFT);  #if HAS_GTKMM_ALIGNMENT
1296        label->set_alignment(Gtk::ALIGN_START);
1297    #else
1298        label->set_halign(Gtk::Align::START);
1299    #endif
1300        // on GTKMM 3 there is absolutely no margin by default
1301    #if GTKMM_MAJOR_VERSION >= 3
1302        label->set_margin_top(18);
1303        label->set_margin_bottom(13);
1304    #endif
1305    #if USE_GTKMM_GRID
1306        table[pageno]->attach(*label, 0, rowno, 3);
1307    #else
1308      table[pageno]->attach(*label, 0, 3, rowno, rowno + 1,      table[pageno]->attach(*label, 0, 3, rowno, rowno + 1,
1309                            Gtk::FILL, Gtk::SHRINK);                            Gtk::FILL, Gtk::SHRINK);
1310    #endif
1311      rowno++;      rowno++;
1312      firstRowInBlock = rowno;      firstRowInBlock = rowno;
1313        return label;
1314    }
1315    
1316    void DimRegionEdit::on_show_tooltips_changed() {
1317        const bool b = Settings::singleton()->showTooltips;
1318    
1319        buttonSelectSample.set_has_tooltip(b);
1320        buttonNullSampleReference->set_has_tooltip(b);
1321        wSample->set_has_tooltip(b);
1322    
1323        eEG1StateOptions.on_show_tooltips_changed();
1324        eEG2StateOptions.on_show_tooltips_changed();
1325    
1326        set_has_tooltip(b);
1327  }  }
1328    
1329  void DimRegionEdit::nextPage()  void DimRegionEdit::nextPage()
# Line 486  void DimRegionEdit::nextPage() Line 1331  void DimRegionEdit::nextPage()
1331      if (firstRowInBlock < rowno - 1)      if (firstRowInBlock < rowno - 1)
1332      {      {
1333          Gtk::Label* filler = new Gtk::Label("    ");          Gtk::Label* filler = new Gtk::Label("    ");
1334    #if USE_GTKMM_GRID
1335            table[pageno]->attach(*filler, 0, firstRowInBlock);
1336    #else
1337          table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,          table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,
1338                                Gtk::FILL, Gtk::SHRINK);                                Gtk::FILL, Gtk::SHRINK);
1339    #endif
1340      }      }
1341      pageno++;      pageno++;
1342      rowno = 0;      rowno = 0;
# Line 496  void DimRegionEdit::nextPage() Line 1345  void DimRegionEdit::nextPage()
1345    
1346  void DimRegionEdit::addProp(BoolEntry& boolentry)  void DimRegionEdit::addProp(BoolEntry& boolentry)
1347  {  {
1348    #if USE_GTKMM_GRID
1349        table[pageno]->attach(boolentry.widget, 1, rowno, 2);
1350    #else
1351      table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1,      table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1,
1352                            Gtk::FILL, Gtk::SHRINK);                            Gtk::FILL, Gtk::SHRINK);
1353    #endif
1354        rowno++;
1355    }
1356    
1357    void DimRegionEdit::addProp(BoolEntryPlus6& boolentry)
1358    {
1359    #if USE_GTKMM_GRID
1360        table[pageno]->attach(boolentry.widget, 1, rowno, 2);
1361    #else
1362        table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1,
1363                              Gtk::FILL, Gtk::SHRINK);
1364    #endif
1365      rowno++;      rowno++;
     boolentry.signal_changed_by_user().connect(dimreg_changed_signal.make_slot());  
1366  }  }
1367    
1368  void DimRegionEdit::addProp(LabelWidget& prop)  void DimRegionEdit::addProp(LabelWidget& prop)
1369  {  {
1370    #if USE_GTKMM_GRID
1371        table[pageno]->attach(prop.label, 1, rowno);
1372        table[pageno]->attach(prop.widget, 2, rowno);
1373    #else
1374      table[pageno]->attach(prop.label, 1, 2, rowno, rowno + 1,      table[pageno]->attach(prop.label, 1, 2, rowno, rowno + 1,
1375                            Gtk::FILL, Gtk::SHRINK);                            Gtk::FILL, Gtk::SHRINK);
1376      table[pageno]->attach(prop.widget, 2, 3, rowno, rowno + 1,      table[pageno]->attach(prop.widget, 2, 3, rowno, rowno + 1,
1377                            Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);                            Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
1378    #endif
1379        rowno++;
1380    }
1381    
1382    void DimRegionEdit::addLine(HBox& line)
1383    {
1384    #if USE_GTKMM_GRID
1385        table[pageno]->attach(line, 1, rowno, 2);
1386    #else
1387        table[pageno]->attach(line, 1, 3, rowno, rowno + 1,
1388                              Gtk::FILL, Gtk::SHRINK);
1389    #endif
1390      rowno++;      rowno++;
     prop.signal_changed_by_user().connect(dimreg_changed_signal.make_slot());  
1391  }  }
1392    
1393    void DimRegionEdit::addRightHandSide(Gtk::Widget& widget)
1394    {
1395    #if USE_GTKMM_GRID
1396        table[pageno]->attach(widget, 2, rowno);
1397    #else
1398        table[pageno]->attach(widget, 2, 3, rowno, rowno + 1,
1399                              Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
1400    #endif
1401        rowno++;
1402    }
1403    
1404  void DimRegionEdit::set_dim_region(gig::DimensionRegion* d)  void DimRegionEdit::set_dim_region(gig::DimensionRegion* d)
1405  {  {
1406      dimregion = d;      dimregion = d;
1407        velocity_curve.set_dim_region(d);
1408        release_curve.set_dim_region(d);
1409        cutoff_curve.set_dim_region(d);
1410        crossfade_curve.set_dim_region(d);
1411        lfo1Graph.set_dim_region(d);
1412        lfo2Graph.set_dim_region(d);
1413        lfo3Graph.set_dim_region(d);
1414    
1415      set_sensitive(d);      set_sensitive(d);
1416      if (!d) return;      if (!d) return;
1417    
1418      wSample->set_text(d->pSample ? d->pSample->pInfo->Name.c_str() : "NULL");      update_model++;
1419      eEG1PreAttack.set_ptr(&d->EG1PreAttack);      eEG1PreAttack.set_value(d->EG1PreAttack);
1420      eEG1Attack.set_ptr(&d->EG1Attack);      eEG1Attack.set_value(d->EG1Attack);
1421      eEG1Decay1.set_ptr(&d->EG1Decay1);      eEG1Decay1.set_value(d->EG1Decay1);
1422      eEG1Decay2.set_ptr(&d->EG1Decay2);      eEG1Decay2.set_value(d->EG1Decay2);
1423      eEG1InfiniteSustain.set_ptr(&d->EG1InfiniteSustain);      eEG1InfiniteSustain.set_value(d->EG1InfiniteSustain);
1424      eEG1Sustain.set_ptr(&d->EG1Sustain);      eEG1Sustain.set_value(d->EG1Sustain);
1425      eEG1Release.set_ptr(&d->EG1Release);      eEG1Release.set_value(d->EG1Release);
1426      eEG1Hold.set_ptr(&d->EG1Hold);      eEG1Hold.set_value(d->EG1Hold);
1427      eEG1Controller.set_ptr(&d->EG1Controller);      eEG1Controller.set_value(d->EG1Controller);
1428      eEG1ControllerInvert.set_ptr(&d->EG1ControllerInvert);      eEG1ControllerInvert.set_value(d->EG1ControllerInvert);
1429      eEG1ControllerAttackInfluence.set_ptr(&d->EG1ControllerAttackInfluence);      eEG1ControllerAttackInfluence.set_value(d->EG1ControllerAttackInfluence);
1430      eEG1ControllerDecayInfluence.set_ptr(&d->EG1ControllerDecayInfluence);      eEG1ControllerDecayInfluence.set_value(d->EG1ControllerDecayInfluence);
1431      eEG1ControllerReleaseInfluence.set_ptr(&d->EG1ControllerReleaseInfluence);      eEG1ControllerReleaseInfluence.set_value(d->EG1ControllerReleaseInfluence);
1432      eLFO1Frequency.set_ptr(&d->LFO1Frequency);      eEG1StateOptions.checkBoxAttack.set_value(d->EG1Options.AttackCancel);
1433      eLFO1InternalDepth.set_ptr(&d->LFO1InternalDepth);      eEG1StateOptions.checkBoxAttackHold.set_value(d->EG1Options.AttackHoldCancel);
1434      eLFO1ControlDepth.set_ptr(&d->LFO1ControlDepth);      eEG1StateOptions.checkBoxDecay1.set_value(d->EG1Options.Decay1Cancel);
1435      eLFO1Controller.set_ptr(&d->LFO1Controller);      eEG1StateOptions.checkBoxDecay2.set_value(d->EG1Options.Decay2Cancel);
1436      eLFO1FlipPhase.set_ptr(&d->LFO1FlipPhase);      eEG1StateOptions.checkBoxRelease.set_value(d->EG1Options.ReleaseCancel);
1437      eLFO1Sync.set_ptr(&d->LFO1Sync);      eLFO1Wave.set_value(d->LFO1WaveForm);
1438      eEG2PreAttack.set_ptr(&d->EG2PreAttack);      eLFO1Frequency.set_value(d->LFO1Frequency);
1439      eEG2Attack.set_ptr(&d->EG2Attack);      eLFO1Phase.set_value(d->LFO1Phase);
1440      eEG2Decay1.set_ptr(&d->EG2Decay1);      eLFO1InternalDepth.set_value(d->LFO1InternalDepth);
1441      eEG2Decay2.set_ptr(&d->EG2Decay2);      eLFO1ControlDepth.set_value(d->LFO1ControlDepth);
1442      eEG2InfiniteSustain.set_ptr(&d->EG2InfiniteSustain);      eLFO1Controller.set_value(d->LFO1Controller);
1443      eEG2Sustain.set_ptr(&d->EG2Sustain);      eLFO1FlipPhase.set_value(d->LFO1FlipPhase);
1444      eEG2Release.set_ptr(&d->EG2Release);      eLFO1Sync.set_value(d->LFO1Sync);
1445      eEG2Controller.set_ptr(&d->EG2Controller);      eEG2PreAttack.set_value(d->EG2PreAttack);
1446      eEG2ControllerInvert.set_ptr(&d->EG2ControllerInvert);      eEG2Attack.set_value(d->EG2Attack);
1447      eEG2ControllerAttackInfluence.set_ptr(&d->EG2ControllerAttackInfluence);      eEG2Decay1.set_value(d->EG2Decay1);
1448      eEG2ControllerDecayInfluence.set_ptr(&d->EG2ControllerDecayInfluence);      eEG2Decay2.set_value(d->EG2Decay2);
1449      eEG2ControllerReleaseInfluence.set_ptr(&d->EG2ControllerReleaseInfluence);      eEG2InfiniteSustain.set_value(d->EG2InfiniteSustain);
1450      eLFO2Frequency.set_ptr(&d->LFO2Frequency);      eEG2Sustain.set_value(d->EG2Sustain);
1451      eLFO2InternalDepth.set_ptr(&d->LFO2InternalDepth);      eEG2Release.set_value(d->EG2Release);
1452      eLFO2ControlDepth.set_ptr(&d->LFO2ControlDepth);      eEG2Controller.set_value(d->EG2Controller);
1453      eLFO2Controller.set_ptr(&d->LFO2Controller);      eEG2ControllerInvert.set_value(d->EG2ControllerInvert);
1454      eLFO2FlipPhase.set_ptr(&d->LFO2FlipPhase);      eEG2ControllerAttackInfluence.set_value(d->EG2ControllerAttackInfluence);
1455      eLFO2Sync.set_ptr(&d->LFO2Sync);      eEG2ControllerDecayInfluence.set_value(d->EG2ControllerDecayInfluence);
1456      eEG3Attack.set_ptr(&d->EG3Attack);      eEG2ControllerReleaseInfluence.set_value(d->EG2ControllerReleaseInfluence);
1457      eEG3Depth.set_ptr(&d->EG3Depth);      eEG2StateOptions.checkBoxAttack.set_value(d->EG2Options.AttackCancel);
1458      eLFO3Frequency.set_ptr(&d->LFO3Frequency);      eEG2StateOptions.checkBoxAttackHold.set_value(d->EG2Options.AttackHoldCancel);
1459      eLFO3InternalDepth.set_ptr(&d->LFO3InternalDepth);      eEG2StateOptions.checkBoxDecay1.set_value(d->EG2Options.Decay1Cancel);
1460      eLFO3ControlDepth.set_ptr(&d->LFO3ControlDepth);      eEG2StateOptions.checkBoxDecay2.set_value(d->EG2Options.Decay2Cancel);
1461      eLFO3Controller.set_ptr(&d->LFO3Controller);      eEG2StateOptions.checkBoxRelease.set_value(d->EG2Options.ReleaseCancel);
1462      eLFO3Sync.set_ptr(&d->LFO3Sync);      eLFO2Wave.set_value(d->LFO2WaveForm);
1463      eVCFEnabled.set_ptr(&d->VCFEnabled);      eLFO2Frequency.set_value(d->LFO2Frequency);
1464      eVCFType.set_ptr(&d->VCFType);      eLFO2Phase.set_value(d->LFO2Phase);
1465      eVCFCutoffController.set_ptr(&d->VCFCutoffController);      eLFO2InternalDepth.set_value(d->LFO2InternalDepth);
1466      eVCFCutoffControllerInvert.set_ptr(&d->VCFCutoffControllerInvert);      eLFO2ControlDepth.set_value(d->LFO2ControlDepth);
1467      eVCFCutoff.set_ptr(&d->VCFCutoff);      eLFO2Controller.set_value(d->LFO2Controller);
1468      eVCFVelocityCurve.set_ptr(&d->VCFVelocityCurve);      eLFO2FlipPhase.set_value(d->LFO2FlipPhase);
1469      eVCFVelocityScale.set_ptr(&d->VCFVelocityScale);      eLFO2Sync.set_value(d->LFO2Sync);
1470      eVCFVelocityDynamicRange.set_ptr(&d->VCFVelocityDynamicRange);      eEG3Attack.set_value(d->EG3Attack);
1471      eVCFResonance.set_ptr(&d->VCFResonance);      eEG3Depth.set_value(d->EG3Depth);
1472      eVCFResonanceDynamic.set_ptr(&d->VCFResonanceDynamic);      eLFO3Wave.set_value(d->LFO3WaveForm);
1473      eVCFResonanceController.set_ptr(&d->VCFResonanceController);      eLFO3Frequency.set_value(d->LFO3Frequency);
1474      eVCFKeyboardTracking.set_ptr(&d->VCFKeyboardTracking);      eLFO3Phase.set_value(d->LFO3Phase);
1475      eVCFKeyboardTrackingBreakpoint.set_ptr(&d->VCFKeyboardTrackingBreakpoint);      eLFO3InternalDepth.set_value(d->LFO3InternalDepth);
1476      eVelocityResponseCurve.set_ptr(&d->VelocityResponseCurve);      eLFO3ControlDepth.set_value(d->LFO3ControlDepth);
1477      eVelocityResponseDepth.set_ptr(&d->VelocityResponseDepth);      eLFO3Controller.set_value(d->LFO3Controller);
1478      eVelocityResponseCurveScaling.set_ptr(&d->VelocityResponseCurveScaling);      eLFO3FlipPhase.set_value(d->LFO3FlipPhase);
1479      eReleaseVelocityResponseCurve.set_ptr(&d->ReleaseVelocityResponseCurve);      eLFO3Sync.set_value(d->LFO3Sync);
1480      eReleaseVelocityResponseDepth.set_ptr(&d->ReleaseVelocityResponseDepth);      eVCFEnabled.set_value(d->VCFEnabled);
1481      eReleaseTriggerDecay.set_ptr(&d->ReleaseTriggerDecay);      eVCFType.set_value(d->VCFType);
1482        eVCFCutoffController.set_value(d->VCFCutoffController);
1483      eCrossfade_in_start.set_ptr(0);      eVCFCutoffControllerInvert.set_value(d->VCFCutoffControllerInvert);
1484      eCrossfade_in_end.set_ptr(0);      eVCFCutoff.set_value(d->VCFCutoff);
1485      eCrossfade_out_start.set_ptr(0);      eVCFVelocityCurve.set_value(d->VCFVelocityCurve);
1486      eCrossfade_out_end.set_ptr(0);      eVCFVelocityScale.set_value(d->VCFVelocityScale);
1487      eCrossfade_in_start.set_ptr(&d->Crossfade.in_start);      eVCFVelocityDynamicRange.set_value(d->VCFVelocityDynamicRange);
1488      eCrossfade_in_end.set_ptr(&d->Crossfade.in_end);      eVCFResonance.set_value(d->VCFResonance);
1489      eCrossfade_out_start.set_ptr(&d->Crossfade.out_start);      eVCFResonanceDynamic.set_value(d->VCFResonanceDynamic);
1490      eCrossfade_out_end.set_ptr(&d->Crossfade.out_end);      eVCFResonanceController.set_value(d->VCFResonanceController);
1491        eVCFKeyboardTracking.set_value(d->VCFKeyboardTracking);
1492      ePitchTrack.set_ptr(&d->PitchTrack);      eVCFKeyboardTrackingBreakpoint.set_value(d->VCFKeyboardTrackingBreakpoint);
1493      eDimensionBypass.set_ptr(&d->DimensionBypass);      eVelocityResponseCurve.set_value(d->VelocityResponseCurve);
1494      ePan.set_ptr(&d->Pan);      eVelocityResponseDepth.set_value(d->VelocityResponseDepth);
1495      eSelfMask.set_ptr(&d->SelfMask);      eVelocityResponseCurveScaling.set_value(d->VelocityResponseCurveScaling);
1496      eAttenuationController.set_ptr(&d->AttenuationController);      eReleaseVelocityResponseCurve.set_value(d->ReleaseVelocityResponseCurve);
1497      eInvertAttenuationController.set_ptr(&d->InvertAttenuationController);      eReleaseVelocityResponseDepth.set_value(d->ReleaseVelocityResponseDepth);
1498      eAttenuationControllerThreshold.set_ptr(&d->AttenuationControllerThreshold);      eReleaseTriggerDecay.set_value(d->ReleaseTriggerDecay);
1499      eChannelOffset.set_ptr(&d->ChannelOffset);      eCrossfade_in_start.set_value(d->Crossfade.in_start);
1500      eSustainDefeat.set_ptr(&d->SustainDefeat);      eCrossfade_in_end.set_value(d->Crossfade.in_end);
1501      eMSDecode.set_ptr(&d->MSDecode);      eCrossfade_out_start.set_value(d->Crossfade.out_start);
1502      eSampleStartOffset.set_ptr(&d->SampleStartOffset);      eCrossfade_out_end.set_value(d->Crossfade.out_end);
1503      eUnityNote.set_ptr(&d->UnityNote);      ePitchTrack.set_value(d->PitchTrack);
1504      eFineTune.set_ptr(&d->FineTune);      eSustainReleaseTrigger.set_value(d->SustainReleaseTrigger);
1505      eGain.set_ptr(&d->Gain);      eNoNoteOffReleaseTrigger.set_value(d->NoNoteOffReleaseTrigger);
1506      eGainPlus6.set_ptr(&d->Gain);      eDimensionBypass.set_value(d->DimensionBypass);
1507        ePan.set_value(d->Pan);
1508        eSelfMask.set_value(d->SelfMask);
1509        eAttenuationController.set_value(d->AttenuationController);
1510        eInvertAttenuationController.set_value(d->InvertAttenuationController);
1511        eAttenuationControllerThreshold.set_value(d->AttenuationControllerThreshold);
1512        eChannelOffset.set_value(d->ChannelOffset);
1513        eSustainDefeat.set_value(d->SustainDefeat);
1514        eMSDecode.set_value(d->MSDecode);
1515        eSampleStartOffset.set_value(d->SampleStartOffset);
1516        eUnityNote.set_value(d->UnityNote);
1517        // show sample group name
1518        {
1519            Glib::ustring s = "---";
1520            if (d->pSample && d->pSample->GetGroup())
1521                s = d->pSample->GetGroup()->Name;
1522            eSampleGroup.text.set_text(s);
1523        }
1524        // assemble sample format info string
1525        {
1526            Glib::ustring s;
1527            if (d->pSample) {
1528                switch (d->pSample->Channels) {
1529                    case 1: s = _("Mono"); break;
1530                    case 2: s = _("Stereo"); break;
1531                    default:
1532                        s = ToString(d->pSample->Channels) + _(" audio channels");
1533                        break;
1534                }
1535                s += " " + ToString(d->pSample->BitDepth) + " Bits";
1536                s += " " + ToString(d->pSample->SamplesPerSecond/1000) + "."
1537                          + ToString((d->pSample->SamplesPerSecond%1000)/100) + " kHz";
1538            } else {
1539                s = _("No sample assigned to this dimension region.");
1540            }
1541            eSampleFormatInfo.text.set_text(s);
1542        }
1543        // generate sample's memory address pointer string
1544        {
1545            Glib::ustring s;
1546            if (d->pSample) {
1547                char buf[64] = {};
1548                snprintf(buf, sizeof(buf), "%p", d->pSample);
1549                s = buf;
1550            } else {
1551                s = "---";
1552            }
1553            eSampleID.text.set_text(s);
1554        }
1555        // generate raw wave form data CRC-32 checksum string
1556        {
1557            Glib::ustring s = "---";
1558            if (d->pSample) {
1559                char buf[64] = {};
1560                snprintf(buf, sizeof(buf), "%x", d->pSample->GetWaveDataCRC32Checksum());
1561                s = buf;
1562            }
1563            eChecksum.text.set_text(s);
1564        }
1565        buttonSelectSample.set_sensitive(d && d->pSample);
1566        eFineTune.set_value(d->FineTune);
1567        eGain.set_value(d->Gain);
1568        eGainPlus6.set_value(d->Gain);
1569        eSampleLoopEnabled.set_value(d->SampleLoops);
1570        eSampleLoopType.set_value(
1571            d->SampleLoops ? d->pSampleLoops[0].LoopType : 0);
1572        eSampleLoopStart.set_value(
1573            d->SampleLoops ? d->pSampleLoops[0].LoopStart : 0);
1574        eSampleLoopLength.set_value(
1575            d->SampleLoops ? d->pSampleLoops[0].LoopLength : 0);
1576        eSampleLoopInfinite.set_value(
1577            d->pSample && d->pSample->LoopPlayCount == 0);
1578        eSampleLoopPlayCount.set_value(
1579            d->pSample ? d->pSample->LoopPlayCount : 0);
1580        update_model--;
1581    
1582      eSampleLoopEnabled.set_active(d->SampleLoops);      wSample->set_text(d->pSample ? gig_to_utf8(d->pSample->pInfo->Name) :
1583      updateLoopElements();                        _("NULL"));
1584    
1585        update_loop_elements();
1586      VCFEnabled_toggled();      VCFEnabled_toggled();
1587  }  }
1588    
1589    
1590  void DimRegionEdit::VCFEnabled_toggled()  void DimRegionEdit::VCFEnabled_toggled()
1591  {  {
1592      bool sensitive = eVCFEnabled.get_active();      bool sensitive = eVCFEnabled.get_value();
1593      eVCFType.set_sensitive(sensitive);      eVCFType.set_sensitive(sensitive);
1594      eVCFCutoffController.set_sensitive(sensitive);      eVCFCutoffController.set_sensitive(sensitive);
1595      eVCFVelocityCurve.set_sensitive(sensitive);      eVCFVelocityCurve.set_sensitive(sensitive);
1596      eVCFVelocityScale.set_sensitive(sensitive);      eVCFVelocityScale.set_sensitive(sensitive);
1597      eVCFVelocityDynamicRange.set_sensitive(sensitive);      eVCFVelocityDynamicRange.set_sensitive(sensitive);
1598        cutoff_curve.set_sensitive(sensitive);
1599      eVCFResonance.set_sensitive(sensitive);      eVCFResonance.set_sensitive(sensitive);
1600      eVCFResonanceController.set_sensitive(sensitive);      eVCFResonanceController.set_sensitive(sensitive);
1601      eVCFKeyboardTracking.set_sensitive(sensitive);      eVCFKeyboardTracking.set_sensitive(sensitive);
1602      eVCFKeyboardTrackingBreakpoint.set_sensitive(sensitive);      eVCFKeyboardTrackingBreakpoint.set_sensitive(sensitive);
1603        lEG2->set_sensitive(sensitive);
1604      eEG2PreAttack.set_sensitive(sensitive);      eEG2PreAttack.set_sensitive(sensitive);
1605      eEG2Attack.set_sensitive(sensitive);      eEG2Attack.set_sensitive(sensitive);
1606      eEG2Decay1.set_sensitive(sensitive);      eEG2Decay1.set_sensitive(sensitive);
# Line 638  void DimRegionEdit::VCFEnabled_toggled() Line 1611  void DimRegionEdit::VCFEnabled_toggled()
1611      eEG2ControllerAttackInfluence.set_sensitive(sensitive);      eEG2ControllerAttackInfluence.set_sensitive(sensitive);
1612      eEG2ControllerDecayInfluence.set_sensitive(sensitive);      eEG2ControllerDecayInfluence.set_sensitive(sensitive);
1613      eEG2ControllerReleaseInfluence.set_sensitive(sensitive);      eEG2ControllerReleaseInfluence.set_sensitive(sensitive);
1614        eEG2StateOptions.set_sensitive(sensitive);
1615        lLFO2->set_sensitive(sensitive);
1616        eLFO2Wave.set_sensitive(sensitive);
1617      eLFO2Frequency.set_sensitive(sensitive);      eLFO2Frequency.set_sensitive(sensitive);
1618        eLFO2Phase.set_sensitive(sensitive);
1619      eLFO2InternalDepth.set_sensitive(sensitive);      eLFO2InternalDepth.set_sensitive(sensitive);
1620      eLFO2ControlDepth.set_sensitive(sensitive);      eLFO2ControlDepth.set_sensitive(sensitive);
1621      eLFO2Controller.set_sensitive(sensitive);      eLFO2Controller.set_sensitive(sensitive);
1622      eLFO2FlipPhase.set_sensitive(sensitive);      eLFO2FlipPhase.set_sensitive(sensitive);
1623      eLFO2Sync.set_sensitive(sensitive);      eLFO2Sync.set_sensitive(sensitive);
1624        lfo2Graph.set_sensitive(sensitive);
1625      if (sensitive) {      if (sensitive) {
1626          VCFCutoffController_changed();          VCFCutoffController_changed();
1627          VCFResonanceController_changed();          VCFResonanceController_changed();
# Line 664  void DimRegionEdit::VCFEnabled_toggled() Line 1642  void DimRegionEdit::VCFEnabled_toggled()
1642    
1643  void DimRegionEdit::VCFCutoffController_changed()  void DimRegionEdit::VCFCutoffController_changed()
1644  {  {
1645      int rowno = eVCFCutoffController.get_active_row_number();      gig::vcf_cutoff_ctrl_t ctrl = eVCFCutoffController.get_value();
1646      bool hasController = rowno != 0 && rowno != 1;      bool hasController = ctrl != gig::vcf_cutoff_ctrl_none && ctrl != gig::vcf_cutoff_ctrl_none2;
1647    
1648      eVCFCutoffControllerInvert.set_sensitive(hasController);      eVCFCutoffControllerInvert.set_sensitive(hasController);
1649      eVCFCutoff.set_sensitive(!hasController);      eVCFCutoff.set_sensitive(!hasController);
1650      eVCFResonanceDynamic.set_sensitive(!hasController);      eVCFResonanceDynamic.set_sensitive(!hasController);
1651      eVCFVelocityScale.label.set_text(hasController ? "Minimum cutoff:" :      eVCFVelocityScale.label.set_text(hasController ? _("Minimum cutoff:") :
1652                                       "Velocity scale:");                                       _("Velocity scale:"));
1653  }  }
1654    
1655  void DimRegionEdit::VCFResonanceController_changed()  void DimRegionEdit::VCFResonanceController_changed()
1656  {  {
1657      bool hasController = eVCFResonanceController.get_active_row_number() != 0;      bool hasController = eVCFResonanceController.get_value() != gig::vcf_res_ctrl_none;
1658      eVCFResonance.set_sensitive(!hasController);      eVCFResonance.set_sensitive(!hasController);
1659  }  }
1660    
1661  void DimRegionEdit::EG1InfiniteSustain_toggled()  void DimRegionEdit::EG1InfiniteSustain_toggled()
1662  {  {
1663      bool infSus = eEG1InfiniteSustain.get_active();      bool infSus = eEG1InfiniteSustain.get_value();
1664      eEG1Decay2.set_sensitive(!infSus);      eEG1Decay2.set_sensitive(!infSus);
1665  }  }
1666    
1667  void DimRegionEdit::EG2InfiniteSustain_toggled()  void DimRegionEdit::EG2InfiniteSustain_toggled()
1668  {  {
1669      bool infSus = eEG2InfiniteSustain.get_active();      bool infSus = eEG2InfiniteSustain.get_value();
1670      eEG2Decay2.set_sensitive(!infSus);      eEG2Decay2.set_sensitive(!infSus);
1671  }  }
1672    
1673  void DimRegionEdit::EG1Controller_changed()  void DimRegionEdit::EG1Controller_changed()
1674  {  {
1675      bool hasController = eEG1Controller.get_active_row_number() != 0;      bool hasController = eEG1Controller.get_value().type != gig::leverage_ctrl_t::type_none;
1676      eEG1ControllerInvert.set_sensitive(hasController);      eEG1ControllerInvert.set_sensitive(hasController);
1677  }  }
1678    
1679  void DimRegionEdit::EG2Controller_changed()  void DimRegionEdit::EG2Controller_changed()
1680  {  {
1681      bool hasController = eEG2Controller.get_active_row_number() != 0;      bool hasController = eEG2Controller.get_value().type != gig::leverage_ctrl_t::type_none;
1682      eEG2ControllerInvert.set_sensitive(hasController);      eEG2ControllerInvert.set_sensitive(hasController);
1683  }  }
1684    
1685  void DimRegionEdit::AttenuationController_changed()  void DimRegionEdit::AttenuationController_changed()
1686  {  {
1687      bool hasController = eAttenuationController.get_active_row_number() != 0;      bool hasController =
1688            eAttenuationController.get_value().type != gig::leverage_ctrl_t::type_none;
1689      eInvertAttenuationController.set_sensitive(hasController);      eInvertAttenuationController.set_sensitive(hasController);
1690      eAttenuationControllerThreshold.set_sensitive(hasController);      eAttenuationControllerThreshold.set_sensitive(hasController);
1691      eCrossfade_in_start.set_sensitive(hasController);      eCrossfade_in_start.set_sensitive(hasController);
1692      eCrossfade_in_end.set_sensitive(hasController);      eCrossfade_in_end.set_sensitive(hasController);
1693      eCrossfade_out_start.set_sensitive(hasController);      eCrossfade_out_start.set_sensitive(hasController);
1694      eCrossfade_out_end.set_sensitive(hasController);      eCrossfade_out_end.set_sensitive(hasController);
1695        crossfade_curve.set_sensitive(hasController);
1696  }  }
1697    
1698  void DimRegionEdit::LFO1Controller_changed()  void DimRegionEdit::LFO1Controller_changed()
1699  {  {
1700      int rowno = eLFO1Controller.get_active_row_number();      gig::lfo1_ctrl_t ctrl = eLFO1Controller.get_value();
1701      eLFO1ControlDepth.set_sensitive(rowno != 0);      eLFO1ControlDepth.set_sensitive(ctrl != gig::lfo1_ctrl_internal);
1702      eLFO1InternalDepth.set_sensitive(rowno != 1 && rowno != 2);      eLFO1InternalDepth.set_sensitive(ctrl != gig::lfo1_ctrl_modwheel &&
1703                                         ctrl != gig::lfo1_ctrl_breath);
1704  }  }
1705    
1706  void DimRegionEdit::LFO2Controller_changed()  void DimRegionEdit::LFO2Controller_changed()
1707  {  {
1708      int rowno = eLFO2Controller.get_active_row_number();      gig::lfo2_ctrl_t ctrl = eLFO2Controller.get_value();
1709      eLFO2ControlDepth.set_sensitive(rowno != 0);      eLFO2ControlDepth.set_sensitive(ctrl != gig::lfo2_ctrl_internal);
1710      eLFO2InternalDepth.set_sensitive(rowno != 1 && rowno != 2);      eLFO2InternalDepth.set_sensitive(ctrl != gig::lfo2_ctrl_modwheel &&
1711                                         ctrl != gig::lfo2_ctrl_foot);
1712  }  }
1713    
1714  void DimRegionEdit::LFO3Controller_changed()  void DimRegionEdit::LFO3Controller_changed()
1715  {  {
1716      int rowno = eLFO3Controller.get_active_row_number();      gig::lfo3_ctrl_t ctrl = eLFO3Controller.get_value();
1717      eLFO3ControlDepth.set_sensitive(rowno != 0);      eLFO3ControlDepth.set_sensitive(ctrl != gig::lfo3_ctrl_internal);
1718      eLFO3InternalDepth.set_sensitive(rowno != 1 && rowno != 2);      eLFO3InternalDepth.set_sensitive(ctrl != gig::lfo3_ctrl_modwheel &&
1719                                         ctrl != gig::lfo3_ctrl_aftertouch);
1720  }  }
1721    
1722  void DimRegionEdit::crossfade1_changed()  void DimRegionEdit::crossfade1_changed()
1723  {  {
1724      double c1 = eCrossfade_in_start.get_value();      update_model++;
1725      double c2 = eCrossfade_in_end.get_value();      eCrossfade_in_end.set_value(dimregion->Crossfade.in_end);
1726      if (c1 > c2) eCrossfade_in_end.set_value(c1);      eCrossfade_out_start.set_value(dimregion->Crossfade.out_start);
1727        eCrossfade_out_end.set_value(dimregion->Crossfade.out_end);
1728        update_model--;
1729  }  }
1730    
1731  void DimRegionEdit::crossfade2_changed()  void DimRegionEdit::crossfade2_changed()
1732  {  {
1733      double c1 = eCrossfade_in_start.get_value();      update_model++;
1734      double c2 = eCrossfade_in_end.get_value();      eCrossfade_in_start.set_value(dimregion->Crossfade.in_start);
1735      double c3 = eCrossfade_out_start.get_value();      eCrossfade_out_start.set_value(dimregion->Crossfade.out_start);
1736        eCrossfade_out_end.set_value(dimregion->Crossfade.out_end);
1737      if (c2 < c1) eCrossfade_in_start.set_value(c2);      update_model--;
     if (c2 > c3) eCrossfade_out_start.set_value(c2);  
1738  }  }
1739    
1740  void DimRegionEdit::crossfade3_changed()  void DimRegionEdit::crossfade3_changed()
1741  {  {
1742      double c2 = eCrossfade_in_end.get_value();      update_model++;
1743      double c3 = eCrossfade_out_start.get_value();      eCrossfade_in_start.set_value(dimregion->Crossfade.in_start);
1744      double c4 = eCrossfade_out_end.get_value();      eCrossfade_in_end.set_value(dimregion->Crossfade.in_end);
1745        eCrossfade_out_end.set_value(dimregion->Crossfade.out_end);
1746      if (c3 < c2) eCrossfade_in_end.set_value(c3);      update_model--;
     if (c3 > c4) eCrossfade_out_end.set_value(c3);  
1747  }  }
1748    
1749  void DimRegionEdit::crossfade4_changed()  void DimRegionEdit::crossfade4_changed()
1750  {  {
1751      double c3 = eCrossfade_out_start.get_value();      update_model++;
1752      double c4 = eCrossfade_out_end.get_value();      eCrossfade_in_start.set_value(dimregion->Crossfade.in_start);
1753        eCrossfade_in_end.set_value(dimregion->Crossfade.in_end);
1754        eCrossfade_out_start.set_value(dimregion->Crossfade.out_start);
1755        update_model--;
1756    }
1757    
1758    void DimRegionEdit::update_loop_elements()
1759    {
1760        update_model++;
1761        const bool active = eSampleLoopEnabled.get_value();
1762        eSampleLoopStart.set_sensitive(active);
1763        eSampleLoopLength.set_sensitive(active);
1764        eSampleLoopType.set_sensitive(active);
1765        eSampleLoopInfinite.set_sensitive(active && dimregion && dimregion->pSample);
1766        // sample loop shall never be longer than the actual sample size
1767        loop_start_changed();
1768        loop_length_changed();
1769        eSampleLoopStart.set_value(
1770            dimregion->SampleLoops ? dimregion->pSampleLoops[0].LoopStart : 0);
1771        eSampleLoopLength.set_value(
1772            dimregion->SampleLoops ? dimregion->pSampleLoops[0].LoopLength : 0);
1773    
1774      if (c4 < c3) eCrossfade_out_start.set_value(c4);      eSampleLoopInfinite.set_value(
1775            dimregion->pSample && dimregion->pSample->LoopPlayCount == 0);
1776    
1777        loop_infinite_toggled();
1778        update_model--;
1779  }  }
1780    
1781  void DimRegionEdit::loop_enabled_toggled()  void DimRegionEdit::loop_start_changed() {
1782        if (dimregion && dimregion->SampleLoops) {
1783            eSampleLoopLength.set_upper(dimregion->pSample ?
1784                                        dimregion->pSample->SamplesTotal -
1785                                        dimregion->pSampleLoops[0].LoopStart : 0);
1786        }
1787    }
1788    
1789    void DimRegionEdit::loop_length_changed() {
1790        if (dimregion && dimregion->SampleLoops) {
1791            eSampleLoopStart.set_upper(dimregion->pSample ?
1792                                       dimregion->pSample->SamplesTotal -
1793                                       dimregion->pSampleLoops[0].LoopLength : 0);
1794        }
1795    }
1796    
1797    void DimRegionEdit::loop_infinite_toggled() {
1798        eSampleLoopPlayCount.set_sensitive(
1799            dimregion && dimregion->pSample &&
1800            !eSampleLoopInfinite.get_value() &&
1801            eSampleLoopEnabled.get_value()
1802        );
1803        update_model++;
1804        eSampleLoopPlayCount.set_value(
1805            dimregion->pSample ? dimregion->pSample->LoopPlayCount : 0);
1806        update_model--;
1807    }
1808    
1809    bool DimRegionEdit::set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop)
1810    {
1811        bool result = false;
1812        for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimregs.begin();
1813             itDimReg != dimregs.end(); ++itDimReg)
1814        {
1815            result |= set_sample(*itDimReg, sample, copy_sample_unity, copy_sample_tune, copy_sample_loop);
1816        }
1817        return result;
1818    }
1819    
1820    bool DimRegionEdit::set_sample(gig::DimensionRegion* dimreg, gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop)
1821  {  {
1822      const bool active = eSampleLoopEnabled.get_active();      if (dimreg) {
1823      if (active) {          //TODO: we should better move the code from MainWindow::on_sample_label_drop_drag_data_received() here
1824    
1825            // currently commented because we're sending a similar signal in MainWindow::on_sample_label_drop_drag_data_received()
1826            //DimRegionChangeGuard(this, dimregion);
1827    
1828            // make sure stereo samples always are the same in both
1829            // dimregs in the samplechannel dimension
1830            int nbDimregs = 1;
1831            gig::DimensionRegion* d[2] = { dimreg, 0 };
1832            if (sample->Channels == 2) {
1833                gig::Region* region = dimreg->GetParent();
1834    
1835                int bitcount = 0;
1836                int stereo_bit = 0;
1837                for (int dim = 0 ; dim < region->Dimensions ; dim++) {
1838                    if (region->pDimensionDefinitions[dim].dimension == gig::dimension_samplechannel) {
1839                        stereo_bit = 1 << bitcount;
1840                        break;
1841                    }
1842                    bitcount += region->pDimensionDefinitions[dim].bits;
1843                }
1844    
1845                if (stereo_bit) {
1846                    int dimregno;
1847                    for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
1848                        if (region->pDimensionRegions[dimregno] == dimreg) {
1849                            break;
1850                        }
1851                    }
1852                    d[0] = region->pDimensionRegions[dimregno & ~stereo_bit];
1853                    d[1] = region->pDimensionRegions[dimregno | stereo_bit];
1854                    nbDimregs = 2;
1855                }
1856            }
1857    
1858            gig::Sample* oldref = dimreg->pSample;
1859    
1860            for (int i = 0 ; i < nbDimregs ; i++) {
1861                d[i]->pSample = sample;
1862    
1863                // copy sample information from Sample to DimensionRegion
1864                if (copy_sample_unity)
1865                    d[i]->UnityNote = sample->MIDIUnityNote;
1866                if (copy_sample_tune)
1867                    d[i]->FineTune = sample->FineTune;
1868                if (copy_sample_loop) {
1869                    int loops = sample->Loops ? 1 : 0;
1870                    while (d[i]->SampleLoops > loops) {
1871                        d[i]->DeleteSampleLoop(&d[i]->pSampleLoops[0]);
1872                    }
1873                    while (d[i]->SampleLoops < sample->Loops) {
1874                        DLS::sample_loop_t loop;
1875                        d[i]->AddSampleLoop(&loop);
1876                    }
1877                    if (loops) {
1878                        d[i]->pSampleLoops[0].Size = sizeof(DLS::sample_loop_t);
1879                        d[i]->pSampleLoops[0].LoopType = sample->LoopType;
1880                        d[i]->pSampleLoops[0].LoopStart = sample->LoopStart;
1881                        d[i]->pSampleLoops[0].LoopLength = sample->LoopEnd - sample->LoopStart + 1;
1882                    }
1883                }
1884            }
1885    
1886            // update ui
1887            update_model++;
1888            wSample->set_text(gig_to_utf8(dimreg->pSample->pInfo->Name));
1889            eUnityNote.set_value(dimreg->UnityNote);
1890            eFineTune.set_value(dimreg->FineTune);
1891            eSampleLoopEnabled.set_value(dimreg->SampleLoops);
1892            update_loop_elements();
1893            update_model--;
1894    
1895            sample_ref_changed_signal.emit(oldref, sample);
1896            return true;
1897        }
1898        return false;
1899    }
1900    
1901    sigc::signal<void, gig::DimensionRegion*>& DimRegionEdit::signal_dimreg_to_be_changed() {
1902        return dimreg_to_be_changed_signal;
1903    }
1904    
1905    sigc::signal<void, gig::DimensionRegion*>& DimRegionEdit::signal_dimreg_changed() {
1906        return dimreg_changed_signal;
1907    }
1908    
1909    sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& DimRegionEdit::signal_sample_ref_changed() {
1910        return sample_ref_changed_signal;
1911    }
1912    
1913    
1914    void DimRegionEdit::set_UnityNote(gig::DimensionRegion& d, uint8_t value)
1915    {
1916        d.UnityNote = value;
1917    }
1918    
1919    void DimRegionEdit::set_FineTune(gig::DimensionRegion& d, int16_t value)
1920    {
1921        d.FineTune = value;
1922    }
1923    
1924    void DimRegionEdit::set_Crossfade_in_start(gig::DimensionRegion& d,
1925                                               uint8_t value)
1926    {
1927        d.Crossfade.in_start = value;
1928        if (d.Crossfade.in_end < value) set_Crossfade_in_end(d, value);
1929    }
1930    
1931    void DimRegionEdit::set_Crossfade_in_end(gig::DimensionRegion& d,
1932                                             uint8_t value)
1933    {
1934        d.Crossfade.in_end = value;
1935        if (value < d.Crossfade.in_start) set_Crossfade_in_start(d, value);
1936        if (value > d.Crossfade.out_start) set_Crossfade_out_start(d, value);
1937    }
1938    
1939    void DimRegionEdit::set_Crossfade_out_start(gig::DimensionRegion& d,
1940                                                uint8_t value)
1941    {
1942        d.Crossfade.out_start = value;
1943        if (value < d.Crossfade.in_end) set_Crossfade_in_end(d, value);
1944        if (value > d.Crossfade.out_end) set_Crossfade_out_end(d, value);
1945    }
1946    
1947    void DimRegionEdit::set_Crossfade_out_end(gig::DimensionRegion& d,
1948                                              uint8_t value)
1949    {
1950        d.Crossfade.out_end = value;
1951        if (value < d.Crossfade.out_start) set_Crossfade_out_start(d, value);
1952    }
1953    
1954    void DimRegionEdit::set_Gain(gig::DimensionRegion& d, int32_t value)
1955    {
1956        d.SetGain(value);
1957    }
1958    
1959    void DimRegionEdit::set_LoopEnabled(gig::DimensionRegion& d, bool value)
1960    {
1961        if (value) {
1962          // create a new sample loop in case there is none yet          // create a new sample loop in case there is none yet
1963          if (!dimregion->SampleLoops) {          if (!d.SampleLoops) {
1964                DimRegionChangeGuard(this, &d);
1965    
1966              DLS::sample_loop_t loop;              DLS::sample_loop_t loop;
1967              loop.LoopType   = gig::loop_type_normal;              loop.LoopType = gig::loop_type_normal;
1968              // loop the whole sample by default              // loop the whole sample by default
1969              loop.LoopStart  = 0;              loop.LoopStart  = 0;
1970              loop.LoopLength =              loop.LoopLength =
1971                  (dimregion->pSample) ? dimregion->pSample->GetSize() : 0;                  (d.pSample) ? d.pSample->SamplesTotal : 0;
1972              dimregion->AddSampleLoop(&loop);              d.AddSampleLoop(&loop);
             dimreg_changed_signal();  
1973          }          }
1974      } else {      } else {
1975          if (dimregion->SampleLoops) {          if (d.SampleLoops) {
1976                DimRegionChangeGuard(this, &d);
1977    
1978              // delete ALL existing sample loops              // delete ALL existing sample loops
1979              while (dimregion->SampleLoops) {              while (d.SampleLoops) {
1980                  dimregion->DeleteSampleLoop(&dimregion->pSampleLoops[0]);                  d.DeleteSampleLoop(&d.pSampleLoops[0]);
1981              }              }
             dimreg_changed_signal();  
1982          }          }
1983      }      }
     updateLoopElements();  
1984  }  }
1985    
1986  void DimRegionEdit::updateLoopElements()  void DimRegionEdit::set_LoopType(gig::DimensionRegion& d, uint32_t value)
1987  {  {
1988      const bool active = eSampleLoopEnabled.get_active();      if (d.SampleLoops) d.pSampleLoops[0].LoopType = value;
1989      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);  
1990    
1991      if (dimregion && dimregion->SampleLoops) {  void DimRegionEdit::set_LoopStart(gig::DimensionRegion& d, uint32_t value)
1992          eSampleLoopStart.set_ptr(&dimregion->pSampleLoops[0].LoopStart);  {
1993          eSampleLoopLength.set_ptr(&dimregion->pSampleLoops[0].LoopLength);      if (d.SampleLoops) {
1994          eSampleLoopType.set_ptr(&dimregion->pSampleLoops[0].LoopType);          d.pSampleLoops[0].LoopStart =
1995          eSampleLoopInfinite.set_active(              d.pSample ?
1996              dimregion->pSample && !dimregion->pSample->LoopPlayCount              std::min(value, uint32_t(d.pSample->SamplesTotal -
1997          );                                       d.pSampleLoops[0].LoopLength)) :
1998          // 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();  
1999      }      }
2000  }  }
2001    
2002  void DimRegionEdit::loop_infinite_toggled() {  void DimRegionEdit::set_LoopLength(gig::DimensionRegion& d, uint32_t value)
2003      eSampleLoopPlayCount.set_sensitive(  {
2004          !eSampleLoopInfinite.get_active() &&      if (d.SampleLoops) {
2005           eSampleLoopEnabled.get_active()          d.pSampleLoops[0].LoopLength =
2006      );              d.pSample ?
2007      if (eSampleLoopInfinite.get_active())              std::min(value, uint32_t(d.pSample->SamplesTotal -
2008          eSampleLoopPlayCount.set_value(0);                                       d.pSampleLoops[0].LoopStart)) :
2009      else if (!eSampleLoopPlayCount.get_value())              0;
2010          eSampleLoopPlayCount.set_value(1);      }
2011    }
2012    
2013    void DimRegionEdit::set_LoopInfinite(gig::DimensionRegion& d, bool value)
2014    {
2015        if (d.pSample) {
2016            if (value) d.pSample->LoopPlayCount = 0;
2017            else if (d.pSample->LoopPlayCount == 0) d.pSample->LoopPlayCount = 1;
2018        }
2019    }
2020    
2021    void DimRegionEdit::set_LoopPlayCount(gig::DimensionRegion& d, uint32_t value)
2022    {
2023        if (d.pSample) d.pSample->LoopPlayCount = value;
2024    }
2025    
2026    void DimRegionEdit::nullOutSampleReference() {
2027        if (!dimregion) return;
2028        gig::Sample* oldref = dimregion->pSample;
2029        if (!oldref) return;
2030    
2031        DimRegionChangeGuard(this, dimregion);
2032    
2033        // in case currently assigned sample is a stereo one, then remove both
2034        // references (expected to be due to a "stereo dimension")
2035        gig::DimensionRegion* d[2] = { dimregion, NULL };
2036        if (oldref->Channels == 2) {
2037            gig::Region* region = dimregion->GetParent();
2038            {
2039                int stereo_bit = 0;
2040                int bitcount = 0;
2041                for (int dim = 0 ; dim < region->Dimensions ; dim++) {
2042                    if (region->pDimensionDefinitions[dim].dimension == gig::dimension_samplechannel) {
2043                        stereo_bit = 1 << bitcount;
2044                        break;
2045                    }
2046                    bitcount += region->pDimensionDefinitions[dim].bits;
2047                }
2048    
2049                if (stereo_bit) {
2050                    int dimregno;
2051                    for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
2052                        if (region->pDimensionRegions[dimregno] == dimregion) {
2053                            break;
2054                        }
2055                    }
2056                    d[0] = region->pDimensionRegions[dimregno & ~stereo_bit];
2057                    d[1] = region->pDimensionRegions[dimregno | stereo_bit];
2058                }
2059            }
2060        }
2061    
2062        if (d[0]) d[0]->pSample = NULL;
2063        if (d[1]) d[1]->pSample = NULL;
2064    
2065        // update UI elements
2066        set_dim_region(dimregion);
2067    
2068        sample_ref_changed_signal.emit(oldref, NULL);
2069    }
2070    
2071    void DimRegionEdit::onButtonSelectSamplePressed() {
2072        if (!dimregion) return;
2073        if (!dimregion->pSample) return;
2074        select_sample_signal.emit(dimregion->pSample);
2075    }
2076    
2077    sigc::signal<void, gig::Sample*>& DimRegionEdit::signal_select_sample() {
2078        return select_sample_signal;
2079  }  }

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

  ViewVC Help
Powered by ViewVC