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

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

  ViewVC Help
Powered by ViewVC