/[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 2151 by persson, Sun Nov 21 12:38:41 2010 UTC revision 3364 by schoenebeck, Tue Nov 14 18:07:25 2017 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006-2010 Andreas Persson   * Copyright (C) 2006-2017 Andreas Persson
3   *   *
4   * This program is free software; you can redistribute it and/or   * This program is free software; you can redistribute it and/or
5   * modify it under the terms of the GNU General Public License as   * modify it under the terms of the GNU General Public License as
# Line 17  Line 17 
17   * 02110-1301 USA.   * 02110-1301 USA.
18   */   */
19    
20    #include "global.h"
21  #include "dimregionedit.h"  #include "dimregionedit.h"
22    
23  #include "global.h"  #include "compat.h"
24    
25    #if USE_GTKMM_GRID
26    # include <gtkmm/grid.h>
27    #else
28    # include <gtkmm/table.h>
29    #endif
30    
31    VelocityCurve::VelocityCurve(double (gig::DimensionRegion::*getter)(uint8_t)) :
32        getter(getter), dimreg(0) {
33        set_size_request(80, 80);
34    }
35    
36    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
37    bool VelocityCurve::on_expose_event(GdkEventExpose* e) {
38        const Cairo::RefPtr<Cairo::Context>& cr =
39            get_window()->create_cairo_context();
40    #if 0
41    }
42    #endif
43    #else
44    bool VelocityCurve::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
45    #endif
46        if (dimreg) {
47            int w = get_width();
48            int h = get_height();
49    
50            for (int pass = 0 ; pass < 2 ; pass++) {
51                for (double x = 0 ; x <= w ; x++) {
52                    int vel = int(x * (127 - 1e-10) / w + 1);
53                    double y = (1 - (dimreg->*getter)(vel)) * (h - 3) + 1.5;
54    
55                    if (x < 1e-10) {
56                        cr->move_to(x, y);
57                    } else {
58                        cr->line_to(x, y);
59                    }
60                }
61                if (pass == 0) {
62                    cr->line_to(w, h);
63                    cr->line_to(0, h);
64                    cr->set_source_rgba(0.5, 0.44, 1.0, is_sensitive() ? 0.2 : 0.1);
65                    cr->fill();
66                } else {
67                    cr->set_line_width(3);
68                    cr->set_source_rgba(0.5, 0.44, 1.0, is_sensitive() ? 1.0 : 0.3);
69                    cr->stroke();
70                }
71            }
72        }
73        return true;
74    }
75    
76    
77    CrossfadeCurve::CrossfadeCurve() : dimreg(0) {
78        set_size_request(280, 80);
79    }
80    
81    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
82    bool CrossfadeCurve::on_expose_event(GdkEventExpose* e) {
83        const Cairo::RefPtr<Cairo::Context>& cr =
84            get_window()->create_cairo_context();
85    #if 0
86    }
87    #endif
88    #else
89    bool CrossfadeCurve::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
90    #endif
91        if (dimreg) {
92            cr->translate(1.5, 0);
93    
94            // first, draw curves for the other layers
95            gig::Region* region = dimreg->GetParent();
96            int dimregno;
97            for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
98                if (region->pDimensionRegions[dimregno] == dimreg) {
99                    break;
100                }
101            }
102            int bitcount = 0;
103            for (int dim = 0 ; dim < region->Dimensions ; dim++) {
104                if (region->pDimensionDefinitions[dim].dimension ==
105                    gig::dimension_layer) {
106                    int mask =
107                        ~(((1 << region->pDimensionDefinitions[dim].bits) - 1) <<
108                          bitcount);
109                    int c = dimregno & mask; // mask away the layer dimension
110    
111                    for (int i = 0 ; i < region->pDimensionDefinitions[dim].zones ;
112                         i++) {
113                        gig::DimensionRegion* d =
114                            region->pDimensionRegions[c + (i << bitcount)];
115                        if (d != dimreg) {
116                            draw_one_curve(cr, d, false);
117                        }
118                    }
119                    break;
120                }
121                bitcount += region->pDimensionDefinitions[dim].bits;
122            }
123    
124            // then, draw the currently selected layer
125            draw_one_curve(cr, dimreg, is_sensitive());
126        }
127        return true;
128    }
129    
130    void CrossfadeCurve::draw_one_curve(const Cairo::RefPtr<Cairo::Context>& cr,
131                                        const gig::DimensionRegion* d,
132                                        bool sensitive) {
133        int w = get_width();
134        int h = get_height();
135    
136        if (d->Crossfade.out_end) {
137            for (int pass = 0 ; pass < 2 ; pass++) {
138                cr->move_to(d->Crossfade.in_start / 127.0 * (w - 3), h);
139                cr->line_to(d->Crossfade.in_end / 127.0 * (w - 3), 1.5);
140                cr->line_to(d->Crossfade.out_start / 127.0 * (w - 3), 1.5);
141                cr->line_to(d->Crossfade.out_end / 127.0 * (w - 3), h);
142    
143                if (pass == 0) {
144                    cr->set_source_rgba(0.5, 0.44, 1.0, sensitive ? 0.2 : 0.1);
145                    cr->fill();
146                } else {
147                    cr->set_line_width(3);
148                    cr->set_source_rgba(0.5, 0.44, 1.0, sensitive ? 1.0 : 0.3);
149                    cr->stroke();
150                }
151            }
152        }
153    }
154    
155    
156    EGStateOptions::EGStateOptions() : HBox(),
157        label(_("May be cancelled: ")),
158        checkBoxAttack(_("Attack")),
159        checkBoxAttackHold(_("Attack Hold")),
160        checkBoxDecay1(_("Decay 1")),
161        checkBoxDecay2(_("Decay 2")),
162        checkBoxRelease(_("Release"))
163    {
164        set_spacing(6);
165    
166        pack_start(label);
167        pack_start(checkBoxAttack, Gtk::PACK_SHRINK);
168        pack_start(checkBoxAttackHold, Gtk::PACK_SHRINK);
169        pack_start(checkBoxDecay1, Gtk::PACK_SHRINK);
170        pack_start(checkBoxDecay2, Gtk::PACK_SHRINK);
171        pack_start(checkBoxRelease, Gtk::PACK_SHRINK);
172    
173        checkBoxAttack.set_tooltip_text(_(
174            "If checked: a note-off aborts the 'attack' stage."
175        ));
176        checkBoxAttackHold.set_tooltip_text(_(
177            "If checked: a note-off aborts the 'attack hold' stage."
178        ));
179        checkBoxDecay1.set_tooltip_text(_(
180            "If checked: a note-off aborts the 'decay 1' stage."
181        ));
182        checkBoxDecay2.set_tooltip_text(_(
183            "If checked: a note-off aborts the 'decay 2' stage."
184        ));
185        checkBoxRelease.set_tooltip_text(_(
186            "If checked: a note-on reverts back from the 'release' stage."
187        ));
188    }
189    
190    
191  DimRegionEdit::DimRegionEdit() :  DimRegionEdit::DimRegionEdit() :
192      eEG1PreAttack(_("Pre-attack"), 0, 100, 2),      velocity_curve(&gig::DimensionRegion::GetVelocityAttenuation),
193      eEG1Attack(_("Attack"), 0, 60, 3),      release_curve(&gig::DimensionRegion::GetVelocityRelease),
194      eEG1Decay1(_("Decay 1"), 0.005, 60, 3),      cutoff_curve(&gig::DimensionRegion::GetVelocityCutoff),
195      eEG1Decay2(_("Decay 2"), 0, 60, 3),      eEG1PreAttack(_("Pre-attack Level (%)"), 0, 100, 2),
196        eEG1Attack(_("Attack Time (seconds)"), 0, 60, 3),
197        eEG1Decay1(_("Decay 1 Time (seconds)"), 0.005, 60, 3),
198        eEG1Decay2(_("Decay 2 Time (seconds)"), 0, 60, 3),
199      eEG1InfiniteSustain(_("Infinite sustain")),      eEG1InfiniteSustain(_("Infinite sustain")),
200      eEG1Sustain(_("Sustain"), 0, 100, 2),      eEG1Sustain(_("Sustain Level (%)"), 0, 100, 2),
201      eEG1Release(_("Release"), 0, 60, 3),      eEG1Release(_("Release Time (seconds)"), 0, 60, 3),
202      eEG1Hold(_("Hold")),      eEG1Hold(_("Hold Attack Stage until Loop End")),
203      eEG1Controller(_("Controller")),      eEG1Controller(_("Controller")),
204      eEG1ControllerInvert(_("Controller invert")),      eEG1ControllerInvert(_("Controller invert")),
205      eEG1ControllerAttackInfluence(_("Controller attack influence"), 0, 3),      eEG1ControllerAttackInfluence(_("Controller attack influence"), 0, 3),
# Line 41  DimRegionEdit::DimRegionEdit() : Line 211  DimRegionEdit::DimRegionEdit() :
211      eLFO1Controller(_("Controller")),      eLFO1Controller(_("Controller")),
212      eLFO1FlipPhase(_("Flip phase")),      eLFO1FlipPhase(_("Flip phase")),
213      eLFO1Sync(_("Sync")),      eLFO1Sync(_("Sync")),
214      eEG2PreAttack(_("Pre-attack"), 0, 100, 2),      eEG2PreAttack(_("Pre-attack Level (%)"), 0, 100, 2),
215      eEG2Attack(_("Attack"), 0, 60, 3),      eEG2Attack(_("Attack Time (seconds)"), 0, 60, 3),
216      eEG2Decay1(_("Decay 1"), 0.005, 60, 3),      eEG2Decay1(_("Decay 1 Time (seconds)"), 0.005, 60, 3),
217      eEG2Decay2(_("Decay 2"), 0, 60, 3),      eEG2Decay2(_("Decay 2 Time (seconds)"), 0, 60, 3),
218      eEG2InfiniteSustain(_("Infinite sustain")),      eEG2InfiniteSustain(_("Infinite sustain")),
219      eEG2Sustain(_("Sustain"), 0, 100, 2),      eEG2Sustain(_("Sustain Level (%)"), 0, 100, 2),
220      eEG2Release(_("Release"), 0, 60, 3),      eEG2Release(_("Release Time (seconds)"), 0, 60, 3),
221      eEG2Controller(_("Controller")),      eEG2Controller(_("Controller")),
222      eEG2ControllerInvert(_("Controller invert")),      eEG2ControllerInvert(_("Controller invert")),
223      eEG2ControllerAttackInfluence(_("Controller attack influence"), 0, 3),      eEG2ControllerAttackInfluence(_("Controller attack influence"), 0, 3),
# Line 92  DimRegionEdit::DimRegionEdit() : Line 262  DimRegionEdit::DimRegionEdit() :
262      ePitchTrack(_("Pitch track")),      ePitchTrack(_("Pitch track")),
263      eDimensionBypass(_("Dimension bypass")),      eDimensionBypass(_("Dimension bypass")),
264      ePan(_("Pan"), -64, 63),      ePan(_("Pan"), -64, 63),
265      eSelfMask(_("Self mask")),      eSelfMask(_("Kill lower velocity voices (a.k.a \"Self mask\")")),
266      eAttenuationController(_("Attenuation controller")),      eAttenuationController(_("Attenuation controller")),
267      eInvertAttenuationController(_("Invert attenuation controller")),      eInvertAttenuationController(_("Invert attenuation controller")),
268      eAttenuationControllerThreshold(_("Attenuation controller threshold")),      eAttenuationControllerThreshold(_("Attenuation controller threshold")),
269      eChannelOffset(_("Channel offset"), 0, 9),      eChannelOffset(_("Channel offset"), 0, 9),
270      eSustainDefeat(_("Sustain defeat")),      eSustainDefeat(_("Ignore Hold Pedal (a.k.a. \"Sustain defeat\")")),
271      eMSDecode(_("MS decode")),      eMSDecode(_("Decode Mid/Side Recordings")),
272      eSampleStartOffset(_("Sample start offset"), 0, 2000),      eSampleStartOffset(_("Sample start offset"), 0, 2000),
273      eUnityNote(_("Unity note")),      eUnityNote(_("Unity note")),
274        eSampleGroup(_("Sample Group")),
275        eSampleFormatInfo(_("Sample Format")),
276        eSampleID("Sample ID"),
277        eChecksum("Wave Data CRC-32"),
278      eFineTune(_("Fine tune"), -49, 50),      eFineTune(_("Fine tune"), -49, 50),
279      eGain(_("Gain"), -96, 0, 2, -655360),      eGain(_("Gain"), -96, 0, 2, -655360),
280      eGainPlus6(_("Gain +6dB"), eGain, 6 * -655360),      eGainPlus6(_("Gain +6dB"), eGain, 6 * -655360),
# Line 110  DimRegionEdit::DimRegionEdit() : Line 284  DimRegionEdit::DimRegionEdit() :
284      eSampleLoopType(_("Loop type")),      eSampleLoopType(_("Loop type")),
285      eSampleLoopInfinite(_("Infinite loop")),      eSampleLoopInfinite(_("Infinite loop")),
286      eSampleLoopPlayCount(_("Playback count"), 1),      eSampleLoopPlayCount(_("Playback count"), 1),
287        buttonSelectSample(UNICODE_LEFT_ARROW + "  " + _("Select Sample")),
288      update_model(0)      update_model(0)
289  {  {
290        // make synthesis parameter page tabs scrollable
291        // (workaround for GTK3: default theme uses huge tabs which breaks layout)
292        set_scrollable();
293    
294      connect(eEG1PreAttack, &gig::DimensionRegion::EG1PreAttack);      connect(eEG1PreAttack, &gig::DimensionRegion::EG1PreAttack);
295      connect(eEG1Attack, &gig::DimensionRegion::EG1Attack);      connect(eEG1Attack, &gig::DimensionRegion::EG1Attack);
296      connect(eEG1Decay1, &gig::DimensionRegion::EG1Decay1);      connect(eEG1Decay1, &gig::DimensionRegion::EG1Decay1);
# Line 128  DimRegionEdit::DimRegionEdit() : Line 307  DimRegionEdit::DimRegionEdit() :
307              &gig::DimensionRegion::EG1ControllerDecayInfluence);              &gig::DimensionRegion::EG1ControllerDecayInfluence);
308      connect(eEG1ControllerReleaseInfluence,      connect(eEG1ControllerReleaseInfluence,
309              &gig::DimensionRegion::EG1ControllerReleaseInfluence);              &gig::DimensionRegion::EG1ControllerReleaseInfluence);
310        {
311            ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG1Options.AttackCancel));
312            connect(eEG1StateOptions.checkBoxAttack, mp.pmember);
313        }
314        {
315            ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG1Options.AttackHoldCancel));
316            connect(eEG1StateOptions.checkBoxAttackHold, mp.pmember);
317        }
318        {
319            ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG1Options.Decay1Cancel));
320            connect(eEG1StateOptions.checkBoxDecay1, mp.pmember);
321        }
322        {
323            ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG1Options.Decay2Cancel));
324            connect(eEG1StateOptions.checkBoxDecay2, mp.pmember);
325        }
326        {
327            ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG1Options.ReleaseCancel));
328            connect(eEG1StateOptions.checkBoxRelease, mp.pmember);
329        }
330      connect(eLFO1Frequency, &gig::DimensionRegion::LFO1Frequency);      connect(eLFO1Frequency, &gig::DimensionRegion::LFO1Frequency);
331      connect(eLFO1InternalDepth, &gig::DimensionRegion::LFO1InternalDepth);      connect(eLFO1InternalDepth, &gig::DimensionRegion::LFO1InternalDepth);
332      connect(eLFO1ControlDepth, &gig::DimensionRegion::LFO1ControlDepth);      connect(eLFO1ControlDepth, &gig::DimensionRegion::LFO1ControlDepth);
# Line 149  DimRegionEdit::DimRegionEdit() : Line 348  DimRegionEdit::DimRegionEdit() :
348              &gig::DimensionRegion::EG2ControllerDecayInfluence);              &gig::DimensionRegion::EG2ControllerDecayInfluence);
349      connect(eEG2ControllerReleaseInfluence,      connect(eEG2ControllerReleaseInfluence,
350              &gig::DimensionRegion::EG2ControllerReleaseInfluence);              &gig::DimensionRegion::EG2ControllerReleaseInfluence);
351        {
352            ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG2Options.AttackCancel));
353            connect(eEG2StateOptions.checkBoxAttack, mp.pmember);
354        }
355        {
356            ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG2Options.AttackHoldCancel));
357            connect(eEG2StateOptions.checkBoxAttackHold, mp.pmember);
358        }
359        {
360            ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG2Options.Decay1Cancel));
361            connect(eEG2StateOptions.checkBoxDecay1, mp.pmember);
362        }
363        {
364            ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG2Options.Decay2Cancel));
365            connect(eEG2StateOptions.checkBoxDecay2, mp.pmember);
366        }
367        {
368            ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG2Options.ReleaseCancel));
369            connect(eEG2StateOptions.checkBoxRelease, mp.pmember);
370        }
371      connect(eLFO2Frequency, &gig::DimensionRegion::LFO2Frequency);      connect(eLFO2Frequency, &gig::DimensionRegion::LFO2Frequency);
372      connect(eLFO2InternalDepth, &gig::DimensionRegion::LFO2InternalDepth);      connect(eLFO2InternalDepth, &gig::DimensionRegion::LFO2InternalDepth);
373      connect(eLFO2ControlDepth, &gig::DimensionRegion::LFO2ControlDepth);      connect(eLFO2ControlDepth, &gig::DimensionRegion::LFO2ControlDepth);
# Line 219  DimRegionEdit::DimRegionEdit() : Line 438  DimRegionEdit::DimRegionEdit() :
438      connect(eSampleLoopLength, &DimRegionEdit::set_LoopLength);      connect(eSampleLoopLength, &DimRegionEdit::set_LoopLength);
439      connect(eSampleLoopInfinite, &DimRegionEdit::set_LoopInfinite);      connect(eSampleLoopInfinite, &DimRegionEdit::set_LoopInfinite);
440      connect(eSampleLoopPlayCount, &DimRegionEdit::set_LoopPlayCount);      connect(eSampleLoopPlayCount, &DimRegionEdit::set_LoopPlayCount);
441        buttonSelectSample.signal_clicked().connect(
442            sigc::mem_fun(*this, &DimRegionEdit::onButtonSelectSamplePressed)
443        );
444    
445      for (int i = 0 ; i < 7 ; i++) {      for (int i = 0 ; i < 7 ; i++) {
446    #if USE_GTKMM_GRID
447            table[i] = new Gtk::Grid;
448            table[i]->set_column_spacing(7);
449    #else
450          table[i] = new Gtk::Table(3, 1);          table[i] = new Gtk::Table(3, 1);
451          table[i]->set_col_spacings(7);          table[i]->set_col_spacings(7);
452    #endif
453    
454      }      }
455    
456      // set tooltips      // set tooltips
457      eUnityNote.set_tip(      eUnityNote.set_tip(
458          _("Note this sample is associated with (a.k.a. 'root note')")          _("Note this sample is associated with (a.k.a. 'root note')")
459      );      );
460        buttonSelectSample.set_tooltip_text(
461            _("Selects the sample of this dimension region on the left hand side's sample tree view.")
462        );
463      eSampleStartOffset.set_tip(_("Sample position at which playback should be started"));      eSampleStartOffset.set_tip(_("Sample position at which playback should be started"));
464      ePan.set_tip(_("Stereo balance (left/right)"));      ePan.set_tip(_("Stereo balance (left/right)"));
465      eChannelOffset.set_tip(      eChannelOffset.set_tip(
# Line 259  DimRegionEdit::DimRegionEdit() : Line 490  DimRegionEdit::DimRegionEdit() :
490            "Caution: this setting is stored on Sample side, thus is shared "            "Caution: this setting is stored on Sample side, thus is shared "
491            "among all dimension regions that use this sample!")            "among all dimension regions that use this sample!")
492      );      );
493        
494        eEG1PreAttack.set_tip(
495            "Very first level this EG starts with. It rises then in Attack Time "
496            "seconds from this initial level to 100%."
497        );
498        eEG1Attack.set_tip(
499            "Duration of the EG's Attack stage, which raises its level from "
500            "Pre-Attack Level to 100%."
501        );
502        eEG1Hold.set_tip(
503           "On looped sounds, enabling this will cause the Decay 1 stage not to "
504           "enter before the loop has been passed one time."
505        );
506        eAttenuationController.set_tip(_(
507            "If you are not using the 'Layer' dimension, then this controller "
508            "simply alters the volume. If you are using the 'Layer' dimension, "
509            "then this controller is controlling the crossfade between Layers in "
510            "real-time."
511        ));
512    
513        eLFO1Sync.set_tip(
514            "If not checked, every voice will use its own LFO instance, which "
515            "causes voices triggered at different points in time to have different "
516            "LFO levels. By enabling 'Sync' here the voices will instead use and "
517            "share one single LFO, causing all voices to have the same LFO level, "
518            "no matter when the individual notes have been triggered."
519        );
520        eLFO2Sync.set_tip(
521            "If not checked, every voice will use its own LFO instance, which "
522            "causes voices triggered at different points in time to have different "
523            "LFO levels. By enabling 'Sync' here the voices will instead use and "
524            "share one single LFO, causing all voices to have the same LFO level, "
525            "no matter when the individual notes have been triggered."
526        );
527        eLFO3Sync.set_tip(
528            "If not checked, every voice will use its own LFO instance, which "
529            "causes voices triggered at different points in time to have different "
530            "LFO levels. By enabling 'Sync' here the voices will instead use and "
531            "share one single LFO, causing all voices to have the same LFO level, "
532            "no matter when the individual notes have been triggered."
533        );
534        eLFO1FlipPhase.set_tip(
535           "Inverts the LFO's generated wave vertically."
536        );
537        eLFO2FlipPhase.set_tip(
538           "Inverts the LFO's generated wave vertically."
539        );
540    
541      pageno = 0;      pageno = 0;
542      rowno = 0;      rowno = 0;
543      firstRowInBlock = 0;      firstRowInBlock = 0;
544    
545      addHeader(_("Mandatory Settings"));      addHeader(_("Mandatory Settings"));
546      addString(_("Sample"), lSample, wSample);      addString(_("Sample"), lSample, wSample, buttonNullSampleReference);
547        buttonNullSampleReference->set_label("X");
548        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."));
549        buttonNullSampleReference->signal_clicked().connect(
550            sigc::mem_fun(*this, &DimRegionEdit::nullOutSampleReference)
551        );
552      //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);
553  #ifdef OLD_TOOLTIPS  #ifdef OLD_TOOLTIPS
554      tooltips.set_tip(*wSample, _("Drop a sample here"));      tooltips.set_tip(*wSample, _("Drag & drop a sample here"));
555  #else  #else
556      wSample->set_tooltip_text(_("Drop a sample here"));      wSample->set_tooltip_text(_("Drag & drop a sample here"));
557  #endif  #endif
558      addProp(eUnityNote);      addProp(eUnityNote);
559        addProp(eSampleGroup);
560        addProp(eSampleFormatInfo);
561        addProp(eSampleID);
562        addProp(eChecksum);
563        addRightHandSide(buttonSelectSample);
564      addHeader(_("Optional Settings"));      addHeader(_("Optional Settings"));
565      addProp(eSampleStartOffset);      addProp(eSampleStartOffset);
566      addProp(eChannelOffset);      addProp(eChannelOffset);
# Line 302  DimRegionEdit::DimRegionEdit() : Line 590  DimRegionEdit::DimRegionEdit() :
590      addHeader(_("Amplitude Envelope (EG1)"));      addHeader(_("Amplitude Envelope (EG1)"));
591      addProp(eEG1PreAttack);      addProp(eEG1PreAttack);
592      addProp(eEG1Attack);      addProp(eEG1Attack);
593        addProp(eEG1Hold);
594      addProp(eEG1Decay1);      addProp(eEG1Decay1);
595      addProp(eEG1Decay2);      addProp(eEG1Decay2);
596      addProp(eEG1InfiniteSustain);      addProp(eEG1InfiniteSustain);
597      addProp(eEG1Sustain);      addProp(eEG1Sustain);
598      addProp(eEG1Release);      addProp(eEG1Release);
     addProp(eEG1Hold);  
