/[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 3368 by schoenebeck, Thu Nov 16 19:18:42 2017 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006, 2007 Andreas Persson   * Copyright (C) 2006-2017 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    VelocityCurve::VelocityCurve(double (gig::DimensionRegion::*getter)(uint8_t)) :
32        getter(getter), dimreg(0) {
33        set_size_request(80, 80);
34    }
35    
36    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
37    bool VelocityCurve::on_expose_event(GdkEventExpose* e) {
38        const Cairo::RefPtr<Cairo::Context>& cr =
39            get_window()->create_cairo_context();
40    #if 0
41    }
42    #endif
43    #else
44    bool VelocityCurve::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
45    #endif
46        if (dimreg) {
47            int w = get_width();
48            int h = get_height();
49    
50            for (int pass = 0 ; pass < 2 ; pass++) {
51                for (double x = 0 ; x <= w ; x++) {
52                    int vel = int(x * (127 - 1e-10) / w + 1);
53                    double y = (1 - (dimreg->*getter)(vel)) * (h - 3) + 1.5;
54    
55                    if (x < 1e-10) {
56                        cr->move_to(x, y);
57                    } else {
58                        cr->line_to(x, y);
59                    }
60                }
61                if (pass == 0) {
62                    cr->line_to(w, h);
63                    cr->line_to(0, h);
64                    cr->set_source_rgba(0.5, 0.44, 1.0, is_sensitive() ? 0.2 : 0.1);
65                    cr->fill();
66                } else {
67                    cr->set_line_width(3);
68                    cr->set_source_rgba(0.5, 0.44, 1.0, is_sensitive() ? 1.0 : 0.3);
69                    cr->stroke();
70                }
71            }
72        }
73        return true;
74    }
75    
76    
77    CrossfadeCurve::CrossfadeCurve() : dimreg(0) {
78        set_size_request(280, 80);
79    }
80    
81    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
82    bool CrossfadeCurve::on_expose_event(GdkEventExpose* e) {
83        const Cairo::RefPtr<Cairo::Context>& cr =
84            get_window()->create_cairo_context();
85    #if 0
86    }
87    #endif
88    #else
89    bool CrossfadeCurve::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
90    #endif
91        if (dimreg) {
92            cr->translate(1.5, 0);
93    
94            // first, draw curves for the other layers
95            gig::Region* region = dimreg->GetParent();
96            int dimregno;
97            for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
98                if (region->pDimensionRegions[dimregno] == dimreg) {
99                    break;
100                }
101            }
102            int bitcount = 0;
103            for (int dim = 0 ; dim < region->Dimensions ; dim++) {
104                if (region->pDimensionDefinitions[dim].dimension ==
105                    gig::dimension_layer) {
106                    int mask =
107                        ~(((1 << region->pDimensionDefinitions[dim].bits) - 1) <<
108                          bitcount);
109                    int c = dimregno & mask; // mask away the layer dimension
110    
111                    for (int i = 0 ; i < region->pDimensionDefinitions[dim].zones ;
112                         i++) {
113                        gig::DimensionRegion* d =
114                            region->pDimensionRegions[c + (i << bitcount)];
115                        if (d != dimreg) {
116                            draw_one_curve(cr, d, false);
117                        }
118                    }
119                    break;
120                }
121                bitcount += region->pDimensionDefinitions[dim].bits;
122            }
123    
124            // then, draw the currently selected layer
125            draw_one_curve(cr, dimreg, is_sensitive());
126        }
127        return true;
128    }
129    
130    void CrossfadeCurve::draw_one_curve(const Cairo::RefPtr<Cairo::Context>& cr,
131                                        const gig::DimensionRegion* d,
132                                        bool sensitive) {
133        int w = get_width();
134        int h = get_height();
135    
136        if (d->Crossfade.out_end) {
137            for (int pass = 0 ; pass < 2 ; pass++) {
138                cr->move_to(d->Crossfade.in_start / 127.0 * (w - 3), h);
139                cr->line_to(d->Crossfade.in_end / 127.0 * (w - 3), 1.5);
140                cr->line_to(d->Crossfade.out_start / 127.0 * (w - 3), 1.5);
141                cr->line_to(d->Crossfade.out_end / 127.0 * (w - 3), h);
142    
143                if (pass == 0) {
144                    cr->set_source_rgba(0.5, 0.44, 1.0, sensitive ? 0.2 : 0.1);
145                    cr->fill();
146                } else {
147                    cr->set_line_width(3);
148                    cr->set_source_rgba(0.5, 0.44, 1.0, sensitive ? 1.0 : 0.3);
149                    cr->stroke();
150                }
151            }
152        }
153    }
154    
155    
156    EGStateOptions::EGStateOptions() : HBox(),
157        label(_("May be cancelled: ")),
158        checkBoxAttack(_("Attack")),
159        checkBoxAttackHold(_("Attack Hold")),
160        checkBoxDecay1(_("Decay 1")),
161        checkBoxDecay2(_("Decay 2")),
162        checkBoxRelease(_("Release"))
163    {
164        set_spacing(6);
165    
166        pack_start(label);
167        pack_start(checkBoxAttack, Gtk::PACK_SHRINK);
168        pack_start(checkBoxAttackHold, Gtk::PACK_SHRINK);
169        pack_start(checkBoxDecay1, Gtk::PACK_SHRINK);
170        pack_start(checkBoxDecay2, Gtk::PACK_SHRINK);
171        pack_start(checkBoxRelease, Gtk::PACK_SHRINK);
172    
173        checkBoxAttack.set_tooltip_text(_(
174            "If checked: a note-off aborts the 'attack' stage."
175        ));
176        checkBoxAttackHold.set_tooltip_text(_(
177            "If checked: a note-off aborts the 'attack hold' stage."
178        ));
179        checkBoxDecay1.set_tooltip_text(_(
180            "If checked: a note-off aborts the 'decay 1' stage."
181        ));
182        checkBoxDecay2.set_tooltip_text(_(
183            "If checked: a note-off aborts the 'decay 2' stage."
184        ));
185        checkBoxRelease.set_tooltip_text(_(
186            "If checked: a note-on reverts back from the 'release' stage."
187        ));
188    }
189    
190    
191  DimRegionEdit::DimRegionEdit() :  DimRegionEdit::DimRegionEdit() :
192      eEG1PreAttack("Pre-attack", 0, 100, 2),      velocity_curve(&gig::DimensionRegion::GetVelocityAttenuation),
193      eEG1Attack("Attack", 0, 60, 3),      release_curve(&gig::DimensionRegion::GetVelocityRelease),
194      eEG1Decay1("Decay 1", 0.005, 60, 3),      cutoff_curve(&gig::DimensionRegion::GetVelocityCutoff),
195      eEG1Decay2("Decay 2", 0, 60, 3),      eEG1PreAttack(_("Pre-attack Level (%)"), 0, 100, 2),
196      eEG1InfiniteSustain("Infinite sustain"),      eEG1Attack(_("Attack Time (seconds)"), 0, 60, 3),
197      eEG1Sustain("Sustain", 0, 100, 2),      eEG1Decay1(_("Decay 1 Time (seconds)"), 0.005, 60, 3),
198      eEG1Release("Release", 0, 60, 3),      eEG1Decay2(_("Decay 2 Time (seconds)"), 0, 60, 3),
199      eEG1Hold("Hold"),      eEG1InfiniteSustain(_("Infinite sustain")),
200      eEG1Controller("Controller"),      eEG1Sustain(_("Sustain Level (%)"), 0, 100, 2),
201      eEG1ControllerInvert("Controller invert"),      eEG1Release(_("Release Time (seconds)"), 0, 60, 3),
202      eEG1ControllerAttackInfluence("Controller attack influence", 0, 3),      eEG1Hold(_("Hold Attack Stage until Loop End")),
203      eEG1ControllerDecayInfluence("Controller decay influence", 0, 3),      eEG1Controller(_("Controller")),
204      eEG1ControllerReleaseInfluence("Controller release influence", 0, 3),      eEG1ControllerInvert(_("Controller invert")),
205      eLFO1Frequency("Frequency", 0.1, 10, 2),      eEG1ControllerAttackInfluence(_("Controller attack influence"), 0, 3),
206      eLFO1InternalDepth("Internal depth", 0, 1200),      eEG1ControllerDecayInfluence(_("Controller decay influence"), 0, 3),
207      eLFO1ControlDepth("Control depth", 0, 1200),      eEG1ControllerReleaseInfluence(_("Controller release influence"), 0, 3),
208      eLFO1Controller("Controller"),      eLFO1Frequency(_("Frequency"), 0.1, 10, 2),
209      eLFO1FlipPhase("Flip phase"),      eLFO1InternalDepth(_("Internal depth"), 0, 1200),
210      eLFO1Sync("Sync"),      eLFO1ControlDepth(_("Control depth"), 0, 1200),
211      eEG2PreAttack("Pre-attack", 0, 100, 2),      eLFO1Controller(_("Controller")),
212      eEG2Attack("Attack", 0, 60, 3),      eLFO1FlipPhase(_("Flip phase")),
213      eEG2Decay1("Decay 1", 0.005, 60, 3),      eLFO1Sync(_("Sync")),
214      eEG2Decay2("Decay 2", 0, 60, 3),      eEG2PreAttack(_("Pre-attack Level (%)"), 0, 100, 2),
215      eEG2InfiniteSustain("Infinite sustain"),      eEG2Attack(_("Attack Time (seconds)"), 0, 60, 3),
216      eEG2Sustain("Sustain", 0, 100, 2),      eEG2Decay1(_("Decay 1 Time (seconds)"), 0.005, 60, 3),
217      eEG2Release("Release", 0, 60, 3),      eEG2Decay2(_("Decay 2 Time (seconds)"), 0, 60, 3),
218      eEG2Controller("Controller"),      eEG2InfiniteSustain(_("Infinite sustain")),
219      eEG2ControllerInvert("Controller invert"),      eEG2Sustain(_("Sustain Level (%)"), 0, 100, 2),
220      eEG2ControllerAttackInfluence("Controller attack influence", 0, 3),      eEG2Release(_("Release Time (seconds)"), 0, 60, 3),
221      eEG2ControllerDecayInfluence("Controller decay influence", 0, 3),      eEG2Controller(_("Controller")),
222      eEG2ControllerReleaseInfluence("Controller release influence", 0, 3),      eEG2ControllerInvert(_("Controller invert")),
223      eLFO2Frequency("Frequency", 0.1, 10, 2),      eEG2ControllerAttackInfluence(_("Controller attack influence"), 0, 3),
224      eLFO2InternalDepth("Internal depth", 0, 1200),      eEG2ControllerDecayInfluence(_("Controller decay influence"), 0, 3),
225      eLFO2ControlDepth("Control depth", 0, 1200),      eEG2ControllerReleaseInfluence(_("Controller release influence"), 0, 3),
226      eLFO2Controller("Controller"),      eLFO2Frequency(_("Frequency"), 0.1, 10, 2),
227      eLFO2FlipPhase("Flip phase"),      eLFO2InternalDepth(_("Internal depth"), 0, 1200),
228      eLFO2Sync("Sync"),      eLFO2ControlDepth(_("Control depth"), 0, 1200),
229      eEG3Attack("Attack", 0, 10, 3),      eLFO2Controller(_("Controller")),
230      eEG3Depth("Depth", -1200, 1200),      eLFO2FlipPhase(_("Flip phase")),
231      eLFO3Frequency("Frequency", 0.1, 10, 2),      eLFO2Sync(_("Sync")),
232      eLFO3InternalDepth("Internal depth", 0, 1200),      eEG3Attack(_("Attack"), 0, 10, 3),
233      eLFO3ControlDepth("Control depth", 0, 1200),      eEG3Depth(_("Depth"), -1200, 1200),
234      eLFO3Controller("Controller"),      eLFO3Frequency(_("Frequency"), 0.1, 10, 2),
235      eLFO3Sync("Sync"),      eLFO3InternalDepth(_("Internal depth"), 0, 1200),
236      eVCFEnabled("Enabled"),      eLFO3ControlDepth(_("Control depth"), 0, 1200),
237      eVCFType("Type"),      eLFO3Controller(_("Controller")),
238      eVCFCutoffController("Cutoff controller"),      eLFO3Sync(_("Sync")),
239      eVCFCutoffControllerInvert("Cutoff controller invert"),      eVCFEnabled(_("Enabled")),
240      eVCFCutoff("Cutoff"),      eVCFType(_("Type")),
241      eVCFVelocityCurve("Velocity curve"),      eVCFCutoffController(_("Cutoff controller")),
242      eVCFVelocityScale("Velocity scale"),      eVCFCutoffControllerInvert(_("Cutoff controller invert")),
243      eVCFVelocityDynamicRange("Velocity dynamic range", 0, 4),      eVCFCutoff(_("Cutoff")),
244      eVCFResonance("Resonance"),      eVCFVelocityCurve(_("Velocity curve")),
245      eVCFResonanceDynamic("Resonance dynamic"),      eVCFVelocityScale(_("Velocity scale")),
246      eVCFResonanceController("Resonance controller"),      eVCFVelocityDynamicRange(_("Velocity dynamic range"), 0, 4),
247      eVCFKeyboardTracking("Keyboard tracking"),      eVCFResonance(_("Resonance")),
248      eVCFKeyboardTrackingBreakpoint("Keyboard tracking breakpoint"),      eVCFResonanceDynamic(_("Resonance dynamic")),
249      eVelocityResponseCurve("Velocity response curve"),      eVCFResonanceController(_("Resonance controller")),
250      eVelocityResponseDepth("Velocity response depth", 0, 4),      eVCFKeyboardTracking(_("Keyboard tracking")),
251      eVelocityResponseCurveScaling("Velocity response curve scaling"),      eVCFKeyboardTrackingBreakpoint(_("Keyboard tracking breakpoint")),
252      eReleaseVelocityResponseCurve("Release velocity response curve"),      eVelocityResponseCurve(_("Velocity response curve")),
253      eReleaseVelocityResponseDepth("Release velocity response depth", 0, 4),      eVelocityResponseDepth(_("Velocity response depth"), 0, 4),
254      eReleaseTriggerDecay("Release trigger decay", 0, 8),      eVelocityResponseCurveScaling(_("Velocity response curve scaling")),
255      eCrossfade_in_start("Crossfade-in start"),      eReleaseVelocityResponseCurve(_("Release velocity response curve")),
256      eCrossfade_in_end("Crossfade-in end"),      eReleaseVelocityResponseDepth(_("Release velocity response depth"), 0, 4),
257      eCrossfade_out_start("Crossfade-out start"),      eReleaseTriggerDecay(_("Release trigger decay"), 0, 8),
258      eCrossfade_out_end("Crossfade-out end"),      eCrossfade_in_start(_("Crossfade-in start")),
259      ePitchTrack("Pitch track"),      eCrossfade_in_end(_("Crossfade-in end")),
260      eDimensionBypass("Dimension bypass"),      eCrossfade_out_start(_("Crossfade-out start")),
261      ePan("Pan", -64, 63),      eCrossfade_out_end(_("Crossfade-out end")),
262      eSelfMask("Self mask"),      ePitchTrack(_("Pitch track")),
263      eAttenuationController("Attenuation controller"),      eDimensionBypass(_("Dimension bypass")),
264      eInvertAttenuationController("Invert attenuation controller"),      ePan(_("Pan"), -64, 63),
265      eAttenuationControllerThreshold("Attenuation controller threshold"),      eSelfMask(_("Kill lower velocity voices (a.k.a \"Self mask\")")),
266      eChannelOffset("Channel offset", 0, 9),      eAttenuationController(_("Attenuation controller")),
267      eSustainDefeat("Sustain defeat"),      eInvertAttenuationController(_("Invert attenuation controller")),
268      eMSDecode("MS decode"),      eAttenuationControllerThreshold(_("Attenuation controller threshold")),
269      eSampleStartOffset("Sample start offset", 0, 2000),      eChannelOffset(_("Channel offset"), 0, 9),
270      eUnityNote("Unity note"),      eSustainDefeat(_("Ignore Hold Pedal (a.k.a. \"Sustain defeat\")")),
271      eFineTune("Fine tune", -49, 50),      eMSDecode(_("Decode Mid/Side Recordings")),
272      eGain("Gain", -96, 0, 2, -655360),      eSampleStartOffset(_("Sample start offset"), 0, 2000),
273      eGainPlus6("Gain +6dB", eGain, 6 * -655360),      eUnityNote(_("Unity note")),
274      eSampleLoopEnabled("Enabled"),      eSampleGroup(_("Sample Group")),
275      eSampleLoopStart("Loop start positon"),      eSampleFormatInfo(_("Sample Format")),
276      eSampleLoopLength("Loop size"),      eSampleID("Sample ID"),
277      eSampleLoopType("Loop type"),      eChecksum("Wave Data CRC-32"),
278      eSampleLoopInfinite("Infinite loop"),      eFineTune(_("Fine tune"), -49, 50),
279      eSampleLoopPlayCount("Playback count")      eGain(_("Gain"), -96, 0, 2, -655360),
280  {      eGainPlus6(_("Gain +6dB"), eGain, 6 * -655360),
281        eSampleLoopEnabled(_("Enabled")),
282        eSampleLoopStart(_("Loop start positon")),
283        eSampleLoopLength(_("Loop size")),
284        eSampleLoopType(_("Loop type")),
285        eSampleLoopInfinite(_("Infinite loop")),
286        eSampleLoopPlayCount(_("Playback count"), 1),
287        buttonSelectSample(UNICODE_LEFT_ARROW + "  " + _("Select Sample")),
288        update_model(0)
289    {
290        // make synthesis parameter page tabs scrollable
291        // (workaround for GTK3: default theme uses huge tabs which breaks layout)
292        set_scrollable();
293    
294        connect(eEG1PreAttack, &gig::DimensionRegion::EG1PreAttack);
295        connect(eEG1Attack, &gig::DimensionRegion::EG1Attack);
296        connect(eEG1Decay1, &gig::DimensionRegion::EG1Decay1);
297        connect(eEG1Decay2, &gig::DimensionRegion::EG1Decay2);
298        connect(eEG1InfiniteSustain, &gig::DimensionRegion::EG1InfiniteSustain);
299        connect(eEG1Sustain, &gig::DimensionRegion::EG1Sustain);
300        connect(eEG1Release, &gig::DimensionRegion::EG1Release);
301        connect(eEG1Hold, &gig::DimensionRegion::EG1Hold);
302        connect(eEG1Controller, &gig::DimensionRegion::EG1Controller);
303        connect(eEG1ControllerInvert, &gig::DimensionRegion::EG1ControllerInvert);
304        connect(eEG1ControllerAttackInfluence,
305                &gig::DimensionRegion::EG1ControllerAttackInfluence);
306        connect(eEG1ControllerDecayInfluence,
307                &gig::DimensionRegion::EG1ControllerDecayInfluence);
308        connect(eEG1ControllerReleaseInfluence,
309                &gig::DimensionRegion::EG1ControllerReleaseInfluence);
310        {
311            ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG1Options.AttackCancel));
312            connect(eEG1StateOptions.checkBoxAttack, mp.pmember);
313        }
314        {
315            ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG1Options.AttackHoldCancel));
316            connect(eEG1StateOptions.checkBoxAttackHold, mp.pmember);
317        }
318        {
319            ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG1Options.Decay1Cancel));
320            connect(eEG1StateOptions.checkBoxDecay1, mp.pmember);
321        }
322        {
323            ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG1Options.Decay2Cancel));
324            connect(eEG1StateOptions.checkBoxDecay2, mp.pmember);
325        }
326        {
327            ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG1Options.ReleaseCancel));
328            connect(eEG1StateOptions.checkBoxRelease, mp.pmember);
329        }
330        connect(eLFO1Frequency, &gig::DimensionRegion::LFO1Frequency);
331        connect(eLFO1InternalDepth, &gig::DimensionRegion::LFO1InternalDepth);
332        connect(eLFO1ControlDepth, &gig::DimensionRegion::LFO1ControlDepth);
333        connect(eLFO1Controller, &gig::DimensionRegion::LFO1Controller);
334        connect(eLFO1FlipPhase, &gig::DimensionRegion::LFO1FlipPhase);
335        connect(eLFO1Sync, &gig::DimensionRegion::LFO1Sync);
336        connect(eEG2PreAttack, &gig::DimensionRegion::EG2PreAttack);
337        connect(eEG2Attack, &gig::DimensionRegion::EG2Attack);
338        connect(eEG2Decay1, &gig::DimensionRegion::EG2Decay1);
339        connect(eEG2Decay2, &gig::DimensionRegion::EG2Decay2);
340        connect(eEG2InfiniteSustain, &gig::DimensionRegion::EG2InfiniteSustain);
341        connect(eEG2Sustain, &gig::DimensionRegion::EG2Sustain);
342        connect(eEG2Release, &gig::DimensionRegion::EG2Release);
343        connect(eEG2Controller, &gig::DimensionRegion::EG2Controller);
344        connect(eEG2ControllerInvert, &gig::DimensionRegion::EG2ControllerInvert);
345        connect(eEG2ControllerAttackInfluence,
346                &gig::DimensionRegion::EG2ControllerAttackInfluence);
347        connect(eEG2ControllerDecayInfluence,
348                &gig::DimensionRegion::EG2ControllerDecayInfluence);
349        connect(eEG2ControllerReleaseInfluence,
350                &gig::DimensionRegion::EG2ControllerReleaseInfluence);
351        {
352            ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG2Options.AttackCancel));
353            connect(eEG2StateOptions.checkBoxAttack, mp.pmember);
354        }
355        {
356            ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG2Options.AttackHoldCancel));
357            connect(eEG2StateOptions.checkBoxAttackHold, mp.pmember);
358        }
359        {
360            ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG2Options.Decay1Cancel));
361            connect(eEG2StateOptions.checkBoxDecay1, mp.pmember);
362        }
363        {
364            ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG2Options.Decay2Cancel));
365            connect(eEG2StateOptions.checkBoxDecay2, mp.pmember);
366        }
367        {
368            ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG2Options.ReleaseCancel));
369            connect(eEG2StateOptions.checkBoxRelease, mp.pmember);
370        }
371        connect(eLFO2Frequency, &gig::DimensionRegion::LFO2Frequency);
372        connect(eLFO2InternalDepth, &gig::DimensionRegion::LFO2InternalDepth);
373        connect(eLFO2ControlDepth, &gig::DimensionRegion::LFO2ControlDepth);
374        connect(eLFO2Controller, &gig::DimensionRegion::LFO2Controller);
375        connect(eLFO2FlipPhase, &gig::DimensionRegion::LFO2FlipPhase);
376        connect(eLFO2Sync, &gig::DimensionRegion::LFO2Sync);
377        connect(eEG3Attack, &gig::DimensionRegion::EG3Attack);
378        connect(eEG3Depth, &gig::DimensionRegion::EG3Depth);
379        connect(eLFO3Frequency, &gig::DimensionRegion::LFO3Frequency);
380        connect(eLFO3InternalDepth, &gig::DimensionRegion::LFO3InternalDepth);
381        connect(eLFO3ControlDepth, &gig::DimensionRegion::LFO3ControlDepth);
382        connect(eLFO3Controller, &gig::DimensionRegion::LFO3Controller);
383        connect(eLFO3Sync, &gig::DimensionRegion::LFO3Sync);
384        connect(eVCFEnabled, &gig::DimensionRegion::VCFEnabled);
385        connect(eVCFType, &gig::DimensionRegion::VCFType);
386        connect(eVCFCutoffController,
387                &gig::DimensionRegion::SetVCFCutoffController);
388        connect(eVCFCutoffControllerInvert,
389                &gig::DimensionRegion::VCFCutoffControllerInvert);
390        connect(eVCFCutoff, &gig::DimensionRegion::VCFCutoff);
391        connect(eVCFVelocityCurve, &gig::DimensionRegion::SetVCFVelocityCurve);
392        connect(eVCFVelocityScale, &gig::DimensionRegion::SetVCFVelocityScale);
393        connect(eVCFVelocityDynamicRange,
394                &gig::DimensionRegion::SetVCFVelocityDynamicRange);
395        connect(eVCFResonance, &gig::DimensionRegion::VCFResonance);
396        connect(eVCFResonanceDynamic, &gig::DimensionRegion::VCFResonanceDynamic);
397        connect(eVCFResonanceController,
398                &gig::DimensionRegion::VCFResonanceController);
399        connect(eVCFKeyboardTracking, &gig::DimensionRegion::VCFKeyboardTracking);
400        connect(eVCFKeyboardTrackingBreakpoint,
401                &gig::DimensionRegion::VCFKeyboardTrackingBreakpoint);
402        connect(eVelocityResponseCurve,
403                &gig::DimensionRegion::SetVelocityResponseCurve);
404        connect(eVelocityResponseDepth,
405                &gig::DimensionRegion::SetVelocityResponseDepth);
406        connect(eVelocityResponseCurveScaling,
407                &gig::DimensionRegion::SetVelocityResponseCurveScaling);
408        connect(eReleaseVelocityResponseCurve,
409                &gig::DimensionRegion::SetReleaseVelocityResponseCurve);
410        connect(eReleaseVelocityResponseDepth,
411                &gig::DimensionRegion::SetReleaseVelocityResponseDepth);
412        connect(eReleaseTriggerDecay, &gig::DimensionRegion::ReleaseTriggerDecay);
413        connect(eCrossfade_in_start, &DimRegionEdit::set_Crossfade_in_start);
414        connect(eCrossfade_in_end, &DimRegionEdit::set_Crossfade_in_end);
415        connect(eCrossfade_out_start, &DimRegionEdit::set_Crossfade_out_start);
416        connect(eCrossfade_out_end, &DimRegionEdit::set_Crossfade_out_end);
417        connect(ePitchTrack, &gig::DimensionRegion::PitchTrack);
418        connect(eDimensionBypass, &gig::DimensionRegion::DimensionBypass);
419        connect(ePan, &gig::DimensionRegion::Pan);
420        connect(eSelfMask, &gig::DimensionRegion::SelfMask);
421        connect(eAttenuationController,
422                &gig::DimensionRegion::AttenuationController);
423        connect(eInvertAttenuationController,
424                &gig::DimensionRegion::InvertAttenuationController);
425        connect(eAttenuationControllerThreshold,
426                &gig::DimensionRegion::AttenuationControllerThreshold);
427        connect(eChannelOffset, &gig::DimensionRegion::ChannelOffset);
428        connect(eSustainDefeat, &gig::DimensionRegion::SustainDefeat);
429        connect(eMSDecode, &gig::DimensionRegion::MSDecode);
430        connect(eSampleStartOffset, &gig::DimensionRegion::SampleStartOffset);
431        connect(eUnityNote, &DimRegionEdit::set_UnityNote);
432        connect(eFineTune, &DimRegionEdit::set_FineTune);
433        connect(eGain, &DimRegionEdit::set_Gain);
434        connect(eGainPlus6, &DimRegionEdit::set_Gain);
435        connect(eSampleLoopEnabled, &DimRegionEdit::set_LoopEnabled);
436        connect(eSampleLoopType, &DimRegionEdit::set_LoopType);
437        connect(eSampleLoopStart, &DimRegionEdit::set_LoopStart);
438        connect(eSampleLoopLength, &DimRegionEdit::set_LoopLength);
439        connect(eSampleLoopInfinite, &DimRegionEdit::set_LoopInfinite);
440        connect(eSampleLoopPlayCount, &DimRegionEdit::set_LoopPlayCount);
441        buttonSelectSample.signal_clicked().connect(
442            sigc::mem_fun(*this, &DimRegionEdit::onButtonSelectSamplePressed)
443        );
444    
445      for (int i = 0 ; i < 7 ; i++) {      for (int i = 0 ; i < 7 ; i++) {
446    #if USE_GTKMM_GRID
447            table[i] = new Gtk::Grid;
448            table[i]->set_column_spacing(7);
449    #else
450          table[i] = new Gtk::Table(3, 1);          table[i] = new Gtk::Table(3, 1);
451          table[i]->set_col_spacings(7);          table[i]->set_col_spacings(7);
452    #endif
453    
454    // on Gtk 3 there is absolutely no margin by default
455    #if GTKMM_MAJOR_VERSION >= 3
456    # if GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION < 12
457            table[i]->set_margin_left(12);
458            table[i]->set_margin_right(12);
459    # else
460            table[i]->set_margin_start(12);
461            table[i]->set_margin_end(12);
462    # endif
463    #endif
464      }      }
465    
466      // set tooltips      // set tooltips
467      eUnityNote.set_tip(      eUnityNote.set_tip(
468          _("Note this sample is associated with (a.k.a. 'root note')")          _("Note this sample is associated with (a.k.a. 'root note')")
469      );      );
470        buttonSelectSample.set_tooltip_text(
471            _("Selects the sample of this dimension region on the left hand side's sample tree view.")
472        );
473      eSampleStartOffset.set_tip(_("Sample position at which playback should be started"));      eSampleStartOffset.set_tip(_("Sample position at which playback should be started"));
474      ePan.set_tip(_("Stereo balance (left/right)"));      ePan.set_tip(_("Stereo balance (left/right)"));
475      eChannelOffset.set_tip(      eChannelOffset.set_tip(
# Line 151  DimRegionEdit::DimRegionEdit() : Line 500  DimRegionEdit::DimRegionEdit() :
500            "Caution: this setting is stored on Sample side, thus is shared "            "Caution: this setting is stored on Sample side, thus is shared "
501            "among all dimension regions that use this sample!")            "among all dimension regions that use this sample!")
502      );      );
503        
504        eEG1PreAttack.set_tip(
505            "Very first level this EG starts with. It rises then in Attack Time "
506            "seconds from this initial level to 100%."
507        );
508        eEG1Attack.set_tip(
509            "Duration of the EG's Attack stage, which raises its level from "
510            "Pre-Attack Level to 100%."
511        );
512        eEG1Hold.set_tip(
513           "On looped sounds, enabling this will cause the Decay 1 stage not to "
514           "enter before the loop has been passed one time."
515        );
516        eAttenuationController.set_tip(_(
517            "If you are not using the 'Layer' dimension, then this controller "
518            "simply alters the volume. If you are using the 'Layer' dimension, "
519            "then this controller is controlling the crossfade between Layers in "
520            "real-time."
521        ));
522    
523        eLFO1Sync.set_tip(
524            "If not checked, every voice will use its own LFO instance, which "
525            "causes voices triggered at different points in time to have different "
526            "LFO levels. By enabling 'Sync' here the voices will instead use and "
527            "share one single LFO, causing all voices to have the same LFO level, "
528            "no matter when the individual notes have been triggered."
529        );
530        eLFO2Sync.set_tip(
531            "If not checked, every voice will use its own LFO instance, which "
532            "causes voices triggered at different points in time to have different "
533            "LFO levels. By enabling 'Sync' here the voices will instead use and "
534            "share one single LFO, causing all voices to have the same LFO level, "
535            "no matter when the individual notes have been triggered."
536        );
537        eLFO3Sync.set_tip(
538            "If not checked, every voice will use its own LFO instance, which "
539            "causes voices triggered at different points in time to have different "
540            "LFO levels. By enabling 'Sync' here the voices will instead use and "
541            "share one single LFO, causing all voices to have the same LFO level, "
542            "no matter when the individual notes have been triggered."
543        );
544        eLFO1FlipPhase.set_tip(
545           "Inverts the LFO's generated wave vertically."
546        );
547        eLFO2FlipPhase.set_tip(
548           "Inverts the LFO's generated wave vertically."
549        );
550    
551      pageno = 0;      pageno = 0;
552      rowno = 0;      rowno = 0;
553      firstRowInBlock = 0;      firstRowInBlock = 0;
554    
555      addHeader(_("Mandatory Settings"));      addHeader(_("Mandatory Settings"));
556      addString("Sample", lSample, wSample);      addString(_("Sample"), lSample, wSample, buttonNullSampleReference);
557        buttonNullSampleReference->set_label("X");
558        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."));
559        buttonNullSampleReference->signal_clicked().connect(
560            sigc::mem_fun(*this, &DimRegionEdit::nullOutSampleReference)
561        );
562      //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);
563      tooltips.set_tip(*wSample, _("Drop a sample here"));  #ifdef OLD_TOOLTIPS
564        tooltips.set_tip(*wSample, _("Drag & drop a sample here"));
565    #else
566        wSample->set_tooltip_text(_("Drag & drop a sample here"));
567    #endif
568      addProp(eUnityNote);      addProp(eUnityNote);
569        addProp(eSampleGroup);
570        addProp(eSampleFormatInfo);
571        addProp(eSampleID);
572        addProp(eChecksum);
573        addRightHandSide(buttonSelectSample);
574      addHeader(_("Optional Settings"));      addHeader(_("Optional Settings"));
575      addProp(eSampleStartOffset);      addProp(eSampleStartOffset);
576      addProp(eChannelOffset);      addProp(eChannelOffset);
577      addHeader("Loops");      addHeader(_("Loops"));
578      addProp(eSampleLoopEnabled);      addProp(eSampleLoopEnabled);
579      addProp(eSampleLoopStart);      addProp(eSampleLoopStart);
580      addProp(eSampleLoopLength);      addProp(eSampleLoopLength);
581      {      {
582          const char* choices[] = { "normal", "bidirectional", "backward", 0 };          const char* choices[] = { _("normal"), _("bidirectional"), _("backward"), 0 };
583          static const uint32_t values[] = {          static const uint32_t values[] = {
584              gig::loop_type_normal,              gig::loop_type_normal,
585              gig::loop_type_bidirectional,              gig::loop_type_bidirectional,
# Line 190  DimRegionEdit::DimRegionEdit() : Line 600  DimRegionEdit::DimRegionEdit() :
600      addHeader(_("Amplitude Envelope (EG1)"));      addHeader(_("Amplitude Envelope (EG1)"));
601      addProp(eEG1PreAttack);      addProp(eEG1PreAttack);
602      addProp(eEG1Attack);      addProp(eEG1Attack);
603        addProp(eEG1Hold);
604      addProp(eEG1Decay1);      addProp(eEG1Decay1);
605      addProp(eEG1Decay2);      addProp(eEG1Decay2);
606      addProp(eEG1InfiniteSustain);      addProp(eEG1InfiniteSustain);
607      addProp(eEG1Sustain);      addProp(eEG1Sustain);
608      addProp(eEG1Release);      addProp(eEG1Release);
     addProp(eEG1Hold);  
609      addProp(eEG1Controller);      addProp(eEG1Controller);
610      addProp(eEG1ControllerInvert);      addProp(eEG1ControllerInvert);
611      addProp(eEG1ControllerAttackInfluence);      addProp(eEG1ControllerAttackInfluence);
612      addProp(eEG1ControllerDecayInfluence);      addProp(eEG1ControllerDecayInfluence);
613      addProp(eEG1ControllerReleaseInfluence);      addProp(eEG1ControllerReleaseInfluence);
614        addLine(eEG1StateOptions);
615    
616      nextPage();      nextPage();
617    
# Line 209  DimRegionEdit::DimRegionEdit() : Line 620  DimRegionEdit::DimRegionEdit() :
620      addProp(eLFO1InternalDepth);      addProp(eLFO1InternalDepth);
621      addProp(eLFO1ControlDepth);      addProp(eLFO1ControlDepth);
622      {      {
623          const char* choices[] = { "internal", "modwheel", "breath",          const char* choices[] = { _("internal"), _("modwheel"), _("breath"),
624                                    "internal+modwheel", "internal+breath", 0 };                                    _("internal+modwheel"), _("internal+breath"), 0 };
625          static const gig::lfo1_ctrl_t values[] = {          static const gig::lfo1_ctrl_t values[] = {
626              gig::lfo1_ctrl_internal,              gig::lfo1_ctrl_internal,
627              gig::lfo1_ctrl_modwheel,              gig::lfo1_ctrl_modwheel,
# Line 223  DimRegionEdit::DimRegionEdit() : Line 634  DimRegionEdit::DimRegionEdit() :
634      addProp(eLFO1Controller);      addProp(eLFO1Controller);
635      addProp(eLFO1FlipPhase);      addProp(eLFO1FlipPhase);
636      addProp(eLFO1Sync);      addProp(eLFO1Sync);
637      addHeader("Crossfade");      addHeader(_("Crossfade"));
638      addProp(eAttenuationController);      addProp(eAttenuationController);
639      addProp(eInvertAttenuationController);      addProp(eInvertAttenuationController);
640      addProp(eAttenuationControllerThreshold);      addProp(eAttenuationControllerThreshold);
# Line 232  DimRegionEdit::DimRegionEdit() : Line 643  DimRegionEdit::DimRegionEdit() :
643      addProp(eCrossfade_out_start);      addProp(eCrossfade_out_start);
644      addProp(eCrossfade_out_end);      addProp(eCrossfade_out_end);
645    
646        Gtk::Frame* frame = new Gtk::Frame;
647        frame->add(crossfade_curve);
648        // on Gtk 3 there is no margin at all by default
649    #if GTKMM_MAJOR_VERSION >= 3
650        frame->set_margin_top(12);
651        frame->set_margin_bottom(12);
652    #endif
653    #if USE_GTKMM_GRID
654        table[pageno]->attach(*frame, 1, rowno, 2);
655    #else
656        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
657                              Gtk::SHRINK, Gtk::SHRINK);
658    #endif
659        rowno++;
660    
661        eCrossfade_in_start.signal_value_changed().connect(
662            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
663        eCrossfade_in_end.signal_value_changed().connect(
664            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
665        eCrossfade_out_start.signal_value_changed().connect(
666            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
667        eCrossfade_out_end.signal_value_changed().connect(
668            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
669    
670      nextPage();      nextPage();
671    
672      addHeader(_("General Filter Settings"));      addHeader(_("General Filter Settings"));
673      addProp(eVCFEnabled);      addProp(eVCFEnabled);
674      {      {
675          const char* choices[] = { "lowpass", "lowpassturbo", "bandpass",          const char* choices[] = { _("lowpass"), _("lowpassturbo"), _("bandpass"),
676                                    "highpass", "bandreject", 0 };                                    _("highpass"), _("bandreject"), 0 };
677          static const gig::vcf_type_t values[] = {          static const gig::vcf_type_t values[] = {
678              gig::vcf_type_lowpass,              gig::vcf_type_lowpass,
679              gig::vcf_type_lowpassturbo,              gig::vcf_type_lowpassturbo,
# Line 250  DimRegionEdit::DimRegionEdit() : Line 685  DimRegionEdit::DimRegionEdit() :
685      }      }
686      addProp(eVCFType);      addProp(eVCFType);
687      {      {
688          const char* choices[] = { "none", "none2", "modwheel", "effect1", "effect2",          const char* choices[] = { _("none"), _("none2"), _("modwheel"), _("effect1"), _("effect2"),
689                                    "breath", "foot", "sustainpedal", "softpedal",                                    _("breath"), _("foot"), _("sustainpedal"), _("softpedal"),
690                                    "genpurpose7", "genpurpose8", "aftertouch", 0 };                                    _("genpurpose7"), _("genpurpose8"), _("aftertouch"), 0 };
691          static const gig::vcf_cutoff_ctrl_t values[] = {          static const gig::vcf_cutoff_ctrl_t values[] = {
692              gig::vcf_cutoff_ctrl_none,              gig::vcf_cutoff_ctrl_none,
693              gig::vcf_cutoff_ctrl_none2,              gig::vcf_cutoff_ctrl_none2,
# Line 272  DimRegionEdit::DimRegionEdit() : Line 707  DimRegionEdit::DimRegionEdit() :
707      addProp(eVCFCutoffController);      addProp(eVCFCutoffController);
708      addProp(eVCFCutoffControllerInvert);      addProp(eVCFCutoffControllerInvert);
709      addProp(eVCFCutoff);      addProp(eVCFCutoff);
710      const char* curve_type_texts[] = { "nonlinear", "linear", "special", 0 };      const char* curve_type_texts[] = { _("nonlinear"), _("linear"), _("special"), 0 };
711      static const gig::curve_type_t curve_type_values[] = {      static const gig::curve_type_t curve_type_values[] = {
712          gig::curve_type_nonlinear,          gig::curve_type_nonlinear,
713          gig::curve_type_linear,          gig::curve_type_linear,
# Line 282  DimRegionEdit::DimRegionEdit() : Line 717  DimRegionEdit::DimRegionEdit() :
717      addProp(eVCFVelocityCurve);      addProp(eVCFVelocityCurve);
718      addProp(eVCFVelocityScale);      addProp(eVCFVelocityScale);
719      addProp(eVCFVelocityDynamicRange);      addProp(eVCFVelocityDynamicRange);
720    
721        eVCFCutoffController.signal_value_changed().connect(
722            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
723        eVCFVelocityCurve.signal_value_changed().connect(
724            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
725        eVCFVelocityScale.signal_value_changed().connect(
726            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
727        eVCFVelocityDynamicRange.signal_value_changed().connect(
728            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
729    
730        frame = new Gtk::Frame;
731        frame->add(cutoff_curve);
732        // on Gtk 3 there is no margin at all by default
733    #if GTKMM_MAJOR_VERSION >= 3
734        frame->set_margin_top(12);
735        frame->set_margin_bottom(12);
736    #endif
737    #if USE_GTKMM_GRID
738        table[pageno]->attach(*frame, 1, rowno, 2);
739    #else
740        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
741                              Gtk::SHRINK, Gtk::SHRINK);
742    #endif
743        rowno++;
744    
745      addProp(eVCFResonance);      addProp(eVCFResonance);
746      addProp(eVCFResonanceDynamic);      addProp(eVCFResonanceDynamic);
747      {      {
748          const char* choices[] = { "none", "genpurpose3", "genpurpose4",          const char* choices[] = { _("none"), _("genpurpose3"), _("genpurpose4"),
749                                    "genpurpose5", "genpurpose6", 0 };                                    _("genpurpose5"), _("genpurpose6"), 0 };
750          static const gig::vcf_res_ctrl_t values[] = {          static const gig::vcf_res_ctrl_t values[] = {
751              gig::vcf_res_ctrl_none,              gig::vcf_res_ctrl_none,
752              gig::vcf_res_ctrl_genpurpose3,              gig::vcf_res_ctrl_genpurpose3,
# Line 302  DimRegionEdit::DimRegionEdit() : Line 762  DimRegionEdit::DimRegionEdit() :
762    
763      nextPage();      nextPage();
764    
765      addHeader(_("Filter Cutoff Envelope (EG2)"));      lEG2 = addHeader(_("Filter Cutoff Envelope (EG2)"));
766      addProp(eEG2PreAttack);      addProp(eEG2PreAttack);
767      addProp(eEG2Attack);      addProp(eEG2Attack);
768      addProp(eEG2Decay1);      addProp(eEG2Decay1);
# Line 315  DimRegionEdit::DimRegionEdit() : Line 775  DimRegionEdit::DimRegionEdit() :
775      addProp(eEG2ControllerAttackInfluence);      addProp(eEG2ControllerAttackInfluence);
776      addProp(eEG2ControllerDecayInfluence);      addProp(eEG2ControllerDecayInfluence);
777      addProp(eEG2ControllerReleaseInfluence);      addProp(eEG2ControllerReleaseInfluence);
778      addHeader(_("Filter Cutoff Oscillator (LFO2)"));      addLine(eEG2StateOptions);
779        lLFO2 = addHeader(_("Filter Cutoff Oscillator (LFO2)"));
780      addProp(eLFO2Frequency);      addProp(eLFO2Frequency);
781      addProp(eLFO2InternalDepth);      addProp(eLFO2InternalDepth);
782      addProp(eLFO2ControlDepth);      addProp(eLFO2ControlDepth);
783      {      {
784          const char* choices[] = { "internal", "modwheel", "foot",          const char* choices[] = { _("internal"), _("modwheel"), _("foot"),
785                                    "internal+modwheel", "internal+foot", 0 };                                    _("internal+modwheel"), _("internal+foot"), 0 };
786          static const gig::lfo2_ctrl_t values[] = {          static const gig::lfo2_ctrl_t values[] = {
787              gig::lfo2_ctrl_internal,              gig::lfo2_ctrl_internal,
788              gig::lfo2_ctrl_modwheel,              gig::lfo2_ctrl_modwheel,
# Line 348  DimRegionEdit::DimRegionEdit() : Line 809  DimRegionEdit::DimRegionEdit() :
809      addProp(eLFO3InternalDepth);      addProp(eLFO3InternalDepth);
810      addProp(eLFO3ControlDepth);      addProp(eLFO3ControlDepth);
811      {      {
812          const char* choices[] = { "internal", "modwheel", "aftertouch",          const char* choices[] = { _("internal"), _("modwheel"), _("aftertouch"),
813                                    "internal+modwheel", "internal+aftertouch", 0 };                                    _("internal+modwheel"), _("internal+aftertouch"), 0 };
814          static const gig::lfo3_ctrl_t values[] = {          static const gig::lfo3_ctrl_t values[] = {
815              gig::lfo3_ctrl_internal,              gig::lfo3_ctrl_internal,
816              gig::lfo3_ctrl_modwheel,              gig::lfo3_ctrl_modwheel,
# Line 364  DimRegionEdit::DimRegionEdit() : Line 825  DimRegionEdit::DimRegionEdit() :
825    
826      nextPage();      nextPage();
827    
828        addHeader(_("Velocity Response"));
829      eVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values);      eVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values);
830      addProp(eVelocityResponseCurve);      addProp(eVelocityResponseCurve);
831      addProp(eVelocityResponseDepth);      addProp(eVelocityResponseDepth);
832      addProp(eVelocityResponseCurveScaling);      addProp(eVelocityResponseCurveScaling);
833    
834        eVelocityResponseCurve.signal_value_changed().connect(
835            sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
836        eVelocityResponseDepth.signal_value_changed().connect(
837            sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
838        eVelocityResponseCurveScaling.signal_value_changed().connect(
839            sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
840    
841        frame = new Gtk::Frame;
842        frame->add(velocity_curve);
843        // on Gtk 3 there is no margin at all by default
844    #if GTKMM_MAJOR_VERSION >= 3
845        frame->set_margin_top(12);
846        frame->set_margin_bottom(12);
847    #endif
848    #if USE_GTKMM_GRID
849        table[pageno]->attach(*frame, 1, rowno, 2);
850    #else
851        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
852                              Gtk::SHRINK, Gtk::SHRINK);
853    #endif
854        rowno++;
855    
856        addHeader(_("Release Velocity Response"));
857      eReleaseVelocityResponseCurve.set_choices(curve_type_texts,      eReleaseVelocityResponseCurve.set_choices(curve_type_texts,
858                                                curve_type_values);                                                curve_type_values);
859      addProp(eReleaseVelocityResponseCurve);      addProp(eReleaseVelocityResponseCurve);
860      addProp(eReleaseVelocityResponseDepth);      addProp(eReleaseVelocityResponseDepth);
861    
862        eReleaseVelocityResponseCurve.signal_value_changed().connect(
863            sigc::mem_fun(release_curve, &VelocityCurve::queue_draw));
864        eReleaseVelocityResponseDepth.signal_value_changed().connect(
865            sigc::mem_fun(release_curve, &VelocityCurve::queue_draw));
866        frame = new Gtk::Frame;
867        frame->add(release_curve);
868        // on Gtk 3 there is no margin at all by default
869    #if GTKMM_MAJOR_VERSION >= 3
870        frame->set_margin_top(12);
871        frame->set_margin_bottom(12);
872    #endif
873    #if USE_GTKMM_GRID
874        table[pageno]->attach(*frame, 1, rowno, 2);
875    #else
876        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
877                              Gtk::SHRINK, Gtk::SHRINK);
878    #endif
879        rowno++;
880    
881      addProp(eReleaseTriggerDecay);      addProp(eReleaseTriggerDecay);
882      {      {
883          const char* choices[] = { "none", "effect4depth", "effect5depth", 0 };          const char* choices[] = { _("none"), _("effect4depth"), _("effect5depth"), 0 };
884          static const gig::dim_bypass_ctrl_t values[] = {          static const gig::dim_bypass_ctrl_t values[] = {
885              gig::dim_bypass_ctrl_none,              gig::dim_bypass_ctrl_none,
886              gig::dim_bypass_ctrl_94,              gig::dim_bypass_ctrl_94,
# Line 383  DimRegionEdit::DimRegionEdit() : Line 889  DimRegionEdit::DimRegionEdit() :
889          eDimensionBypass.set_choices(choices, values);          eDimensionBypass.set_choices(choices, values);
890      }      }
891      addProp(eDimensionBypass);      addProp(eDimensionBypass);
892        eSelfMask.widget.set_tooltip_text(_(
893            "If enabled: new notes with higher velocity value will stop older "
894            "notes with lower velocity values, that way you can save voices that "
895            "would barely be audible. This is also useful for certain drum sounds."
896        ));
897      addProp(eSelfMask);      addProp(eSelfMask);
898        eSustainDefeat.widget.set_tooltip_text(_(
899            "If enabled: sustain pedal will not hold a note. This way you can use "
900            "the sustain pedal for other purposes, for example to switch among "
901            "dimension regions."
902        ));
903      addProp(eSustainDefeat);      addProp(eSustainDefeat);
904        eMSDecode.widget.set_tooltip_text(_(
905            "Defines if Mid/Side Recordings should be decoded. Mid/Side Recordings "
906            "are an alternative way to record sounds in stereo. The sampler needs "
907            "to decode such samples to actually make use of them. Note: this "
908            "feature is currently not supported by LinuxSampler."
909        ));
910      addProp(eMSDecode);      addProp(eMSDecode);
911    
912      nextPage();      nextPage();
913    
914    
915      eEG1InfiniteSustain.signal_toggled().connect(      eEG1InfiniteSustain.signal_value_changed().connect(
916          sigc::mem_fun(*this, &DimRegionEdit::EG1InfiniteSustain_toggled) );          sigc::mem_fun(*this, &DimRegionEdit::EG1InfiniteSustain_toggled));
917      eEG2InfiniteSustain.signal_toggled().connect(      eEG2InfiniteSustain.signal_value_changed().connect(
918          sigc::mem_fun(*this, &DimRegionEdit::EG2InfiniteSustain_toggled) );          sigc::mem_fun(*this, &DimRegionEdit::EG2InfiniteSustain_toggled));
919      eEG1Controller.signal_changed().connect(      eEG1Controller.signal_value_changed().connect(
920          sigc::mem_fun(*this, &DimRegionEdit::EG1Controller_changed) );          sigc::mem_fun(*this, &DimRegionEdit::EG1Controller_changed));
921      eEG2Controller.signal_changed().connect(      eEG2Controller.signal_value_changed().connect(
922          sigc::mem_fun(*this, &DimRegionEdit::EG2Controller_changed) );          sigc::mem_fun(*this, &DimRegionEdit::EG2Controller_changed));
923      eLFO1Controller.signal_changed().connect(      eLFO1Controller.signal_value_changed().connect(
924          sigc::mem_fun(*this, &DimRegionEdit::LFO1Controller_changed) );          sigc::mem_fun(*this, &DimRegionEdit::LFO1Controller_changed));
925      eLFO2Controller.signal_changed().connect(      eLFO2Controller.signal_value_changed().connect(
926          sigc::mem_fun(*this, &DimRegionEdit::LFO2Controller_changed) );          sigc::mem_fun(*this, &DimRegionEdit::LFO2Controller_changed));
927      eLFO3Controller.signal_changed().connect(      eLFO3Controller.signal_value_changed().connect(
928          sigc::mem_fun(*this, &DimRegionEdit::LFO3Controller_changed) );          sigc::mem_fun(*this, &DimRegionEdit::LFO3Controller_changed));
929      eAttenuationController.signal_changed().connect(      eAttenuationController.signal_value_changed().connect(
930          sigc::mem_fun(*this, &DimRegionEdit::AttenuationController_changed) );          sigc::mem_fun(*this, &DimRegionEdit::AttenuationController_changed));
931      eVCFEnabled.signal_toggled().connect(      eVCFEnabled.signal_value_changed().connect(
932          sigc::mem_fun(*this, &DimRegionEdit::VCFEnabled_toggled) );          sigc::mem_fun(*this, &DimRegionEdit::VCFEnabled_toggled));
933      eVCFCutoffController.signal_changed().connect(      eVCFCutoffController.signal_value_changed().connect(
934          sigc::mem_fun(*this, &DimRegionEdit::VCFCutoffController_changed) );          sigc::mem_fun(*this, &DimRegionEdit::VCFCutoffController_changed));
935      eVCFResonanceController.signal_changed().connect(      eVCFResonanceController.signal_value_changed().connect(
936          sigc::mem_fun(*this, &DimRegionEdit::VCFResonanceController_changed) );          sigc::mem_fun(*this, &DimRegionEdit::VCFResonanceController_changed));
937    
938      eCrossfade_in_start.signal_changed_by_user().connect(      eCrossfade_in_start.signal_value_changed().connect(
939          sigc::mem_fun(*this, &DimRegionEdit::crossfade1_changed));          sigc::mem_fun(*this, &DimRegionEdit::crossfade1_changed));
940      eCrossfade_in_end.signal_changed_by_user().connect(      eCrossfade_in_end.signal_value_changed().connect(
941          sigc::mem_fun(*this, &DimRegionEdit::crossfade2_changed));          sigc::mem_fun(*this, &DimRegionEdit::crossfade2_changed));
942      eCrossfade_out_start.signal_changed_by_user().connect(      eCrossfade_out_start.signal_value_changed().connect(
943          sigc::mem_fun(*this, &DimRegionEdit::crossfade3_changed));          sigc::mem_fun(*this, &DimRegionEdit::crossfade3_changed));
944      eCrossfade_out_end.signal_changed_by_user().connect(      eCrossfade_out_end.signal_value_changed().connect(
945          sigc::mem_fun(*this, &DimRegionEdit::crossfade4_changed));          sigc::mem_fun(*this, &DimRegionEdit::crossfade4_changed));
946    
947      eSampleLoopEnabled.signal_toggled().connect(      eSampleLoopEnabled.signal_value_changed().connect(
948          sigc::mem_fun(*this, &DimRegionEdit::loop_enabled_toggled));          sigc::mem_fun(*this, &DimRegionEdit::update_loop_elements));
949      eSampleLoopStart.signal_changed_by_user().connect(      eSampleLoopStart.signal_value_changed().connect(
950          sigc::mem_fun(*this, &DimRegionEdit::updateLoopElements));          sigc::mem_fun(*this, &DimRegionEdit::loop_start_changed));
951      eSampleLoopLength.signal_changed_by_user().connect(      eSampleLoopLength.signal_value_changed().connect(
952          sigc::mem_fun(*this, &DimRegionEdit::updateLoopElements));          sigc::mem_fun(*this, &DimRegionEdit::loop_length_changed));
953      eSampleLoopInfinite.signal_toggled().connect(      eSampleLoopInfinite.signal_value_changed().connect(
954          sigc::mem_fun(*this, &DimRegionEdit::loop_infinite_toggled));          sigc::mem_fun(*this, &DimRegionEdit::loop_infinite_toggled));
955    
956      append_page(*table[0], "Sample");      append_page(*table[0], _("Sample"));
957      append_page(*table[1], "Amplitude (1)");      append_page(*table[1], _("Amplitude (1)"));
958      append_page(*table[2], "Amplitude (2)");      append_page(*table[2], _("Amplitude (2)"));
959      append_page(*table[3], "Filter (1)");      append_page(*table[3], _("Filter (1)"));
960      append_page(*table[4], "Filter (2)");      append_page(*table[4], _("Filter (2)"));
961      append_page(*table[5], "Pitch");      append_page(*table[5], _("Pitch"));
962      append_page(*table[6], "Misc");      append_page(*table[6], _("Misc"));
963  }  }
964    
965  DimRegionEdit::~DimRegionEdit()  DimRegionEdit::~DimRegionEdit()
# Line 448  void DimRegionEdit::addString(const char Line 970  void DimRegionEdit::addString(const char
970                                Gtk::Entry*& widget)                                Gtk::Entry*& widget)
971  {  {
972      label = new Gtk::Label(Glib::ustring(labelText) + ":");      label = new Gtk::Label(Glib::ustring(labelText) + ":");
973      label->set_alignment(Gtk::ALIGN_LEFT);  #if HAS_GTKMM_ALIGNMENT
974        label->set_alignment(Gtk::ALIGN_START);
975    #else
976        label->set_halign(Gtk::Align::START);
977    #endif
978    
979    #if USE_GTKMM_GRID
980        table[pageno]->attach(*label, 1, rowno);
981    #else
982      table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,      table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,
983                            Gtk::FILL, Gtk::SHRINK);                            Gtk::FILL, Gtk::SHRINK);
984    #endif
985    
986      widget = new Gtk::Entry();      widget = new Gtk::Entry();
987    
988    #if USE_GTKMM_GRID
989        table[pageno]->attach(*widget, 2, rowno);
990    #else
991      table[pageno]->attach(*widget, 2, 3, rowno, rowno + 1,      table[pageno]->attach(*widget, 2, 3, rowno, rowno + 1,
992                            Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);                            Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
993    #endif
994    
995        rowno++;
996    }
997    
998    void DimRegionEdit::addString(const char* labelText, Gtk::Label*& label,
999                                  Gtk::Entry*& widget, Gtk::Button*& button)
1000    {
1001        label = new Gtk::Label(Glib::ustring(labelText) + ":");
1002    #if HAS_GTKMM_ALIGNMENT
1003        label->set_alignment(Gtk::ALIGN_START);
1004    #else
1005        label->set_halign(Gtk::Align::START);
1006    #endif
1007    
1008    #if USE_GTKMM_GRID
1009        table[pageno]->attach(*label, 1, rowno);
1010    #else
1011        table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,
1012                              Gtk::FILL, Gtk::SHRINK);
1013    #endif
1014    
1015        widget = new Gtk::Entry();
1016        button = new Gtk::Button();
1017    
1018        HBox* hbox = new HBox;
1019        hbox->pack_start(*widget);
1020        hbox->pack_start(*button, Gtk::PACK_SHRINK);
1021    
1022    #if USE_GTKMM_GRID
1023        table[pageno]->attach(*hbox, 2, rowno);
1024    #else
1025        table[pageno]->attach(*hbox, 2, 3, rowno, rowno + 1,
1026                              Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
1027    #endif
1028    
1029      rowno++;      rowno++;
1030  }  }
1031    
1032  void DimRegionEdit::addHeader(const char* text)  Gtk::Label* DimRegionEdit::addHeader(const char* text)
1033  {  {
1034      if (firstRowInBlock < rowno - 1)      if (firstRowInBlock < rowno - 1)
1035      {      {
1036          Gtk::Label* filler = new Gtk::Label("    ");          Gtk::Label* filler = new Gtk::Label("    ");
1037    #if USE_GTKMM_GRID
1038            table[pageno]->attach(*filler, 0, firstRowInBlock);
1039    #else
1040          table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,          table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,
1041                                Gtk::FILL, Gtk::SHRINK);                                Gtk::FILL, Gtk::SHRINK);
1042    #endif
1043      }      }
1044      Glib::ustring str = "<b>";      Glib::ustring str = "<b>";
1045      str += text;      str += text;
1046      str += "</b>";      str += "</b>";
1047      Gtk::Label* label = new Gtk::Label(str);      Gtk::Label* label = new Gtk::Label(str);
1048      label->set_use_markup();      label->set_use_markup();
1049      label->set_alignment(Gtk::ALIGN_LEFT);  #if HAS_GTKMM_ALIGNMENT
1050        label->set_alignment(Gtk::ALIGN_START);
1051    #else
1052        label->set_halign(Gtk::Align::START);
1053    #endif
1054        // on GTKMM 3 there is absolutely no margin by default
1055    #if GTKMM_MAJOR_VERSION >= 3
1056        label->set_margin_top(18);
1057        label->set_margin_bottom(13);
1058    #endif
1059    #if USE_GTKMM_GRID
1060        table[pageno]->attach(*label, 0, rowno, 3);
1061    #else
1062      table[pageno]->attach(*label, 0, 3, rowno, rowno + 1,      table[pageno]->attach(*label, 0, 3, rowno, rowno + 1,
1063                            Gtk::FILL, Gtk::SHRINK);                            Gtk::FILL, Gtk::SHRINK);
1064    #endif
1065      rowno++;      rowno++;
1066      firstRowInBlock = rowno;      firstRowInBlock = rowno;
1067        return label;
1068  }  }
1069    
1070  void DimRegionEdit::nextPage()  void DimRegionEdit::nextPage()
# Line 486  void DimRegionEdit::nextPage() Line 1072  void DimRegionEdit::nextPage()
1072      if (firstRowInBlock < rowno - 1)      if (firstRowInBlock < rowno - 1)
1073      {      {
1074          Gtk::Label* filler = new Gtk::Label("    ");          Gtk::Label* filler = new Gtk::Label("    ");
1075    #if USE_GTKMM_GRID
1076            table[pageno]->attach(*filler, 0, firstRowInBlock);
1077    #else
1078          table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,          table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,
1079                                Gtk::FILL, Gtk::SHRINK);                                Gtk::FILL, Gtk::SHRINK);
1080    #endif
1081      }      }
1082      pageno++;      pageno++;
1083      rowno = 0;      rowno = 0;
# Line 496  void DimRegionEdit::nextPage() Line 1086  void DimRegionEdit::nextPage()
1086    
1087  void DimRegionEdit::addProp(BoolEntry& boolentry)  void DimRegionEdit::addProp(BoolEntry& boolentry)
1088  {  {
1089    #if USE_GTKMM_GRID
1090        table[pageno]->attach(boolentry.widget, 1, rowno, 2);
1091    #else
1092        table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1,
1093                              Gtk::FILL, Gtk::SHRINK);
1094    #endif
1095        rowno++;
1096    }
1097    
1098    void DimRegionEdit::addProp(BoolEntryPlus6& boolentry)
1099    {
1100    #if USE_GTKMM_GRID
1101        table[pageno]->attach(boolentry.widget, 1, rowno, 2);
1102    #else
1103      table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1,      table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1,
1104                            Gtk::FILL, Gtk::SHRINK);                            Gtk::FILL, Gtk::SHRINK);
1105    #endif
1106      rowno++;      rowno++;
     boolentry.signal_changed_by_user().connect(dimreg_changed_signal.make_slot());  
1107  }  }
1108    
1109  void DimRegionEdit::addProp(LabelWidget& prop)  void DimRegionEdit::addProp(LabelWidget& prop)
1110  {  {
1111    #if USE_GTKMM_GRID
1112        table[pageno]->attach(prop.label, 1, rowno);
1113        table[pageno]->attach(prop.widget, 2, rowno);
1114    #else
1115      table[pageno]->attach(prop.label, 1, 2, rowno, rowno + 1,      table[pageno]->attach(prop.label, 1, 2, rowno, rowno + 1,
1116                            Gtk::FILL, Gtk::SHRINK);                            Gtk::FILL, Gtk::SHRINK);
1117      table[pageno]->attach(prop.widget, 2, 3, rowno, rowno + 1,      table[pageno]->attach(prop.widget, 2, 3, rowno, rowno + 1,
1118                            Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);                            Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
1119    #endif
1120        rowno++;
1121    }
1122    
1123    void DimRegionEdit::addLine(HBox& line)
1124    {
1125    #if USE_GTKMM_GRID
1126        table[pageno]->attach(line, 1, rowno, 2);
1127    #else
1128        table[pageno]->attach(line, 1, 3, rowno, rowno + 1,
1129                              Gtk::FILL, Gtk::SHRINK);
1130    #endif
1131      rowno++;      rowno++;
     prop.signal_changed_by_user().connect(dimreg_changed_signal.make_slot());  
1132  }  }
1133    
1134    void DimRegionEdit::addRightHandSide(Gtk::Widget& widget)
1135    {
1136    #if USE_GTKMM_GRID
1137        table[pageno]->attach(widget, 2, rowno);
1138    #else
1139        table[pageno]->attach(widget, 2, 3, rowno, rowno + 1,
1140                              Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
1141    #endif
1142        rowno++;
1143    }
1144    
1145  void DimRegionEdit::set_dim_region(gig::DimensionRegion* d)  void DimRegionEdit::set_dim_region(gig::DimensionRegion* d)
1146  {  {
1147      dimregion = d;      dimregion = d;
1148        velocity_curve.set_dim_region(d);
1149        release_curve.set_dim_region(d);
1150        cutoff_curve.set_dim_region(d);
1151        crossfade_curve.set_dim_region(d);
1152    
1153      set_sensitive(d);      set_sensitive(d);
1154      if (!d) return;      if (!d) return;
1155    
1156      wSample->set_text(d->pSample ? d->pSample->pInfo->Name.c_str() : "NULL");      update_model++;
1157      eEG1PreAttack.set_ptr(&d->EG1PreAttack);      eEG1PreAttack.set_value(d->EG1PreAttack);
1158      eEG1Attack.set_ptr(&d->EG1Attack);      eEG1Attack.set_value(d->EG1Attack);
1159      eEG1Decay1.set_ptr(&d->EG1Decay1);      eEG1Decay1.set_value(d->EG1Decay1);
1160      eEG1Decay2.set_ptr(&d->EG1Decay2);      eEG1Decay2.set_value(d->EG1Decay2);
1161      eEG1InfiniteSustain.set_ptr(&d->EG1InfiniteSustain);      eEG1InfiniteSustain.set_value(d->EG1InfiniteSustain);
1162      eEG1Sustain.set_ptr(&d->EG1Sustain);      eEG1Sustain.set_value(d->EG1Sustain);
1163      eEG1Release.set_ptr(&d->EG1Release);      eEG1Release.set_value(d->EG1Release);
1164      eEG1Hold.set_ptr(&d->EG1Hold);      eEG1Hold.set_value(d->EG1Hold);
1165      eEG1Controller.set_ptr(&d->EG1Controller);      eEG1Controller.set_value(d->EG1Controller);
1166      eEG1ControllerInvert.set_ptr(&d->EG1ControllerInvert);      eEG1ControllerInvert.set_value(d->EG1ControllerInvert);
1167      eEG1ControllerAttackInfluence.set_ptr(&d->EG1ControllerAttackInfluence);      eEG1ControllerAttackInfluence.set_value(d->EG1ControllerAttackInfluence);
1168      eEG1ControllerDecayInfluence.set_ptr(&d->EG1ControllerDecayInfluence);      eEG1ControllerDecayInfluence.set_value(d->EG1ControllerDecayInfluence);
1169      eEG1ControllerReleaseInfluence.set_ptr(&d->EG1ControllerReleaseInfluence);      eEG1ControllerReleaseInfluence.set_value(d->EG1ControllerReleaseInfluence);
1170      eLFO1Frequency.set_ptr(&d->LFO1Frequency);      eEG1StateOptions.checkBoxAttack.set_value(d->EG1Options.AttackCancel);
1171      eLFO1InternalDepth.set_ptr(&d->LFO1InternalDepth);      eEG1StateOptions.checkBoxAttackHold.set_value(d->EG1Options.AttackHoldCancel);
1172      eLFO1ControlDepth.set_ptr(&d->LFO1ControlDepth);      eEG1StateOptions.checkBoxDecay1.set_value(d->EG1Options.Decay1Cancel);
1173      eLFO1Controller.set_ptr(&d->LFO1Controller);      eEG1StateOptions.checkBoxDecay2.set_value(d->EG1Options.Decay2Cancel);
1174      eLFO1FlipPhase.set_ptr(&d->LFO1FlipPhase);      eEG1StateOptions.checkBoxRelease.set_value(d->EG1Options.ReleaseCancel);
1175      eLFO1Sync.set_ptr(&d->LFO1Sync);      eLFO1Frequency.set_value(d->LFO1Frequency);
1176      eEG2PreAttack.set_ptr(&d->EG2PreAttack);      eLFO1InternalDepth.set_value(d->LFO1InternalDepth);
1177      eEG2Attack.set_ptr(&d->EG2Attack);      eLFO1ControlDepth.set_value(d->LFO1ControlDepth);
1178      eEG2Decay1.set_ptr(&d->EG2Decay1);      eLFO1Controller.set_value(d->LFO1Controller);
1179      eEG2Decay2.set_ptr(&d->EG2Decay2);      eLFO1FlipPhase.set_value(d->LFO1FlipPhase);
1180      eEG2InfiniteSustain.set_ptr(&d->EG2InfiniteSustain);      eLFO1Sync.set_value(d->LFO1Sync);
1181      eEG2Sustain.set_ptr(&d->EG2Sustain);      eEG2PreAttack.set_value(d->EG2PreAttack);
1182      eEG2Release.set_ptr(&d->EG2Release);      eEG2Attack.set_value(d->EG2Attack);
1183      eEG2Controller.set_ptr(&d->EG2Controller);      eEG2Decay1.set_value(d->EG2Decay1);
1184      eEG2ControllerInvert.set_ptr(&d->EG2ControllerInvert);      eEG2Decay2.set_value(d->EG2Decay2);
1185      eEG2ControllerAttackInfluence.set_ptr(&d->EG2ControllerAttackInfluence);      eEG2InfiniteSustain.set_value(d->EG2InfiniteSustain);
1186      eEG2ControllerDecayInfluence.set_ptr(&d->EG2ControllerDecayInfluence);      eEG2Sustain.set_value(d->EG2Sustain);
1187      eEG2ControllerReleaseInfluence.set_ptr(&d->EG2ControllerReleaseInfluence);      eEG2Release.set_value(d->EG2Release);
1188      eLFO2Frequency.set_ptr(&d->LFO2Frequency);      eEG2Controller.set_value(d->EG2Controller);
1189      eLFO2InternalDepth.set_ptr(&d->LFO2InternalDepth);      eEG2ControllerInvert.set_value(d->EG2ControllerInvert);
1190      eLFO2ControlDepth.set_ptr(&d->LFO2ControlDepth);      eEG2ControllerAttackInfluence.set_value(d->EG2ControllerAttackInfluence);
1191      eLFO2Controller.set_ptr(&d->LFO2Controller);      eEG2ControllerDecayInfluence.set_value(d->EG2ControllerDecayInfluence);
1192      eLFO2FlipPhase.set_ptr(&d->LFO2FlipPhase);      eEG2ControllerReleaseInfluence.set_value(d->EG2ControllerReleaseInfluence);
1193      eLFO2Sync.set_ptr(&d->LFO2Sync);      eEG2StateOptions.checkBoxAttack.set_value(d->EG2Options.AttackCancel);
1194      eEG3Attack.set_ptr(&d->EG3Attack);      eEG2StateOptions.checkBoxAttackHold.set_value(d->EG2Options.AttackHoldCancel);
1195      eEG3Depth.set_ptr(&d->EG3Depth);      eEG2StateOptions.checkBoxDecay1.set_value(d->EG2Options.Decay1Cancel);
1196      eLFO3Frequency.set_ptr(&d->LFO3Frequency);      eEG2StateOptions.checkBoxDecay2.set_value(d->EG2Options.Decay2Cancel);
1197      eLFO3InternalDepth.set_ptr(&d->LFO3InternalDepth);      eEG2StateOptions.checkBoxRelease.set_value(d->EG2Options.ReleaseCancel);
1198      eLFO3ControlDepth.set_ptr(&d->LFO3ControlDepth);      eLFO2Frequency.set_value(d->LFO2Frequency);
1199      eLFO3Controller.set_ptr(&d->LFO3Controller);      eLFO2InternalDepth.set_value(d->LFO2InternalDepth);
1200      eLFO3Sync.set_ptr(&d->LFO3Sync);      eLFO2ControlDepth.set_value(d->LFO2ControlDepth);
1201      eVCFEnabled.set_ptr(&d->VCFEnabled);      eLFO2Controller.set_value(d->LFO2Controller);
1202      eVCFType.set_ptr(&d->VCFType);      eLFO2FlipPhase.set_value(d->LFO2FlipPhase);
1203      eVCFCutoffController.set_ptr(&d->VCFCutoffController);      eLFO2Sync.set_value(d->LFO2Sync);
1204      eVCFCutoffControllerInvert.set_ptr(&d->VCFCutoffControllerInvert);      eEG3Attack.set_value(d->EG3Attack);
1205      eVCFCutoff.set_ptr(&d->VCFCutoff);      eEG3Depth.set_value(d->EG3Depth);
1206      eVCFVelocityCurve.set_ptr(&d->VCFVelocityCurve);      eLFO3Frequency.set_value(d->LFO3Frequency);
1207      eVCFVelocityScale.set_ptr(&d->VCFVelocityScale);      eLFO3InternalDepth.set_value(d->LFO3InternalDepth);
1208      eVCFVelocityDynamicRange.set_ptr(&d->VCFVelocityDynamicRange);      eLFO3ControlDepth.set_value(d->LFO3ControlDepth);
1209      eVCFResonance.set_ptr(&d->VCFResonance);      eLFO3Controller.set_value(d->LFO3Controller);
1210      eVCFResonanceDynamic.set_ptr(&d->VCFResonanceDynamic);      eLFO3Sync.set_value(d->LFO3Sync);
1211      eVCFResonanceController.set_ptr(&d->VCFResonanceController);      eVCFEnabled.set_value(d->VCFEnabled);
1212      eVCFKeyboardTracking.set_ptr(&d->VCFKeyboardTracking);      eVCFType.set_value(d->VCFType);
1213      eVCFKeyboardTrackingBreakpoint.set_ptr(&d->VCFKeyboardTrackingBreakpoint);      eVCFCutoffController.set_value(d->VCFCutoffController);
1214      eVelocityResponseCurve.set_ptr(&d->VelocityResponseCurve);      eVCFCutoffControllerInvert.set_value(d->VCFCutoffControllerInvert);
1215      eVelocityResponseDepth.set_ptr(&d->VelocityResponseDepth);      eVCFCutoff.set_value(d->VCFCutoff);
1216      eVelocityResponseCurveScaling.set_ptr(&d->VelocityResponseCurveScaling);      eVCFVelocityCurve.set_value(d->VCFVelocityCurve);
1217      eReleaseVelocityResponseCurve.set_ptr(&d->ReleaseVelocityResponseCurve);      eVCFVelocityScale.set_value(d->VCFVelocityScale);
1218      eReleaseVelocityResponseDepth.set_ptr(&d->ReleaseVelocityResponseDepth);      eVCFVelocityDynamicRange.set_value(d->VCFVelocityDynamicRange);
1219      eReleaseTriggerDecay.set_ptr(&d->ReleaseTriggerDecay);      eVCFResonance.set_value(d->VCFResonance);
1220        eVCFResonanceDynamic.set_value(d->VCFResonanceDynamic);
1221      eCrossfade_in_start.set_ptr(0);      eVCFResonanceController.set_value(d->VCFResonanceController);
1222      eCrossfade_in_end.set_ptr(0);      eVCFKeyboardTracking.set_value(d->VCFKeyboardTracking);
1223      eCrossfade_out_start.set_ptr(0);      eVCFKeyboardTrackingBreakpoint.set_value(d->VCFKeyboardTrackingBreakpoint);
1224      eCrossfade_out_end.set_ptr(0);      eVelocityResponseCurve.set_value(d->VelocityResponseCurve);
1225      eCrossfade_in_start.set_ptr(&d->Crossfade.in_start);      eVelocityResponseDepth.set_value(d->VelocityResponseDepth);
1226      eCrossfade_in_end.set_ptr(&d->Crossfade.in_end);      eVelocityResponseCurveScaling.set_value(d->VelocityResponseCurveScaling);
1227      eCrossfade_out_start.set_ptr(&d->Crossfade.out_start);      eReleaseVelocityResponseCurve.set_value(d->ReleaseVelocityResponseCurve);
1228      eCrossfade_out_end.set_ptr(&d->Crossfade.out_end);      eReleaseVelocityResponseDepth.set_value(d->ReleaseVelocityResponseDepth);
1229        eReleaseTriggerDecay.set_value(d->ReleaseTriggerDecay);
1230      ePitchTrack.set_ptr(&d->PitchTrack);      eCrossfade_in_start.set_value(d->Crossfade.in_start);
1231      eDimensionBypass.set_ptr(&d->DimensionBypass);      eCrossfade_in_end.set_value(d->Crossfade.in_end);
1232      ePan.set_ptr(&d->Pan);      eCrossfade_out_start.set_value(d->Crossfade.out_start);
1233      eSelfMask.set_ptr(&d->SelfMask);      eCrossfade_out_end.set_value(d->Crossfade.out_end);
1234      eAttenuationController.set_ptr(&d->AttenuationController);      ePitchTrack.set_value(d->PitchTrack);
1235      eInvertAttenuationController.set_ptr(&d->InvertAttenuationController);      eDimensionBypass.set_value(d->DimensionBypass);
1236      eAttenuationControllerThreshold.set_ptr(&d->AttenuationControllerThreshold);      ePan.set_value(d->Pan);
1237      eChannelOffset.set_ptr(&d->ChannelOffset);      eSelfMask.set_value(d->SelfMask);
1238      eSustainDefeat.set_ptr(&d->SustainDefeat);      eAttenuationController.set_value(d->AttenuationController);
1239      eMSDecode.set_ptr(&d->MSDecode);      eInvertAttenuationController.set_value(d->InvertAttenuationController);
1240      eSampleStartOffset.set_ptr(&d->SampleStartOffset);      eAttenuationControllerThreshold.set_value(d->AttenuationControllerThreshold);
1241      eUnityNote.set_ptr(&d->UnityNote);      eChannelOffset.set_value(d->ChannelOffset);
1242      eFineTune.set_ptr(&d->FineTune);      eSustainDefeat.set_value(d->SustainDefeat);
1243      eGain.set_ptr(&d->Gain);      eMSDecode.set_value(d->MSDecode);
1244      eGainPlus6.set_ptr(&d->Gain);      eSampleStartOffset.set_value(d->SampleStartOffset);
1245        eUnityNote.set_value(d->UnityNote);
1246        // show sample group name
1247        {
1248            Glib::ustring s = "---";
1249            if (d->pSample && d->pSample->GetGroup())
1250                s = d->pSample->GetGroup()->Name;
1251            eSampleGroup.text.set_text(s);
1252        }
1253        // assemble sample format info string
1254        {
1255            Glib::ustring s;
1256            if (d->pSample) {
1257                switch (d->pSample->Channels) {
1258                    case 1: s = _("Mono"); break;
1259                    case 2: s = _("Stereo"); break;
1260                    default:
1261                        s = ToString(d->pSample->Channels) + _(" audio channels");
1262                        break;
1263                }
1264                s += " " + ToString(d->pSample->BitDepth) + " Bits";
1265                s += " " + ToString(d->pSample->SamplesPerSecond/1000) + "."
1266                          + ToString((d->pSample->SamplesPerSecond%1000)/100) + " kHz";
1267            } else {
1268                s = _("No sample assigned to this dimension region.");
1269            }
1270            eSampleFormatInfo.text.set_text(s);
1271        }
1272        // generate sample's memory address pointer string
1273        {
1274            Glib::ustring s;
1275            if (d->pSample) {
1276                char buf[64] = {};
1277                snprintf(buf, sizeof(buf), "%p", d->pSample);
1278                s = buf;
1279            } else {
1280                s = "---";
1281            }
1282            eSampleID.text.set_text(s);
1283        }
1284        // generate raw wave form data CRC-32 checksum string
1285        {
1286            Glib::ustring s = "---";
1287            if (d->pSample) {
1288                char buf[64] = {};
1289                snprintf(buf, sizeof(buf), "%x", d->pSample->GetWaveDataCRC32Checksum());
1290                s = buf;
1291            }
1292            eChecksum.text.set_text(s);
1293        }
1294        buttonSelectSample.set_sensitive(d && d->pSample);
1295        eFineTune.set_value(d->FineTune);
1296        eGain.set_value(d->Gain);
1297        eGainPlus6.set_value(d->Gain);
1298        eSampleLoopEnabled.set_value(d->SampleLoops);
1299        eSampleLoopType.set_value(
1300            d->SampleLoops ? d->pSampleLoops[0].LoopType : 0);
1301        eSampleLoopStart.set_value(
1302            d->SampleLoops ? d->pSampleLoops[0].LoopStart : 0);
1303        eSampleLoopLength.set_value(
1304            d->SampleLoops ? d->pSampleLoops[0].LoopLength : 0);
1305        eSampleLoopInfinite.set_value(
1306            d->pSample && d->pSample->LoopPlayCount == 0);
1307        eSampleLoopPlayCount.set_value(
1308            d->pSample ? d->pSample->LoopPlayCount : 0);
1309        update_model--;
1310    
1311      eSampleLoopEnabled.set_active(d->SampleLoops);      wSample->set_text(d->pSample ? gig_to_utf8(d->pSample->pInfo->Name) :
1312      updateLoopElements();                        _("NULL"));
1313    
1314        update_loop_elements();
1315      VCFEnabled_toggled();      VCFEnabled_toggled();
1316  }  }
1317    
1318    
1319  void DimRegionEdit::VCFEnabled_toggled()  void DimRegionEdit::VCFEnabled_toggled()
1320  {  {
1321      bool sensitive = eVCFEnabled.get_active();      bool sensitive = eVCFEnabled.get_value();
1322      eVCFType.set_sensitive(sensitive);      eVCFType.set_sensitive(sensitive);
1323      eVCFCutoffController.set_sensitive(sensitive);      eVCFCutoffController.set_sensitive(sensitive);
1324      eVCFVelocityCurve.set_sensitive(sensitive);      eVCFVelocityCurve.set_sensitive(sensitive);
1325      eVCFVelocityScale.set_sensitive(sensitive);      eVCFVelocityScale.set_sensitive(sensitive);
1326      eVCFVelocityDynamicRange.set_sensitive(sensitive);      eVCFVelocityDynamicRange.set_sensitive(sensitive);
1327        cutoff_curve.set_sensitive(sensitive);
1328      eVCFResonance.set_sensitive(sensitive);      eVCFResonance.set_sensitive(sensitive);
1329      eVCFResonanceController.set_sensitive(sensitive);      eVCFResonanceController.set_sensitive(sensitive);
1330      eVCFKeyboardTracking.set_sensitive(sensitive);      eVCFKeyboardTracking.set_sensitive(sensitive);
1331      eVCFKeyboardTrackingBreakpoint.set_sensitive(sensitive);      eVCFKeyboardTrackingBreakpoint.set_sensitive(sensitive);
1332        lEG2->set_sensitive(sensitive);
1333      eEG2PreAttack.set_sensitive(sensitive);      eEG2PreAttack.set_sensitive(sensitive);
1334      eEG2Attack.set_sensitive(sensitive);      eEG2Attack.set_sensitive(sensitive);
1335      eEG2Decay1.set_sensitive(sensitive);      eEG2Decay1.set_sensitive(sensitive);
# Line 638  void DimRegionEdit::VCFEnabled_toggled() Line 1340  void DimRegionEdit::VCFEnabled_toggled()
1340      eEG2ControllerAttackInfluence.set_sensitive(sensitive);      eEG2ControllerAttackInfluence.set_sensitive(sensitive);
1341      eEG2ControllerDecayInfluence.set_sensitive(sensitive);      eEG2ControllerDecayInfluence.set_sensitive(sensitive);
1342      eEG2ControllerReleaseInfluence.set_sensitive(sensitive);      eEG2ControllerReleaseInfluence.set_sensitive(sensitive);
1343        eEG2StateOptions.set_sensitive(sensitive);
1344        lLFO2->set_sensitive(sensitive);
1345      eLFO2Frequency.set_sensitive(sensitive);      eLFO2Frequency.set_sensitive(sensitive);
1346      eLFO2InternalDepth.set_sensitive(sensitive);      eLFO2InternalDepth.set_sensitive(sensitive);
1347      eLFO2ControlDepth.set_sensitive(sensitive);      eLFO2ControlDepth.set_sensitive(sensitive);
# Line 664  void DimRegionEdit::VCFEnabled_toggled() Line 1368  void DimRegionEdit::VCFEnabled_toggled()
1368    
1369  void DimRegionEdit::VCFCutoffController_changed()  void DimRegionEdit::VCFCutoffController_changed()
1370  {  {
1371      int rowno = eVCFCutoffController.get_active_row_number();      gig::vcf_cutoff_ctrl_t ctrl = eVCFCutoffController.get_value();
1372      bool hasController = rowno != 0 && rowno != 1;      bool hasController = ctrl != gig::vcf_cutoff_ctrl_none && ctrl != gig::vcf_cutoff_ctrl_none2;
1373    
1374      eVCFCutoffControllerInvert.set_sensitive(hasController);      eVCFCutoffControllerInvert.set_sensitive(hasController);
1375      eVCFCutoff.set_sensitive(!hasController);      eVCFCutoff.set_sensitive(!hasController);
1376      eVCFResonanceDynamic.set_sensitive(!hasController);      eVCFResonanceDynamic.set_sensitive(!hasController);
1377      eVCFVelocityScale.label.set_text(hasController ? "Minimum cutoff:" :      eVCFVelocityScale.label.set_text(hasController ? _("Minimum cutoff:") :
1378                                       "Velocity scale:");                                       _("Velocity scale:"));
1379  }  }
1380    
1381  void DimRegionEdit::VCFResonanceController_changed()  void DimRegionEdit::VCFResonanceController_changed()
1382  {  {
1383      bool hasController = eVCFResonanceController.get_active_row_number() != 0;      bool hasController = eVCFResonanceController.get_value() != gig::vcf_res_ctrl_none;
1384      eVCFResonance.set_sensitive(!hasController);      eVCFResonance.set_sensitive(!hasController);
1385  }  }
1386    
1387  void DimRegionEdit::EG1InfiniteSustain_toggled()  void DimRegionEdit::EG1InfiniteSustain_toggled()
1388  {  {
1389      bool infSus = eEG1InfiniteSustain.get_active();      bool infSus = eEG1InfiniteSustain.get_value();
1390      eEG1Decay2.set_sensitive(!infSus);      eEG1Decay2.set_sensitive(!infSus);
1391  }  }
1392    
1393  void DimRegionEdit::EG2InfiniteSustain_toggled()  void DimRegionEdit::EG2InfiniteSustain_toggled()
1394  {  {
1395      bool infSus = eEG2InfiniteSustain.get_active();      bool infSus = eEG2InfiniteSustain.get_value();
1396      eEG2Decay2.set_sensitive(!infSus);      eEG2Decay2.set_sensitive(!infSus);
1397  }  }
1398    
1399  void DimRegionEdit::EG1Controller_changed()  void DimRegionEdit::EG1Controller_changed()
1400  {  {
1401      bool hasController = eEG1Controller.get_active_row_number() != 0;      bool hasController = eEG1Controller.get_value().type != gig::leverage_ctrl_t::type_none;
1402      eEG1ControllerInvert.set_sensitive(hasController);      eEG1ControllerInvert.set_sensitive(hasController);
1403  }  }
1404    
1405  void DimRegionEdit::EG2Controller_changed()  void DimRegionEdit::EG2Controller_changed()
1406  {  {
1407      bool hasController = eEG2Controller.get_active_row_number() != 0;      bool hasController = eEG2Controller.get_value().type != gig::leverage_ctrl_t::type_none;
1408      eEG2ControllerInvert.set_sensitive(hasController);      eEG2ControllerInvert.set_sensitive(hasController);
1409  }  }
1410    
1411  void DimRegionEdit::AttenuationController_changed()  void DimRegionEdit::AttenuationController_changed()
1412  {  {
1413      bool hasController = eAttenuationController.get_active_row_number() != 0;      bool hasController =
1414            eAttenuationController.get_value().type != gig::leverage_ctrl_t::type_none;
1415      eInvertAttenuationController.set_sensitive(hasController);      eInvertAttenuationController.set_sensitive(hasController);
1416      eAttenuationControllerThreshold.set_sensitive(hasController);      eAttenuationControllerThreshold.set_sensitive(hasController);
1417      eCrossfade_in_start.set_sensitive(hasController);      eCrossfade_in_start.set_sensitive(hasController);
1418      eCrossfade_in_end.set_sensitive(hasController);      eCrossfade_in_end.set_sensitive(hasController);
1419      eCrossfade_out_start.set_sensitive(hasController);      eCrossfade_out_start.set_sensitive(hasController);
1420      eCrossfade_out_end.set_sensitive(hasController);      eCrossfade_out_end.set_sensitive(hasController);
1421        crossfade_curve.set_sensitive(hasController);
1422  }  }
1423    
1424  void DimRegionEdit::LFO1Controller_changed()  void DimRegionEdit::LFO1Controller_changed()
1425  {  {
1426      int rowno = eLFO1Controller.get_active_row_number();      gig::lfo1_ctrl_t ctrl = eLFO1Controller.get_value();
1427      eLFO1ControlDepth.set_sensitive(rowno != 0);      eLFO1ControlDepth.set_sensitive(ctrl != gig::lfo1_ctrl_internal);
1428      eLFO1InternalDepth.set_sensitive(rowno != 1 && rowno != 2);      eLFO1InternalDepth.set_sensitive(ctrl != gig::lfo1_ctrl_modwheel &&
1429                                         ctrl != gig::lfo1_ctrl_breath);
1430  }  }
1431    
1432  void DimRegionEdit::LFO2Controller_changed()  void DimRegionEdit::LFO2Controller_changed()
1433  {  {
1434      int rowno = eLFO2Controller.get_active_row_number();      gig::lfo2_ctrl_t ctrl = eLFO2Controller.get_value();
1435      eLFO2ControlDepth.set_sensitive(rowno != 0);      eLFO2ControlDepth.set_sensitive(ctrl != gig::lfo2_ctrl_internal);
1436      eLFO2InternalDepth.set_sensitive(rowno != 1 && rowno != 2);      eLFO2InternalDepth.set_sensitive(ctrl != gig::lfo2_ctrl_modwheel &&
1437                                         ctrl != gig::lfo2_ctrl_foot);
1438  }  }
1439    
1440  void DimRegionEdit::LFO3Controller_changed()  void DimRegionEdit::LFO3Controller_changed()
1441  {  {
1442      int rowno = eLFO3Controller.get_active_row_number();      gig::lfo3_ctrl_t ctrl = eLFO3Controller.get_value();
1443      eLFO3ControlDepth.set_sensitive(rowno != 0);      eLFO3ControlDepth.set_sensitive(ctrl != gig::lfo3_ctrl_internal);
1444      eLFO3InternalDepth.set_sensitive(rowno != 1 && rowno != 2);      eLFO3InternalDepth.set_sensitive(ctrl != gig::lfo3_ctrl_modwheel &&
1445                                         ctrl != gig::lfo3_ctrl_aftertouch);
1446  }  }
1447    
1448  void DimRegionEdit::crossfade1_changed()  void DimRegionEdit::crossfade1_changed()
1449  {  {
1450      double c1 = eCrossfade_in_start.get_value();      update_model++;
1451      double c2 = eCrossfade_in_end.get_value();      eCrossfade_in_end.set_value(dimregion->Crossfade.in_end);
1452      if (c1 > c2) eCrossfade_in_end.set_value(c1);      eCrossfade_out_start.set_value(dimregion->Crossfade.out_start);
1453        eCrossfade_out_end.set_value(dimregion->Crossfade.out_end);
1454        update_model--;
1455  }  }
1456    
1457  void DimRegionEdit::crossfade2_changed()  void DimRegionEdit::crossfade2_changed()
1458  {  {
1459      double c1 = eCrossfade_in_start.get_value();      update_model++;
1460      double c2 = eCrossfade_in_end.get_value();      eCrossfade_in_start.set_value(dimregion->Crossfade.in_start);
1461      double c3 = eCrossfade_out_start.get_value();      eCrossfade_out_start.set_value(dimregion->Crossfade.out_start);
1462        eCrossfade_out_end.set_value(dimregion->Crossfade.out_end);
1463      if (c2 < c1) eCrossfade_in_start.set_value(c2);      update_model--;
     if (c2 > c3) eCrossfade_out_start.set_value(c2);  
1464  }  }
1465    
1466  void DimRegionEdit::crossfade3_changed()  void DimRegionEdit::crossfade3_changed()
1467  {  {
1468      double c2 = eCrossfade_in_end.get_value();      update_model++;
1469      double c3 = eCrossfade_out_start.get_value();      eCrossfade_in_start.set_value(dimregion->Crossfade.in_start);
1470      double c4 = eCrossfade_out_end.get_value();      eCrossfade_in_end.set_value(dimregion->Crossfade.in_end);
1471        eCrossfade_out_end.set_value(dimregion->Crossfade.out_end);
1472      if (c3 < c2) eCrossfade_in_end.set_value(c3);      update_model--;
     if (c3 > c4) eCrossfade_out_end.set_value(c3);  
1473  }  }
1474    
1475  void DimRegionEdit::crossfade4_changed()  void DimRegionEdit::crossfade4_changed()
1476  {  {
1477      double c3 = eCrossfade_out_start.get_value();      update_model++;
1478      double c4 = eCrossfade_out_end.get_value();      eCrossfade_in_start.set_value(dimregion->Crossfade.in_start);
1479        eCrossfade_in_end.set_value(dimregion->Crossfade.in_end);
1480        eCrossfade_out_start.set_value(dimregion->Crossfade.out_start);
1481        update_model--;
1482    }
1483    
1484    void DimRegionEdit::update_loop_elements()
1485    {
1486        update_model++;
1487        const bool active = eSampleLoopEnabled.get_value();
1488        eSampleLoopStart.set_sensitive(active);
1489        eSampleLoopLength.set_sensitive(active);
1490        eSampleLoopType.set_sensitive(active);
1491        eSampleLoopInfinite.set_sensitive(active && dimregion && dimregion->pSample);
1492        // sample loop shall never be longer than the actual sample size
1493        loop_start_changed();
1494        loop_length_changed();
1495        eSampleLoopStart.set_value(
1496            dimregion->SampleLoops ? dimregion->pSampleLoops[0].LoopStart : 0);
1497        eSampleLoopLength.set_value(
1498            dimregion->SampleLoops ? dimregion->pSampleLoops[0].LoopLength : 0);
1499    
1500        eSampleLoopInfinite.set_value(
1501            dimregion->pSample && dimregion->pSample->LoopPlayCount == 0);
1502    
1503        loop_infinite_toggled();
1504        update_model--;
1505    }
1506    
1507    void DimRegionEdit::loop_start_changed() {
1508        if (dimregion && dimregion->SampleLoops) {
1509            eSampleLoopLength.set_upper(dimregion->pSample ?
1510                                        dimregion->pSample->SamplesTotal -
1511                                        dimregion->pSampleLoops[0].LoopStart : 0);
1512        }
1513    }
1514    
1515    void DimRegionEdit::loop_length_changed() {
1516        if (dimregion && dimregion->SampleLoops) {
1517            eSampleLoopStart.set_upper(dimregion->pSample ?
1518                                       dimregion->pSample->SamplesTotal -
1519                                       dimregion->pSampleLoops[0].LoopLength : 0);
1520        }
1521    }
1522    
1523    void DimRegionEdit::loop_infinite_toggled() {
1524        eSampleLoopPlayCount.set_sensitive(
1525            dimregion && dimregion->pSample &&
1526            !eSampleLoopInfinite.get_value() &&
1527            eSampleLoopEnabled.get_value()
1528        );
1529        update_model++;
1530        eSampleLoopPlayCount.set_value(
1531            dimregion->pSample ? dimregion->pSample->LoopPlayCount : 0);
1532        update_model--;
1533    }
1534    
1535    bool DimRegionEdit::set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop)
1536    {
1537        bool result = false;
1538        for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimregs.begin();
1539             itDimReg != dimregs.end(); ++itDimReg)
1540        {
1541            result |= set_sample(*itDimReg, sample, copy_sample_unity, copy_sample_tune, copy_sample_loop);
1542        }
1543        return result;
1544    }
1545    
1546    bool DimRegionEdit::set_sample(gig::DimensionRegion* dimreg, gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop)
1547    {
1548        if (dimreg) {
1549            //TODO: we should better move the code from MainWindow::on_sample_label_drop_drag_data_received() here
1550    
1551            // currently commented because we're sending a similar signal in MainWindow::on_sample_label_drop_drag_data_received()
1552            //DimRegionChangeGuard(this, dimregion);
1553    
1554            // make sure stereo samples always are the same in both
1555            // dimregs in the samplechannel dimension
1556            int nbDimregs = 1;
1557            gig::DimensionRegion* d[2] = { dimreg, 0 };
1558            if (sample->Channels == 2) {
1559                gig::Region* region = dimreg->GetParent();
1560    
1561                int bitcount = 0;
1562                int stereo_bit = 0;
1563                for (int dim = 0 ; dim < region->Dimensions ; dim++) {
1564                    if (region->pDimensionDefinitions[dim].dimension == gig::dimension_samplechannel) {
1565                        stereo_bit = 1 << bitcount;
1566                        break;
1567                    }
1568                    bitcount += region->pDimensionDefinitions[dim].bits;
1569                }
1570    
1571                if (stereo_bit) {
1572                    int dimregno;
1573                    for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
1574                        if (region->pDimensionRegions[dimregno] == dimreg) {
1575                            break;
1576                        }
1577                    }
1578                    d[0] = region->pDimensionRegions[dimregno & ~stereo_bit];
1579                    d[1] = region->pDimensionRegions[dimregno | stereo_bit];
1580                    nbDimregs = 2;
1581                }
1582            }
1583    
1584      if (c4 < c3) eCrossfade_out_start.set_value(c4);          gig::Sample* oldref = dimreg->pSample;
1585    
1586            for (int i = 0 ; i < nbDimregs ; i++) {
1587                d[i]->pSample = sample;
1588    
1589                // copy sample information from Sample to DimensionRegion
1590                if (copy_sample_unity)
1591                    d[i]->UnityNote = sample->MIDIUnityNote;
1592                if (copy_sample_tune)
1593                    d[i]->FineTune = sample->FineTune;
1594                if (copy_sample_loop) {
1595                    int loops = sample->Loops ? 1 : 0;
1596                    while (d[i]->SampleLoops > loops) {
1597                        d[i]->DeleteSampleLoop(&d[i]->pSampleLoops[0]);
1598                    }
1599                    while (d[i]->SampleLoops < sample->Loops) {
1600                        DLS::sample_loop_t loop;
1601                        d[i]->AddSampleLoop(&loop);
1602                    }
1603                    if (loops) {
1604                        d[i]->pSampleLoops[0].Size = sizeof(DLS::sample_loop_t);
1605                        d[i]->pSampleLoops[0].LoopType = sample->LoopType;
1606                        d[i]->pSampleLoops[0].LoopStart = sample->LoopStart;
1607                        d[i]->pSampleLoops[0].LoopLength = sample->LoopEnd - sample->LoopStart + 1;
1608                    }
1609                }
1610            }
1611    
1612            // update ui
1613            update_model++;
1614            wSample->set_text(gig_to_utf8(dimreg->pSample->pInfo->Name));
1615            eUnityNote.set_value(dimreg->UnityNote);
1616            eFineTune.set_value(dimreg->FineTune);
1617            eSampleLoopEnabled.set_value(dimreg->SampleLoops);
1618            update_loop_elements();
1619            update_model--;
1620    
1621            sample_ref_changed_signal.emit(oldref, sample);
1622            return true;
1623        }
1624        return false;
1625  }  }
1626    
1627  void DimRegionEdit::loop_enabled_toggled()  sigc::signal<void, gig::DimensionRegion*>& DimRegionEdit::signal_dimreg_to_be_changed() {
1628        return dimreg_to_be_changed_signal;
1629    }
1630    
1631    sigc::signal<void, gig::DimensionRegion*>& DimRegionEdit::signal_dimreg_changed() {
1632        return dimreg_changed_signal;
1633    }
1634    
1635    sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& DimRegionEdit::signal_sample_ref_changed() {
1636        return sample_ref_changed_signal;
1637    }
1638    
1639    
1640    void DimRegionEdit::set_UnityNote(gig::DimensionRegion* d, uint8_t value)
1641  {  {
1642      const bool active = eSampleLoopEnabled.get_active();      d->UnityNote = value;
1643      if (active) {  }
1644    
1645    void DimRegionEdit::set_FineTune(gig::DimensionRegion* d, int16_t value)
1646    {
1647        d->FineTune = value;
1648    }
1649    
1650    void DimRegionEdit::set_Crossfade_in_start(gig::DimensionRegion* d,
1651                                               uint8_t value)
1652    {
1653        d->Crossfade.in_start = value;
1654        if (d->Crossfade.in_end < value) set_Crossfade_in_end(d, value);
1655    }
1656    
1657    void DimRegionEdit::set_Crossfade_in_end(gig::DimensionRegion* d,
1658                                             uint8_t value)
1659    {
1660        d->Crossfade.in_end = value;
1661        if (value < d->Crossfade.in_start) set_Crossfade_in_start(d, value);
1662        if (value > d->Crossfade.out_start) set_Crossfade_out_start(d, value);
1663    }
1664    
1665    void DimRegionEdit::set_Crossfade_out_start(gig::DimensionRegion* d,
1666                                                uint8_t value)
1667    {
1668        d->Crossfade.out_start = value;
1669        if (value < d->Crossfade.in_end) set_Crossfade_in_end(d, value);
1670        if (value > d->Crossfade.out_end) set_Crossfade_out_end(d, value);
1671    }
1672    
1673    void DimRegionEdit::set_Crossfade_out_end(gig::DimensionRegion* d,
1674                                              uint8_t value)
1675    {
1676        d->Crossfade.out_end = value;
1677        if (value < d->Crossfade.out_start) set_Crossfade_out_start(d, value);
1678    }
1679    
1680    void DimRegionEdit::set_Gain(gig::DimensionRegion* d, int32_t value)
1681    {
1682        d->SetGain(value);
1683    }
1684    
1685    void DimRegionEdit::set_LoopEnabled(gig::DimensionRegion* d, bool value)
1686    {
1687        if (value) {
1688          // create a new sample loop in case there is none yet          // create a new sample loop in case there is none yet
1689          if (!dimregion->SampleLoops) {          if (!d->SampleLoops) {
1690                DimRegionChangeGuard(this, d);
1691    
1692              DLS::sample_loop_t loop;              DLS::sample_loop_t loop;
1693              loop.LoopType   = gig::loop_type_normal;              loop.LoopType = gig::loop_type_normal;
1694              // loop the whole sample by default              // loop the whole sample by default
1695              loop.LoopStart  = 0;              loop.LoopStart  = 0;
1696              loop.LoopLength =              loop.LoopLength =
1697                  (dimregion->pSample) ? dimregion->pSample->GetSize() : 0;                  (d->pSample) ? d->pSample->SamplesTotal : 0;
1698              dimregion->AddSampleLoop(&loop);              d->AddSampleLoop(&loop);
             dimreg_changed_signal();  
1699          }          }
1700      } else {      } else {
1701          if (dimregion->SampleLoops) {          if (d->SampleLoops) {
1702                DimRegionChangeGuard(this, d);
1703    
1704              // delete ALL existing sample loops              // delete ALL existing sample loops
1705              while (dimregion->SampleLoops) {              while (d->SampleLoops) {
1706                  dimregion->DeleteSampleLoop(&dimregion->pSampleLoops[0]);                  d->DeleteSampleLoop(&d->pSampleLoops[0]);
1707              }              }
             dimreg_changed_signal();  
1708          }          }
1709      }      }
     updateLoopElements();  
1710  }  }
1711    
1712  void DimRegionEdit::updateLoopElements()  void DimRegionEdit::set_LoopType(gig::DimensionRegion* d, uint32_t value)
1713  {  {
1714      const bool active = eSampleLoopEnabled.get_active();      if (d->SampleLoops) d->pSampleLoops[0].LoopType = value;
1715      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);  
1716    
1717      if (dimregion && dimregion->SampleLoops) {  void DimRegionEdit::set_LoopStart(gig::DimensionRegion* d, uint32_t value)
1718          eSampleLoopStart.set_ptr(&dimregion->pSampleLoops[0].LoopStart);  {
1719          eSampleLoopLength.set_ptr(&dimregion->pSampleLoops[0].LoopLength);      if (d->SampleLoops) {
1720          eSampleLoopType.set_ptr(&dimregion->pSampleLoops[0].LoopType);          d->pSampleLoops[0].LoopStart =
1721          eSampleLoopInfinite.set_active(              d->pSample ?
1722              dimregion->pSample && !dimregion->pSample->LoopPlayCount              std::min(value, uint32_t(d->pSample->SamplesTotal -
1723          );                                       d->pSampleLoops[0].LoopLength)) :
1724          // 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();  
1725      }      }
1726  }  }
1727    
1728  void DimRegionEdit::loop_infinite_toggled() {  void DimRegionEdit::set_LoopLength(gig::DimensionRegion* d, uint32_t value)
1729      eSampleLoopPlayCount.set_sensitive(  {
1730          !eSampleLoopInfinite.get_active() &&      if (d->SampleLoops) {
1731           eSampleLoopEnabled.get_active()          d->pSampleLoops[0].LoopLength =
1732      );              d->pSample ?
1733      if (eSampleLoopInfinite.get_active())              std::min(value, uint32_t(d->pSample->SamplesTotal -
1734          eSampleLoopPlayCount.set_value(0);                                       d->pSampleLoops[0].LoopStart)) :
1735      else if (!eSampleLoopPlayCount.get_value())              0;
1736          eSampleLoopPlayCount.set_value(1);      }
1737    }
1738    
1739    void DimRegionEdit::set_LoopInfinite(gig::DimensionRegion* d, bool value)
1740    {
1741        if (d->pSample) {
1742            if (value) d->pSample->LoopPlayCount = 0;
1743            else if (d->pSample->LoopPlayCount == 0) d->pSample->LoopPlayCount = 1;
1744        }
1745    }
1746    
1747    void DimRegionEdit::set_LoopPlayCount(gig::DimensionRegion* d, uint32_t value)
1748    {
1749        if (d->pSample) d->pSample->LoopPlayCount = value;
1750    }
1751    
1752    void DimRegionEdit::nullOutSampleReference() {
1753        if (!dimregion) return;
1754        gig::Sample* oldref = dimregion->pSample;
1755        if (!oldref) return;
1756    
1757        DimRegionChangeGuard(this, dimregion);
1758    
1759        // in case currently assigned sample is a stereo one, then remove both
1760        // references (expected to be due to a "stereo dimension")
1761        gig::DimensionRegion* d[2] = { dimregion, NULL };
1762        if (oldref->Channels == 2) {
1763            gig::Region* region = dimregion->GetParent();
1764            {
1765                int stereo_bit = 0;
1766                int bitcount = 0;
1767                for (int dim = 0 ; dim < region->Dimensions ; dim++) {
1768                    if (region->pDimensionDefinitions[dim].dimension == gig::dimension_samplechannel) {
1769                        stereo_bit = 1 << bitcount;
1770                        break;
1771                    }
1772                    bitcount += region->pDimensionDefinitions[dim].bits;
1773                }
1774    
1775                if (stereo_bit) {
1776                    int dimregno;
1777                    for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
1778                        if (region->pDimensionRegions[dimregno] == dimregion) {
1779                            break;
1780                        }
1781                    }
1782                    d[0] = region->pDimensionRegions[dimregno & ~stereo_bit];
1783                    d[1] = region->pDimensionRegions[dimregno | stereo_bit];
1784                }
1785            }
1786        }
1787    
1788        if (d[0]) d[0]->pSample = NULL;
1789        if (d[1]) d[1]->pSample = NULL;
1790    
1791        // update UI elements
1792        set_dim_region(dimregion);
1793    
1794        sample_ref_changed_signal.emit(oldref, NULL);
1795    }
1796    
1797    void DimRegionEdit::onButtonSelectSamplePressed() {
1798        if (!dimregion) return;
1799        if (!dimregion->pSample) return;
1800        select_sample_signal.emit(dimregion->pSample);
1801    }
1802    
1803    sigc::signal<void, gig::Sample*>& DimRegionEdit::signal_select_sample() {
1804        return select_sample_signal;
1805  }  }

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

  ViewVC Help
Powered by ViewVC