/[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 1303 by persson, Sun Aug 26 09:29:52 2007 UTC revision 2841 by persson, Sun Aug 30 10:00:49 2015 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006, 2007 Andreas Persson   * Copyright (C) 2006-2015 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 19  Line 19 
19    
20  #include "dimregionedit.h"  #include "dimregionedit.h"
21    
22  #include <libintl.h>  #include "global.h"
23  #define _(String) gettext(String)  #include "compat.h"
24    
25    VelocityCurve::VelocityCurve(double (gig::DimensionRegion::*getter)(uint8_t)) :
26        getter(getter), dimreg(0) {
27        set_size_request(80, 80);
28    }
29    
30    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
31    bool VelocityCurve::on_expose_event(GdkEventExpose* e) {
32        const Cairo::RefPtr<Cairo::Context>& cr =
33            get_window()->create_cairo_context();
34    #if 0
35    }
36    #endif
37    #else
38    bool VelocityCurve::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
39    #endif
40        if (dimreg) {
41            int w = get_width();
42            int h = get_height();
43    
44            for (int pass = 0 ; pass < 2 ; pass++) {
45                for (double x = 0 ; x <= w ; x++) {
46                    int vel = int(x * (127 - 1e-10) / w + 1);
47                    double y = (1 - (dimreg->*getter)(vel)) * (h - 3) + 1.5;
48    
49                    if (x < 1e-10) {
50                        cr->move_to(x, y);
51                    } else {
52                        cr->line_to(x, y);
53                    }
54                }
55                if (pass == 0) {
56                    cr->line_to(w, h);
57                    cr->line_to(0, h);
58                    cr->set_source_rgba(0.5, 0.44, 1.0, is_sensitive() ? 0.2 : 0.1);
59                    cr->fill();
60                } else {
61                    cr->set_line_width(3);
62                    cr->set_source_rgba(0.5, 0.44, 1.0, is_sensitive() ? 1.0 : 0.3);
63                    cr->stroke();
64                }
65            }
66        }
67        return true;
68    }
69    
70    
71    CrossfadeCurve::CrossfadeCurve() : dimreg(0) {
72        set_size_request(280, 80);
73    }
74    
75    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
76    bool CrossfadeCurve::on_expose_event(GdkEventExpose* e) {
77        const Cairo::RefPtr<Cairo::Context>& cr =
78            get_window()->create_cairo_context();
79    #if 0
80    }
81    #endif
82    #else
83    bool CrossfadeCurve::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
84    #endif
85        if (dimreg) {
86            cr->translate(1.5, 0);
87    
88            // first, draw curves for the other layers
89            gig::Region* region = dimreg->GetParent();
90            int dimregno;
91            for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
92                if (region->pDimensionRegions[dimregno] == dimreg) {
93                    break;
94                }
95            }
96            int bitcount = 0;
97            for (int dim = 0 ; dim < region->Dimensions ; dim++) {
98                if (region->pDimensionDefinitions[dim].dimension ==
99                    gig::dimension_layer) {
100                    int mask =
101                        ~(((1 << region->pDimensionDefinitions[dim].bits) - 1) <<
102                          bitcount);
103                    int c = dimregno & mask; // mask away the layer dimension
104    
105                    for (int i = 0 ; i < region->pDimensionDefinitions[dim].zones ;
106                         i++) {
107                        gig::DimensionRegion* d =
108                            region->pDimensionRegions[c + (i << bitcount)];
109                        if (d != dimreg) {
110                            draw_one_curve(cr, d, false);
111                        }
112                    }
113                    break;
114                }
115                bitcount += region->pDimensionDefinitions[dim].bits;
116            }
117    
118            // then, draw the currently selected layer
119            draw_one_curve(cr, dimreg, is_sensitive());
120        }
121        return true;
122    }
123    
124    void CrossfadeCurve::draw_one_curve(const Cairo::RefPtr<Cairo::Context>& cr,
125                                        const gig::DimensionRegion* d,
126                                        bool sensitive) {
127        int w = get_width();
128        int h = get_height();
129    
130        if (d->Crossfade.out_end) {
131            for (int pass = 0 ; pass < 2 ; pass++) {
132                cr->move_to(d->Crossfade.in_start / 127.0 * (w - 3), h);
133                cr->line_to(d->Crossfade.in_end / 127.0 * (w - 3), 1.5);
134                cr->line_to(d->Crossfade.out_start / 127.0 * (w - 3), 1.5);
135                cr->line_to(d->Crossfade.out_end / 127.0 * (w - 3), h);
136    
137                if (pass == 0) {
138                    cr->set_source_rgba(0.5, 0.44, 1.0, sensitive ? 0.2 : 0.1);
139                    cr->fill();
140                } else {
141                    cr->set_line_width(3);
142                    cr->set_source_rgba(0.5, 0.44, 1.0, sensitive ? 1.0 : 0.3);
143                    cr->stroke();
144                }
145            }
146        }
147    }
148    
149    
150  DimRegionEdit::DimRegionEdit() :  DimRegionEdit::DimRegionEdit() :
151      eEG1PreAttack("Pre-attack", 0, 100, 2),      velocity_curve(&gig::DimensionRegion::GetVelocityAttenuation),
152      eEG1Attack("Attack", 0, 60, 3),      release_curve(&gig::DimensionRegion::GetVelocityRelease),
153      eEG1Decay1("Decay 1", 0.005, 60, 3),      cutoff_curve(&gig::DimensionRegion::GetVelocityCutoff),
154      eEG1Decay2("Decay 2", 0, 60, 3),      eEG1PreAttack(_("Pre-attack Level (%)"), 0, 100, 2),
155      eEG1InfiniteSustain("Infinite sustain"),      eEG1Attack(_("Attack Time (seconds)"), 0, 60, 3),
156      eEG1Sustain("Sustain", 0, 100, 2),      eEG1Decay1(_("Decay 1 Time (seconds)"), 0.005, 60, 3),
157      eEG1Release("Release", 0, 60, 3),      eEG1Decay2(_("Decay 2 Time (seconds)"), 0, 60, 3),
158      eEG1Hold("Hold"),      eEG1InfiniteSustain(_("Infinite sustain")),
159      eEG1Controller("Controller"),      eEG1Sustain(_("Sustain Level (%)"), 0, 100, 2),
160      eEG1ControllerInvert("Controller invert"),      eEG1Release(_("Release Time (seconds)"), 0, 60, 3),
161      eEG1ControllerAttackInfluence("Controller attack influence", 0, 3),      eEG1Hold(_("Hold Attack Stage until Loop End")),
162      eEG1ControllerDecayInfluence("Controller decay influence", 0, 3),      eEG1Controller(_("Controller")),
163      eEG1ControllerReleaseInfluence("Controller release influence", 0, 3),      eEG1ControllerInvert(_("Controller invert")),
164      eLFO1Frequency("Frequency", 0.1, 10, 2),      eEG1ControllerAttackInfluence(_("Controller attack influence"), 0, 3),
165      eLFO1InternalDepth("Internal depth", 0, 1200),      eEG1ControllerDecayInfluence(_("Controller decay influence"), 0, 3),
166      eLFO1ControlDepth("Control depth", 0, 1200),      eEG1ControllerReleaseInfluence(_("Controller release influence"), 0, 3),
167      eLFO1Controller("Controller"),      eLFO1Frequency(_("Frequency"), 0.1, 10, 2),
168      eLFO1FlipPhase("Flip phase"),      eLFO1InternalDepth(_("Internal depth"), 0, 1200),
169      eLFO1Sync("Sync"),      eLFO1ControlDepth(_("Control depth"), 0, 1200),
170      eEG2PreAttack("Pre-attack", 0, 100, 2),      eLFO1Controller(_("Controller")),
171      eEG2Attack("Attack", 0, 60, 3),      eLFO1FlipPhase(_("Flip phase")),
172      eEG2Decay1("Decay 1", 0.005, 60, 3),      eLFO1Sync(_("Sync")),
173      eEG2Decay2("Decay 2", 0, 60, 3),      eEG2PreAttack(_("Pre-attack Level (%)"), 0, 100, 2),
174      eEG2InfiniteSustain("Infinite sustain"),      eEG2Attack(_("Attack Time (seconds)"), 0, 60, 3),
175      eEG2Sustain("Sustain", 0, 100, 2),      eEG2Decay1(_("Decay 1 Time (seconds)"), 0.005, 60, 3),
176      eEG2Release("Release", 0, 60, 3),      eEG2Decay2(_("Decay 2 Time (seconds)"), 0, 60, 3),
177      eEG2Controller("Controller"),      eEG2InfiniteSustain(_("Infinite sustain")),
178      eEG2ControllerInvert("Controller invert"),      eEG2Sustain(_("Sustain Level (%)"), 0, 100, 2),
179      eEG2ControllerAttackInfluence("Controller attack influence", 0, 3),      eEG2Release(_("Release Time (seconds)"), 0, 60, 3),
180      eEG2ControllerDecayInfluence("Controller decay influence", 0, 3),      eEG2Controller(_("Controller")),
181      eEG2ControllerReleaseInfluence("Controller release influence", 0, 3),      eEG2ControllerInvert(_("Controller invert")),
182      eLFO2Frequency("Frequency", 0.1, 10, 2),      eEG2ControllerAttackInfluence(_("Controller attack influence"), 0, 3),
183      eLFO2InternalDepth("Internal depth", 0, 1200),      eEG2ControllerDecayInfluence(_("Controller decay influence"), 0, 3),
184      eLFO2ControlDepth("Control depth", 0, 1200),      eEG2ControllerReleaseInfluence(_("Controller release influence"), 0, 3),
185      eLFO2Controller("Controller"),      eLFO2Frequency(_("Frequency"), 0.1, 10, 2),
186      eLFO2FlipPhase("Flip phase"),      eLFO2InternalDepth(_("Internal depth"), 0, 1200),
187      eLFO2Sync("Sync"),      eLFO2ControlDepth(_("Control depth"), 0, 1200),
188      eEG3Attack("Attack", 0, 10, 3),      eLFO2Controller(_("Controller")),
189      eEG3Depth("Depth", -1200, 1200),      eLFO2FlipPhase(_("Flip phase")),
190      eLFO3Frequency("Frequency", 0.1, 10, 2),      eLFO2Sync(_("Sync")),
191      eLFO3InternalDepth("Internal depth", 0, 1200),      eEG3Attack(_("Attack"), 0, 10, 3),
192      eLFO3ControlDepth("Control depth", 0, 1200),      eEG3Depth(_("Depth"), -1200, 1200),
193      eLFO3Controller("Controller"),      eLFO3Frequency(_("Frequency"), 0.1, 10, 2),
194      eLFO3Sync("Sync"),      eLFO3InternalDepth(_("Internal depth"), 0, 1200),
195      eVCFEnabled("Enabled"),      eLFO3ControlDepth(_("Control depth"), 0, 1200),
196      eVCFType("Type"),      eLFO3Controller(_("Controller")),
197      eVCFCutoffController("Cutoff controller"),      eLFO3Sync(_("Sync")),
198      eVCFCutoffControllerInvert("Cutoff controller invert"),      eVCFEnabled(_("Enabled")),
199      eVCFCutoff("Cutoff"),      eVCFType(_("Type")),
200      eVCFVelocityCurve("Velocity curve"),      eVCFCutoffController(_("Cutoff controller")),
201      eVCFVelocityScale("Velocity scale"),      eVCFCutoffControllerInvert(_("Cutoff controller invert")),
202      eVCFVelocityDynamicRange("Velocity dynamic range", 0, 4),      eVCFCutoff(_("Cutoff")),
203      eVCFResonance("Resonance"),      eVCFVelocityCurve(_("Velocity curve")),
204      eVCFResonanceDynamic("Resonance dynamic"),      eVCFVelocityScale(_("Velocity scale")),
205      eVCFResonanceController("Resonance controller"),      eVCFVelocityDynamicRange(_("Velocity dynamic range"), 0, 4),
206      eVCFKeyboardTracking("Keyboard tracking"),      eVCFResonance(_("Resonance")),
207      eVCFKeyboardTrackingBreakpoint("Keyboard tracking breakpoint"),      eVCFResonanceDynamic(_("Resonance dynamic")),
208      eVelocityResponseCurve("Velocity response curve"),      eVCFResonanceController(_("Resonance controller")),
209      eVelocityResponseDepth("Velocity response depth", 0, 4),      eVCFKeyboardTracking(_("Keyboard tracking")),
210      eVelocityResponseCurveScaling("Velocity response curve scaling"),      eVCFKeyboardTrackingBreakpoint(_("Keyboard tracking breakpoint")),
211      eReleaseVelocityResponseCurve("Release velocity response curve"),      eVelocityResponseCurve(_("Velocity response curve")),
212      eReleaseVelocityResponseDepth("Release velocity response depth", 0, 4),      eVelocityResponseDepth(_("Velocity response depth"), 0, 4),
213      eReleaseTriggerDecay("Release trigger decay", 0, 8),      eVelocityResponseCurveScaling(_("Velocity response curve scaling")),
214      eCrossfade_in_start("Crossfade-in start"),      eReleaseVelocityResponseCurve(_("Release velocity response curve")),
215      eCrossfade_in_end("Crossfade-in end"),      eReleaseVelocityResponseDepth(_("Release velocity response depth"), 0, 4),
216      eCrossfade_out_start("Crossfade-out start"),      eReleaseTriggerDecay(_("Release trigger decay"), 0, 8),
217      eCrossfade_out_end("Crossfade-out end"),      eCrossfade_in_start(_("Crossfade-in start")),
218      ePitchTrack("Pitch track"),      eCrossfade_in_end(_("Crossfade-in end")),
219      eDimensionBypass("Dimension bypass"),      eCrossfade_out_start(_("Crossfade-out start")),
220      ePan("Pan", -64, 63),      eCrossfade_out_end(_("Crossfade-out end")),
221      eSelfMask("Self mask"),      ePitchTrack(_("Pitch track")),
222      eAttenuationController("Attenuation controller"),      eDimensionBypass(_("Dimension bypass")),
223      eInvertAttenuationController("Invert attenuation controller"),      ePan(_("Pan"), -64, 63),
224      eAttenuationControllerThreshold("Attenuation controller threshold"),      eSelfMask(_("Kill lower velocity voices (a.k.a \"Self mask\")")),
225      eChannelOffset("Channel offset", 0, 9),      eAttenuationController(_("Attenuation controller")),
226      eSustainDefeat("Sustain defeat"),      eInvertAttenuationController(_("Invert attenuation controller")),
227      eMSDecode("MS decode"),      eAttenuationControllerThreshold(_("Attenuation controller threshold")),
228      eSampleStartOffset("Sample start offset", 0, 2000),      eChannelOffset(_("Channel offset"), 0, 9),
229      eUnityNote("Unity note"),      eSustainDefeat(_("Ignore Hold Pedal (a.k.a. \"Sustain defeat\")")),
230      eFineTune("Fine tune", -49, 50),      eMSDecode(_("Decode Mid/Side Recordings")),
231      eGain("Gain", -96, 0, 2, -655360),      eSampleStartOffset(_("Sample start offset"), 0, 2000),
232      eGainPlus6("Gain +6dB", eGain, 6 * -655360),      eUnityNote(_("Unity note")),
233      eSampleLoopEnabled("Enabled"),      eSampleFormatInfo(_("Sample Format")),
234      eSampleLoopStart("Loop start positon"),      eSampleID("Sample ID"),
235      eSampleLoopLength("Loop size"),      eFineTune(_("Fine tune"), -49, 50),
236      eSampleLoopType("Loop type"),      eGain(_("Gain"), -96, 0, 2, -655360),
237      eSampleLoopInfinite("Infinite loop"),      eGainPlus6(_("Gain +6dB"), eGain, 6 * -655360),
238      eSampleLoopPlayCount("Playback count")      eSampleLoopEnabled(_("Enabled")),
239  {      eSampleLoopStart(_("Loop start positon")),
240        eSampleLoopLength(_("Loop size")),
241        eSampleLoopType(_("Loop type")),
242        eSampleLoopInfinite(_("Infinite loop")),
243        eSampleLoopPlayCount(_("Playback count"), 1),
244        buttonSelectSample(UNICODE_LEFT_ARROW + "  " + _("Select Sample")),
245        update_model(0)
246    {
247        connect(eEG1PreAttack, &gig::DimensionRegion::EG1PreAttack);
248        connect(eEG1Attack, &gig::DimensionRegion::EG1Attack);
249        connect(eEG1Decay1, &gig::DimensionRegion::EG1Decay1);
250        connect(eEG1Decay2, &gig::DimensionRegion::EG1Decay2);
251        connect(eEG1InfiniteSustain, &gig::DimensionRegion::EG1InfiniteSustain);
252        connect(eEG1Sustain, &gig::DimensionRegion::EG1Sustain);
253        connect(eEG1Release, &gig::DimensionRegion::EG1Release);
254        connect(eEG1Hold, &gig::DimensionRegion::EG1Hold);
255        connect(eEG1Controller, &gig::DimensionRegion::EG1Controller);
256        connect(eEG1ControllerInvert, &gig::DimensionRegion::EG1ControllerInvert);
257        connect(eEG1ControllerAttackInfluence,
258                &gig::DimensionRegion::EG1ControllerAttackInfluence);
259        connect(eEG1ControllerDecayInfluence,
260                &gig::DimensionRegion::EG1ControllerDecayInfluence);
261        connect(eEG1ControllerReleaseInfluence,
262                &gig::DimensionRegion::EG1ControllerReleaseInfluence);
263        connect(eLFO1Frequency, &gig::DimensionRegion::LFO1Frequency);
264        connect(eLFO1InternalDepth, &gig::DimensionRegion::LFO1InternalDepth);
265        connect(eLFO1ControlDepth, &gig::DimensionRegion::LFO1ControlDepth);
266        connect(eLFO1Controller, &gig::DimensionRegion::LFO1Controller);
267        connect(eLFO1FlipPhase, &gig::DimensionRegion::LFO1FlipPhase);
268        connect(eLFO1Sync, &gig::DimensionRegion::LFO1Sync);
269        connect(eEG2PreAttack, &gig::DimensionRegion::EG2PreAttack);
270        connect(eEG2Attack, &gig::DimensionRegion::EG2Attack);
271        connect(eEG2Decay1, &gig::DimensionRegion::EG2Decay1);
272        connect(eEG2Decay2, &gig::DimensionRegion::EG2Decay2);
273        connect(eEG2InfiniteSustain, &gig::DimensionRegion::EG2InfiniteSustain);
274        connect(eEG2Sustain, &gig::DimensionRegion::EG2Sustain);
275        connect(eEG2Release, &gig::DimensionRegion::EG2Release);
276        connect(eEG2Controller, &gig::DimensionRegion::EG2Controller);
277        connect(eEG2ControllerInvert, &gig::DimensionRegion::EG2ControllerInvert);
278        connect(eEG2ControllerAttackInfluence,
279                &gig::DimensionRegion::EG2ControllerAttackInfluence);
280        connect(eEG2ControllerDecayInfluence,
281                &gig::DimensionRegion::EG2ControllerDecayInfluence);
282        connect(eEG2ControllerReleaseInfluence,
283                &gig::DimensionRegion::EG2ControllerReleaseInfluence);
284        connect(eLFO2Frequency, &gig::DimensionRegion::LFO2Frequency);
285        connect(eLFO2InternalDepth, &gig::DimensionRegion::LFO2InternalDepth);
286        connect(eLFO2ControlDepth, &gig::DimensionRegion::LFO2ControlDepth);
287        connect(eLFO2Controller, &gig::DimensionRegion::LFO2Controller);
288        connect(eLFO2FlipPhase, &gig::DimensionRegion::LFO2FlipPhase);
289        connect(eLFO2Sync, &gig::DimensionRegion::LFO2Sync);
290        connect(eEG3Attack, &gig::DimensionRegion::EG3Attack);
291        connect(eEG3Depth, &gig::DimensionRegion::EG3Depth);
292        connect(eLFO3Frequency, &gig::DimensionRegion::LFO3Frequency);
293        connect(eLFO3InternalDepth, &gig::DimensionRegion::LFO3InternalDepth);
294        connect(eLFO3ControlDepth, &gig::DimensionRegion::LFO3ControlDepth);
295        connect(eLFO3Controller, &gig::DimensionRegion::LFO3Controller);
296        connect(eLFO3Sync, &gig::DimensionRegion::LFO3Sync);
297        connect(eVCFEnabled, &gig::DimensionRegion::VCFEnabled);
298        connect(eVCFType, &gig::DimensionRegion::VCFType);
299        connect(eVCFCutoffController,
300                &gig::DimensionRegion::SetVCFCutoffController);
301        connect(eVCFCutoffControllerInvert,
302                &gig::DimensionRegion::VCFCutoffControllerInvert);
303        connect(eVCFCutoff, &gig::DimensionRegion::VCFCutoff);
304        connect(eVCFVelocityCurve, &gig::DimensionRegion::SetVCFVelocityCurve);
305        connect(eVCFVelocityScale, &gig::DimensionRegion::SetVCFVelocityScale);
306        connect(eVCFVelocityDynamicRange,
307                &gig::DimensionRegion::SetVCFVelocityDynamicRange);
308        connect(eVCFResonance, &gig::DimensionRegion::VCFResonance);
309        connect(eVCFResonanceDynamic, &gig::DimensionRegion::VCFResonanceDynamic);
310        connect(eVCFResonanceController,
311                &gig::DimensionRegion::VCFResonanceController);
312        connect(eVCFKeyboardTracking, &gig::DimensionRegion::VCFKeyboardTracking);
313        connect(eVCFKeyboardTrackingBreakpoint,
314                &gig::DimensionRegion::VCFKeyboardTrackingBreakpoint);
315        connect(eVelocityResponseCurve,
316                &gig::DimensionRegion::SetVelocityResponseCurve);
317        connect(eVelocityResponseDepth,
318                &gig::DimensionRegion::SetVelocityResponseDepth);
319        connect(eVelocityResponseCurveScaling,
320                &gig::DimensionRegion::SetVelocityResponseCurveScaling);
321        connect(eReleaseVelocityResponseCurve,
322                &gig::DimensionRegion::SetReleaseVelocityResponseCurve);
323        connect(eReleaseVelocityResponseDepth,
324                &gig::DimensionRegion::SetReleaseVelocityResponseDepth);
325        connect(eReleaseTriggerDecay, &gig::DimensionRegion::ReleaseTriggerDecay);
326        connect(eCrossfade_in_start, &DimRegionEdit::set_Crossfade_in_start);
327        connect(eCrossfade_in_end, &DimRegionEdit::set_Crossfade_in_end);
328        connect(eCrossfade_out_start, &DimRegionEdit::set_Crossfade_out_start);
329        connect(eCrossfade_out_end, &DimRegionEdit::set_Crossfade_out_end);
330        connect(ePitchTrack, &gig::DimensionRegion::PitchTrack);
331        connect(eDimensionBypass, &gig::DimensionRegion::DimensionBypass);
332        connect(ePan, &gig::DimensionRegion::Pan);
333        connect(eSelfMask, &gig::DimensionRegion::SelfMask);
334        connect(eAttenuationController,
335                &gig::DimensionRegion::AttenuationController);
336        connect(eInvertAttenuationController,
337                &gig::DimensionRegion::InvertAttenuationController);
338        connect(eAttenuationControllerThreshold,
339                &gig::DimensionRegion::AttenuationControllerThreshold);
340        connect(eChannelOffset, &gig::DimensionRegion::ChannelOffset);
341        connect(eSustainDefeat, &gig::DimensionRegion::SustainDefeat);
342        connect(eMSDecode, &gig::DimensionRegion::MSDecode);
343        connect(eSampleStartOffset, &gig::DimensionRegion::SampleStartOffset);
344        connect(eUnityNote, &DimRegionEdit::set_UnityNote);
345        connect(eFineTune, &DimRegionEdit::set_FineTune);
346        connect(eGain, &DimRegionEdit::set_Gain);
347        connect(eGainPlus6, &DimRegionEdit::set_Gain);
348        connect(eSampleLoopEnabled, &DimRegionEdit::set_LoopEnabled);
349        connect(eSampleLoopType, &DimRegionEdit::set_LoopType);
350        connect(eSampleLoopStart, &DimRegionEdit::set_LoopStart);
351        connect(eSampleLoopLength, &DimRegionEdit::set_LoopLength);
352        connect(eSampleLoopInfinite, &DimRegionEdit::set_LoopInfinite);
353        connect(eSampleLoopPlayCount, &DimRegionEdit::set_LoopPlayCount);
354        buttonSelectSample.signal_clicked().connect(
355            sigc::mem_fun(*this, &DimRegionEdit::onButtonSelectSamplePressed)
356        );
357    
358      for (int i = 0 ; i < 7 ; i++) {      for (int i = 0 ; i < 7 ; i++) {
359          table[i] = new Gtk::Table(3, 1);          table[i] = new Gtk::Table(3, 1);
360          table[i]->set_col_spacings(7);          table[i]->set_col_spacings(7);
# Line 121  DimRegionEdit::DimRegionEdit() : Line 364  DimRegionEdit::DimRegionEdit() :
364      eUnityNote.set_tip(      eUnityNote.set_tip(
365          _("Note this sample is associated with (a.k.a. 'root note')")          _("Note this sample is associated with (a.k.a. 'root note')")
366      );      );
367        buttonSelectSample.set_tooltip_text(
368            _("Selects the sample of this dimension region on the left hand side's sample tree view.")
369        );
370      eSampleStartOffset.set_tip(_("Sample position at which playback should be started"));      eSampleStartOffset.set_tip(_("Sample position at which playback should be started"));
371      ePan.set_tip(_("Stereo balance (left/right)"));      ePan.set_tip(_("Stereo balance (left/right)"));
372      eChannelOffset.set_tip(      eChannelOffset.set_tip(
# Line 151  DimRegionEdit::DimRegionEdit() : Line 397  DimRegionEdit::DimRegionEdit() :
397            "Caution: this setting is stored on Sample side, thus is shared "            "Caution: this setting is stored on Sample side, thus is shared "
398            "among all dimension regions that use this sample!")            "among all dimension regions that use this sample!")
399      );      );
400        
401        eEG1PreAttack.set_tip(
402            "Very first level this EG starts with. It rises then in Attack Time "
403            "seconds from this initial level to 100%."
404        );
405        eEG1Attack.set_tip(
406            "Duration of the EG's Attack stage, which raises its level from "
407            "Pre-Attack Level to 100%."
408        );
409        eEG1Hold.set_tip(
410           "On looped sounds, enabling this will cause the Decay 1 stage not to "
411           "enter before the loop has been passed one time."
412        );
413        eAttenuationController.set_tip(_(
414            "If you are not using the 'Layer' dimension, then this controller "
415            "simply alters the volume. If you are using the 'Layer' dimension, "
416            "then this controller is controlling the crossfade between Layers in "
417            "real-time."
418        ));
419    
420        eLFO1Sync.set_tip(
421            "If not checked, every voice will use its own LFO instance, which "
422            "causes voices triggered at different points in time to have different "
423            "LFO levels. By enabling 'Sync' here the voices will instead use and "
424            "share one single LFO, causing all voices to have the same LFO level, "
425            "no matter when the individual notes have been triggered."
426        );
427        eLFO2Sync.set_tip(
428            "If not checked, every voice will use its own LFO instance, which "
429            "causes voices triggered at different points in time to have different "
430            "LFO levels. By enabling 'Sync' here the voices will instead use and "
431            "share one single LFO, causing all voices to have the same LFO level, "
432            "no matter when the individual notes have been triggered."
433        );
434        eLFO3Sync.set_tip(
435            "If not checked, every voice will use its own LFO instance, which "
436            "causes voices triggered at different points in time to have different "
437            "LFO levels. By enabling 'Sync' here the voices will instead use and "
438            "share one single LFO, causing all voices to have the same LFO level, "
439            "no matter when the individual notes have been triggered."
440        );
441        eLFO1FlipPhase.set_tip(
442           "Inverts the LFO's generated wave vertically."
443        );
444        eLFO2FlipPhase.set_tip(
445           "Inverts the LFO's generated wave vertically."
446        );
447    
448      pageno = 0;      pageno = 0;
449      rowno = 0;      rowno = 0;
450      firstRowInBlock = 0;      firstRowInBlock = 0;
451    
452      addHeader(_("Mandatory Settings"));      addHeader(_("Mandatory Settings"));
453      addString("Sample", lSample, wSample);      addString(_("Sample"), lSample, wSample, buttonNullSampleReference);
454        buttonNullSampleReference->set_label("X");
455        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."));
456        buttonNullSampleReference->signal_clicked().connect(
457            sigc::mem_fun(*this, &DimRegionEdit::nullOutSampleReference)
458        );
459      //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);
460      tooltips.set_tip(*wSample, _("Drop a sample here"));  #ifdef OLD_TOOLTIPS
461        tooltips.set_tip(*wSample, _("Drag & drop a sample here"));
462    #else
463        wSample->set_tooltip_text(_("Drag & drop a sample here"));
464    #endif
465      addProp(eUnityNote);      addProp(eUnityNote);
466        addProp(eSampleFormatInfo);
467        addProp(eSampleID);
468        addRightHandSide(buttonSelectSample);
469      addHeader(_("Optional Settings"));      addHeader(_("Optional Settings"));
470      addProp(eSampleStartOffset);      addProp(eSampleStartOffset);
471      addProp(eChannelOffset);      addProp(eChannelOffset);
472      addHeader("Loops");      addHeader(_("Loops"));
473      addProp(eSampleLoopEnabled);      addProp(eSampleLoopEnabled);
474      addProp(eSampleLoopStart);      addProp(eSampleLoopStart);
475      addProp(eSampleLoopLength);      addProp(eSampleLoopLength);
476      {      {
477          const char* choices[] = { "normal", "bidirectional", "backward", 0 };          const char* choices[] = { _("normal"), _("bidirectional"), _("backward"), 0 };
478          static const uint32_t values[] = {          static const uint32_t values[] = {
479              gig::loop_type_normal,              gig::loop_type_normal,
480              gig::loop_type_bidirectional,              gig::loop_type_bidirectional,
# Line 190  DimRegionEdit::DimRegionEdit() : Line 495  DimRegionEdit::DimRegionEdit() :
495      addHeader(_("Amplitude Envelope (EG1)"));      addHeader(_("Amplitude Envelope (EG1)"));
496      addProp(eEG1PreAttack);      addProp(eEG1PreAttack);
497      addProp(eEG1Attack);      addProp(eEG1Attack);
498        addProp(eEG1Hold);
499      addProp(eEG1Decay1);      addProp(eEG1Decay1);
500      addProp(eEG1Decay2);      addProp(eEG1Decay2);
501      addProp(eEG1InfiniteSustain);      addProp(eEG1InfiniteSustain);
502      addProp(eEG1Sustain);      addProp(eEG1Sustain);
503      addProp(eEG1Release);      addProp(eEG1Release);
     addProp(eEG1Hold);  
504      addProp(eEG1Controller);      addProp(eEG1Controller);
505      addProp(eEG1ControllerInvert);      addProp(eEG1ControllerInvert);
506      addProp(eEG1ControllerAttackInfluence);      addProp(eEG1ControllerAttackInfluence);
# Line 209  DimRegionEdit::DimRegionEdit() : Line 514  DimRegionEdit::DimRegionEdit() :
514      addProp(eLFO1InternalDepth);      addProp(eLFO1InternalDepth);
515      addProp(eLFO1ControlDepth);      addProp(eLFO1ControlDepth);
516      {      {
517          const char* choices[] = { "internal", "modwheel", "breath",          const char* choices[] = { _("internal"), _("modwheel"), _("breath"),
518                                    "internal+modwheel", "internal+breath", 0 };                                    _("internal+modwheel"), _("internal+breath"), 0 };
519          static const gig::lfo1_ctrl_t values[] = {          static const gig::lfo1_ctrl_t values[] = {
520              gig::lfo1_ctrl_internal,              gig::lfo1_ctrl_internal,
521              gig::lfo1_ctrl_modwheel,              gig::lfo1_ctrl_modwheel,
# Line 223  DimRegionEdit::DimRegionEdit() : Line 528  DimRegionEdit::DimRegionEdit() :
528      addProp(eLFO1Controller);      addProp(eLFO1Controller);
529      addProp(eLFO1FlipPhase);      addProp(eLFO1FlipPhase);
530      addProp(eLFO1Sync);      addProp(eLFO1Sync);
531      addHeader("Crossfade");      addHeader(_("Crossfade"));
532      addProp(eAttenuationController);      addProp(eAttenuationController);
533      addProp(eInvertAttenuationController);      addProp(eInvertAttenuationController);
534      addProp(eAttenuationControllerThreshold);      addProp(eAttenuationControllerThreshold);
# Line 232  DimRegionEdit::DimRegionEdit() : Line 537  DimRegionEdit::DimRegionEdit() :
537      addProp(eCrossfade_out_start);      addProp(eCrossfade_out_start);
538      addProp(eCrossfade_out_end);      addProp(eCrossfade_out_end);
539    
540        Gtk::Frame* frame = new Gtk::Frame;
541        frame->add(crossfade_curve);
542        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
543                              Gtk::SHRINK, Gtk::SHRINK);
544        rowno++;
545    
546        eCrossfade_in_start.signal_value_changed().connect(
547            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
548        eCrossfade_in_end.signal_value_changed().connect(
549            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
550        eCrossfade_out_start.signal_value_changed().connect(
551            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
552        eCrossfade_out_end.signal_value_changed().connect(
553            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
554    
555      nextPage();      nextPage();
556    
557      addHeader(_("General Filter Settings"));      addHeader(_("General Filter Settings"));
558      addProp(eVCFEnabled);      addProp(eVCFEnabled);
559      {      {
560          const char* choices[] = { "lowpass", "lowpassturbo", "bandpass",          const char* choices[] = { _("lowpass"), _("lowpassturbo"), _("bandpass"),
561                                    "highpass", "bandreject", 0 };                                    _("highpass"), _("bandreject"), 0 };
562          static const gig::vcf_type_t values[] = {          static const gig::vcf_type_t values[] = {
563              gig::vcf_type_lowpass,              gig::vcf_type_lowpass,
564              gig::vcf_type_lowpassturbo,              gig::vcf_type_lowpassturbo,
# Line 250  DimRegionEdit::DimRegionEdit() : Line 570  DimRegionEdit::DimRegionEdit() :
570      }      }
571      addProp(eVCFType);      addProp(eVCFType);
572      {      {
573          const char* choices[] = { "none", "none2", "modwheel", "effect1", "effect2",          const char* choices[] = { _("none"), _("none2"), _("modwheel"), _("effect1"), _("effect2"),
574                                    "breath", "foot", "sustainpedal", "softpedal",                                    _("breath"), _("foot"), _("sustainpedal"), _("softpedal"),
575                                    "genpurpose7", "genpurpose8", "aftertouch", 0 };                                    _("genpurpose7"), _("genpurpose8"), _("aftertouch"), 0 };
576          static const gig::vcf_cutoff_ctrl_t values[] = {          static const gig::vcf_cutoff_ctrl_t values[] = {
577              gig::vcf_cutoff_ctrl_none,              gig::vcf_cutoff_ctrl_none,
578              gig::vcf_cutoff_ctrl_none2,              gig::vcf_cutoff_ctrl_none2,
# Line 272  DimRegionEdit::DimRegionEdit() : Line 592  DimRegionEdit::DimRegionEdit() :
592      addProp(eVCFCutoffController);      addProp(eVCFCutoffController);
593      addProp(eVCFCutoffControllerInvert);      addProp(eVCFCutoffControllerInvert);
594      addProp(eVCFCutoff);      addProp(eVCFCutoff);
595      const char* curve_type_texts[] = { "nonlinear", "linear", "special", 0 };      const char* curve_type_texts[] = { _("nonlinear"), _("linear"), _("special"), 0 };
596      static const gig::curve_type_t curve_type_values[] = {      static const gig::curve_type_t curve_type_values[] = {
597          gig::curve_type_nonlinear,          gig::curve_type_nonlinear,
598          gig::curve_type_linear,          gig::curve_type_linear,
# Line 282  DimRegionEdit::DimRegionEdit() : Line 602  DimRegionEdit::DimRegionEdit() :
602      addProp(eVCFVelocityCurve);      addProp(eVCFVelocityCurve);
603      addProp(eVCFVelocityScale);      addProp(eVCFVelocityScale);
604      addProp(eVCFVelocityDynamicRange);      addProp(eVCFVelocityDynamicRange);
605    
606        eVCFCutoffController.signal_value_changed().connect(
607            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
608        eVCFVelocityCurve.signal_value_changed().connect(
609            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
610        eVCFVelocityScale.signal_value_changed().connect(
611            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
612        eVCFVelocityDynamicRange.signal_value_changed().connect(
613            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
614    
615        frame = new Gtk::Frame;
616        frame->add(cutoff_curve);
617        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
618                              Gtk::SHRINK, Gtk::SHRINK);
619        rowno++;
620    
621      addProp(eVCFResonance);      addProp(eVCFResonance);
622      addProp(eVCFResonanceDynamic);      addProp(eVCFResonanceDynamic);
623      {      {
624          const char* choices[] = { "none", "genpurpose3", "genpurpose4",          const char* choices[] = { _("none"), _("genpurpose3"), _("genpurpose4"),
625                                    "genpurpose5", "genpurpose6", 0 };                                    _("genpurpose5"), _("genpurpose6"), 0 };
626          static const gig::vcf_res_ctrl_t values[] = {          static const gig::vcf_res_ctrl_t values[] = {
627              gig::vcf_res_ctrl_none,              gig::vcf_res_ctrl_none,
628              gig::vcf_res_ctrl_genpurpose3,              gig::vcf_res_ctrl_genpurpose3,
# Line 302  DimRegionEdit::DimRegionEdit() : Line 638  DimRegionEdit::DimRegionEdit() :
638    
639      nextPage();      nextPage();
640    
641      addHeader(_("Filter Cutoff Envelope (EG2)"));      lEG2 = addHeader(_("Filter Cutoff Envelope (EG2)"));
642      addProp(eEG2PreAttack);      addProp(eEG2PreAttack);
643      addProp(eEG2Attack);      addProp(eEG2Attack);
644      addProp(eEG2Decay1);      addProp(eEG2Decay1);
# Line 315  DimRegionEdit::DimRegionEdit() : Line 651  DimRegionEdit::DimRegionEdit() :
651      addProp(eEG2ControllerAttackInfluence);      addProp(eEG2ControllerAttackInfluence);
652      addProp(eEG2ControllerDecayInfluence);      addProp(eEG2ControllerDecayInfluence);
653      addProp(eEG2ControllerReleaseInfluence);      addProp(eEG2ControllerReleaseInfluence);
654      addHeader(_("Filter Cutoff Oscillator (LFO2)"));      lLFO2 = addHeader(_("Filter Cutoff Oscillator (LFO2)"));
655      addProp(eLFO2Frequency);      addProp(eLFO2Frequency);
656      addProp(eLFO2InternalDepth);      addProp(eLFO2InternalDepth);
657      addProp(eLFO2ControlDepth);      addProp(eLFO2ControlDepth);
658      {      {
659          const char* choices[] = { "internal", "modwheel", "foot",          const char* choices[] = { _("internal"), _("modwheel"), _("foot"),
660                                    "internal+modwheel", "internal+foot", 0 };                                    _("internal+modwheel"), _("internal+foot"), 0 };
661          static const gig::lfo2_ctrl_t values[] = {          static const gig::lfo2_ctrl_t values[] = {
662              gig::lfo2_ctrl_internal,              gig::lfo2_ctrl_internal,
663              gig::lfo2_ctrl_modwheel,              gig::lfo2_ctrl_modwheel,
# Line 348  DimRegionEdit::DimRegionEdit() : Line 684  DimRegionEdit::DimRegionEdit() :
684      addProp(eLFO3InternalDepth);      addProp(eLFO3InternalDepth);
685      addProp(eLFO3ControlDepth);      addProp(eLFO3ControlDepth);
686      {      {
687          const char* choices[] = { "internal", "modwheel", "aftertouch",          const char* choices[] = { _("internal"), _("modwheel"), _("aftertouch"),
688                                    "internal+modwheel", "internal+aftertouch", 0 };                                    _("internal+modwheel"), _("internal+aftertouch"), 0 };
689          static const gig::lfo3_ctrl_t values[] = {          static const gig::lfo3_ctrl_t values[] = {
690              gig::lfo3_ctrl_internal,              gig::lfo3_ctrl_internal,
691              gig::lfo3_ctrl_modwheel,              gig::lfo3_ctrl_modwheel,
# Line 364  DimRegionEdit::DimRegionEdit() : Line 700  DimRegionEdit::DimRegionEdit() :
700    
701      nextPage();      nextPage();
702    
703        addHeader(_("Velocity Response"));
704      eVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values);      eVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values);
705      addProp(eVelocityResponseCurve);      addProp(eVelocityResponseCurve);
706      addProp(eVelocityResponseDepth);      addProp(eVelocityResponseDepth);
707      addProp(eVelocityResponseCurveScaling);      addProp(eVelocityResponseCurveScaling);
708    
709        eVelocityResponseCurve.signal_value_changed().connect(
710            sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
711        eVelocityResponseDepth.signal_value_changed().connect(
712            sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
713        eVelocityResponseCurveScaling.signal_value_changed().connect(
714            sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
715    
716        frame = new Gtk::Frame;
717        frame->add(velocity_curve);
718        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
719                              Gtk::SHRINK, Gtk::SHRINK);
720        rowno++;
721    
722        addHeader(_("Release Velocity Response"));
723      eReleaseVelocityResponseCurve.set_choices(curve_type_texts,      eReleaseVelocityResponseCurve.set_choices(curve_type_texts,
724                                                curve_type_values);                                                curve_type_values);
725      addProp(eReleaseVelocityResponseCurve);      addProp(eReleaseVelocityResponseCurve);
726      addProp(eReleaseVelocityResponseDepth);      addProp(eReleaseVelocityResponseDepth);
727    
728        eReleaseVelocityResponseCurve.signal_value_changed().connect(
729            sigc::mem_fun(release_curve, &VelocityCurve::queue_draw));
730        eReleaseVelocityResponseDepth.signal_value_changed().connect(
731            sigc::mem_fun(release_curve, &VelocityCurve::queue_draw));
732        frame = new Gtk::Frame;
733        frame->add(release_curve);
734        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
735                              Gtk::SHRINK, Gtk::SHRINK);
736        rowno++;
737    
738      addProp(eReleaseTriggerDecay);      addProp(eReleaseTriggerDecay);
739      {      {
740          const char* choices[] = { "none", "effect4depth", "effect5depth", 0 };          const char* choices[] = { _("none"), _("effect4depth"), _("effect5depth"), 0 };
741          static const gig::dim_bypass_ctrl_t values[] = {          static const gig::dim_bypass_ctrl_t values[] = {
742              gig::dim_bypass_ctrl_none,              gig::dim_bypass_ctrl_none,
743              gig::dim_bypass_ctrl_94,              gig::dim_bypass_ctrl_94,
# Line 383  DimRegionEdit::DimRegionEdit() : Line 746  DimRegionEdit::DimRegionEdit() :
746          eDimensionBypass.set_choices(choices, values);          eDimensionBypass.set_choices(choices, values);
747      }      }
748      addProp(eDimensionBypass);      addProp(eDimensionBypass);
749        eSelfMask.widget.set_tooltip_text(_(
750            "If enabled: new notes with higher velocity value will stop older "
751            "notes with lower velocity values, that way you can save voices that "
752            "would barely be audible. This is also useful for certain drum sounds."
753        ));
754      addProp(eSelfMask);      addProp(eSelfMask);
755        eSustainDefeat.widget.set_tooltip_text(_(
756            "If enabled: sustain pedal will not hold a note. This way you can use "
757            "the sustain pedal for other purposes, for example to switch among "
758            "dimension regions."
759        ));
760      addProp(eSustainDefeat);      addProp(eSustainDefeat);
761        eMSDecode.widget.set_tooltip_text(_(
762            "Defines if Mid/Side Recordings should be decoded. Mid/Side Recordings "
763            "are an alternative way to record sounds in stereo. The sampler needs "
764            "to decode such samples to actually make use of them. Note: this "
765            "feature is currently not supported by LinuxSampler."
766        ));
767      addProp(eMSDecode);      addProp(eMSDecode);
768    
769      nextPage();      nextPage();
770    
771    
772      eEG1InfiniteSustain.signal_toggled().connect(      eEG1InfiniteSustain.signal_value_changed().connect(
773          sigc::mem_fun(*this, &DimRegionEdit::EG1InfiniteSustain_toggled) );          sigc::mem_fun(*this, &DimRegionEdit::EG1InfiniteSustain_toggled));
774      eEG2InfiniteSustain.signal_toggled().connect(      eEG2InfiniteSustain.signal_value_changed().connect(
775          sigc::mem_fun(*this, &DimRegionEdit::EG2InfiniteSustain_toggled) );          sigc::mem_fun(*this, &DimRegionEdit::EG2InfiniteSustain_toggled));
776      eEG1Controller.signal_changed().connect(      eEG1Controller.signal_value_changed().connect(
777          sigc::mem_fun(*this, &DimRegionEdit::EG1Controller_changed) );          sigc::mem_fun(*this, &DimRegionEdit::EG1Controller_changed));
778      eEG2Controller.signal_changed().connect(      eEG2Controller.signal_value_changed().connect(
779          sigc::mem_fun(*this, &DimRegionEdit::EG2Controller_changed) );          sigc::mem_fun(*this, &DimRegionEdit::EG2Controller_changed));
780      eLFO1Controller.signal_changed().connect(      eLFO1Controller.signal_value_changed().connect(
781          sigc::mem_fun(*this, &DimRegionEdit::LFO1Controller_changed) );          sigc::mem_fun(*this, &DimRegionEdit::LFO1Controller_changed));
782      eLFO2Controller.signal_changed().connect(      eLFO2Controller.signal_value_changed().connect(
783          sigc::mem_fun(*this, &DimRegionEdit::LFO2Controller_changed) );          sigc::mem_fun(*this, &DimRegionEdit::LFO2Controller_changed));
784      eLFO3Controller.signal_changed().connect(      eLFO3Controller.signal_value_changed().connect(
785          sigc::mem_fun(*this, &DimRegionEdit::LFO3Controller_changed) );          sigc::mem_fun(*this, &DimRegionEdit::LFO3Controller_changed));
786      eAttenuationController.signal_changed().connect(      eAttenuationController.signal_value_changed().connect(
787          sigc::mem_fun(*this, &DimRegionEdit::AttenuationController_changed) );          sigc::mem_fun(*this, &DimRegionEdit::AttenuationController_changed));
788      eVCFEnabled.signal_toggled().connect(      eVCFEnabled.signal_value_changed().connect(
789          sigc::mem_fun(*this, &DimRegionEdit::VCFEnabled_toggled) );          sigc::mem_fun(*this, &DimRegionEdit::VCFEnabled_toggled));
790      eVCFCutoffController.signal_changed().connect(      eVCFCutoffController.signal_value_changed().connect(
791          sigc::mem_fun(*this, &DimRegionEdit::VCFCutoffController_changed) );          sigc::mem_fun(*this, &DimRegionEdit::VCFCutoffController_changed));
792      eVCFResonanceController.signal_changed().connect(      eVCFResonanceController.signal_value_changed().connect(
793          sigc::mem_fun(*this, &DimRegionEdit::VCFResonanceController_changed) );          sigc::mem_fun(*this, &DimRegionEdit::VCFResonanceController_changed));
794    
795      eCrossfade_in_start.signal_changed_by_user().connect(      eCrossfade_in_start.signal_value_changed().connect(
796          sigc::mem_fun(*this, &DimRegionEdit::crossfade1_changed));          sigc::mem_fun(*this, &DimRegionEdit::crossfade1_changed));
797      eCrossfade_in_end.signal_changed_by_user().connect(      eCrossfade_in_end.signal_value_changed().connect(
798          sigc::mem_fun(*this, &DimRegionEdit::crossfade2_changed));          sigc::mem_fun(*this, &DimRegionEdit::crossfade2_changed));
799      eCrossfade_out_start.signal_changed_by_user().connect(      eCrossfade_out_start.signal_value_changed().connect(
800          sigc::mem_fun(*this, &DimRegionEdit::crossfade3_changed));          sigc::mem_fun(*this, &DimRegionEdit::crossfade3_changed));
801      eCrossfade_out_end.signal_changed_by_user().connect(      eCrossfade_out_end.signal_value_changed().connect(
802          sigc::mem_fun(*this, &DimRegionEdit::crossfade4_changed));          sigc::mem_fun(*this, &DimRegionEdit::crossfade4_changed));
803    
804      eSampleLoopEnabled.signal_toggled().connect(      eSampleLoopEnabled.signal_value_changed().connect(
805          sigc::mem_fun(*this, &DimRegionEdit::loop_enabled_toggled));          sigc::mem_fun(*this, &DimRegionEdit::update_loop_elements));
806      eSampleLoopStart.signal_changed_by_user().connect(      eSampleLoopStart.signal_value_changed().connect(
807          sigc::mem_fun(*this, &DimRegionEdit::updateLoopElements));          sigc::mem_fun(*this, &DimRegionEdit::loop_start_changed));
808      eSampleLoopLength.signal_changed_by_user().connect(      eSampleLoopLength.signal_value_changed().connect(
809          sigc::mem_fun(*this, &DimRegionEdit::updateLoopElements));          sigc::mem_fun(*this, &DimRegionEdit::loop_length_changed));
810      eSampleLoopInfinite.signal_toggled().connect(      eSampleLoopInfinite.signal_value_changed().connect(
811          sigc::mem_fun(*this, &DimRegionEdit::loop_infinite_toggled));          sigc::mem_fun(*this, &DimRegionEdit::loop_infinite_toggled));
812    
813      append_page(*table[0], "Sample");      append_page(*table[0], _("Sample"));
814      append_page(*table[1], "Amplitude (1)");      append_page(*table[1], _("Amplitude (1)"));
815      append_page(*table[2], "Amplitude (2)");      append_page(*table[2], _("Amplitude (2)"));
816      append_page(*table[3], "Filter (1)");      append_page(*table[3], _("Filter (1)"));
817      append_page(*table[4], "Filter (2)");      append_page(*table[4], _("Filter (2)"));
818      append_page(*table[5], "Pitch");      append_page(*table[5], _("Pitch"));
819      append_page(*table[6], "Misc");      append_page(*table[6], _("Misc"));
820  }  }
821    
822  DimRegionEdit::~DimRegionEdit()  DimRegionEdit::~DimRegionEdit()
# Line 448  void DimRegionEdit::addString(const char Line 827  void DimRegionEdit::addString(const char
827                                Gtk::Entry*& widget)                                Gtk::Entry*& widget)
828  {  {
829      label = new Gtk::Label(Glib::ustring(labelText) + ":");      label = new Gtk::Label(Glib::ustring(labelText) + ":");
830      label->set_alignment(Gtk::ALIGN_LEFT);      label->set_alignment(Gtk::ALIGN_START);
831    
832      table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,      table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,
833                            Gtk::FILL, Gtk::SHRINK);                            Gtk::FILL, Gtk::SHRINK);
# Line 461  void DimRegionEdit::addString(const char Line 840  void DimRegionEdit::addString(const char
840      rowno++;      rowno++;
841  }  }
842    
843  void DimRegionEdit::addHeader(const char* text)  void DimRegionEdit::addString(const char* labelText, Gtk::Label*& label,
844                                  Gtk::Entry*& widget, Gtk::Button*& button)
845    {
846        label = new Gtk::Label(Glib::ustring(labelText) + ":");
847        label->set_alignment(Gtk::ALIGN_START);
848    
849        table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,
850                              Gtk::FILL, Gtk::SHRINK);
851    
852        widget = new Gtk::Entry();
853        button = new Gtk::Button();
854    
855        Gtk::HBox* hbox = new Gtk::HBox;
856        hbox->pack_start(*widget);
857        hbox->pack_start(*button, Gtk::PACK_SHRINK);
858    
859        table[pageno]->attach(*hbox, 2, 3, rowno, rowno + 1,
860                              Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
861    
862        rowno++;
863    }
864    
865    Gtk::Label* DimRegionEdit::addHeader(const char* text)
866  {  {
867      if (firstRowInBlock < rowno - 1)      if (firstRowInBlock < rowno - 1)
868      {      {
# Line 474  void DimRegionEdit::addHeader(const char Line 875  void DimRegionEdit::addHeader(const char
875      str += "</b>";      str += "</b>";
876      Gtk::Label* label = new Gtk::Label(str);      Gtk::Label* label = new Gtk::Label(str);
877      label->set_use_markup();      label->set_use_markup();
878      label->set_alignment(Gtk::ALIGN_LEFT);      label->set_alignment(Gtk::ALIGN_START);
879      table[pageno]->attach(*label, 0, 3, rowno, rowno + 1,      table[pageno]->attach(*label, 0, 3, rowno, rowno + 1,
880                            Gtk::FILL, Gtk::SHRINK);                            Gtk::FILL, Gtk::SHRINK);
881      rowno++;      rowno++;
882      firstRowInBlock = rowno;      firstRowInBlock = rowno;
883        return label;
884  }  }
885    
886  void DimRegionEdit::nextPage()  void DimRegionEdit::nextPage()
# Line 499  void DimRegionEdit::addProp(BoolEntry& b Line 901  void DimRegionEdit::addProp(BoolEntry& b
901      table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1,      table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1,
902                            Gtk::FILL, Gtk::SHRINK);                            Gtk::FILL, Gtk::SHRINK);
903      rowno++;      rowno++;
     boolentry.signal_changed_by_user().connect(dimreg_changed_signal.make_slot());  
904  }  }
905    
906  void DimRegionEdit::addProp(BoolEntryPlus6& boolentry)  void DimRegionEdit::addProp(BoolEntryPlus6& boolentry)
# Line 507  void DimRegionEdit::addProp(BoolEntryPlu Line 908  void DimRegionEdit::addProp(BoolEntryPlu
908      table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1,      table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1,
909                            Gtk::FILL, Gtk::SHRINK);                            Gtk::FILL, Gtk::SHRINK);
910      rowno++;      rowno++;
     boolentry.signal_changed_by_user().connect(dimreg_changed_signal.make_slot());  
911  }  }
912    
913  void DimRegionEdit::addProp(LabelWidget& prop)  void DimRegionEdit::addProp(LabelWidget& prop)
# Line 517  void DimRegionEdit::addProp(LabelWidget& Line 917  void DimRegionEdit::addProp(LabelWidget&
917      table[pageno]->attach(prop.widget, 2, 3, rowno, rowno + 1,      table[pageno]->attach(prop.widget, 2, 3, rowno, rowno + 1,
918                            Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);                            Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
919      rowno++;      rowno++;
     prop.signal_changed_by_user().connect(dimreg_changed_signal.make_slot());  
920  }  }
921    
922    void DimRegionEdit::addRightHandSide(Gtk::Widget& widget)
923    {
924        table[pageno]->attach(widget, 2, 3, rowno, rowno + 1,
925                              Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
926        rowno++;
927    }
928    
929  void DimRegionEdit::set_dim_region(gig::DimensionRegion* d)  void DimRegionEdit::set_dim_region(gig::DimensionRegion* d)
930  {  {
931      dimregion = d;      dimregion = d;
932        velocity_curve.set_dim_region(d);
933        release_curve.set_dim_region(d);
934        cutoff_curve.set_dim_region(d);
935        crossfade_curve.set_dim_region(d);
936    
937      set_sensitive(d);      set_sensitive(d);
938      if (!d) return;      if (!d) return;
939    
940      wSample->set_text(d->pSample ? d->pSample->pInfo->Name.c_str() : "NULL");      update_model++;
941      eEG1PreAttack.set_ptr(&d->EG1PreAttack);      eEG1PreAttack.set_value(d->EG1PreAttack);
942      eEG1Attack.set_ptr(&d->EG1Attack);      eEG1Attack.set_value(d->EG1Attack);
943      eEG1Decay1.set_ptr(&d->EG1Decay1);      eEG1Decay1.set_value(d->EG1Decay1);
944      eEG1Decay2.set_ptr(&d->EG1Decay2);      eEG1Decay2.set_value(d->EG1Decay2);
945      eEG1InfiniteSustain.set_ptr(&d->EG1InfiniteSustain);      eEG1InfiniteSustain.set_value(d->EG1InfiniteSustain);
946      eEG1Sustain.set_ptr(&d->EG1Sustain);      eEG1Sustain.set_value(d->EG1Sustain);
947      eEG1Release.set_ptr(&d->EG1Release);      eEG1Release.set_value(d->EG1Release);
948      eEG1Hold.set_ptr(&d->EG1Hold);      eEG1Hold.set_value(d->EG1Hold);
949      eEG1Controller.set_ptr(&d->EG1Controller);      eEG1Controller.set_value(d->EG1Controller);
950      eEG1ControllerInvert.set_ptr(&d->EG1ControllerInvert);      eEG1ControllerInvert.set_value(d->EG1ControllerInvert);
951      eEG1ControllerAttackInfluence.set_ptr(&d->EG1ControllerAttackInfluence);      eEG1ControllerAttackInfluence.set_value(d->EG1ControllerAttackInfluence);
952      eEG1ControllerDecayInfluence.set_ptr(&d->EG1ControllerDecayInfluence);      eEG1ControllerDecayInfluence.set_value(d->EG1ControllerDecayInfluence);
953      eEG1ControllerReleaseInfluence.set_ptr(&d->EG1ControllerReleaseInfluence);      eEG1ControllerReleaseInfluence.set_value(d->EG1ControllerReleaseInfluence);
954      eLFO1Frequency.set_ptr(&d->LFO1Frequency);      eLFO1Frequency.set_value(d->LFO1Frequency);
955      eLFO1InternalDepth.set_ptr(&d->LFO1InternalDepth);      eLFO1InternalDepth.set_value(d->LFO1InternalDepth);
956      eLFO1ControlDepth.set_ptr(&d->LFO1ControlDepth);      eLFO1ControlDepth.set_value(d->LFO1ControlDepth);
957      eLFO1Controller.set_ptr(&d->LFO1Controller);      eLFO1Controller.set_value(d->LFO1Controller);
958      eLFO1FlipPhase.set_ptr(&d->LFO1FlipPhase);      eLFO1FlipPhase.set_value(d->LFO1FlipPhase);
959      eLFO1Sync.set_ptr(&d->LFO1Sync);      eLFO1Sync.set_value(d->LFO1Sync);
960      eEG2PreAttack.set_ptr(&d->EG2PreAttack);      eEG2PreAttack.set_value(d->EG2PreAttack);
961      eEG2Attack.set_ptr(&d->EG2Attack);      eEG2Attack.set_value(d->EG2Attack);
962      eEG2Decay1.set_ptr(&d->EG2Decay1);      eEG2Decay1.set_value(d->EG2Decay1);
963      eEG2Decay2.set_ptr(&d->EG2Decay2);      eEG2Decay2.set_value(d->EG2Decay2);
964      eEG2InfiniteSustain.set_ptr(&d->EG2InfiniteSustain);      eEG2InfiniteSustain.set_value(d->EG2InfiniteSustain);
965      eEG2Sustain.set_ptr(&d->EG2Sustain);      eEG2Sustain.set_value(d->EG2Sustain);
966      eEG2Release.set_ptr(&d->EG2Release);      eEG2Release.set_value(d->EG2Release);
967      eEG2Controller.set_ptr(&d->EG2Controller);      eEG2Controller.set_value(d->EG2Controller);
968      eEG2ControllerInvert.set_ptr(&d->EG2ControllerInvert);      eEG2ControllerInvert.set_value(d->EG2ControllerInvert);
969      eEG2ControllerAttackInfluence.set_ptr(&d->EG2ControllerAttackInfluence);      eEG2ControllerAttackInfluence.set_value(d->EG2ControllerAttackInfluence);
970      eEG2ControllerDecayInfluence.set_ptr(&d->EG2ControllerDecayInfluence);      eEG2ControllerDecayInfluence.set_value(d->EG2ControllerDecayInfluence);
971      eEG2ControllerReleaseInfluence.set_ptr(&d->EG2ControllerReleaseInfluence);      eEG2ControllerReleaseInfluence.set_value(d->EG2ControllerReleaseInfluence);
972      eLFO2Frequency.set_ptr(&d->LFO2Frequency);      eLFO2Frequency.set_value(d->LFO2Frequency);
973      eLFO2InternalDepth.set_ptr(&d->LFO2InternalDepth);      eLFO2InternalDepth.set_value(d->LFO2InternalDepth);
974      eLFO2ControlDepth.set_ptr(&d->LFO2ControlDepth);      eLFO2ControlDepth.set_value(d->LFO2ControlDepth);
975      eLFO2Controller.set_ptr(&d->LFO2Controller);      eLFO2Controller.set_value(d->LFO2Controller);
976      eLFO2FlipPhase.set_ptr(&d->LFO2FlipPhase);      eLFO2FlipPhase.set_value(d->LFO2FlipPhase);
977      eLFO2Sync.set_ptr(&d->LFO2Sync);      eLFO2Sync.set_value(d->LFO2Sync);
978      eEG3Attack.set_ptr(&d->EG3Attack);      eEG3Attack.set_value(d->EG3Attack);
979      eEG3Depth.set_ptr(&d->EG3Depth);      eEG3Depth.set_value(d->EG3Depth);
980      eLFO3Frequency.set_ptr(&d->LFO3Frequency);      eLFO3Frequency.set_value(d->LFO3Frequency);
981      eLFO3InternalDepth.set_ptr(&d->LFO3InternalDepth);      eLFO3InternalDepth.set_value(d->LFO3InternalDepth);
982      eLFO3ControlDepth.set_ptr(&d->LFO3ControlDepth);      eLFO3ControlDepth.set_value(d->LFO3ControlDepth);
983      eLFO3Controller.set_ptr(&d->LFO3Controller);      eLFO3Controller.set_value(d->LFO3Controller);
984      eLFO3Sync.set_ptr(&d->LFO3Sync);      eLFO3Sync.set_value(d->LFO3Sync);
985      eVCFEnabled.set_ptr(&d->VCFEnabled);      eVCFEnabled.set_value(d->VCFEnabled);
986      eVCFType.set_ptr(&d->VCFType);      eVCFType.set_value(d->VCFType);
987      eVCFCutoffController.set_ptr(&d->VCFCutoffController);      eVCFCutoffController.set_value(d->VCFCutoffController);
988      eVCFCutoffControllerInvert.set_ptr(&d->VCFCutoffControllerInvert);      eVCFCutoffControllerInvert.set_value(d->VCFCutoffControllerInvert);
989      eVCFCutoff.set_ptr(&d->VCFCutoff);      eVCFCutoff.set_value(d->VCFCutoff);
990      eVCFVelocityCurve.set_ptr(&d->VCFVelocityCurve);      eVCFVelocityCurve.set_value(d->VCFVelocityCurve);
991      eVCFVelocityScale.set_ptr(&d->VCFVelocityScale);      eVCFVelocityScale.set_value(d->VCFVelocityScale);
992      eVCFVelocityDynamicRange.set_ptr(&d->VCFVelocityDynamicRange);      eVCFVelocityDynamicRange.set_value(d->VCFVelocityDynamicRange);
993      eVCFResonance.set_ptr(&d->VCFResonance);      eVCFResonance.set_value(d->VCFResonance);
994      eVCFResonanceDynamic.set_ptr(&d->VCFResonanceDynamic);      eVCFResonanceDynamic.set_value(d->VCFResonanceDynamic);
995      eVCFResonanceController.set_ptr(&d->VCFResonanceController);      eVCFResonanceController.set_value(d->VCFResonanceController);
996      eVCFKeyboardTracking.set_ptr(&d->VCFKeyboardTracking);      eVCFKeyboardTracking.set_value(d->VCFKeyboardTracking);
997      eVCFKeyboardTrackingBreakpoint.set_ptr(&d->VCFKeyboardTrackingBreakpoint);      eVCFKeyboardTrackingBreakpoint.set_value(d->VCFKeyboardTrackingBreakpoint);
998      eVelocityResponseCurve.set_ptr(&d->VelocityResponseCurve);      eVelocityResponseCurve.set_value(d->VelocityResponseCurve);
999      eVelocityResponseDepth.set_ptr(&d->VelocityResponseDepth);      eVelocityResponseDepth.set_value(d->VelocityResponseDepth);
1000      eVelocityResponseCurveScaling.set_ptr(&d->VelocityResponseCurveScaling);      eVelocityResponseCurveScaling.set_value(d->VelocityResponseCurveScaling);
1001      eReleaseVelocityResponseCurve.set_ptr(&d->ReleaseVelocityResponseCurve);      eReleaseVelocityResponseCurve.set_value(d->ReleaseVelocityResponseCurve);
1002      eReleaseVelocityResponseDepth.set_ptr(&d->ReleaseVelocityResponseDepth);      eReleaseVelocityResponseDepth.set_value(d->ReleaseVelocityResponseDepth);
1003      eReleaseTriggerDecay.set_ptr(&d->ReleaseTriggerDecay);      eReleaseTriggerDecay.set_value(d->ReleaseTriggerDecay);
1004        eCrossfade_in_start.set_value(d->Crossfade.in_start);
1005      eCrossfade_in_start.set_ptr(0);      eCrossfade_in_end.set_value(d->Crossfade.in_end);
1006      eCrossfade_in_end.set_ptr(0);      eCrossfade_out_start.set_value(d->Crossfade.out_start);
1007      eCrossfade_out_start.set_ptr(0);      eCrossfade_out_end.set_value(d->Crossfade.out_end);
1008      eCrossfade_out_end.set_ptr(0);      ePitchTrack.set_value(d->PitchTrack);
1009      eCrossfade_in_start.set_ptr(&d->Crossfade.in_start);      eDimensionBypass.set_value(d->DimensionBypass);
1010      eCrossfade_in_end.set_ptr(&d->Crossfade.in_end);      ePan.set_value(d->Pan);
1011      eCrossfade_out_start.set_ptr(&d->Crossfade.out_start);      eSelfMask.set_value(d->SelfMask);
1012      eCrossfade_out_end.set_ptr(&d->Crossfade.out_end);      eAttenuationController.set_value(d->AttenuationController);
1013        eInvertAttenuationController.set_value(d->InvertAttenuationController);
1014      ePitchTrack.set_ptr(&d->PitchTrack);      eAttenuationControllerThreshold.set_value(d->AttenuationControllerThreshold);
1015      eDimensionBypass.set_ptr(&d->DimensionBypass);      eChannelOffset.set_value(d->ChannelOffset);
1016      ePan.set_ptr(&d->Pan);      eSustainDefeat.set_value(d->SustainDefeat);
1017      eSelfMask.set_ptr(&d->SelfMask);      eMSDecode.set_value(d->MSDecode);
1018      eAttenuationController.set_ptr(&d->AttenuationController);      eSampleStartOffset.set_value(d->SampleStartOffset);
1019      eInvertAttenuationController.set_ptr(&d->InvertAttenuationController);      eUnityNote.set_value(d->UnityNote);
1020      eAttenuationControllerThreshold.set_ptr(&d->AttenuationControllerThreshold);      // assemble sample format info string
1021      eChannelOffset.set_ptr(&d->ChannelOffset);      {
1022      eSustainDefeat.set_ptr(&d->SustainDefeat);          Glib::ustring s;
1023      eMSDecode.set_ptr(&d->MSDecode);          if (d->pSample) {
1024      eSampleStartOffset.set_ptr(&d->SampleStartOffset);              switch (d->pSample->Channels) {
1025      eUnityNote.set_ptr(&d->UnityNote);                  case 1: s = _("Mono"); break;
1026      eFineTune.set_ptr(&d->FineTune);                  case 2: s = _("Stereo"); break;
1027      eGain.set_ptr(&d->Gain);                  default:
1028      eGainPlus6.set_ptr(&d->Gain);                      s = ToString(d->pSample->Channels) + _(" audio channels");
1029                        break;
1030                }
1031                s += " " + ToString(d->pSample->BitDepth) + " Bits";
1032                s += " " + ToString(d->pSample->SamplesPerSecond/1000) + "."
1033                          + ToString((d->pSample->SamplesPerSecond%1000)/100) + " kHz";
1034            } else {
1035                s = _("No sample assigned to this dimension region.");
1036            }
1037            eSampleFormatInfo.text.set_text(s);
1038        }
1039        // generate sample's memory address pointer string
1040        {
1041            Glib::ustring s;
1042            if (d->pSample) {
1043                char buf[64] = {};
1044                snprintf(buf, sizeof(buf), "%p", d->pSample);
1045                s = buf;
1046            } else {
1047                s = "---";
1048            }
1049            eSampleID.text.set_text(s);
1050        }
1051        buttonSelectSample.set_sensitive(d && d->pSample);
1052        eFineTune.set_value(d->FineTune);
1053        eGain.set_value(d->Gain);
1054        eGainPlus6.set_value(d->Gain);
1055        eSampleLoopEnabled.set_value(d->SampleLoops);
1056        eSampleLoopType.set_value(
1057            d->SampleLoops ? d->pSampleLoops[0].LoopType : 0);
1058        eSampleLoopStart.set_value(
1059            d->SampleLoops ? d->pSampleLoops[0].LoopStart : 0);
1060        eSampleLoopLength.set_value(
1061            d->SampleLoops ? d->pSampleLoops[0].LoopLength : 0);
1062        eSampleLoopInfinite.set_value(
1063            d->pSample && d->pSample->LoopPlayCount == 0);
1064        eSampleLoopPlayCount.set_value(
1065            d->pSample ? d->pSample->LoopPlayCount : 0);
1066        update_model--;
1067    
1068      eSampleLoopEnabled.set_active(d->SampleLoops);      wSample->set_text(d->pSample ? gig_to_utf8(d->pSample->pInfo->Name) :
1069      updateLoopElements();                        _("NULL"));
1070    
1071        update_loop_elements();
1072      VCFEnabled_toggled();      VCFEnabled_toggled();
1073  }  }
1074    
1075    
1076  void DimRegionEdit::VCFEnabled_toggled()  void DimRegionEdit::VCFEnabled_toggled()
1077  {  {
1078      bool sensitive = eVCFEnabled.get_active();      bool sensitive = eVCFEnabled.get_value();
1079      eVCFType.set_sensitive(sensitive);      eVCFType.set_sensitive(sensitive);
1080      eVCFCutoffController.set_sensitive(sensitive);      eVCFCutoffController.set_sensitive(sensitive);
1081      eVCFVelocityCurve.set_sensitive(sensitive);      eVCFVelocityCurve.set_sensitive(sensitive);
1082      eVCFVelocityScale.set_sensitive(sensitive);      eVCFVelocityScale.set_sensitive(sensitive);
1083      eVCFVelocityDynamicRange.set_sensitive(sensitive);      eVCFVelocityDynamicRange.set_sensitive(sensitive);
1084        cutoff_curve.set_sensitive(sensitive);
1085      eVCFResonance.set_sensitive(sensitive);      eVCFResonance.set_sensitive(sensitive);
1086      eVCFResonanceController.set_sensitive(sensitive);      eVCFResonanceController.set_sensitive(sensitive);
1087      eVCFKeyboardTracking.set_sensitive(sensitive);      eVCFKeyboardTracking.set_sensitive(sensitive);
1088      eVCFKeyboardTrackingBreakpoint.set_sensitive(sensitive);      eVCFKeyboardTrackingBreakpoint.set_sensitive(sensitive);
1089        lEG2->set_sensitive(sensitive);
1090      eEG2PreAttack.set_sensitive(sensitive);      eEG2PreAttack.set_sensitive(sensitive);
1091      eEG2Attack.set_sensitive(sensitive);      eEG2Attack.set_sensitive(sensitive);
1092      eEG2Decay1.set_sensitive(sensitive);      eEG2Decay1.set_sensitive(sensitive);
# Line 646  void DimRegionEdit::VCFEnabled_toggled() Line 1097  void DimRegionEdit::VCFEnabled_toggled()
1097      eEG2ControllerAttackInfluence.set_sensitive(sensitive);      eEG2ControllerAttackInfluence.set_sensitive(sensitive);
1098      eEG2ControllerDecayInfluence.set_sensitive(sensitive);      eEG2ControllerDecayInfluence.set_sensitive(sensitive);
1099      eEG2ControllerReleaseInfluence.set_sensitive(sensitive);      eEG2ControllerReleaseInfluence.set_sensitive(sensitive);
1100        lLFO2->set_sensitive(sensitive);
1101      eLFO2Frequency.set_sensitive(sensitive);      eLFO2Frequency.set_sensitive(sensitive);
1102      eLFO2InternalDepth.set_sensitive(sensitive);      eLFO2InternalDepth.set_sensitive(sensitive);
1103      eLFO2ControlDepth.set_sensitive(sensitive);      eLFO2ControlDepth.set_sensitive(sensitive);
# Line 672  void DimRegionEdit::VCFEnabled_toggled() Line 1124  void DimRegionEdit::VCFEnabled_toggled()
1124    
1125  void DimRegionEdit::VCFCutoffController_changed()  void DimRegionEdit::VCFCutoffController_changed()
1126  {  {
1127      int rowno = eVCFCutoffController.get_active_row_number();      gig::vcf_cutoff_ctrl_t ctrl = eVCFCutoffController.get_value();
1128      bool hasController = rowno != 0 && rowno != 1;      bool hasController = ctrl != gig::vcf_cutoff_ctrl_none && ctrl != gig::vcf_cutoff_ctrl_none2;
1129    
1130      eVCFCutoffControllerInvert.set_sensitive(hasController);      eVCFCutoffControllerInvert.set_sensitive(hasController);
1131      eVCFCutoff.set_sensitive(!hasController);      eVCFCutoff.set_sensitive(!hasController);
1132      eVCFResonanceDynamic.set_sensitive(!hasController);      eVCFResonanceDynamic.set_sensitive(!hasController);
1133      eVCFVelocityScale.label.set_text(hasController ? "Minimum cutoff:" :      eVCFVelocityScale.label.set_text(hasController ? _("Minimum cutoff:") :
1134                                       "Velocity scale:");                                       _("Velocity scale:"));
1135  }  }
1136    
1137  void DimRegionEdit::VCFResonanceController_changed()  void DimRegionEdit::VCFResonanceController_changed()
1138  {  {
1139      bool hasController = eVCFResonanceController.get_active_row_number() != 0;      bool hasController = eVCFResonanceController.get_value() != gig::vcf_res_ctrl_none;
1140      eVCFResonance.set_sensitive(!hasController);      eVCFResonance.set_sensitive(!hasController);
1141  }  }
1142    
1143  void DimRegionEdit::EG1InfiniteSustain_toggled()  void DimRegionEdit::EG1InfiniteSustain_toggled()
1144  {  {
1145      bool infSus = eEG1InfiniteSustain.get_active();      bool infSus = eEG1InfiniteSustain.get_value();
1146      eEG1Decay2.set_sensitive(!infSus);      eEG1Decay2.set_sensitive(!infSus);
1147  }  }
1148    
1149  void DimRegionEdit::EG2InfiniteSustain_toggled()  void DimRegionEdit::EG2InfiniteSustain_toggled()
1150  {  {
1151      bool infSus = eEG2InfiniteSustain.get_active();      bool infSus = eEG2InfiniteSustain.get_value();
1152      eEG2Decay2.set_sensitive(!infSus);      eEG2Decay2.set_sensitive(!infSus);
1153  }  }
1154    
1155  void DimRegionEdit::EG1Controller_changed()  void DimRegionEdit::EG1Controller_changed()
1156  {  {
1157      bool hasController = eEG1Controller.get_active_row_number() != 0;      bool hasController = eEG1Controller.get_value().type != gig::leverage_ctrl_t::type_none;
1158      eEG1ControllerInvert.set_sensitive(hasController);      eEG1ControllerInvert.set_sensitive(hasController);
1159  }  }
1160    
1161  void DimRegionEdit::EG2Controller_changed()  void DimRegionEdit::EG2Controller_changed()
1162  {  {
1163      bool hasController = eEG2Controller.get_active_row_number() != 0;      bool hasController = eEG2Controller.get_value().type != gig::leverage_ctrl_t::type_none;
1164      eEG2ControllerInvert.set_sensitive(hasController);      eEG2ControllerInvert.set_sensitive(hasController);
1165  }  }
1166    
1167  void DimRegionEdit::AttenuationController_changed()  void DimRegionEdit::AttenuationController_changed()
1168  {  {
1169      bool hasController = eAttenuationController.get_active_row_number() != 0;      bool hasController =
1170            eAttenuationController.get_value().type != gig::leverage_ctrl_t::type_none;
1171      eInvertAttenuationController.set_sensitive(hasController);      eInvertAttenuationController.set_sensitive(hasController);
1172      eAttenuationControllerThreshold.set_sensitive(hasController);      eAttenuationControllerThreshold.set_sensitive(hasController);
1173      eCrossfade_in_start.set_sensitive(hasController);      eCrossfade_in_start.set_sensitive(hasController);
1174      eCrossfade_in_end.set_sensitive(hasController);      eCrossfade_in_end.set_sensitive(hasController);
1175      eCrossfade_out_start.set_sensitive(hasController);      eCrossfade_out_start.set_sensitive(hasController);
1176      eCrossfade_out_end.set_sensitive(hasController);      eCrossfade_out_end.set_sensitive(hasController);
1177        crossfade_curve.set_sensitive(hasController);
1178  }  }
1179    
1180  void DimRegionEdit::LFO1Controller_changed()  void DimRegionEdit::LFO1Controller_changed()
1181  {  {
1182      int rowno = eLFO1Controller.get_active_row_number();      gig::lfo1_ctrl_t ctrl = eLFO1Controller.get_value();
1183      eLFO1ControlDepth.set_sensitive(rowno != 0);      eLFO1ControlDepth.set_sensitive(ctrl != gig::lfo1_ctrl_internal);
1184      eLFO1InternalDepth.set_sensitive(rowno != 1 && rowno != 2);      eLFO1InternalDepth.set_sensitive(ctrl != gig::lfo1_ctrl_modwheel &&
1185                                         ctrl != gig::lfo1_ctrl_breath);
1186  }  }
1187    
1188  void DimRegionEdit::LFO2Controller_changed()  void DimRegionEdit::LFO2Controller_changed()
1189  {  {
1190      int rowno = eLFO2Controller.get_active_row_number();      gig::lfo2_ctrl_t ctrl = eLFO2Controller.get_value();
1191      eLFO2ControlDepth.set_sensitive(rowno != 0);      eLFO2ControlDepth.set_sensitive(ctrl != gig::lfo2_ctrl_internal);
1192      eLFO2InternalDepth.set_sensitive(rowno != 1 && rowno != 2);      eLFO2InternalDepth.set_sensitive(ctrl != gig::lfo2_ctrl_modwheel &&
1193                                         ctrl != gig::lfo2_ctrl_foot);
1194  }  }
1195    
1196  void DimRegionEdit::LFO3Controller_changed()  void DimRegionEdit::LFO3Controller_changed()
1197  {  {
1198      int rowno = eLFO3Controller.get_active_row_number();      gig::lfo3_ctrl_t ctrl = eLFO3Controller.get_value();
1199      eLFO3ControlDepth.set_sensitive(rowno != 0);      eLFO3ControlDepth.set_sensitive(ctrl != gig::lfo3_ctrl_internal);
1200      eLFO3InternalDepth.set_sensitive(rowno != 1 && rowno != 2);      eLFO3InternalDepth.set_sensitive(ctrl != gig::lfo3_ctrl_modwheel &&
1201                                         ctrl != gig::lfo3_ctrl_aftertouch);
1202  }  }
1203    
1204  void DimRegionEdit::crossfade1_changed()  void DimRegionEdit::crossfade1_changed()
1205  {  {
1206      double c1 = eCrossfade_in_start.get_value();      update_model++;
1207      double c2 = eCrossfade_in_end.get_value();      eCrossfade_in_end.set_value(dimregion->Crossfade.in_end);
1208      if (c1 > c2) eCrossfade_in_end.set_value(c1);      eCrossfade_out_start.set_value(dimregion->Crossfade.out_start);
1209        eCrossfade_out_end.set_value(dimregion->Crossfade.out_end);
1210        update_model--;
1211  }  }
1212    
1213  void DimRegionEdit::crossfade2_changed()  void DimRegionEdit::crossfade2_changed()
1214  {  {
1215      double c1 = eCrossfade_in_start.get_value();      update_model++;
1216      double c2 = eCrossfade_in_end.get_value();      eCrossfade_in_start.set_value(dimregion->Crossfade.in_start);
1217      double c3 = eCrossfade_out_start.get_value();      eCrossfade_out_start.set_value(dimregion->Crossfade.out_start);
1218        eCrossfade_out_end.set_value(dimregion->Crossfade.out_end);
1219      if (c2 < c1) eCrossfade_in_start.set_value(c2);      update_model--;
     if (c2 > c3) eCrossfade_out_start.set_value(c2);  
1220  }  }
1221    
1222  void DimRegionEdit::crossfade3_changed()  void DimRegionEdit::crossfade3_changed()
1223  {  {
1224      double c2 = eCrossfade_in_end.get_value();      update_model++;
1225      double c3 = eCrossfade_out_start.get_value();      eCrossfade_in_start.set_value(dimregion->Crossfade.in_start);
1226      double c4 = eCrossfade_out_end.get_value();      eCrossfade_in_end.set_value(dimregion->Crossfade.in_end);
1227        eCrossfade_out_end.set_value(dimregion->Crossfade.out_end);
1228      if (c3 < c2) eCrossfade_in_end.set_value(c3);      update_model--;
     if (c3 > c4) eCrossfade_out_end.set_value(c3);  
1229  }  }
1230    
1231  void DimRegionEdit::crossfade4_changed()  void DimRegionEdit::crossfade4_changed()
1232  {  {
1233      double c3 = eCrossfade_out_start.get_value();      update_model++;
1234      double c4 = eCrossfade_out_end.get_value();      eCrossfade_in_start.set_value(dimregion->Crossfade.in_start);
1235        eCrossfade_in_end.set_value(dimregion->Crossfade.in_end);
1236        eCrossfade_out_start.set_value(dimregion->Crossfade.out_start);
1237        update_model--;
1238    }
1239    
1240    void DimRegionEdit::update_loop_elements()
1241    {
1242        update_model++;
1243        const bool active = eSampleLoopEnabled.get_value();
1244        eSampleLoopStart.set_sensitive(active);
1245        eSampleLoopLength.set_sensitive(active);
1246        eSampleLoopType.set_sensitive(active);
1247        eSampleLoopInfinite.set_sensitive(active && dimregion && dimregion->pSample);
1248        // sample loop shall never be longer than the actual sample size
1249        loop_start_changed();
1250        loop_length_changed();
1251        eSampleLoopStart.set_value(
1252            dimregion->SampleLoops ? dimregion->pSampleLoops[0].LoopStart : 0);
1253        eSampleLoopLength.set_value(
1254            dimregion->SampleLoops ? dimregion->pSampleLoops[0].LoopLength : 0);
1255    
1256        eSampleLoopInfinite.set_value(
1257            dimregion->pSample && dimregion->pSample->LoopPlayCount == 0);
1258    
1259        loop_infinite_toggled();
1260        update_model--;
1261    }
1262    
1263    void DimRegionEdit::loop_start_changed() {
1264        if (dimregion && dimregion->SampleLoops) {
1265            eSampleLoopLength.set_upper(dimregion->pSample ?
1266                                        dimregion->pSample->SamplesTotal -
1267                                        dimregion->pSampleLoops[0].LoopStart : 0);
1268        }
1269    }
1270    
1271    void DimRegionEdit::loop_length_changed() {
1272        if (dimregion && dimregion->SampleLoops) {
1273            eSampleLoopStart.set_upper(dimregion->pSample ?
1274                                       dimregion->pSample->SamplesTotal -
1275                                       dimregion->pSampleLoops[0].LoopLength : 0);
1276        }
1277    }
1278    
1279    void DimRegionEdit::loop_infinite_toggled() {
1280        eSampleLoopPlayCount.set_sensitive(
1281            dimregion && dimregion->pSample &&
1282            !eSampleLoopInfinite.get_value() &&
1283            eSampleLoopEnabled.get_value()
1284        );
1285        update_model++;
1286        eSampleLoopPlayCount.set_value(
1287            dimregion->pSample ? dimregion->pSample->LoopPlayCount : 0);
1288        update_model--;
1289    }
1290    
1291    bool DimRegionEdit::set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop)
1292    {
1293        if (dimregion) {
1294            //TODO: we should better move the code from MainWindow::on_sample_label_drop_drag_data_received() here
1295    
1296            // currently commented because we're sending a similar signal in MainWindow::on_sample_label_drop_drag_data_received()
1297            //dimreg_to_be_changed_signal.emit(dimregion);
1298    
1299            // make sure stereo samples always are the same in both
1300            // dimregs in the samplechannel dimension
1301            int nbDimregs = 1;
1302            gig::DimensionRegion* d[2] = { dimregion, 0 };
1303            if (sample->Channels == 2) {
1304                gig::Region* region = dimregion->GetParent();
1305    
1306                int bitcount = 0;
1307                int stereo_bit = 0;
1308                for (int dim = 0 ; dim < region->Dimensions ; dim++) {
1309                    if (region->pDimensionDefinitions[dim].dimension == gig::dimension_samplechannel) {
1310                        stereo_bit = 1 << bitcount;
1311                        break;
1312                    }
1313                    bitcount += region->pDimensionDefinitions[dim].bits;
1314                }
1315    
1316                if (stereo_bit) {
1317                    int dimregno;
1318                    for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
1319                        if (region->pDimensionRegions[dimregno] == dimregion) {
1320                            break;
1321                        }
1322                    }
1323                    d[0] = region->pDimensionRegions[dimregno & ~stereo_bit];
1324                    d[1] = region->pDimensionRegions[dimregno | stereo_bit];
1325                    nbDimregs = 2;
1326                }
1327            }
1328    
1329            gig::Sample* oldref = dimregion->pSample;
1330    
1331            for (int i = 0 ; i < nbDimregs ; i++) {
1332                d[i]->pSample = sample;
1333    
1334                // copy sample information from Sample to DimensionRegion
1335                if (copy_sample_unity)
1336                    d[i]->UnityNote = sample->MIDIUnityNote;
1337                if (copy_sample_tune)
1338                    d[i]->FineTune = sample->FineTune;
1339                if (copy_sample_loop) {
1340                    int loops = sample->Loops ? 1 : 0;
1341                    while (d[i]->SampleLoops > loops) {
1342                        d[i]->DeleteSampleLoop(&d[i]->pSampleLoops[0]);
1343                    }
1344                    while (d[i]->SampleLoops < sample->Loops) {
1345                        DLS::sample_loop_t loop;
1346                        d[i]->AddSampleLoop(&loop);
1347                    }
1348                    if (loops) {
1349                        d[i]->pSampleLoops[0].Size = sizeof(DLS::sample_loop_t);
1350                        d[i]->pSampleLoops[0].LoopType = sample->LoopType;
1351                        d[i]->pSampleLoops[0].LoopStart = sample->LoopStart;
1352                        d[i]->pSampleLoops[0].LoopLength = sample->LoopEnd - sample->LoopStart + 1;
1353                    }
1354                }
1355            }
1356    
1357            // update ui
1358            update_model++;
1359            wSample->set_text(gig_to_utf8(dimregion->pSample->pInfo->Name));
1360            eUnityNote.set_value(dimregion->UnityNote);
1361            eFineTune.set_value(dimregion->FineTune);
1362            eSampleLoopEnabled.set_value(dimregion->SampleLoops);
1363            update_loop_elements();
1364            update_model--;
1365    
1366            sample_ref_changed_signal.emit(oldref, sample);
1367            // currently commented because we're sending a similar signal in MainWindow::on_sample_label_drop_drag_data_received()
1368            //dimreg_changed_signal.emit(dimregion);
1369            return true;
1370        }
1371        return false;
1372    }
1373    
1374    sigc::signal<void, gig::DimensionRegion*>& DimRegionEdit::signal_dimreg_to_be_changed() {
1375        return dimreg_to_be_changed_signal;
1376    }
1377    
1378    sigc::signal<void, gig::DimensionRegion*>& DimRegionEdit::signal_dimreg_changed() {
1379        return dimreg_changed_signal;
1380    }
1381    
1382    sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& DimRegionEdit::signal_sample_ref_changed() {
1383        return sample_ref_changed_signal;
1384    }
1385    
1386    
1387    void DimRegionEdit::set_UnityNote(gig::DimensionRegion* d, uint8_t value)
1388    {
1389        d->UnityNote = value;
1390    }
1391    
1392    void DimRegionEdit::set_FineTune(gig::DimensionRegion* d, int16_t value)
1393    {
1394        d->FineTune = value;
1395    }
1396    
1397    void DimRegionEdit::set_Crossfade_in_start(gig::DimensionRegion* d,
1398                                               uint8_t value)
1399    {
1400        d->Crossfade.in_start = value;
1401        if (d->Crossfade.in_end < value) set_Crossfade_in_end(d, value);
1402    }
1403    
1404    void DimRegionEdit::set_Crossfade_in_end(gig::DimensionRegion* d,
1405                                             uint8_t value)
1406    {
1407        d->Crossfade.in_end = value;
1408        if (value < d->Crossfade.in_start) set_Crossfade_in_start(d, value);
1409        if (value > d->Crossfade.out_start) set_Crossfade_out_start(d, value);
1410    }
1411    
1412    void DimRegionEdit::set_Crossfade_out_start(gig::DimensionRegion* d,
1413                                                uint8_t value)
1414    {
1415        d->Crossfade.out_start = value;
1416        if (value < d->Crossfade.in_end) set_Crossfade_in_end(d, value);
1417        if (value > d->Crossfade.out_end) set_Crossfade_out_end(d, value);
1418    }
1419    
1420      if (c4 < c3) eCrossfade_out_start.set_value(c4);  void DimRegionEdit::set_Crossfade_out_end(gig::DimensionRegion* d,
1421                                              uint8_t value)
1422    {
1423        d->Crossfade.out_end = value;
1424        if (value < d->Crossfade.out_start) set_Crossfade_out_start(d, value);
1425  }  }
1426    
1427  void DimRegionEdit::loop_enabled_toggled()  void DimRegionEdit::set_Gain(gig::DimensionRegion* d, int32_t value)
1428  {  {
1429      const bool active = eSampleLoopEnabled.get_active();      d->SetGain(value);
1430      if (active) {  }
1431    
1432    void DimRegionEdit::set_LoopEnabled(gig::DimensionRegion* d, bool value)
1433    {
1434        if (value) {
1435          // create a new sample loop in case there is none yet          // create a new sample loop in case there is none yet
1436          if (!dimregion->SampleLoops) {          if (!d->SampleLoops) {
1437              DLS::sample_loop_t loop;              DLS::sample_loop_t loop;
1438              loop.LoopType   = gig::loop_type_normal;              loop.LoopType = gig::loop_type_normal;
1439              // loop the whole sample by default              // loop the whole sample by default
1440              loop.LoopStart  = 0;              loop.LoopStart  = 0;
1441              loop.LoopLength =              loop.LoopLength =
1442                  (dimregion->pSample) ? dimregion->pSample->GetSize() : 0;                  (d->pSample) ? d->pSample->SamplesTotal : 0;
1443              dimregion->AddSampleLoop(&loop);              dimreg_to_be_changed_signal.emit(d);
1444              dimreg_changed_signal();              d->AddSampleLoop(&loop);
1445                dimreg_changed_signal.emit(d);
1446          }          }
1447      } else {      } else {
1448          if (dimregion->SampleLoops) {          if (d->SampleLoops) {
1449                dimreg_to_be_changed_signal.emit(d);
1450              // delete ALL existing sample loops              // delete ALL existing sample loops
1451              while (dimregion->SampleLoops) {              while (d->SampleLoops) {
1452                  dimregion->DeleteSampleLoop(&dimregion->pSampleLoops[0]);                  d->DeleteSampleLoop(&d->pSampleLoops[0]);
1453              }              }
1454              dimreg_changed_signal();              dimreg_changed_signal.emit(d);
1455          }          }
1456      }      }
     updateLoopElements();  
1457  }  }
1458    
1459  void DimRegionEdit::updateLoopElements()  void DimRegionEdit::set_LoopType(gig::DimensionRegion* d, uint32_t value)
1460  {  {
1461      const bool active = eSampleLoopEnabled.get_active();      if (d->SampleLoops) d->pSampleLoops[0].LoopType = value;
1462      eSampleLoopStart.set_sensitive(active);  }
     eSampleLoopLength.set_sensitive(active);  
     eSampleLoopType.set_sensitive(active);  
     eSampleLoopInfinite.set_sensitive(active && dimregion && dimregion->pSample);  
     eSampleLoopStart.set_ptr(0);  
     eSampleLoopLength.set_ptr(0);  
     eSampleLoopPlayCount.set_ptr(0);  
1463    
1464      if (dimregion && dimregion->SampleLoops) {  void DimRegionEdit::set_LoopStart(gig::DimensionRegion* d, uint32_t value)
1465          eSampleLoopStart.set_ptr(&dimregion->pSampleLoops[0].LoopStart);  {
1466          eSampleLoopLength.set_ptr(&dimregion->pSampleLoops[0].LoopLength);      if (d->SampleLoops) {
1467          eSampleLoopType.set_ptr(&dimregion->pSampleLoops[0].LoopType);          d->pSampleLoops[0].LoopStart =
1468          eSampleLoopInfinite.set_active(              d->pSample ?
1469              dimregion->pSample && !dimregion->pSample->LoopPlayCount              std::min(value, uint32_t(d->pSample->SamplesTotal -
1470          );                                       d->pSampleLoops[0].LoopLength)) :
1471          // 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->SamplesTotal -  
                   dimregion->pSampleLoops[0].LoopLength  
                 : 0  
         );  
         eSampleLoopLength.set_upper(  
             (dimregion->pSample)  
                 ? dimregion->pSample->SamplesTotal -  
                   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();  
1472      }      }
1473  }  }
1474    
1475  void DimRegionEdit::loop_infinite_toggled() {  void DimRegionEdit::set_LoopLength(gig::DimensionRegion* d, uint32_t value)
1476      eSampleLoopPlayCount.set_sensitive(  {
1477          dimregion && dimregion->pSample &&      if (d->SampleLoops) {
1478          !eSampleLoopInfinite.get_active() &&          d->pSampleLoops[0].LoopLength =
1479           eSampleLoopEnabled.get_active()              d->pSample ?
1480      );              std::min(value, uint32_t(d->pSample->SamplesTotal -
1481      if (eSampleLoopInfinite.get_active())                                       d->pSampleLoops[0].LoopStart)) :
1482          eSampleLoopPlayCount.set_value(0);              0;
1483      else if (!eSampleLoopPlayCount.get_value())      }
         eSampleLoopPlayCount.set_value(1);  
1484  }  }
1485    
1486  bool DimRegionEdit::set_sample(gig::Sample* sample)  void DimRegionEdit::set_LoopInfinite(gig::DimensionRegion* d, bool value)
1487  {  {
1488      if (dimregion) {      if (d->pSample) {
1489          dimregion->pSample = sample;          if (value) d->pSample->LoopPlayCount = 0;
1490            else if (d->pSample->LoopPlayCount == 0) d->pSample->LoopPlayCount = 1;
1491        }
1492    }
1493    
1494          // copy sample information from Sample to DimensionRegion  void DimRegionEdit::set_LoopPlayCount(gig::DimensionRegion* d, uint32_t value)
1495    {
1496        if (d->pSample) d->pSample->LoopPlayCount = value;
1497    }
1498    
1499          dimregion->UnityNote = sample->MIDIUnityNote;  void DimRegionEdit::nullOutSampleReference() {
1500          dimregion->FineTune = sample->FineTune;      if (!dimregion) return;
1501        gig::Sample* oldref = dimregion->pSample;
1502        if (!oldref) return;
1503    
1504        dimreg_to_be_changed_signal.emit(dimregion);
1505    
1506        // in case currently assigned sample is a stereo one, then remove both
1507        // references (expected to be due to a "stereo dimension")
1508        gig::DimensionRegion* d[2] = { dimregion, NULL };
1509        if (oldref->Channels == 2) {
1510            gig::Region* region = dimregion->GetParent();
1511            {
1512                int stereo_bit = 0;
1513                int bitcount = 0;
1514                for (int dim = 0 ; dim < region->Dimensions ; dim++) {
1515                    if (region->pDimensionDefinitions[dim].dimension == gig::dimension_samplechannel) {
1516                        stereo_bit = 1 << bitcount;
1517                        break;
1518                    }
1519                    bitcount += region->pDimensionDefinitions[dim].bits;
1520                }
1521    
1522          int loops = sample->Loops ? 1 : 0;              if (stereo_bit) {
1523          while (dimregion->SampleLoops > loops) {                  int dimregno;
1524              dimregion->DeleteSampleLoop(&dimregion->pSampleLoops[0]);                  for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
1525          }                      if (region->pDimensionRegions[dimregno] == dimregion) {
1526          while (dimregion->SampleLoops < sample->Loops) {                          break;
1527              DLS::sample_loop_t loop;                      }
1528              dimregion->AddSampleLoop(&loop);                  }
1529          }                  d[0] = region->pDimensionRegions[dimregno & ~stereo_bit];
1530          if (loops) {                  d[1] = region->pDimensionRegions[dimregno | stereo_bit];
1531              dimregion->pSampleLoops[0].Size = sizeof(DLS::sample_loop_t);              }
             dimregion->pSampleLoops[0].LoopType = sample->LoopType;  
             dimregion->pSampleLoops[0].LoopStart = sample->LoopStart;  
             dimregion->pSampleLoops[0].LoopLength = sample->LoopEnd - sample->LoopStart + 1;  
1532          }          }
1533        }
1534    
1535          // update ui      if (d[0]) d[0]->pSample = NULL;
1536          wSample->set_text(dimregion->pSample->pInfo->Name);      if (d[1]) d[1]->pSample = NULL;
         eUnityNote.set_ptr(&dimregion->UnityNote);  
         eFineTune.set_ptr(&dimregion->FineTune);  
         eSampleLoopEnabled.set_active(dimregion->SampleLoops);  
         updateLoopElements();  
1537    
1538          dimreg_changed_signal();      // update UI elements
1539          return true;      set_dim_region(dimregion);
1540      }  
1541      return false;      sample_ref_changed_signal.emit(oldref, NULL);
1542        dimreg_changed_signal.emit(dimregion);
1543    }
1544    
1545    void DimRegionEdit::onButtonSelectSamplePressed() {
1546        if (!dimregion) return;
1547        if (!dimregion->pSample) return;
1548        select_sample_signal.emit(dimregion->pSample);
1549    }
1550    
1551    sigc::signal<void, gig::Sample*>& DimRegionEdit::signal_select_sample() {
1552        return select_sample_signal;
1553  }  }

Legend:
Removed from v.1303  
changed lines
  Added in v.2841

  ViewVC Help
Powered by ViewVC