599      addProp(eEG1Controller);      addProp(eEG1Controller);
600      addProp(eEG1ControllerInvert);      addProp(eEG1ControllerInvert);
601      addProp(eEG1ControllerAttackInfluence);      addProp(eEG1ControllerAttackInfluence);
602      addProp(eEG1ControllerDecayInfluence);      addProp(eEG1ControllerDecayInfluence);
603      addProp(eEG1ControllerReleaseInfluence);      addProp(eEG1ControllerReleaseInfluence);
604        addLine(eEG1StateOptions);
605    
606      nextPage();      nextPage();
607    
# Line 344  DimRegionEdit::DimRegionEdit() : Line 633  DimRegionEdit::DimRegionEdit() :
633      addProp(eCrossfade_out_start);      addProp(eCrossfade_out_start);
634      addProp(eCrossfade_out_end);      addProp(eCrossfade_out_end);
635    
636        Gtk::Frame* frame = new Gtk::Frame;
637        frame->add(crossfade_curve);
638    #if USE_GTKMM_GRID
639        table[pageno]->attach(*frame, 1, rowno, 2);
640    #else
641        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
642                              Gtk::SHRINK, Gtk::SHRINK);
643    #endif
644        rowno++;
645    
646        eCrossfade_in_start.signal_value_changed().connect(
647            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
648        eCrossfade_in_end.signal_value_changed().connect(
649            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
650        eCrossfade_out_start.signal_value_changed().connect(
651            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
652        eCrossfade_out_end.signal_value_changed().connect(
653            sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
654    
655      nextPage();      nextPage();
656    
657      addHeader(_("General Filter Settings"));      addHeader(_("General Filter Settings"));
# Line 394  DimRegionEdit::DimRegionEdit() : Line 702  DimRegionEdit::DimRegionEdit() :
702      addProp(eVCFVelocityCurve);      addProp(eVCFVelocityCurve);
703      addProp(eVCFVelocityScale);      addProp(eVCFVelocityScale);
704      addProp(eVCFVelocityDynamicRange);      addProp(eVCFVelocityDynamicRange);
705    
706        eVCFCutoffController.signal_value_changed().connect(
707            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
708        eVCFVelocityCurve.signal_value_changed().connect(
709            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
710        eVCFVelocityScale.signal_value_changed().connect(
711            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
712        eVCFVelocityDynamicRange.signal_value_changed().connect(
713            sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
714    
715        frame = new Gtk::Frame;
716        frame->add(cutoff_curve);
717    #if USE_GTKMM_GRID
718        table[pageno]->attach(*frame, 1, rowno, 2);
719    #else
720        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
721                              Gtk::SHRINK, Gtk::SHRINK);
722    #endif
723        rowno++;
724    
725      addProp(eVCFResonance);      addProp(eVCFResonance);
726      addProp(eVCFResonanceDynamic);      addProp(eVCFResonanceDynamic);
727      {      {
# Line 427  DimRegionEdit::DimRegionEdit() : Line 755  DimRegionEdit::DimRegionEdit() :
755      addProp(eEG2ControllerAttackInfluence);      addProp(eEG2ControllerAttackInfluence);
756      addProp(eEG2ControllerDecayInfluence);      addProp(eEG2ControllerDecayInfluence);
757      addProp(eEG2ControllerReleaseInfluence);      addProp(eEG2ControllerReleaseInfluence);
758        addLine(eEG2StateOptions);
759      lLFO2 = addHeader(_("Filter Cutoff Oscillator (LFO2)"));      lLFO2 = addHeader(_("Filter Cutoff Oscillator (LFO2)"));
760      addProp(eLFO2Frequency);      addProp(eLFO2Frequency);
761      addProp(eLFO2InternalDepth);      addProp(eLFO2InternalDepth);
# Line 476  DimRegionEdit::DimRegionEdit() : Line 805  DimRegionEdit::DimRegionEdit() :
805    
806      nextPage();      nextPage();
807    
808        addHeader(_("Velocity Response"));
809      eVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values);      eVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values);
810      addProp(eVelocityResponseCurve);      addProp(eVelocityResponseCurve);
811      addProp(eVelocityResponseDepth);      addProp(eVelocityResponseDepth);
812      addProp(eVelocityResponseCurveScaling);      addProp(eVelocityResponseCurveScaling);
813    
814        eVelocityResponseCurve.signal_value_changed().connect(
815            sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
816        eVelocityResponseDepth.signal_value_changed().connect(
817            sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
818        eVelocityResponseCurveScaling.signal_value_changed().connect(
819            sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
820    
821        frame = new Gtk::Frame;
822        frame->add(velocity_curve);
823    #if USE_GTKMM_GRID
824        table[pageno]->attach(*frame, 1, rowno, 2);
825    #else
826        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
827                              Gtk::SHRINK, Gtk::SHRINK);
828    #endif
829        rowno++;
830    
831        addHeader(_("Release Velocity Response"));
832      eReleaseVelocityResponseCurve.set_choices(curve_type_texts,      eReleaseVelocityResponseCurve.set_choices(curve_type_texts,
833                                                curve_type_values);                                                curve_type_values);
834      addProp(eReleaseVelocityResponseCurve);      addProp(eReleaseVelocityResponseCurve);
835      addProp(eReleaseVelocityResponseDepth);      addProp(eReleaseVelocityResponseDepth);
836    
837        eReleaseVelocityResponseCurve.signal_value_changed().connect(
838            sigc::mem_fun(release_curve, &VelocityCurve::queue_draw));
839        eReleaseVelocityResponseDepth.signal_value_changed().connect(
840            sigc::mem_fun(release_curve, &VelocityCurve::queue_draw));
841        frame = new Gtk::Frame;
842        frame->add(release_curve);
843    #if USE_GTKMM_GRID
844        table[pageno]->attach(*frame, 1, rowno, 2);
845    #else
846        table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
847                              Gtk::SHRINK, Gtk::SHRINK);
848    #endif
849        rowno++;
850    
851      addProp(eReleaseTriggerDecay);      addProp(eReleaseTriggerDecay);
852      {      {
853          const char* choices[] = { _("none"), _("effect4depth"), _("effect5depth"), 0 };          const char* choices[] = { _("none"), _("effect4depth"), _("effect5depth"), 0 };
# Line 495  DimRegionEdit::DimRegionEdit() : Line 859  DimRegionEdit::DimRegionEdit() :
859          eDimensionBypass.set_choices(choices, values);          eDimensionBypass.set_choices(choices, values);
860      }      }
861      addProp(eDimensionBypass);      addProp(eDimensionBypass);
862        eSelfMask.widget.set_tooltip_text(_(
863            "If enabled: new notes with higher velocity value will stop older "
864            "notes with lower velocity values, that way you can save voices that "
865            "would barely be audible. This is also useful for certain drum sounds."
866        ));
867      addProp(eSelfMask);      addProp(eSelfMask);
868        eSustainDefeat.widget.set_tooltip_text(_(
869            "If enabled: sustain pedal will not hold a note. This way you can use "
870            "the sustain pedal for other purposes, for example to switch among "
871            "dimension regions."
872        ));
873      addProp(eSustainDefeat);      addProp(eSustainDefeat);
874        eMSDecode.widget.set_tooltip_text(_(
875            "Defines if Mid/Side Recordings should be decoded. Mid/Side Recordings "
876            "are an alternative way to record sounds in stereo. The sampler needs "
877            "to decode such samples to actually make use of them. Note: this "
878            "feature is currently not supported by LinuxSampler."
879        ));
880      addProp(eMSDecode);      addProp(eMSDecode);
881    
882      nextPage();      nextPage();
# Line 560  void DimRegionEdit::addString(const char Line 940  void DimRegionEdit::addString(const char
940                                Gtk::Entry*& widget)                                Gtk::Entry*& widget)
941  {  {
942      label = new Gtk::Label(Glib::ustring(labelText) + ":");      label = new Gtk::Label(Glib::ustring(labelText) + ":");
943      label->set_alignment(Gtk::ALIGN_LEFT);  #if HAS_GTKMM_ALIGNMENT
944        label->set_alignment(Gtk::ALIGN_START);
945    #else
946        label->set_halign(Gtk::Align::START);
947    #endif
948    
949    #if USE_GTKMM_GRID
950        table[pageno]->attach(*label, 1, rowno);
951    #else
952      table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,      table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,
953                            Gtk::FILL, Gtk::SHRINK);                            Gtk::FILL, Gtk::SHRINK);
954    #endif
955    
956      widget = new Gtk::Entry();      widget = new Gtk::Entry();
957    
958    #if USE_GTKMM_GRID
959        table[pageno]->attach(*widget, 2, rowno);
960    #else
961      table[pageno]->attach(*widget, 2, 3, rowno, rowno + 1,      table[pageno]->attach(*widget, 2, 3, rowno, rowno + 1,
962                            Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);                            Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
963    #endif
964    
965        rowno++;
966    }
967    
968    void DimRegionEdit::addString(const char* labelText, Gtk::Label*& label,
969                                  Gtk::Entry*& widget, Gtk::Button*& button)
970    {
971        label = new Gtk::Label(Glib::ustring(labelText) + ":");
972    #if HAS_GTKMM_ALIGNMENT
973        label->set_alignment(Gtk::ALIGN_START);
974    #else
975        label->set_halign(Gtk::Align::START);
976    #endif
977    
978    #if USE_GTKMM_GRID
979        table[pageno]->attach(*label, 1, rowno);
980    #else
981        table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,
982                              Gtk::FILL, Gtk::SHRINK);
983    #endif
984    
985        widget = new Gtk::Entry();
986        button = new Gtk::Button();
987    
988        HBox* hbox = new HBox;
989        hbox->pack_start(*widget);
990        hbox->pack_start(*button, Gtk::PACK_SHRINK);
991    
992    #if USE_GTKMM_GRID
993        table[pageno]->attach(*hbox, 2, rowno);
994    #else
995        table[pageno]->attach(*hbox, 2, 3, rowno, rowno + 1,
996                              Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
997    #endif
998    
999      rowno++;      rowno++;
1000  }  }
# Line 578  Gtk::Label* DimRegionEdit::addHeader(con Line 1004  Gtk::Label* DimRegionEdit::addHeader(con
1004      if (firstRowInBlock < rowno - 1)      if (firstRowInBlock < rowno - 1)
1005      {      {
1006          Gtk::Label* filler = new Gtk::Label("    ");          Gtk::Label* filler = new Gtk::Label("    ");
1007    #if USE_GTKMM_GRID
1008            table[pageno]->attach(*filler, 0, firstRowInBlock);
1009    #else
1010          table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,          table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,
1011                                Gtk::FILL, Gtk::SHRINK);                                Gtk::FILL, Gtk::SHRINK);
1012    #endif
1013      }      }
1014      Glib::ustring str = "<b>";      Glib::ustring str = "<b>";
1015      str += text;      str += text;
1016      str += "</b>";      str += "</b>";
1017      Gtk::Label* label = new Gtk::Label(str);      Gtk::Label* label = new Gtk::Label(str);
1018      label->set_use_markup();      label->set_use_markup();
1019      label->set_alignment(Gtk::ALIGN_LEFT);  #if HAS_GTKMM_ALIGNMENT
1020        label->set_alignment(Gtk::ALIGN_START);
1021    #else
1022        label->set_halign(Gtk::Align::START);
1023    #endif
1024    #if USE_GTKMM_GRID
1025        table[pageno]->attach(*label, 0, rowno, 3);
1026    #else
1027      table[pageno]->attach(*label, 0, 3, rowno, rowno + 1,      table[pageno]->attach(*label, 0, 3, rowno, rowno + 1,
1028                            Gtk::FILL, Gtk::SHRINK);                            Gtk::FILL, Gtk::SHRINK);
1029    #endif
1030      rowno++;      rowno++;
1031      firstRowInBlock = rowno;      firstRowInBlock = rowno;
1032      return label;      return label;
# Line 599  void DimRegionEdit::nextPage() Line 1037  void DimRegionEdit::nextPage()
1037      if (firstRowInBlock < rowno - 1)      if (firstRowInBlock < rowno - 1)
1038      {      {
1039          Gtk::Label* filler = new Gtk::Label("    ");          Gtk::Label* filler = new Gtk::Label("    ");
1040    #if USE_GTKMM_GRID
1041            table[pageno]->attach(*filler, 0, firstRowInBlock);
1042    #else
1043          table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,          table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,
1044                                Gtk::FILL, Gtk::SHRINK);                                Gtk::FILL, Gtk::SHRINK);
1045    #endif
1046      }      }
1047      pageno++;      pageno++;
1048      rowno = 0;      rowno = 0;
# Line 609  void DimRegionEdit::nextPage() Line 1051  void DimRegionEdit::nextPage()
1051    
1052  void DimRegionEdit::addProp(BoolEntry& boolentry)  void DimRegionEdit::addProp(BoolEntry& boolentry)
1053  {  {
1054    #if USE_GTKMM_GRID
1055        table[pageno]->attach(boolentry.widget, 1, rowno, 2);
1056    #else
1057      table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1,      table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1,
1058                            Gtk::FILL, Gtk::SHRINK);                            Gtk::FILL, Gtk::SHRINK);
1059    #endif
1060      rowno++;      rowno++;
1061  }  }
1062    
1063  void DimRegionEdit::addProp(BoolEntryPlus6& boolentry)  void DimRegionEdit::addProp(BoolEntryPlus6& boolentry)
1064  {  {
1065    #if USE_GTKMM_GRID
1066        table[pageno]->attach(boolentry.widget, 1, rowno, 2);
1067    #else
1068      table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1,      table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1,
1069                            Gtk::FILL, Gtk::SHRINK);                            Gtk::FILL, Gtk::SHRINK);
1070    #endif
1071      rowno++;      rowno++;
1072  }  }
1073    
1074  void DimRegionEdit::addProp(LabelWidget& prop)  void DimRegionEdit::addProp(LabelWidget& prop)
1075  {  {
1076    #if USE_GTKMM_GRID
1077        table[pageno]->attach(prop.label, 1, rowno);
1078        table[pageno]->attach(prop.widget, 2, rowno);
1079    #else
1080      table[pageno]->attach(prop.label, 1, 2, rowno, rowno + 1,      table[pageno]->attach(prop.label, 1, 2, rowno, rowno + 1,
1081                            Gtk::FILL, Gtk::SHRINK);                            Gtk::FILL, Gtk::SHRINK);
1082      table[pageno]->attach(prop.widget, 2, 3, rowno, rowno + 1,      table[pageno]->attach(prop.widget, 2, 3, rowno, rowno + 1,
1083                            Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);                            Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
1084    #endif
1085      rowno++;      rowno++;
1086  }  }
1087    
1088    void DimRegionEdit::addLine(HBox& line)
1089    {
1090    #if USE_GTKMM_GRID
1091        table[pageno]->attach(line, 1, rowno, 2);
1092    #else
1093        table[pageno]->attach(line, 1, 3, rowno, rowno + 1,
1094                              Gtk::FILL, Gtk::SHRINK);
1095    #endif
1096        rowno++;
1097    }
1098    
1099    void DimRegionEdit::addRightHandSide(Gtk::Widget& widget)
1100    {
1101    #if USE_GTKMM_GRID
1102        table[pageno]->attach(widget, 2, rowno);
1103    #else
1104        table[pageno]->attach(widget, 2, 3, rowno, rowno + 1,
1105                              Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
1106    #endif
1107        rowno++;
1108    }
1109    
1110  void DimRegionEdit::set_dim_region(gig::DimensionRegion* d)  void DimRegionEdit::set_dim_region(gig::DimensionRegion* d)
1111  {  {
1112      dimregion = d;      dimregion = d;
1113        velocity_curve.set_dim_region(d);
1114        release_curve.set_dim_region(d);
1115        cutoff_curve.set_dim_region(d);
1116        crossfade_curve.set_dim_region(d);
1117    
1118      set_sensitive(d);      set_sensitive(d);
1119      if (!d) return;      if (!d) return;
# Line 652  void DimRegionEdit::set_dim_region(gig:: Line 1132  void DimRegionEdit::set_dim_region(gig::
1132      eEG1ControllerAttackInfluence.set_value(d->EG1ControllerAttackInfluence);      eEG1ControllerAttackInfluence.set_value(d->EG1ControllerAttackInfluence);
1133      eEG1ControllerDecayInfluence.set_value(d->EG1ControllerDecayInfluence);      eEG1ControllerDecayInfluence.set_value(d->EG1ControllerDecayInfluence);
1134      eEG1ControllerReleaseInfluence.set_value(d->EG1ControllerReleaseInfluence);      eEG1ControllerReleaseInfluence.set_value(d->EG1ControllerReleaseInfluence);
1135        eEG1StateOptions.checkBoxAttack.set_value(d->EG1Options.AttackCancel);
1136        eEG1StateOptions.checkBoxAttackHold.set_value(d->EG1Options.AttackHoldCancel);
1137        eEG1StateOptions.checkBoxDecay1.set_value(d->EG1Options.Decay1Cancel);
1138        eEG1StateOptions.checkBoxDecay2.set_value(d->EG1Options.Decay2Cancel);
1139        eEG1StateOptions.checkBoxRelease.set_value(d->EG1Options.ReleaseCancel);
1140      eLFO1Frequency.set_value(d->LFO1Frequency);      eLFO1Frequency.set_value(d->LFO1Frequency);
1141      eLFO1InternalDepth.set_value(d->LFO1InternalDepth);      eLFO1InternalDepth.set_value(d->LFO1InternalDepth);
1142      eLFO1ControlDepth.set_value(d->LFO1ControlDepth);      eLFO1ControlDepth.set_value(d->LFO1ControlDepth);
# Line 670  void DimRegionEdit::set_dim_region(gig:: Line 1155  void DimRegionEdit::set_dim_region(gig::
1155      eEG2ControllerAttackInfluence.set_value(d->EG2ControllerAttackInfluence);      eEG2ControllerAttackInfluence.set_value(d->EG2ControllerAttackInfluence);
1156      eEG2ControllerDecayInfluence.set_value(d->EG2ControllerDecayInfluence);      eEG2ControllerDecayInfluence.set_value(d->EG2ControllerDecayInfluence);
1157      eEG2ControllerReleaseInfluence.set_value(d->EG2ControllerReleaseInfluence);      eEG2ControllerReleaseInfluence.set_value(d->EG2ControllerReleaseInfluence);
1158        eEG2StateOptions.checkBoxAttack.set_value(d->EG2Options.AttackCancel);
1159        eEG2StateOptions.checkBoxAttackHold.set_value(d->EG2Options.AttackHoldCancel);
1160        eEG2StateOptions.checkBoxDecay1.set_value(d->EG2Options.Decay1Cancel);
1161        eEG2StateOptions.checkBoxDecay2.set_value(d->EG2Options.Decay2Cancel);
1162        eEG2StateOptions.checkBoxRelease.set_value(d->EG2Options.ReleaseCancel);
1163      eLFO2Frequency.set_value(d->LFO2Frequency);      eLFO2Frequency.set_value(d->LFO2Frequency);
1164      eLFO2InternalDepth.set_value(d->LFO2InternalDepth);      eLFO2InternalDepth.set_value(d->LFO2InternalDepth);
1165      eLFO2ControlDepth.set_value(d->LFO2ControlDepth);      eLFO2ControlDepth.set_value(d->LFO2ControlDepth);
# Line 718  void DimRegionEdit::set_dim_region(gig:: Line 1208  void DimRegionEdit::set_dim_region(gig::
1208      eMSDecode.set_value(d->MSDecode);      eMSDecode.set_value(d->MSDecode);
1209      eSampleStartOffset.set_value(d->SampleStartOffset);      eSampleStartOffset.set_value(d->SampleStartOffset);
1210      eUnityNote.set_value(d->UnityNote);      eUnityNote.set_value(d->UnityNote);
1211        // show sample group name
1212        {
1213            Glib::ustring s = "---";
1214            if (d->pSample && d->pSample->GetGroup())
1215                s = d->pSample->GetGroup()->Name;
1216            eSampleGroup.text.set_text(s);
1217        }
1218        // assemble sample format info string
1219        {
1220            Glib::ustring s;
1221            if (d->pSample) {
1222                switch (d->pSample->Channels) {
1223                    case 1: s = _("Mono"); break;
1224                    case 2: s = _("Stereo"); break;
1225                    default:
1226                        s = ToString(d->pSample->Channels) + _(" audio channels");
1227                        break;
1228                }
1229                s += " " + ToString(d->pSample->BitDepth) + " Bits";
1230                s += " " + ToString(d->pSample->SamplesPerSecond/1000) + "."
1231                          + ToString((d->pSample->SamplesPerSecond%1000)/100) + " kHz";
1232            } else {
1233                s = _("No sample assigned to this dimension region.");
1234            }
1235            eSampleFormatInfo.text.set_text(s);
1236        }
1237        // generate sample's memory address pointer string
1238        {
1239            Glib::ustring s;
1240            if (d->pSample) {
1241                char buf[64] = {};
1242                snprintf(buf, sizeof(buf), "%p", d->pSample);
1243                s = buf;
1244            } else {
1245                s = "---";
1246            }
1247            eSampleID.text.set_text(s);
1248        }
1249        // generate raw wave form data CRC-32 checksum string
1250        {
1251            Glib::ustring s = "---";
1252            if (d->pSample) {
1253                char buf[64] = {};
1254                snprintf(buf, sizeof(buf), "%x", d->pSample->GetWaveDataCRC32Checksum());
1255                s = buf;
1256            }
1257            eChecksum.text.set_text(s);
1258        }
1259        buttonSelectSample.set_sensitive(d && d->pSample);
1260      eFineTune.set_value(d->FineTune);      eFineTune.set_value(d->FineTune);
1261      eGain.set_value(d->Gain);      eGain.set_value(d->Gain);
1262      eGainPlus6.set_value(d->Gain);      eGainPlus6.set_value(d->Gain);
# Line 734  void DimRegionEdit::set_dim_region(gig:: Line 1273  void DimRegionEdit::set_dim_region(gig::
1273          d->pSample ? d->pSample->LoopPlayCount : 0);          d->pSample ? d->pSample->LoopPlayCount : 0);
1274      update_model--;      update_model--;
1275    
1276      wSample->set_text(d->pSample ? d->pSample->pInfo->Name.c_str() : _("NULL"));      wSample->set_text(d->pSample ? gig_to_utf8(d->pSample->pInfo->Name) :
1277                          _("NULL"));
1278    
1279      update_loop_elements();      update_loop_elements();
1280      VCFEnabled_toggled();      VCFEnabled_toggled();
# Line 749  void DimRegionEdit::VCFEnabled_toggled() Line 1289  void DimRegionEdit::VCFEnabled_toggled()
1289      eVCFVelocityCurve.set_sensitive(sensitive);      eVCFVelocityCurve.set_sensitive(sensitive);
1290      eVCFVelocityScale.set_sensitive(sensitive);      eVCFVelocityScale.set_sensitive(sensitive);
1291      eVCFVelocityDynamicRange.set_sensitive(sensitive);      eVCFVelocityDynamicRange.set_sensitive(sensitive);
1292        cutoff_curve.set_sensitive(sensitive);
1293      eVCFResonance.set_sensitive(sensitive);      eVCFResonance.set_sensitive(sensitive);
1294      eVCFResonanceController.set_sensitive(sensitive);      eVCFResonanceController.set_sensitive(sensitive);
1295      eVCFKeyboardTracking.set_sensitive(sensitive);      eVCFKeyboardTracking.set_sensitive(sensitive);
# Line 764  void DimRegionEdit::VCFEnabled_toggled() Line 1305  void DimRegionEdit::VCFEnabled_toggled()
1305      eEG2ControllerAttackInfluence.set_sensitive(sensitive);      eEG2ControllerAttackInfluence.set_sensitive(sensitive);
1306      eEG2ControllerDecayInfluence.set_sensitive(sensitive);      eEG2ControllerDecayInfluence.set_sensitive(sensitive);
1307      eEG2ControllerReleaseInfluence.set_sensitive(sensitive);      eEG2ControllerReleaseInfluence.set_sensitive(sensitive);
1308        eEG2StateOptions.set_sensitive(sensitive);
1309      lLFO2->set_sensitive(sensitive);      lLFO2->set_sensitive(sensitive);
1310      eLFO2Frequency.set_sensitive(sensitive);      eLFO2Frequency.set_sensitive(sensitive);
1311      eLFO2InternalDepth.set_sensitive(sensitive);      eLFO2InternalDepth.set_sensitive(sensitive);
# Line 841  void DimRegionEdit::AttenuationControlle Line 1383  void DimRegionEdit::AttenuationControlle
1383      eCrossfade_in_end.set_sensitive(hasController);      eCrossfade_in_end.set_sensitive(hasController);
1384      eCrossfade_out_start.set_sensitive(hasController);      eCrossfade_out_start.set_sensitive(hasController);
1385      eCrossfade_out_end.set_sensitive(hasController);      eCrossfade_out_end.set_sensitive(hasController);
1386        crossfade_curve.set_sensitive(hasController);
1387  }  }
1388    
1389  void DimRegionEdit::LFO1Controller_changed()  void DimRegionEdit::LFO1Controller_changed()
# Line 954  void DimRegionEdit::loop_infinite_toggle Line 1497  void DimRegionEdit::loop_infinite_toggle
1497      update_model--;      update_model--;
1498  }  }
1499    
1500  bool DimRegionEdit::set_sample(gig::Sample* sample)  bool DimRegionEdit::set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop)
1501  {  {
1502      if (dimregion) {      bool result = false;
1503        for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimregs.begin();
1504             itDimReg != dimregs.end(); ++itDimReg)
1505        {
1506            result |= set_sample(*itDimReg, sample, copy_sample_unity, copy_sample_tune, copy_sample_loop);
1507        }
1508        return result;
1509    }
1510    
1511    bool DimRegionEdit::set_sample(gig::DimensionRegion* dimreg, gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop)
1512    {
1513        if (dimreg) {
1514          //TODO: we should better move the code from MainWindow::on_sample_label_drop_drag_data_received() here          //TODO: we should better move the code from MainWindow::on_sample_label_drop_drag_data_received() here
1515    
1516          // currently commented because we're sending a similar signal in MainWindow::on_sample_label_drop_drag_data_received()          // currently commented because we're sending a similar signal in MainWindow::on_sample_label_drop_drag_data_received()
1517          //dimreg_to_be_changed_signal.emit(dimregion);          //DimRegionChangeGuard(this, dimregion);
1518    
1519          // make sure stereo samples always are the same in both          // make sure stereo samples always are the same in both
1520          // dimregs in the samplechannel dimension          // dimregs in the samplechannel dimension
1521          int nbDimregs = 1;          int nbDimregs = 1;
1522          gig::DimensionRegion* d[2] = { dimregion, 0 };          gig::DimensionRegion* d[2] = { dimreg, 0 };
1523          if (sample->Channels == 2) {          if (sample->Channels == 2) {
1524              gig::Region* region = dimregion->GetParent();              gig::Region* region = dimreg->GetParent();
1525    
1526              int bitcount = 0;              int bitcount = 0;
1527              int stereo_bit = 0;              int stereo_bit = 0;
# Line 982  bool DimRegionEdit::set_sample(gig::Samp Line 1536  bool DimRegionEdit::set_sample(gig::Samp
1536              if (stereo_bit) {              if (stereo_bit) {
1537                  int dimregno;                  int dimregno;
1538                  for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {                  for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
1539                      if (region->pDimensionRegions[dimregno] == dimregion) {                      if (region->pDimensionRegions[dimregno] == dimreg) {
1540                          break;                          break;
1541                      }                      }
1542                  }                  }
# Line 992  bool DimRegionEdit::set_sample(gig::Samp Line 1546  bool DimRegionEdit::set_sample(gig::Samp
1546              }              }
1547          }          }
1548    
1549          gig::Sample* oldref = dimregion->pSample;          gig::Sample* oldref = dimreg->pSample;
1550    
1551          for (int i = 0 ; i < nbDimregs ; i++) {          for (int i = 0 ; i < nbDimregs ; i++) {
1552              d[i]->pSample = sample;              d[i]->pSample = sample;
1553    
1554              // copy sample information from Sample to DimensionRegion              // copy sample information from Sample to DimensionRegion
1555                if (copy_sample_unity)
1556              d[i]->UnityNote = sample->MIDIUnityNote;                  d[i]->UnityNote = sample->MIDIUnityNote;
1557              d[i]->FineTune = sample->FineTune;              if (copy_sample_tune)
1558                    d[i]->FineTune = sample->FineTune;
1559              int loops = sample->Loops ? 1 : 0;              if (copy_sample_loop) {
1560              while (d[i]->SampleLoops > loops) {                  int loops = sample->Loops ? 1 : 0;
1561                  d[i]->DeleteSampleLoop(&d[i]->pSampleLoops[0]);                  while (d[i]->SampleLoops > loops) {
1562              }                      d[i]->DeleteSampleLoop(&d[i]->pSampleLoops[0]);
1563              while (d[i]->SampleLoops < sample->Loops) {                  }
1564                  DLS::sample_loop_t loop;                  while (d[i]->SampleLoops < sample->Loops) {
1565                  d[i]->AddSampleLoop(&loop);                      DLS::sample_loop_t loop;
1566              }                      d[i]->AddSampleLoop(&loop);
1567              if (loops) {                  }
1568                  d[i]->pSampleLoops[0].Size = sizeof(DLS::sample_loop_t);                  if (loops) {
1569                  d[i]->pSampleLoops[0].LoopType = sample->LoopType;                      d[i]->pSampleLoops[0].Size = sizeof(DLS::sample_loop_t);
1570                  d[i]->pSampleLoops[0].LoopStart = sample->LoopStart;                      d[i]->pSampleLoops[0].LoopType = sample->LoopType;
1571                  d[i]->pSampleLoops[0].LoopLength = sample->LoopEnd - sample->LoopStart + 1;                      d[i]->pSampleLoops[0].LoopStart = sample->LoopStart;
1572                        d[i]->pSampleLoops[0].LoopLength = sample->LoopEnd - sample->LoopStart + 1;
1573                    }
1574              }              }
1575          }          }
1576    
1577          // update ui          // update ui
1578          update_model++;          update_model++;
1579          wSample->set_text(dimregion->pSample->pInfo->Name);          wSample->set_text(gig_to_utf8(dimreg->pSample->pInfo->Name));
1580          eUnityNote.set_value(dimregion->UnityNote);          eUnityNote.set_value(dimreg->UnityNote);
1581          eFineTune.set_value(dimregion->FineTune);          eFineTune.set_value(dimreg->FineTune);
1582          eSampleLoopEnabled.set_value(dimregion->SampleLoops);          eSampleLoopEnabled.set_value(dimreg->SampleLoops);
1583          update_loop_elements();          update_loop_elements();
1584          update_model--;          update_model--;
1585    
1586          sample_ref_changed_signal.emit(oldref, sample);          sample_ref_changed_signal.emit(oldref, sample);
         // currently commented because we're sending a similar signal in MainWindow::on_sample_label_drop_drag_data_received()  
         //dimreg_changed_signal.emit(dimregion);  
1587          return true;          return true;
1588      }      }
1589      return false;      return false;
# Line 1098  void DimRegionEdit::set_LoopEnabled(gig: Line 1652  void DimRegionEdit::set_LoopEnabled(gig:
1652      if (value) {      if (value) {
1653          // create a new sample loop in case there is none yet          // create a new sample loop in case there is none yet
1654          if (!d->SampleLoops) {          if (!d->SampleLoops) {
1655                DimRegionChangeGuard(this, d);
1656    
1657              DLS::sample_loop_t loop;              DLS::sample_loop_t loop;
1658              loop.LoopType = gig::loop_type_normal;              loop.LoopType = gig::loop_type_normal;
1659              // loop the whole sample by default              // loop the whole sample by default
1660              loop.LoopStart  = 0;              loop.LoopStart  = 0;
1661              loop.LoopLength =              loop.LoopLength =
1662                  (d->pSample) ? d->pSample->SamplesTotal : 0;                  (d->pSample) ? d->pSample->SamplesTotal : 0;
             dimreg_to_be_changed_signal.emit(d);  
1663              d->AddSampleLoop(&loop);              d->AddSampleLoop(&loop);
             dimreg_changed_signal.emit(d);  
1664          }          }
1665      } else {      } else {
1666          if (d->SampleLoops) {          if (d->SampleLoops) {
1667              dimreg_to_be_changed_signal.emit(d);              DimRegionChangeGuard(this, d);
1668    
1669              // delete ALL existing sample loops              // delete ALL existing sample loops
1670              while (d->SampleLoops) {              while (d->SampleLoops) {
1671                  d->DeleteSampleLoop(&d->pSampleLoops[0]);                  d->DeleteSampleLoop(&d->pSampleLoops[0]);
1672              }              }
             dimreg_changed_signal.emit(d);  
1673          }          }
1674      }      }
1675  }  }
# Line 1159  void DimRegionEdit::set_LoopPlayCount(gi Line 1713  void DimRegionEdit::set_LoopPlayCount(gi
1713  {  {
1714      if (d->pSample) d->pSample->LoopPlayCount = value;      if (d->pSample) d->pSample->LoopPlayCount = value;
1715  }  }
1716    
1717    void DimRegionEdit::nullOutSampleReference() {
1718        if (!dimregion) return;
1719        gig::Sample* oldref = dimregion->pSample;
1720        if (!oldref) return;
1721    
1722        DimRegionChangeGuard(this, dimregion);
1723    
1724        // in case currently assigned sample is a stereo one, then remove both
1725        // references (expected to be due to a "stereo dimension")
1726        gig::DimensionRegion* d[2] = { dimregion, NULL };
1727        if (oldref->Channels == 2) {
1728            gig::Region* region = dimregion->GetParent();
1729            {
1730                int stereo_bit = 0;
1731                int bitcount = 0;
1732                for (int dim = 0 ; dim < region->Dimensions ; dim++) {
1733                    if (region->pDimensionDefinitions[dim].dimension == gig::dimension_samplechannel) {
1734                        stereo_bit = 1 << bitcount;
1735                        break;
1736                    }
1737                    bitcount += region->pDimensionDefinitions[dim].bits;
1738                }
1739    
1740                if (stereo_bit) {
1741                    int dimregno;
1742                    for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
1743                        if (region->pDimensionRegions[dimregno] == dimregion) {
1744                            break;
1745                        }
1746                    }
1747                    d[0] = region->pDimensionRegions[dimregno & ~stereo_bit];
1748                    d[1] = region->pDimensionRegions[dimregno | stereo_bit];
1749                }
1750            }
1751        }
1752    
1753        if (d[0]) d[0]->pSample = NULL;
1754        if (d[1]) d[1]->pSample = NULL;
1755    
1756        // update UI elements
1757        set_dim_region(dimregion);
1758    
1759        sample_ref_changed_signal.emit(oldref, NULL);
1760    }
1761    
1762    void DimRegionEdit::onButtonSelectSamplePressed() {
1763        if (!dimregion) return;
1764        if (!dimregion->pSample) return;
1765        select_sample_signal.emit(dimregion->pSample);
1766    }
1767    
1768    sigc::signal<void, gig::Sample*>& DimRegionEdit::signal_select_sample() {
1769        return select_sample_signal;
1770    }

Legend:
Removed from v.2151  
changed lines
  Added in v.3364

  ViewVC Help
Powered by ViewVC