/[svn]/gigedit/trunk/src/gigedit/dimregionedit.cpp
ViewVC logotype

Annotation of /gigedit/trunk/src/gigedit/dimregionedit.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3741 - (hide annotations) (download)
Thu Feb 6 17:33:21 2020 UTC (7 months, 2 weeks ago) by schoenebeck
File size: 84977 byte(s)
DimRegionEdit: init member variable 'dimregion' with NULL.

[ Usually it is not accessed before set_dim_region() was called,
  but just to be sure. ]

1 schoenebeck 1225 /*
2 persson 3458 * Copyright (C) 2006-2019 Andreas Persson
3 schoenebeck 1225 *
4     * This program is free software; you can redistribute it and/or
5     * modify it under the terms of the GNU General Public License as
6     * published by the Free Software Foundation; either version 2, or (at
7     * your option) any later version.
8     *
9     * This program is distributed in the hope that it will be useful, but
10     * WITHOUT ANY WARRANTY; without even the implied warranty of
11     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12     * General Public License for more details.
13     *
14     * You should have received a copy of the GNU General Public License
15     * along with program; see the file COPYING. If not, write to the Free
16     * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17     * 02110-1301 USA.
18     */
19    
20 persson 3202 #include "global.h"
21 schoenebeck 1225 #include "dimregionedit.h"
22    
23 persson 2169 #include "compat.h"
24 schoenebeck 1225
25 schoenebeck 3364 #if USE_GTKMM_GRID
26     # include <gtkmm/grid.h>
27     #else
28     # include <gtkmm/table.h>
29     #endif
30    
31 schoenebeck 3409 #include "Settings.h"
32    
33 persson 2392 VelocityCurve::VelocityCurve(double (gig::DimensionRegion::*getter)(uint8_t)) :
34     getter(getter), dimreg(0) {
35     set_size_request(80, 80);
36     }
37    
38     #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
39     bool VelocityCurve::on_expose_event(GdkEventExpose* e) {
40     const Cairo::RefPtr<Cairo::Context>& cr =
41     get_window()->create_cairo_context();
42     #else
43     bool VelocityCurve::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
44     #endif
45     if (dimreg) {
46     int w = get_width();
47     int h = get_height();
48    
49     for (int pass = 0 ; pass < 2 ; pass++) {
50 persson 2397 for (double x = 0 ; x <= w ; x++) {
51     int vel = int(x * (127 - 1e-10) / w + 1);
52     double y = (1 - (dimreg->*getter)(vel)) * (h - 3) + 1.5;
53 persson 2392
54 persson 2397 if (x < 1e-10) {
55 persson 2392 cr->move_to(x, y);
56     } else {
57     cr->line_to(x, y);
58     }
59     }
60     if (pass == 0) {
61 persson 2397 cr->line_to(w, h);
62     cr->line_to(0, h);
63 persson 2430 cr->set_source_rgba(0.5, 0.44, 1.0, is_sensitive() ? 0.2 : 0.1);
64 persson 2392 cr->fill();
65     } else {
66     cr->set_line_width(3);
67 persson 2430 cr->set_source_rgba(0.5, 0.44, 1.0, is_sensitive() ? 1.0 : 0.3);
68 persson 2392 cr->stroke();
69     }
70     }
71     }
72     return true;
73     }
74    
75    
76     CrossfadeCurve::CrossfadeCurve() : dimreg(0) {
77 schoenebeck 3627 set_size_request(500, 100);
78 persson 2392 }
79    
80     #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
81     bool CrossfadeCurve::on_expose_event(GdkEventExpose* e) {
82     const Cairo::RefPtr<Cairo::Context>& cr =
83     get_window()->create_cairo_context();
84     #else
85     bool CrossfadeCurve::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
86     #endif
87 persson 2430 if (dimreg) {
88 persson 2397 cr->translate(1.5, 0);
89 persson 2430
90     // first, draw curves for the other layers
91     gig::Region* region = dimreg->GetParent();
92     int dimregno;
93     for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
94     if (region->pDimensionRegions[dimregno] == dimreg) {
95     break;
96     }
97     }
98     int bitcount = 0;
99     for (int dim = 0 ; dim < region->Dimensions ; dim++) {
100     if (region->pDimensionDefinitions[dim].dimension ==
101     gig::dimension_layer) {
102     int mask =
103     ~(((1 << region->pDimensionDefinitions[dim].bits) - 1) <<
104     bitcount);
105     int c = dimregno & mask; // mask away the layer dimension
106    
107     for (int i = 0 ; i < region->pDimensionDefinitions[dim].zones ;
108     i++) {
109     gig::DimensionRegion* d =
110     region->pDimensionRegions[c + (i << bitcount)];
111     if (d != dimreg) {
112     draw_one_curve(cr, d, false);
113     }
114     }
115     break;
116     }
117     bitcount += region->pDimensionDefinitions[dim].bits;
118     }
119    
120     // then, draw the currently selected layer
121     draw_one_curve(cr, dimreg, is_sensitive());
122     }
123     return true;
124     }
125    
126     void CrossfadeCurve::draw_one_curve(const Cairo::RefPtr<Cairo::Context>& cr,
127     const gig::DimensionRegion* d,
128     bool sensitive) {
129     int w = get_width();
130     int h = get_height();
131    
132     if (d->Crossfade.out_end) {
133 persson 2392 for (int pass = 0 ; pass < 2 ; pass++) {
134 persson 2430 cr->move_to(d->Crossfade.in_start / 127.0 * (w - 3), h);
135     cr->line_to(d->Crossfade.in_end / 127.0 * (w - 3), 1.5);
136     cr->line_to(d->Crossfade.out_start / 127.0 * (w - 3), 1.5);
137     cr->line_to(d->Crossfade.out_end / 127.0 * (w - 3), h);
138 persson 2392
139     if (pass == 0) {
140 persson 2430 cr->set_source_rgba(0.5, 0.44, 1.0, sensitive ? 0.2 : 0.1);
141 persson 2392 cr->fill();
142     } else {
143     cr->set_line_width(3);
144 persson 2430 cr->set_source_rgba(0.5, 0.44, 1.0, sensitive ? 1.0 : 0.3);
145 persson 2392 cr->stroke();
146     }
147     }
148     }
149     }
150    
151    
152 schoenebeck 3619 LFOGraph::LFOGraph() : dimreg(0) {
153     set_size_request(500, 100);
154     }
155    
156     #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
157     bool LFOGraph::on_expose_event(GdkEventExpose* e) {
158     const Cairo::RefPtr<Cairo::Context>& cr =
159     get_window()->create_cairo_context();
160     #else
161     bool LFOGraph::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
162     #endif
163     if (dimreg) {
164     const int w = get_width();
165     const int h = get_height();
166     const bool sensitive = is_sensitive();
167     const bool signedRange = this->signedRange();
168     const float visiblePeriods = 5.f; // such that minimum LFO frequency 0.1 Hz draws exactly a half period
169    
170     // short-hand functions for setting colors
171     auto setGrayColor = [&] {
172     cr->set_source_rgba(0.88, 0.88, 0.88, sensitive ? 1.0 : 0.3);
173     };
174     auto setBlackColor = [&] {
175     cr->set_source_rgba(0, 0, 0, sensitive ? 1.0 : 0.3);
176     };
177     auto setGreenColor = [&] {
178     cr->set_source_rgba(94/255.f, 219/255.f, 80/255.f, sensitive ? 1.0 : 0.3);
179     };
180     auto setRedColor = [&] {
181     cr->set_source_rgba(255.f, 44/255.f, 44/255.f, sensitive ? 1.0 : 0.3);
182     };
183     /*auto setBlueColor = [&] {
184     cr->set_source_rgba(53/255.f, 167/255.f, 255.f, sensitive ? 1.0 : 0.3);
185     };*/
186     auto setOrangeColor = [&] {
187     cr->set_source_rgba(255.f, 177/255.f, 82/255.f, sensitive ? 1.0 : 0.3);
188     };
189 schoenebeck 3622 auto setWhiteColor = [&] {
190     cr->set_source_rgba(255.f, 255.f, 255.f, sensitive ? 1.0 : 0.3);
191     };
192 schoenebeck 3619
193 schoenebeck 3622 // fill background white
194     cr->rectangle(0, 0, w, h);
195     setWhiteColor();
196     cr->fill();
197    
198 schoenebeck 3619 // draw horizontal center line (dashed gray) if LFO range is signed
199     if (signedRange) {
200     cr->move_to(0, h/2);
201     cr->line_to(w, h/2);
202     cr->set_line_width(2);
203     setGrayColor();
204     cr->set_dash(std::vector<double>{ 7, 5 }, 0 /*offset*/);
205     cr->stroke();
206     }
207    
208     // draw a vertical line for each second
209     for (int period = 1; period < visiblePeriods; ++period) {
210     int x = float(w) / float(visiblePeriods) * period;
211     cr->move_to(x, 0);
212     cr->line_to(x, h);
213     cr->set_line_width(2);
214     setGrayColor();
215     cr->set_dash(std::vector<double>{ 5, 3 }, 0 /*offset*/);
216     cr->stroke();
217     }
218    
219     // how many curves shall we draw, two or one?
220     const int runs = (hasControllerAssigned()) ? 2 : 1;
221     // only draw the two curves in dashed style if they're very close to each other
222     const bool dashedCurves = (runs == 2 && controllerDepth() < 63);
223     // draw the required amount of curves
224     for (int run = 0; run < runs; ++run) {
225     // setup the LFO generator with the relevant parameters
226     lfo.setup({
227 schoenebeck 3624 .waveType = waveType(),
228 schoenebeck 3619 .rangeType = (signedRange) ? LinuxSampler::LFO::range_signed : LinuxSampler::LFO::range_unsigned,
229     .frequency = frequency(),
230 schoenebeck 3624 .phase = phase(),
231 schoenebeck 3619 .startLevel = startLevel(),
232     .internalDepth = internalDepth(),
233     .midiControllerDepth = controllerDepth(),
234     .flipPolarity = flipPolarity(),
235     .samplerate = w / visiblePeriods,
236     .maxValue = (signedRange) ? h/2 : h,
237     });
238     // 1st curve reflects min. CC value, 2nd curve max. CC value
239     lfo.setMIDICtrlValue( (run == 0) ? 0 : 127 );
240    
241     // the actual render/draw loop
242     for (int x = 0; x < w ; ++x) {
243     const float y =
244     (signedRange) ?
245     h/2 - lfo.render() :
246     h - lfo.render();
247     if (x == 0)
248     cr->move_to(x, y);
249     else
250     cr->line_to(x, y);
251     }
252     cr->set_line_width( (frequency() <= 4.f) ? 2 : 1 );
253     if (runs == 1)
254     setOrangeColor();
255     else if (run == 0)
256     setGreenColor();
257     else
258     setRedColor();
259     if (dashedCurves)
260     cr->set_dash(std::vector<double>{ 3, 3 }, (run == 0) ? 0 : 3 /*offset*/);
261     else
262     cr->set_dash(std::vector<double>(), 0 /*offset*/);
263     cr->stroke();
264     }
265    
266     // draw text legend
267     if (runs == 2) {
268     setRedColor();
269     cr->move_to(2, 10);
270     cr->show_text("CC Max.");
271    
272     setGreenColor();
273     cr->move_to(2, 23);
274     cr->show_text("CC Min.");
275     } else { // no controller assigned, internal depth only ...
276     setOrangeColor();
277     cr->move_to(2, 10);
278     cr->show_text("Const. Depth");
279     }
280     // draw text legend for each second ("1s", "2s", ...)
281     for (int period = 1; period < visiblePeriods; ++period) {
282     int x = float(w) / float(visiblePeriods) * period;
283     setBlackColor();
284     cr->move_to(x - 13, h - 3);
285     cr->show_text(ToString(period) + "s");
286     }
287     }
288     return true;
289     }
290    
291    
292 schoenebeck 3329 EGStateOptions::EGStateOptions() : HBox(),
293     label(_("May be cancelled: ")),
294     checkBoxAttack(_("Attack")),
295     checkBoxAttackHold(_("Attack Hold")),
296     checkBoxDecay1(_("Decay 1")),
297     checkBoxDecay2(_("Decay 2")),
298     checkBoxRelease(_("Release"))
299     {
300     set_spacing(6);
301    
302     pack_start(label);
303     pack_start(checkBoxAttack, Gtk::PACK_SHRINK);
304     pack_start(checkBoxAttackHold, Gtk::PACK_SHRINK);
305     pack_start(checkBoxDecay1, Gtk::PACK_SHRINK);
306     pack_start(checkBoxDecay2, Gtk::PACK_SHRINK);
307     pack_start(checkBoxRelease, Gtk::PACK_SHRINK);
308    
309     checkBoxAttack.set_tooltip_text(_(
310     "If checked: a note-off aborts the 'attack' stage."
311     ));
312     checkBoxAttackHold.set_tooltip_text(_(
313     "If checked: a note-off aborts the 'attack hold' stage."
314     ));
315     checkBoxDecay1.set_tooltip_text(_(
316     "If checked: a note-off aborts the 'decay 1' stage."
317     ));
318     checkBoxDecay2.set_tooltip_text(_(
319     "If checked: a note-off aborts the 'decay 2' stage."
320     ));
321     checkBoxRelease.set_tooltip_text(_(
322     "If checked: a note-on reverts back from the 'release' stage."
323     ));
324     }
325    
326 schoenebeck 3409 void EGStateOptions::on_show_tooltips_changed() {
327     const bool b = Settings::singleton()->showTooltips;
328 schoenebeck 3329
329 schoenebeck 3409 checkBoxAttack.set_has_tooltip(b);
330     checkBoxAttackHold.set_has_tooltip(b);
331     checkBoxDecay1.set_has_tooltip(b);
332     checkBoxDecay2.set_has_tooltip(b);
333     checkBoxRelease.set_has_tooltip(b);
334     }
335    
336    
337 schoenebeck 1225 DimRegionEdit::DimRegionEdit() :
338 persson 2392 velocity_curve(&gig::DimensionRegion::GetVelocityAttenuation),
339     release_curve(&gig::DimensionRegion::GetVelocityRelease),
340     cutoff_curve(&gig::DimensionRegion::GetVelocityCutoff),
341 schoenebeck 2566 eEG1PreAttack(_("Pre-attack Level (%)"), 0, 100, 2),
342     eEG1Attack(_("Attack Time (seconds)"), 0, 60, 3),
343     eEG1Decay1(_("Decay 1 Time (seconds)"), 0.005, 60, 3),
344     eEG1Decay2(_("Decay 2 Time (seconds)"), 0, 60, 3),
345 persson 1831 eEG1InfiniteSustain(_("Infinite sustain")),
346 schoenebeck 2566 eEG1Sustain(_("Sustain Level (%)"), 0, 100, 2),
347     eEG1Release(_("Release Time (seconds)"), 0, 60, 3),
348     eEG1Hold(_("Hold Attack Stage until Loop End")),
349 persson 1831 eEG1Controller(_("Controller")),
350     eEG1ControllerInvert(_("Controller invert")),
351     eEG1ControllerAttackInfluence(_("Controller attack influence"), 0, 3),
352     eEG1ControllerDecayInfluence(_("Controller decay influence"), 0, 3),
353     eEG1ControllerReleaseInfluence(_("Controller release influence"), 0, 3),
354 schoenebeck 3624 eLFO1Wave(_("Wave Form")),
355 persson 1831 eLFO1Frequency(_("Frequency"), 0.1, 10, 2),
356 schoenebeck 3624 eLFO1Phase(_("Phase"), 0.0, 360.0, 2),
357 persson 1831 eLFO1InternalDepth(_("Internal depth"), 0, 1200),
358     eLFO1ControlDepth(_("Control depth"), 0, 1200),
359     eLFO1Controller(_("Controller")),
360     eLFO1FlipPhase(_("Flip phase")),
361     eLFO1Sync(_("Sync")),
362 schoenebeck 2566 eEG2PreAttack(_("Pre-attack Level (%)"), 0, 100, 2),
363     eEG2Attack(_("Attack Time (seconds)"), 0, 60, 3),
364     eEG2Decay1(_("Decay 1 Time (seconds)"), 0.005, 60, 3),
365     eEG2Decay2(_("Decay 2 Time (seconds)"), 0, 60, 3),
366 persson 1831 eEG2InfiniteSustain(_("Infinite sustain")),
367 schoenebeck 2566 eEG2Sustain(_("Sustain Level (%)"), 0, 100, 2),
368     eEG2Release(_("Release Time (seconds)"), 0, 60, 3),
369 persson 1831 eEG2Controller(_("Controller")),
370     eEG2ControllerInvert(_("Controller invert")),
371     eEG2ControllerAttackInfluence(_("Controller attack influence"), 0, 3),
372     eEG2ControllerDecayInfluence(_("Controller decay influence"), 0, 3),
373     eEG2ControllerReleaseInfluence(_("Controller release influence"), 0, 3),
374 schoenebeck 3624 eLFO2Wave(_("Wave Form")),
375 persson 1831 eLFO2Frequency(_("Frequency"), 0.1, 10, 2),
376 schoenebeck 3624 eLFO2Phase(_("Phase"), 0.0, 360.0, 2),
377 persson 1831 eLFO2InternalDepth(_("Internal depth"), 0, 1200),
378     eLFO2ControlDepth(_("Control depth"), 0, 1200),
379     eLFO2Controller(_("Controller")),
380     eLFO2FlipPhase(_("Flip phase")),
381     eLFO2Sync(_("Sync")),
382     eEG3Attack(_("Attack"), 0, 10, 3),
383     eEG3Depth(_("Depth"), -1200, 1200),
384 schoenebeck 3624 eLFO3Wave(_("Wave Form")),
385 persson 1831 eLFO3Frequency(_("Frequency"), 0.1, 10, 2),
386 schoenebeck 3624 eLFO3Phase(_("Phase"), 0.0, 360.0, 2),
387 persson 1831 eLFO3InternalDepth(_("Internal depth"), 0, 1200),
388     eLFO3ControlDepth(_("Control depth"), 0, 1200),
389     eLFO3Controller(_("Controller")),
390 schoenebeck 3624 eLFO3FlipPhase(_("Flip phase")),
391 persson 1831 eLFO3Sync(_("Sync")),
392     eVCFEnabled(_("Enabled")),
393     eVCFType(_("Type")),
394     eVCFCutoffController(_("Cutoff controller")),
395     eVCFCutoffControllerInvert(_("Cutoff controller invert")),
396     eVCFCutoff(_("Cutoff")),
397     eVCFVelocityCurve(_("Velocity curve")),
398     eVCFVelocityScale(_("Velocity scale")),
399     eVCFVelocityDynamicRange(_("Velocity dynamic range"), 0, 4),
400     eVCFResonance(_("Resonance")),
401     eVCFResonanceDynamic(_("Resonance dynamic")),
402     eVCFResonanceController(_("Resonance controller")),
403     eVCFKeyboardTracking(_("Keyboard tracking")),
404     eVCFKeyboardTrackingBreakpoint(_("Keyboard tracking breakpoint")),
405     eVelocityResponseCurve(_("Velocity response curve")),
406     eVelocityResponseDepth(_("Velocity response depth"), 0, 4),
407     eVelocityResponseCurveScaling(_("Velocity response curve scaling")),
408     eReleaseVelocityResponseCurve(_("Release velocity response curve")),
409     eReleaseVelocityResponseDepth(_("Release velocity response depth"), 0, 4),
410     eReleaseTriggerDecay(_("Release trigger decay"), 0, 8),
411     eCrossfade_in_start(_("Crossfade-in start")),
412     eCrossfade_in_end(_("Crossfade-in end")),
413     eCrossfade_out_start(_("Crossfade-out start")),
414     eCrossfade_out_end(_("Crossfade-out end")),
415     ePitchTrack(_("Pitch track")),
416 schoenebeck 3449 eSustainReleaseTrigger(_("Sustain Release Trigger")),
417     eNoNoteOffReleaseTrigger(_("No note-off release trigger")),
418 persson 1831 eDimensionBypass(_("Dimension bypass")),
419     ePan(_("Pan"), -64, 63),
420 schoenebeck 2566 eSelfMask(_("Kill lower velocity voices (a.k.a \"Self mask\")")),
421 persson 1831 eAttenuationController(_("Attenuation controller")),
422     eInvertAttenuationController(_("Invert attenuation controller")),
423     eAttenuationControllerThreshold(_("Attenuation controller threshold")),
424     eChannelOffset(_("Channel offset"), 0, 9),
425 schoenebeck 2536 eSustainDefeat(_("Ignore Hold Pedal (a.k.a. \"Sustain defeat\")")),
426 schoenebeck 2566 eMSDecode(_("Decode Mid/Side Recordings")),
427 persson 1831 eSampleStartOffset(_("Sample start offset"), 0, 2000),
428     eUnityNote(_("Unity note")),
429 schoenebeck 2991 eSampleGroup(_("Sample Group")),
430 schoenebeck 2690 eSampleFormatInfo(_("Sample Format")),
431     eSampleID("Sample ID"),
432 schoenebeck 2991 eChecksum("Wave Data CRC-32"),
433 persson 1831 eFineTune(_("Fine tune"), -49, 50),
434 schoenebeck 3643 eGain(_("Gain (dB)"), -96, +96, 2, -655360),
435 persson 1831 eSampleLoopEnabled(_("Enabled")),
436 schoenebeck 3408 eSampleLoopStart(_("Loop start position")),
437 persson 1831 eSampleLoopLength(_("Loop size")),
438     eSampleLoopType(_("Loop type")),
439     eSampleLoopInfinite(_("Infinite loop")),
440     eSampleLoopPlayCount(_("Playback count"), 1),
441 schoenebeck 2692 buttonSelectSample(UNICODE_LEFT_ARROW + " " + _("Select Sample")),
442 schoenebeck 3737 editScriptSlotsButton(_("Edit Slots ...")),
443 schoenebeck 3741 dimregion(NULL),
444 persson 1460 update_model(0)
445 schoenebeck 1225 {
446 schoenebeck 2877 // make synthesis parameter page tabs scrollable
447     // (workaround for GTK3: default theme uses huge tabs which breaks layout)
448     set_scrollable();
449    
450 schoenebeck 3738 // use more appropriate increment/decrement steps for these spinboxes
451     eEG1PreAttack.set_increments(0.1, 5.0);
452     eEG2PreAttack.set_increments(0.1, 5.0);
453     eEG1Sustain.set_increments(0.1, 5.0);
454     eEG2Sustain.set_increments(0.1, 5.0);
455     eLFO1Frequency.set_increments(0.02, 0.2);
456     eLFO2Frequency.set_increments(0.02, 0.2);
457     eLFO3Frequency.set_increments(0.02, 0.2);
458     eLFO1Phase.set_increments(1.0, 10.0);
459     eLFO2Phase.set_increments(1.0, 10.0);
460     eLFO3Phase.set_increments(1.0, 10.0);
461    
462 persson 1460 connect(eEG1PreAttack, &gig::DimensionRegion::EG1PreAttack);
463     connect(eEG1Attack, &gig::DimensionRegion::EG1Attack);
464     connect(eEG1Decay1, &gig::DimensionRegion::EG1Decay1);
465     connect(eEG1Decay2, &gig::DimensionRegion::EG1Decay2);
466     connect(eEG1InfiniteSustain, &gig::DimensionRegion::EG1InfiniteSustain);
467     connect(eEG1Sustain, &gig::DimensionRegion::EG1Sustain);
468     connect(eEG1Release, &gig::DimensionRegion::EG1Release);
469     connect(eEG1Hold, &gig::DimensionRegion::EG1Hold);
470     connect(eEG1Controller, &gig::DimensionRegion::EG1Controller);
471     connect(eEG1ControllerInvert, &gig::DimensionRegion::EG1ControllerInvert);
472     connect(eEG1ControllerAttackInfluence,
473     &gig::DimensionRegion::EG1ControllerAttackInfluence);
474     connect(eEG1ControllerDecayInfluence,
475     &gig::DimensionRegion::EG1ControllerDecayInfluence);
476     connect(eEG1ControllerReleaseInfluence,
477     &gig::DimensionRegion::EG1ControllerReleaseInfluence);
478 persson 3458 connect(eEG1StateOptions.checkBoxAttack, &gig::DimensionRegion::EG1Options,
479     &gig::eg_opt_t::AttackCancel);
480     connect(eEG1StateOptions.checkBoxAttackHold, &gig::DimensionRegion::EG1Options,
481     &gig::eg_opt_t::AttackHoldCancel);
482     connect(eEG1StateOptions.checkBoxDecay1, &gig::DimensionRegion::EG1Options,
483     &gig::eg_opt_t::Decay1Cancel);
484     connect(eEG1StateOptions.checkBoxDecay2, &gig::DimensionRegion::EG1Options,
485     &gig::eg_opt_t::Decay2Cancel);
486     connect(eEG1StateOptions.checkBoxRelease, &gig::DimensionRegion::EG1Options,
487     &gig::eg_opt_t::ReleaseCancel);
488 schoenebeck 3624 connect(eLFO1Wave, &gig::DimensionRegion::LFO1WaveForm);
489 persson 1460 connect(eLFO1Frequency, &gig::DimensionRegion::LFO1Frequency);
490 schoenebeck 3624 connect(eLFO1Phase, &gig::DimensionRegion::LFO1Phase);
491 persson 1460 connect(eLFO1InternalDepth, &gig::DimensionRegion::LFO1InternalDepth);
492     connect(eLFO1ControlDepth, &gig::DimensionRegion::LFO1ControlDepth);
493     connect(eLFO1Controller, &gig::DimensionRegion::LFO1Controller);
494     connect(eLFO1FlipPhase, &gig::DimensionRegion::LFO1FlipPhase);
495     connect(eLFO1Sync, &gig::DimensionRegion::LFO1Sync);
496     connect(eEG2PreAttack, &gig::DimensionRegion::EG2PreAttack);
497     connect(eEG2Attack, &gig::DimensionRegion::EG2Attack);
498     connect(eEG2Decay1, &gig::DimensionRegion::EG2Decay1);
499     connect(eEG2Decay2, &gig::DimensionRegion::EG2Decay2);
500     connect(eEG2InfiniteSustain, &gig::DimensionRegion::EG2InfiniteSustain);
501     connect(eEG2Sustain, &gig::DimensionRegion::EG2Sustain);
502     connect(eEG2Release, &gig::DimensionRegion::EG2Release);
503     connect(eEG2Controller, &gig::DimensionRegion::EG2Controller);
504     connect(eEG2ControllerInvert, &gig::DimensionRegion::EG2ControllerInvert);
505     connect(eEG2ControllerAttackInfluence,
506     &gig::DimensionRegion::EG2ControllerAttackInfluence);
507     connect(eEG2ControllerDecayInfluence,
508     &gig::DimensionRegion::EG2ControllerDecayInfluence);
509     connect(eEG2ControllerReleaseInfluence,
510     &gig::DimensionRegion::EG2ControllerReleaseInfluence);
511 persson 3458 connect(eEG2StateOptions.checkBoxAttack, &gig::DimensionRegion::EG2Options,
512     &gig::eg_opt_t::AttackCancel);
513     connect(eEG2StateOptions.checkBoxAttackHold, &gig::DimensionRegion::EG2Options,
514     &gig::eg_opt_t::AttackHoldCancel);
515     connect(eEG2StateOptions.checkBoxDecay1, &gig::DimensionRegion::EG2Options,
516     &gig::eg_opt_t::Decay1Cancel);
517     connect(eEG2StateOptions.checkBoxDecay2, &gig::DimensionRegion::EG2Options,
518     &gig::eg_opt_t::Decay2Cancel);
519     connect(eEG2StateOptions.checkBoxRelease, &gig::DimensionRegion::EG2Options,
520     &gig::eg_opt_t::ReleaseCancel);
521 schoenebeck 3624 connect(eLFO2Wave, &gig::DimensionRegion::LFO2WaveForm);
522 persson 1460 connect(eLFO2Frequency, &gig::DimensionRegion::LFO2Frequency);
523 schoenebeck 3624 connect(eLFO2Phase, &gig::DimensionRegion::LFO2Phase);
524 persson 1460 connect(eLFO2InternalDepth, &gig::DimensionRegion::LFO2InternalDepth);
525     connect(eLFO2ControlDepth, &gig::DimensionRegion::LFO2ControlDepth);
526     connect(eLFO2Controller, &gig::DimensionRegion::LFO2Controller);
527     connect(eLFO2FlipPhase, &gig::DimensionRegion::LFO2FlipPhase);
528     connect(eLFO2Sync, &gig::DimensionRegion::LFO2Sync);
529     connect(eEG3Attack, &gig::DimensionRegion::EG3Attack);
530     connect(eEG3Depth, &gig::DimensionRegion::EG3Depth);
531 schoenebeck 3624 connect(eLFO3Wave, &gig::DimensionRegion::LFO3WaveForm);
532 persson 1460 connect(eLFO3Frequency, &gig::DimensionRegion::LFO3Frequency);
533 schoenebeck 3624 connect(eLFO3Phase, &gig::DimensionRegion::LFO3Phase);
534 persson 1460 connect(eLFO3InternalDepth, &gig::DimensionRegion::LFO3InternalDepth);
535     connect(eLFO3ControlDepth, &gig::DimensionRegion::LFO3ControlDepth);
536     connect(eLFO3Controller, &gig::DimensionRegion::LFO3Controller);
537 schoenebeck 3624 connect(eLFO3FlipPhase, &gig::DimensionRegion::LFO3FlipPhase);
538 persson 1460 connect(eLFO3Sync, &gig::DimensionRegion::LFO3Sync);
539     connect(eVCFEnabled, &gig::DimensionRegion::VCFEnabled);
540     connect(eVCFType, &gig::DimensionRegion::VCFType);
541     connect(eVCFCutoffController,
542     &gig::DimensionRegion::SetVCFCutoffController);
543     connect(eVCFCutoffControllerInvert,
544     &gig::DimensionRegion::VCFCutoffControllerInvert);
545     connect(eVCFCutoff, &gig::DimensionRegion::VCFCutoff);
546     connect(eVCFVelocityCurve, &gig::DimensionRegion::SetVCFVelocityCurve);
547     connect(eVCFVelocityScale, &gig::DimensionRegion::SetVCFVelocityScale);
548     connect(eVCFVelocityDynamicRange,
549     &gig::DimensionRegion::SetVCFVelocityDynamicRange);
550     connect(eVCFResonance, &gig::DimensionRegion::VCFResonance);
551     connect(eVCFResonanceDynamic, &gig::DimensionRegion::VCFResonanceDynamic);
552     connect(eVCFResonanceController,
553     &gig::DimensionRegion::VCFResonanceController);
554     connect(eVCFKeyboardTracking, &gig::DimensionRegion::VCFKeyboardTracking);
555     connect(eVCFKeyboardTrackingBreakpoint,
556     &gig::DimensionRegion::VCFKeyboardTrackingBreakpoint);
557     connect(eVelocityResponseCurve,
558     &gig::DimensionRegion::SetVelocityResponseCurve);
559     connect(eVelocityResponseDepth,
560     &gig::DimensionRegion::SetVelocityResponseDepth);
561     connect(eVelocityResponseCurveScaling,
562     &gig::DimensionRegion::SetVelocityResponseCurveScaling);
563     connect(eReleaseVelocityResponseCurve,
564     &gig::DimensionRegion::SetReleaseVelocityResponseCurve);
565     connect(eReleaseVelocityResponseDepth,
566     &gig::DimensionRegion::SetReleaseVelocityResponseDepth);
567     connect(eReleaseTriggerDecay, &gig::DimensionRegion::ReleaseTriggerDecay);
568     connect(eCrossfade_in_start, &DimRegionEdit::set_Crossfade_in_start);
569     connect(eCrossfade_in_end, &DimRegionEdit::set_Crossfade_in_end);
570     connect(eCrossfade_out_start, &DimRegionEdit::set_Crossfade_out_start);
571     connect(eCrossfade_out_end, &DimRegionEdit::set_Crossfade_out_end);
572     connect(ePitchTrack, &gig::DimensionRegion::PitchTrack);
573 schoenebeck 3449 connect(eSustainReleaseTrigger, &gig::DimensionRegion::SustainReleaseTrigger);
574     connect(eNoNoteOffReleaseTrigger, &gig::DimensionRegion::NoNoteOffReleaseTrigger);
575 persson 1460 connect(eDimensionBypass, &gig::DimensionRegion::DimensionBypass);
576     connect(ePan, &gig::DimensionRegion::Pan);
577     connect(eSelfMask, &gig::DimensionRegion::SelfMask);
578     connect(eAttenuationController,
579     &gig::DimensionRegion::AttenuationController);
580     connect(eInvertAttenuationController,
581     &gig::DimensionRegion::InvertAttenuationController);
582     connect(eAttenuationControllerThreshold,
583     &gig::DimensionRegion::AttenuationControllerThreshold);
584     connect(eChannelOffset, &gig::DimensionRegion::ChannelOffset);
585     connect(eSustainDefeat, &gig::DimensionRegion::SustainDefeat);
586     connect(eMSDecode, &gig::DimensionRegion::MSDecode);
587     connect(eSampleStartOffset, &gig::DimensionRegion::SampleStartOffset);
588     connect(eUnityNote, &DimRegionEdit::set_UnityNote);
589     connect(eFineTune, &DimRegionEdit::set_FineTune);
590     connect(eGain, &DimRegionEdit::set_Gain);
591     connect(eSampleLoopEnabled, &DimRegionEdit::set_LoopEnabled);
592     connect(eSampleLoopType, &DimRegionEdit::set_LoopType);
593     connect(eSampleLoopStart, &DimRegionEdit::set_LoopStart);
594     connect(eSampleLoopLength, &DimRegionEdit::set_LoopLength);
595     connect(eSampleLoopInfinite, &DimRegionEdit::set_LoopInfinite);
596     connect(eSampleLoopPlayCount, &DimRegionEdit::set_LoopPlayCount);
597 schoenebeck 2691 buttonSelectSample.signal_clicked().connect(
598     sigc::mem_fun(*this, &DimRegionEdit::onButtonSelectSamplePressed)
599     );
600 persson 1460
601 schoenebeck 3737 for (int i = 0; i < tableSize; i++) {
602 schoenebeck 3364 #if USE_GTKMM_GRID
603     table[i] = new Gtk::Grid;
604     table[i]->set_column_spacing(7);
605     #else
606 schoenebeck 1225 table[i] = new Gtk::Table(3, 1);
607     table[i]->set_col_spacings(7);
608 schoenebeck 3364 #endif
609    
610 schoenebeck 3368 // on Gtk 3 there is absolutely no margin by default
611     #if GTKMM_MAJOR_VERSION >= 3
612     # if GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION < 12
613     table[i]->set_margin_left(12);
614     table[i]->set_margin_right(12);
615     # else
616     table[i]->set_margin_start(12);
617     table[i]->set_margin_end(12);
618     # endif
619     #endif
620 schoenebeck 1225 }
621    
622     // set tooltips
623     eUnityNote.set_tip(
624     _("Note this sample is associated with (a.k.a. 'root note')")
625     );
626 schoenebeck 2691 buttonSelectSample.set_tooltip_text(
627     _("Selects the sample of this dimension region on the left hand side's sample tree view.")
628     );
629 schoenebeck 1225 eSampleStartOffset.set_tip(_("Sample position at which playback should be started"));
630     ePan.set_tip(_("Stereo balance (left/right)"));
631     eChannelOffset.set_tip(
632     _("Output channel where the audio signal should be routed to (0 - 9)")
633     );
634     ePitchTrack.set_tip(
635     _("If true: sample will be pitched according to the key position "
636     "(this would be disabled for drums for example)")
637     );
638     eSampleLoopEnabled.set_tip(_("If enabled: repeats to playback the sample"));
639     eSampleLoopStart.set_tip(
640     _("Start position within the sample (in sample points) of the area to "
641     "be looped")
642     );
643     eSampleLoopLength.set_tip(
644     _("Duration (in sample points) of the area to be looped")
645     );
646     eSampleLoopType.set_tip(
647     _("Direction in which the loop area in the sample should be played back")
648     );
649     eSampleLoopInfinite.set_tip(
650     _("Whether the loop area should be played back forever\n"
651     "Caution: this setting is stored on Sample side, thus is shared "
652     "among all dimension regions that use this sample!")
653     );
654     eSampleLoopPlayCount.set_tip(
655     _("How many times the loop area should be played back\n"
656     "Caution: this setting is stored on Sample side, thus is shared "
657     "among all dimension regions that use this sample!")
658     );
659 schoenebeck 2566
660     eEG1PreAttack.set_tip(
661     "Very first level this EG starts with. It rises then in Attack Time "
662     "seconds from this initial level to 100%."
663     );
664     eEG1Attack.set_tip(
665     "Duration of the EG's Attack stage, which raises its level from "
666     "Pre-Attack Level to 100%."
667     );
668     eEG1Hold.set_tip(
669     "On looped sounds, enabling this will cause the Decay 1 stage not to "
670     "enter before the loop has been passed one time."
671     );
672     eAttenuationController.set_tip(_(
673     "If you are not using the 'Layer' dimension, then this controller "
674     "simply alters the volume. If you are using the 'Layer' dimension, "
675     "then this controller is controlling the crossfade between Layers in "
676     "real-time."
677     ));
678 schoenebeck 1225
679 schoenebeck 2566 eLFO1Sync.set_tip(
680     "If not checked, every voice will use its own LFO instance, which "
681     "causes voices triggered at different points in time to have different "
682     "LFO levels. By enabling 'Sync' here the voices will instead use and "
683     "share one single LFO, causing all voices to have the same LFO level, "
684     "no matter when the individual notes have been triggered."
685     );
686     eLFO2Sync.set_tip(
687     "If not checked, every voice will use its own LFO instance, which "
688     "causes voices triggered at different points in time to have different "
689     "LFO levels. By enabling 'Sync' here the voices will instead use and "
690     "share one single LFO, causing all voices to have the same LFO level, "
691     "no matter when the individual notes have been triggered."
692     );
693     eLFO3Sync.set_tip(
694     "If not checked, every voice will use its own LFO instance, which "
695     "causes voices triggered at different points in time to have different "
696     "LFO levels. By enabling 'Sync' here the voices will instead use and "
697     "share one single LFO, causing all voices to have the same LFO level, "
698     "no matter when the individual notes have been triggered."
699     );
700     eLFO1FlipPhase.set_tip(
701     "Inverts the LFO's generated wave vertically."
702     );
703     eLFO2FlipPhase.set_tip(
704     "Inverts the LFO's generated wave vertically."
705     );
706 schoenebeck 3624 eLFO3FlipPhase.set_tip(
707     "Inverts the LFO's generated wave vertically."
708     );
709 schoenebeck 2566
710 schoenebeck 1225 pageno = 0;
711     rowno = 0;
712     firstRowInBlock = 0;
713    
714     addHeader(_("Mandatory Settings"));
715 schoenebeck 2720 addString(_("Sample"), lSample, wSample, buttonNullSampleReference);
716     buttonNullSampleReference->set_label("X");
717     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."));
718     buttonNullSampleReference->signal_clicked().connect(
719     sigc::mem_fun(*this, &DimRegionEdit::nullOutSampleReference)
720     );
721 schoenebeck 1225 //TODO: the following would break drag&drop: wSample->property_editable().set_value(false); or this: wSample->set_editable(false);
722 persson 2151 #ifdef OLD_TOOLTIPS
723 schoenebeck 2536 tooltips.set_tip(*wSample, _("Drag & drop a sample here"));
724 persson 2151 #else
725 schoenebeck 2536 wSample->set_tooltip_text(_("Drag & drop a sample here"));
726 persson 2151 #endif
727 schoenebeck 1225 addProp(eUnityNote);
728 schoenebeck 2991 addProp(eSampleGroup);
729 schoenebeck 2690 addProp(eSampleFormatInfo);
730     addProp(eSampleID);
731 schoenebeck 2991 addProp(eChecksum);
732 schoenebeck 2691 addRightHandSide(buttonSelectSample);
733 schoenebeck 1225 addHeader(_("Optional Settings"));
734     addProp(eSampleStartOffset);
735     addProp(eChannelOffset);
736 persson 1831 addHeader(_("Loops"));
737 schoenebeck 1225 addProp(eSampleLoopEnabled);
738     addProp(eSampleLoopStart);
739     addProp(eSampleLoopLength);
740     {
741 persson 1831 const char* choices[] = { _("normal"), _("bidirectional"), _("backward"), 0 };
742 schoenebeck 1225 static const uint32_t values[] = {
743     gig::loop_type_normal,
744     gig::loop_type_bidirectional,
745     gig::loop_type_backward
746     };
747     eSampleLoopType.set_choices(choices, values);
748     }
749     addProp(eSampleLoopType);
750     addProp(eSampleLoopInfinite);
751     addProp(eSampleLoopPlayCount);
752    
753     nextPage();
754    
755     addHeader(_("General Amplitude Settings"));
756     addProp(eGain);
757     addProp(ePan);
758     addHeader(_("Amplitude Envelope (EG1)"));
759     addProp(eEG1PreAttack);
760     addProp(eEG1Attack);
761 schoenebeck 2566 addProp(eEG1Hold);
762 schoenebeck 1225 addProp(eEG1Decay1);
763     addProp(eEG1Decay2);
764     addProp(eEG1InfiniteSustain);
765     addProp(eEG1Sustain);
766     addProp(eEG1Release);
767     addProp(eEG1Controller);
768     addProp(eEG1ControllerInvert);
769     addProp(eEG1ControllerAttackInfluence);
770     addProp(eEG1ControllerDecayInfluence);
771     addProp(eEG1ControllerReleaseInfluence);
772 schoenebeck 3329 addLine(eEG1StateOptions);
773 schoenebeck 1225
774     nextPage();
775    
776     addHeader(_("Amplitude Oscillator (LFO1)"));
777 schoenebeck 3624 addProp(eLFO1Wave);
778 schoenebeck 1225 addProp(eLFO1Frequency);
779 schoenebeck 3624 addProp(eLFO1Phase);
780 schoenebeck 1225 addProp(eLFO1InternalDepth);
781     addProp(eLFO1ControlDepth);
782     {
783 persson 1831 const char* choices[] = { _("internal"), _("modwheel"), _("breath"),
784     _("internal+modwheel"), _("internal+breath"), 0 };
785 schoenebeck 1225 static const gig::lfo1_ctrl_t values[] = {
786     gig::lfo1_ctrl_internal,
787     gig::lfo1_ctrl_modwheel,
788     gig::lfo1_ctrl_breath,
789     gig::lfo1_ctrl_internal_modwheel,
790     gig::lfo1_ctrl_internal_breath
791     };
792     eLFO1Controller.set_choices(choices, values);
793     }
794     addProp(eLFO1Controller);
795     addProp(eLFO1FlipPhase);
796     addProp(eLFO1Sync);
797 schoenebeck 3619 {
798     Gtk::Frame* frame = new Gtk::Frame;
799     frame->add(lfo1Graph);
800     // on Gtk 3 there is no margin at all by default
801     #if GTKMM_MAJOR_VERSION >= 3
802     frame->set_margin_top(12);
803     frame->set_margin_bottom(12);
804     #endif
805     #if USE_GTKMM_GRID
806     table[pageno]->attach(*frame, 1, rowno, 2);
807     #else
808     table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
809     Gtk::SHRINK, Gtk::SHRINK);
810     #endif
811     rowno++;
812     }
813 schoenebeck 3632 eLFO1Wave.signal_value_changed().connect(
814     sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw)
815     );
816     eLFO1Frequency.signal_value_changed().connect(
817     sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw)
818     );
819     eLFO1Phase.signal_value_changed().connect(
820     sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw)
821     );
822     eLFO1InternalDepth.signal_value_changed().connect(
823     sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw)
824     );
825     eLFO1ControlDepth.signal_value_changed().connect(
826     sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw)
827     );
828     eLFO1Controller.signal_value_changed().connect(
829     sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw)
830     );
831 schoenebeck 3619 eLFO1FlipPhase.signal_value_changed().connect(
832     sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw)
833     );
834 schoenebeck 3632 eLFO1Sync.signal_value_changed().connect(
835     sigc::mem_fun(lfo1Graph, &LFOGraph::queue_draw)
836     );
837 schoenebeck 3619
838     nextPage();
839    
840 persson 1831 addHeader(_("Crossfade"));
841 schoenebeck 1225 addProp(eAttenuationController);
842     addProp(eInvertAttenuationController);
843     addProp(eAttenuationControllerThreshold);
844     addProp(eCrossfade_in_start);
845     addProp(eCrossfade_in_end);
846     addProp(eCrossfade_out_start);
847     addProp(eCrossfade_out_end);
848    
849 persson 2392 Gtk::Frame* frame = new Gtk::Frame;
850     frame->add(crossfade_curve);
851 schoenebeck 3368 // on Gtk 3 there is no margin at all by default
852     #if GTKMM_MAJOR_VERSION >= 3
853     frame->set_margin_top(12);
854     frame->set_margin_bottom(12);
855     #endif
856 schoenebeck 3364 #if USE_GTKMM_GRID
857     table[pageno]->attach(*frame, 1, rowno, 2);
858     #else
859 persson 2392 table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
860     Gtk::SHRINK, Gtk::SHRINK);
861 schoenebeck 3364 #endif
862 persson 2392 rowno++;
863    
864     eCrossfade_in_start.signal_value_changed().connect(
865     sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
866     eCrossfade_in_end.signal_value_changed().connect(
867     sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
868     eCrossfade_out_start.signal_value_changed().connect(
869     sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
870     eCrossfade_out_end.signal_value_changed().connect(
871     sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
872    
873 schoenebeck 1225 nextPage();
874    
875     addHeader(_("General Filter Settings"));
876     addProp(eVCFEnabled);
877     {
878 schoenebeck 3647 const char* choices[] = {
879     _("lowpass"), _("lowpassturbo"), _("bandpass"), _("highpass"),
880     _("bandreject"),
881     _("lowpass 1-pole [EXT]"),
882     _("lowpass 2-pole [EXT]"),
883     _("lowpass 4-pole [EXT]"),
884     _("lowpass 6-pole [EXT]"),
885     _("highpass 1-pole [EXT]"),
886     _("highpass 2-pole [EXT]"),
887     _("highpass 4-pole [EXT]"),
888     _("highpass 6-pole [EXT]"),
889     _("bandpass 2-pole [EXT]"),
890     _("bandreject 2-pole [EXT]"),
891     NULL
892     };
893 schoenebeck 1225 static const gig::vcf_type_t values[] = {
894 schoenebeck 3647 // GigaStudio original filter types
895 schoenebeck 1225 gig::vcf_type_lowpass,
896     gig::vcf_type_lowpassturbo,
897     gig::vcf_type_bandpass,
898     gig::vcf_type_highpass,
899 schoenebeck 3647 gig::vcf_type_bandreject,
900     // LinuxSampler filter types (as gig format extension)
901     gig::vcf_type_lowpass_1p,
902     gig::vcf_type_lowpass_2p,
903     gig::vcf_type_lowpass_4p,
904     gig::vcf_type_lowpass_6p,
905     gig::vcf_type_highpass_1p,
906     gig::vcf_type_highpass_2p,
907     gig::vcf_type_highpass_4p,
908     gig::vcf_type_highpass_6p,
909     gig::vcf_type_bandpass_2p,
910     gig::vcf_type_bandreject_2p,
911 schoenebeck 1225 };
912     eVCFType.set_choices(choices, values);
913     }
914     addProp(eVCFType);
915     {
916 persson 1831 const char* choices[] = { _("none"), _("none2"), _("modwheel"), _("effect1"), _("effect2"),
917     _("breath"), _("foot"), _("sustainpedal"), _("softpedal"),
918     _("genpurpose7"), _("genpurpose8"), _("aftertouch"), 0 };
919 schoenebeck 1225 static const gig::vcf_cutoff_ctrl_t values[] = {
920     gig::vcf_cutoff_ctrl_none,
921     gig::vcf_cutoff_ctrl_none2,
922     gig::vcf_cutoff_ctrl_modwheel,
923     gig::vcf_cutoff_ctrl_effect1,
924     gig::vcf_cutoff_ctrl_effect2,
925     gig::vcf_cutoff_ctrl_breath,
926     gig::vcf_cutoff_ctrl_foot,
927     gig::vcf_cutoff_ctrl_sustainpedal,
928     gig::vcf_cutoff_ctrl_softpedal,
929     gig::vcf_cutoff_ctrl_genpurpose7,
930     gig::vcf_cutoff_ctrl_genpurpose8,
931     gig::vcf_cutoff_ctrl_aftertouch
932     };
933     eVCFCutoffController.set_choices(choices, values);
934     }
935     addProp(eVCFCutoffController);
936     addProp(eVCFCutoffControllerInvert);
937     addProp(eVCFCutoff);
938 persson 1831 const char* curve_type_texts[] = { _("nonlinear"), _("linear"), _("special"), 0 };
939 schoenebeck 1225 static const gig::curve_type_t curve_type_values[] = {
940     gig::curve_type_nonlinear,
941     gig::curve_type_linear,
942     gig::curve_type_special
943     };
944     eVCFVelocityCurve.set_choices(curve_type_texts, curve_type_values);
945     addProp(eVCFVelocityCurve);
946     addProp(eVCFVelocityScale);
947     addProp(eVCFVelocityDynamicRange);
948 persson 2392
949     eVCFCutoffController.signal_value_changed().connect(
950     sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
951     eVCFVelocityCurve.signal_value_changed().connect(
952     sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
953     eVCFVelocityScale.signal_value_changed().connect(
954     sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
955     eVCFVelocityDynamicRange.signal_value_changed().connect(
956     sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
957    
958     frame = new Gtk::Frame;
959     frame->add(cutoff_curve);
960 schoenebeck 3368 // on Gtk 3 there is no margin at all by default
961     #if GTKMM_MAJOR_VERSION >= 3
962     frame->set_margin_top(12);
963     frame->set_margin_bottom(12);
964     #endif
965 schoenebeck 3364 #if USE_GTKMM_GRID
966     table[pageno]->attach(*frame, 1, rowno, 2);
967     #else
968 persson 2392 table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
969     Gtk::SHRINK, Gtk::SHRINK);
970 schoenebeck 3364 #endif
971 persson 2392 rowno++;
972    
973 schoenebeck 1225 addProp(eVCFResonance);
974     addProp(eVCFResonanceDynamic);
975     {
976 persson 1831 const char* choices[] = { _("none"), _("genpurpose3"), _("genpurpose4"),
977     _("genpurpose5"), _("genpurpose6"), 0 };
978 schoenebeck 1225 static const gig::vcf_res_ctrl_t values[] = {
979     gig::vcf_res_ctrl_none,
980     gig::vcf_res_ctrl_genpurpose3,
981     gig::vcf_res_ctrl_genpurpose4,
982     gig::vcf_res_ctrl_genpurpose5,
983     gig::vcf_res_ctrl_genpurpose6
984     };
985     eVCFResonanceController.set_choices(choices, values);
986     }
987     addProp(eVCFResonanceController);
988     addProp(eVCFKeyboardTracking);
989     addProp(eVCFKeyboardTrackingBreakpoint);
990    
991     nextPage();
992    
993 persson 1623 lEG2 = addHeader(_("Filter Cutoff Envelope (EG2)"));
994 schoenebeck 1225 addProp(eEG2PreAttack);
995     addProp(eEG2Attack);
996     addProp(eEG2Decay1);
997     addProp(eEG2Decay2);
998     addProp(eEG2InfiniteSustain);
999     addProp(eEG2Sustain);
1000     addProp(eEG2Release);
1001     addProp(eEG2Controller);
1002     addProp(eEG2ControllerInvert);
1003     addProp(eEG2ControllerAttackInfluence);
1004     addProp(eEG2ControllerDecayInfluence);
1005     addProp(eEG2ControllerReleaseInfluence);
1006 schoenebeck 3329 addLine(eEG2StateOptions);
1007 schoenebeck 3619
1008     nextPage();
1009    
1010 persson 1623 lLFO2 = addHeader(_("Filter Cutoff Oscillator (LFO2)"));
1011 schoenebeck 3624 addProp(eLFO2Wave);
1012 schoenebeck 1225 addProp(eLFO2Frequency);
1013 schoenebeck 3624 addProp(eLFO2Phase);
1014 schoenebeck 1225 addProp(eLFO2InternalDepth);
1015     addProp(eLFO2ControlDepth);
1016     {
1017 persson 1831 const char* choices[] = { _("internal"), _("modwheel"), _("foot"),
1018     _("internal+modwheel"), _("internal+foot"), 0 };
1019 schoenebeck 1225 static const gig::lfo2_ctrl_t values[] = {
1020     gig::lfo2_ctrl_internal,
1021     gig::lfo2_ctrl_modwheel,
1022     gig::lfo2_ctrl_foot,
1023     gig::lfo2_ctrl_internal_modwheel,
1024     gig::lfo2_ctrl_internal_foot
1025     };
1026     eLFO2Controller.set_choices(choices, values);
1027     }
1028     addProp(eLFO2Controller);
1029     addProp(eLFO2FlipPhase);
1030     addProp(eLFO2Sync);
1031 schoenebeck 3619 {
1032     Gtk::Frame* frame = new Gtk::Frame;
1033     frame->add(lfo2Graph);
1034     // on Gtk 3 there is no margin at all by default
1035     #if GTKMM_MAJOR_VERSION >= 3
1036     frame->set_margin_top(12);
1037     frame->set_margin_bottom(12);
1038     #endif
1039     #if USE_GTKMM_GRID
1040     table[pageno]->attach(*frame, 1, rowno, 2);
1041     #else
1042     table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
1043     Gtk::SHRINK, Gtk::SHRINK);
1044     #endif
1045     rowno++;
1046     }
1047 schoenebeck 3632 eLFO2Wave.signal_value_changed().connect(
1048     sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw)
1049     );
1050     eLFO2Frequency.signal_value_changed().connect(
1051     sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw)
1052     );
1053     eLFO2Phase.signal_value_changed().connect(
1054     sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw)
1055     );
1056     eLFO2InternalDepth.signal_value_changed().connect(
1057     sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw)
1058     );
1059     eLFO2ControlDepth.signal_value_changed().connect(
1060     sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw)
1061     );
1062     eLFO2Controller.signal_value_changed().connect(
1063     sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw)
1064     );
1065 schoenebeck 3619 eLFO2FlipPhase.signal_value_changed().connect(
1066     sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw)
1067     );
1068 schoenebeck 3632 eLFO2Sync.signal_value_changed().connect(
1069     sigc::mem_fun(lfo2Graph, &LFOGraph::queue_draw)
1070     );
1071 schoenebeck 1225
1072     nextPage();
1073    
1074     addHeader(_("General Pitch Settings"));
1075     addProp(eFineTune);
1076     addProp(ePitchTrack);
1077     addHeader(_("Pitch Envelope (EG3)"));
1078     addProp(eEG3Attack);
1079     addProp(eEG3Depth);
1080     addHeader(_("Pitch Oscillator (LFO3)"));
1081 schoenebeck 3624 addProp(eLFO3Wave);
1082 schoenebeck 1225 addProp(eLFO3Frequency);
1083 schoenebeck 3624 addProp(eLFO3Phase);
1084 schoenebeck 1225 addProp(eLFO3InternalDepth);
1085     addProp(eLFO3ControlDepth);
1086     {
1087 persson 1831 const char* choices[] = { _("internal"), _("modwheel"), _("aftertouch"),
1088     _("internal+modwheel"), _("internal+aftertouch"), 0 };
1089 schoenebeck 1225 static const gig::lfo3_ctrl_t values[] = {
1090     gig::lfo3_ctrl_internal,
1091     gig::lfo3_ctrl_modwheel,
1092     gig::lfo3_ctrl_aftertouch,
1093     gig::lfo3_ctrl_internal_modwheel,
1094     gig::lfo3_ctrl_internal_aftertouch
1095     };
1096     eLFO3Controller.set_choices(choices, values);
1097     }
1098     addProp(eLFO3Controller);
1099 schoenebeck 3624 addProp(eLFO3FlipPhase);
1100 schoenebeck 1225 addProp(eLFO3Sync);
1101 schoenebeck 3619 {
1102     Gtk::Frame* frame = new Gtk::Frame;
1103     frame->add(lfo3Graph);
1104     // on Gtk 3 there is no margin at all by default
1105     #if GTKMM_MAJOR_VERSION >= 3
1106     frame->set_margin_top(12);
1107     frame->set_margin_bottom(12);
1108     #endif
1109     #if USE_GTKMM_GRID
1110     table[pageno]->attach(*frame, 1, rowno, 2);
1111     #else
1112     table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
1113     Gtk::SHRINK, Gtk::SHRINK);
1114     #endif
1115     rowno++;
1116     }
1117 schoenebeck 3632 eLFO3Wave.signal_value_changed().connect(
1118     sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw)
1119     );
1120     eLFO3Frequency.signal_value_changed().connect(
1121     sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw)
1122     );
1123     eLFO3Phase.signal_value_changed().connect(
1124     sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw)
1125     );
1126     eLFO3InternalDepth.signal_value_changed().connect(
1127     sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw)
1128     );
1129     eLFO3ControlDepth.signal_value_changed().connect(
1130     sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw)
1131     );
1132     eLFO3Controller.signal_value_changed().connect(
1133     sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw)
1134     );
1135 schoenebeck 3624 eLFO3FlipPhase.signal_value_changed().connect(
1136     sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw)
1137     );
1138 schoenebeck 3632 eLFO3Sync.signal_value_changed().connect(
1139     sigc::mem_fun(lfo3Graph, &LFOGraph::queue_draw)
1140     );
1141 schoenebeck 1225
1142     nextPage();
1143    
1144 schoenebeck 2539 addHeader(_("Velocity Response"));
1145 schoenebeck 1225 eVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values);
1146     addProp(eVelocityResponseCurve);
1147     addProp(eVelocityResponseDepth);
1148     addProp(eVelocityResponseCurveScaling);
1149 persson 2392
1150     eVelocityResponseCurve.signal_value_changed().connect(
1151     sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
1152     eVelocityResponseDepth.signal_value_changed().connect(
1153     sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
1154     eVelocityResponseCurveScaling.signal_value_changed().connect(
1155     sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
1156    
1157     frame = new Gtk::Frame;
1158     frame->add(velocity_curve);
1159 schoenebeck 3368 // on Gtk 3 there is no margin at all by default
1160     #if GTKMM_MAJOR_VERSION >= 3
1161     frame->set_margin_top(12);
1162     frame->set_margin_bottom(12);
1163     #endif
1164 schoenebeck 3364 #if USE_GTKMM_GRID
1165     table[pageno]->attach(*frame, 1, rowno, 2);
1166     #else
1167 persson 2392 table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
1168     Gtk::SHRINK, Gtk::SHRINK);
1169 schoenebeck 3364 #endif
1170 persson 2392 rowno++;
1171    
1172 schoenebeck 2539 addHeader(_("Release Velocity Response"));
1173 schoenebeck 1225 eReleaseVelocityResponseCurve.set_choices(curve_type_texts,
1174     curve_type_values);
1175     addProp(eReleaseVelocityResponseCurve);
1176     addProp(eReleaseVelocityResponseDepth);
1177 persson 2392
1178     eReleaseVelocityResponseCurve.signal_value_changed().connect(
1179     sigc::mem_fun(release_curve, &VelocityCurve::queue_draw));
1180     eReleaseVelocityResponseDepth.signal_value_changed().connect(
1181     sigc::mem_fun(release_curve, &VelocityCurve::queue_draw));
1182     frame = new Gtk::Frame;
1183     frame->add(release_curve);
1184 schoenebeck 3368 // on Gtk 3 there is no margin at all by default
1185     #if GTKMM_MAJOR_VERSION >= 3
1186     frame->set_margin_top(12);
1187     frame->set_margin_bottom(12);
1188     #endif
1189 schoenebeck 3364 #if USE_GTKMM_GRID
1190     table[pageno]->attach(*frame, 1, rowno, 2);
1191     #else
1192 persson 2392 table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
1193     Gtk::SHRINK, Gtk::SHRINK);
1194 schoenebeck 3364 #endif
1195 persson 2392 rowno++;
1196    
1197 schoenebeck 1225 addProp(eReleaseTriggerDecay);
1198     {
1199 schoenebeck 3449 const char* choices[] = { _("off"), _("on (max. velocity)"), _("on (key velocity)"), 0 };
1200     static const gig::sust_rel_trg_t values[] = {
1201     gig::sust_rel_trg_none,
1202     gig::sust_rel_trg_maxvelocity,
1203     gig::sust_rel_trg_keyvelocity
1204     };
1205     eSustainReleaseTrigger.set_choices(choices, values);
1206     }
1207     eSustainReleaseTrigger.set_tip(_(
1208     "By default release trigger samples are played on note-off events only. "
1209     "This option allows to play release trigger sample on sustain pedal up "
1210     "events as well. NOTE: This is a format extension!"
1211     ));
1212     addProp(eSustainReleaseTrigger);
1213     {
1214 persson 1831 const char* choices[] = { _("none"), _("effect4depth"), _("effect5depth"), 0 };
1215 schoenebeck 1225 static const gig::dim_bypass_ctrl_t values[] = {
1216     gig::dim_bypass_ctrl_none,
1217     gig::dim_bypass_ctrl_94,
1218     gig::dim_bypass_ctrl_95
1219     };
1220     eDimensionBypass.set_choices(choices, values);
1221     }
1222 schoenebeck 3449 eNoNoteOffReleaseTrigger.set_tip(_(
1223     "By default release trigger samples are played on note-off events only. "
1224     "If this option is checked, then no release trigger sample is played "
1225     "when releasing a note. NOTE: This is a format extension!"
1226     ));
1227     addProp(eNoNoteOffReleaseTrigger);
1228 schoenebeck 1225 addProp(eDimensionBypass);
1229 schoenebeck 2566 eSelfMask.widget.set_tooltip_text(_(
1230     "If enabled: new notes with higher velocity value will stop older "
1231     "notes with lower velocity values, that way you can save voices that "
1232     "would barely be audible. This is also useful for certain drum sounds."
1233     ));
1234 schoenebeck 1225 addProp(eSelfMask);
1235 schoenebeck 2566 eSustainDefeat.widget.set_tooltip_text(_(
1236     "If enabled: sustain pedal will not hold a note. This way you can use "
1237     "the sustain pedal for other purposes, for example to switch among "
1238     "dimension regions."
1239     ));
1240 schoenebeck 1225 addProp(eSustainDefeat);
1241 schoenebeck 2566 eMSDecode.widget.set_tooltip_text(_(
1242     "Defines if Mid/Side Recordings should be decoded. Mid/Side Recordings "
1243     "are an alternative way to record sounds in stereo. The sampler needs "
1244     "to decode such samples to actually make use of them. Note: this "
1245     "feature is currently not supported by LinuxSampler."
1246     ));
1247 schoenebeck 1225 addProp(eMSDecode);
1248    
1249     nextPage();
1250    
1251    
1252 persson 1460 eEG1InfiniteSustain.signal_value_changed().connect(
1253     sigc::mem_fun(*this, &DimRegionEdit::EG1InfiniteSustain_toggled));
1254     eEG2InfiniteSustain.signal_value_changed().connect(
1255     sigc::mem_fun(*this, &DimRegionEdit::EG2InfiniteSustain_toggled));
1256     eEG1Controller.signal_value_changed().connect(
1257     sigc::mem_fun(*this, &DimRegionEdit::EG1Controller_changed));
1258     eEG2Controller.signal_value_changed().connect(
1259     sigc::mem_fun(*this, &DimRegionEdit::EG2Controller_changed));
1260     eLFO1Controller.signal_value_changed().connect(
1261     sigc::mem_fun(*this, &DimRegionEdit::LFO1Controller_changed));
1262     eLFO2Controller.signal_value_changed().connect(
1263     sigc::mem_fun(*this, &DimRegionEdit::LFO2Controller_changed));
1264     eLFO3Controller.signal_value_changed().connect(
1265     sigc::mem_fun(*this, &DimRegionEdit::LFO3Controller_changed));
1266     eAttenuationController.signal_value_changed().connect(
1267     sigc::mem_fun(*this, &DimRegionEdit::AttenuationController_changed));
1268     eVCFEnabled.signal_value_changed().connect(
1269     sigc::mem_fun(*this, &DimRegionEdit::VCFEnabled_toggled));
1270     eVCFCutoffController.signal_value_changed().connect(
1271     sigc::mem_fun(*this, &DimRegionEdit::VCFCutoffController_changed));
1272     eVCFResonanceController.signal_value_changed().connect(
1273     sigc::mem_fun(*this, &DimRegionEdit::VCFResonanceController_changed));
1274 schoenebeck 1225
1275 persson 1460 eCrossfade_in_start.signal_value_changed().connect(
1276 schoenebeck 1225 sigc::mem_fun(*this, &DimRegionEdit::crossfade1_changed));
1277 persson 1460 eCrossfade_in_end.signal_value_changed().connect(
1278 schoenebeck 1225 sigc::mem_fun(*this, &DimRegionEdit::crossfade2_changed));
1279 persson 1460 eCrossfade_out_start.signal_value_changed().connect(
1280 schoenebeck 1225 sigc::mem_fun(*this, &DimRegionEdit::crossfade3_changed));
1281 persson 1460 eCrossfade_out_end.signal_value_changed().connect(
1282 schoenebeck 1225 sigc::mem_fun(*this, &DimRegionEdit::crossfade4_changed));
1283    
1284 persson 1460 eSampleLoopEnabled.signal_value_changed().connect(
1285     sigc::mem_fun(*this, &DimRegionEdit::update_loop_elements));
1286     eSampleLoopStart.signal_value_changed().connect(
1287     sigc::mem_fun(*this, &DimRegionEdit::loop_start_changed));
1288     eSampleLoopLength.signal_value_changed().connect(
1289     sigc::mem_fun(*this, &DimRegionEdit::loop_length_changed));
1290     eSampleLoopInfinite.signal_value_changed().connect(
1291 schoenebeck 1225 sigc::mem_fun(*this, &DimRegionEdit::loop_infinite_toggled));
1292    
1293 schoenebeck 3737
1294     addHeader(_("Script Patch Variables"));
1295    
1296     m_labelPatchVarsDescr.set_markup(
1297     _("These are variables declared in scripts with keyword "
1298     "<span color='#FF4FF3'><b>patch</b></span>. "
1299     "A 'patch' variable allows to override its default value on a per "
1300     "instrument basis. That way a script may be shared by instruments "
1301     "while being able to fine tune certain script parameters for each "
1302     "instrument individually if necessary. Overridden default values "
1303     "are displayed in bold. To revert back to the script's default "
1304     "value, select the variable(s) and hit <b>&#x232b;</b> or "
1305     "<b>&#x2326;</b> key.")
1306     );
1307     scriptVarsDescrBox.set_spacing(13);
1308     scriptVarsDescrBox.pack_start(m_labelPatchVarsDescr, true, true);
1309     scriptVarsDescrBox.pack_start(editScriptSlotsButton, false, false);
1310     #if USE_GTKMM_GRID
1311     table[pageno]->attach(scriptVarsDescrBox, 1, rowno, 2);
1312     #else
1313     table[pageno]->attach(scriptVarsDescrBox, 1, 3, rowno, rowno + 1,
1314     Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
1315     #endif
1316     rowno++;
1317    
1318     #if GTKMM_MAJOR_VERSION >= 3
1319     scriptVars.set_margin_top(20);
1320     #endif
1321     #if USE_GTKMM_GRID
1322     table[pageno]->attach(scriptVars, 1, rowno, 2);
1323     #else
1324    
1325     table[pageno]->attach(scriptVars, 1, 3, rowno, rowno + 1,
1326     Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL);
1327     #endif
1328     rowno++;
1329    
1330    
1331 persson 1831 append_page(*table[0], _("Sample"));
1332 schoenebeck 3619 append_page(*table[1], _("Amp (1)"));
1333     append_page(*table[2], _("Amp (2)"));
1334     append_page(*table[3], _("Amp (3)"));
1335     append_page(*table[4], _("Filter (1)"));
1336     append_page(*table[5], _("Filter (2)"));
1337     append_page(*table[6], _("Filter (3)"));
1338     append_page(*table[7], _("Pitch"));
1339     append_page(*table[8], _("Misc"));
1340 schoenebeck 3737 append_page(*table[9], _("Script"));
1341 schoenebeck 3409
1342     Settings::singleton()->showTooltips.get_proxy().signal_changed().connect(
1343     sigc::mem_fun(*this, &DimRegionEdit::on_show_tooltips_changed)
1344     );
1345    
1346     on_show_tooltips_changed();
1347 schoenebeck 1225 }
1348    
1349     DimRegionEdit::~DimRegionEdit()
1350     {
1351     }
1352    
1353     void DimRegionEdit::addString(const char* labelText, Gtk::Label*& label,
1354     Gtk::Entry*& widget)
1355     {
1356     label = new Gtk::Label(Glib::ustring(labelText) + ":");
1357 schoenebeck 3364 #if HAS_GTKMM_ALIGNMENT
1358 persson 2169 label->set_alignment(Gtk::ALIGN_START);
1359 schoenebeck 3364 #else
1360     label->set_halign(Gtk::Align::START);
1361     #endif
1362 schoenebeck 1225
1363 schoenebeck 3364 #if USE_GTKMM_GRID
1364     table[pageno]->attach(*label, 1, rowno);
1365     #else
1366 schoenebeck 1225 table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,
1367     Gtk::FILL, Gtk::SHRINK);
1368 schoenebeck 3364 #endif
1369 schoenebeck 1225
1370     widget = new Gtk::Entry();
1371    
1372 schoenebeck 3364 #if USE_GTKMM_GRID
1373     table[pageno]->attach(*widget, 2, rowno);
1374     #else
1375 schoenebeck 1225 table[pageno]->attach(*widget, 2, 3, rowno, rowno + 1,
1376     Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
1377 schoenebeck 3364 #endif
1378 schoenebeck 1225
1379     rowno++;
1380     }
1381    
1382 schoenebeck 2720 void DimRegionEdit::addString(const char* labelText, Gtk::Label*& label,
1383     Gtk::Entry*& widget, Gtk::Button*& button)
1384     {
1385     label = new Gtk::Label(Glib::ustring(labelText) + ":");
1386 schoenebeck 3364 #if HAS_GTKMM_ALIGNMENT
1387 schoenebeck 2720 label->set_alignment(Gtk::ALIGN_START);
1388 schoenebeck 3364 #else
1389     label->set_halign(Gtk::Align::START);
1390     #endif
1391 schoenebeck 2720
1392 schoenebeck 3364 #if USE_GTKMM_GRID
1393     table[pageno]->attach(*label, 1, rowno);
1394     #else
1395 schoenebeck 2720 table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,
1396     Gtk::FILL, Gtk::SHRINK);
1397 schoenebeck 3364 #endif
1398 schoenebeck 2720
1399     widget = new Gtk::Entry();
1400     button = new Gtk::Button();
1401    
1402 schoenebeck 3364 HBox* hbox = new HBox;
1403 schoenebeck 2720 hbox->pack_start(*widget);
1404     hbox->pack_start(*button, Gtk::PACK_SHRINK);
1405    
1406 schoenebeck 3364 #if USE_GTKMM_GRID
1407     table[pageno]->attach(*hbox, 2, rowno);
1408     #else
1409 schoenebeck 2720 table[pageno]->attach(*hbox, 2, 3, rowno, rowno + 1,
1410     Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
1411 schoenebeck 3364 #endif
1412 schoenebeck 2720
1413     rowno++;
1414     }
1415    
1416 persson 1623 Gtk::Label* DimRegionEdit::addHeader(const char* text)
1417 schoenebeck 1225 {
1418     if (firstRowInBlock < rowno - 1)
1419     {
1420     Gtk::Label* filler = new Gtk::Label(" ");
1421 schoenebeck 3364 #if USE_GTKMM_GRID
1422     table[pageno]->attach(*filler, 0, firstRowInBlock);
1423     #else
1424 schoenebeck 1225 table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,
1425     Gtk::FILL, Gtk::SHRINK);
1426 schoenebeck 3364 #endif
1427 schoenebeck 1225 }
1428     Glib::ustring str = "<b>";
1429     str += text;
1430     str += "</b>";
1431     Gtk::Label* label = new Gtk::Label(str);
1432     label->set_use_markup();
1433 schoenebeck 3364 #if HAS_GTKMM_ALIGNMENT
1434 persson 2169 label->set_alignment(Gtk::ALIGN_START);
1435 schoenebeck 3364 #else
1436     label->set_halign(Gtk::Align::START);
1437     #endif
1438 schoenebeck 3368 // on GTKMM 3 there is absolutely no margin by default
1439     #if GTKMM_MAJOR_VERSION >= 3
1440     label->set_margin_top(18);
1441     label->set_margin_bottom(13);
1442     #endif
1443 schoenebeck 3364 #if USE_GTKMM_GRID
1444     table[pageno]->attach(*label, 0, rowno, 3);
1445     #else
1446 schoenebeck 1225 table[pageno]->attach(*label, 0, 3, rowno, rowno + 1,
1447     Gtk::FILL, Gtk::SHRINK);
1448 schoenebeck 3364 #endif
1449 schoenebeck 1225 rowno++;
1450     firstRowInBlock = rowno;
1451 persson 1623 return label;
1452 schoenebeck 1225 }
1453    
1454 schoenebeck 3409 void DimRegionEdit::on_show_tooltips_changed() {
1455     const bool b = Settings::singleton()->showTooltips;
1456    
1457     buttonSelectSample.set_has_tooltip(b);
1458     buttonNullSampleReference->set_has_tooltip(b);
1459     wSample->set_has_tooltip(b);
1460    
1461     eEG1StateOptions.on_show_tooltips_changed();
1462     eEG2StateOptions.on_show_tooltips_changed();
1463    
1464     set_has_tooltip(b);
1465     }
1466    
1467 schoenebeck 1225 void DimRegionEdit::nextPage()
1468     {
1469     if (firstRowInBlock < rowno - 1)
1470     {
1471     Gtk::Label* filler = new Gtk::Label(" ");
1472 schoenebeck 3364 #if USE_GTKMM_GRID
1473     table[pageno]->attach(*filler, 0, firstRowInBlock);
1474     #else
1475 schoenebeck 1225 table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,
1476     Gtk::FILL, Gtk::SHRINK);
1477 schoenebeck 3364 #endif
1478 schoenebeck 1225 }
1479     pageno++;
1480     rowno = 0;
1481     firstRowInBlock = 0;
1482     }
1483    
1484     void DimRegionEdit::addProp(BoolEntry& boolentry)
1485     {
1486 schoenebeck 3364 #if USE_GTKMM_GRID
1487     table[pageno]->attach(boolentry.widget, 1, rowno, 2);
1488     #else
1489 schoenebeck 1225 table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1,
1490     Gtk::FILL, Gtk::SHRINK);
1491 schoenebeck 3364 #endif
1492 schoenebeck 1225 rowno++;
1493     }
1494    
1495     void DimRegionEdit::addProp(LabelWidget& prop)
1496     {
1497 schoenebeck 3364 #if USE_GTKMM_GRID
1498     table[pageno]->attach(prop.label, 1, rowno);
1499     table[pageno]->attach(prop.widget, 2, rowno);
1500     #else
1501 schoenebeck 1225 table[pageno]->attach(prop.label, 1, 2, rowno, rowno + 1,
1502     Gtk::FILL, Gtk::SHRINK);
1503     table[pageno]->attach(prop.widget, 2, 3, rowno, rowno + 1,
1504     Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
1505 schoenebeck 3364 #endif
1506 schoenebeck 1225 rowno++;
1507     }
1508    
1509 schoenebeck 3364 void DimRegionEdit::addLine(HBox& line)
1510 schoenebeck 3329 {
1511 schoenebeck 3364 #if USE_GTKMM_GRID
1512     table[pageno]->attach(line, 1, rowno, 2);
1513     #else
1514 schoenebeck 3329 table[pageno]->attach(line, 1, 3, rowno, rowno + 1,
1515     Gtk::FILL, Gtk::SHRINK);
1516 schoenebeck 3364 #endif
1517 schoenebeck 3329 rowno++;
1518     }
1519    
1520 schoenebeck 2691 void DimRegionEdit::addRightHandSide(Gtk::Widget& widget)
1521     {
1522 schoenebeck 3364 #if USE_GTKMM_GRID
1523     table[pageno]->attach(widget, 2, rowno);
1524     #else
1525 schoenebeck 2691 table[pageno]->attach(widget, 2, 3, rowno, rowno + 1,
1526     Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
1527 schoenebeck 3364 #endif
1528 schoenebeck 2691 rowno++;
1529     }
1530 schoenebeck 1225
1531     void DimRegionEdit::set_dim_region(gig::DimensionRegion* d)
1532     {
1533     dimregion = d;
1534 persson 2392 velocity_curve.set_dim_region(d);
1535     release_curve.set_dim_region(d);
1536     cutoff_curve.set_dim_region(d);
1537     crossfade_curve.set_dim_region(d);
1538 schoenebeck 3619 lfo1Graph.set_dim_region(d);
1539     lfo2Graph.set_dim_region(d);
1540     lfo3Graph.set_dim_region(d);
1541 schoenebeck 1225
1542     set_sensitive(d);
1543     if (!d) return;
1544    
1545 persson 1460 update_model++;
1546     eEG1PreAttack.set_value(d->EG1PreAttack);
1547     eEG1Attack.set_value(d->EG1Attack);
1548     eEG1Decay1.set_value(d->EG1Decay1);
1549     eEG1Decay2.set_value(d->EG1Decay2);
1550     eEG1InfiniteSustain.set_value(d->EG1InfiniteSustain);
1551     eEG1Sustain.set_value(d->EG1Sustain);
1552     eEG1Release.set_value(d->EG1Release);
1553     eEG1Hold.set_value(d->EG1Hold);
1554     eEG1Controller.set_value(d->EG1Controller);
1555     eEG1ControllerInvert.set_value(d->EG1ControllerInvert);
1556     eEG1ControllerAttackInfluence.set_value(d->EG1ControllerAttackInfluence);
1557     eEG1ControllerDecayInfluence.set_value(d->EG1ControllerDecayInfluence);
1558     eEG1ControllerReleaseInfluence.set_value(d->EG1ControllerReleaseInfluence);
1559 schoenebeck 3329 eEG1StateOptions.checkBoxAttack.set_value(d->EG1Options.AttackCancel);
1560     eEG1StateOptions.checkBoxAttackHold.set_value(d->EG1Options.AttackHoldCancel);
1561     eEG1StateOptions.checkBoxDecay1.set_value(d->EG1Options.Decay1Cancel);
1562     eEG1StateOptions.checkBoxDecay2.set_value(d->EG1Options.Decay2Cancel);
1563     eEG1StateOptions.checkBoxRelease.set_value(d->EG1Options.ReleaseCancel);
1564 schoenebeck 3624 eLFO1Wave.set_value(d->LFO1WaveForm);
1565 persson 1460 eLFO1Frequency.set_value(d->LFO1Frequency);
1566 schoenebeck 3624 eLFO1Phase.set_value(d->LFO1Phase);
1567 persson 1460 eLFO1InternalDepth.set_value(d->LFO1InternalDepth);
1568     eLFO1ControlDepth.set_value(d->LFO1ControlDepth);
1569     eLFO1Controller.set_value(d->LFO1Controller);
1570     eLFO1FlipPhase.set_value(d->LFO1FlipPhase);
1571     eLFO1Sync.set_value(d->LFO1Sync);
1572     eEG2PreAttack.set_value(d->EG2PreAttack);
1573     eEG2Attack.set_value(d->EG2Attack);
1574     eEG2Decay1.set_value(d->EG2Decay1);
1575     eEG2Decay2.set_value(d->EG2Decay2);
1576     eEG2InfiniteSustain.set_value(d->EG2InfiniteSustain);
1577     eEG2Sustain.set_value(d->EG2Sustain);
1578     eEG2Release.set_value(d->EG2Release);
1579     eEG2Controller.set_value(d->EG2Controller);
1580     eEG2ControllerInvert.set_value(d->EG2ControllerInvert);
1581     eEG2ControllerAttackInfluence.set_value(d->EG2ControllerAttackInfluence);
1582     eEG2ControllerDecayInfluence.set_value(d->EG2ControllerDecayInfluence);
1583     eEG2ControllerReleaseInfluence.set_value(d->EG2ControllerReleaseInfluence);
1584 schoenebeck 3329 eEG2StateOptions.checkBoxAttack.set_value(d->EG2Options.AttackCancel);
1585     eEG2StateOptions.checkBoxAttackHold.set_value(d->EG2Options.AttackHoldCancel);
1586     eEG2StateOptions.checkBoxDecay1.set_value(d->EG2Options.Decay1Cancel);
1587     eEG2StateOptions.checkBoxDecay2.set_value(d->EG2Options.Decay2Cancel);
1588     eEG2StateOptions.checkBoxRelease.set_value(d->EG2Options.ReleaseCancel);
1589 schoenebeck 3624 eLFO2Wave.set_value(d->LFO2WaveForm);
1590 persson 1460 eLFO2Frequency.set_value(d->LFO2Frequency);
1591 schoenebeck 3624 eLFO2Phase.set_value(d->LFO2Phase);
1592 persson 1460 eLFO2InternalDepth.set_value(d->LFO2InternalDepth);
1593     eLFO2ControlDepth.set_value(d->LFO2ControlDepth);
1594     eLFO2Controller.set_value(d->LFO2Controller);
1595     eLFO2FlipPhase.set_value(d->LFO2FlipPhase);
1596     eLFO2Sync.set_value(d->LFO2Sync);
1597     eEG3Attack.set_value(d->EG3Attack);
1598     eEG3Depth.set_value(d->EG3Depth);
1599 schoenebeck 3624 eLFO3Wave.set_value(d->LFO3WaveForm);
1600 persson 1460 eLFO3Frequency.set_value(d->LFO3Frequency);
1601 schoenebeck 3624 eLFO3Phase.set_value(d->LFO3Phase);
1602 persson 1460 eLFO3InternalDepth.set_value(d->LFO3InternalDepth);
1603     eLFO3ControlDepth.set_value(d->LFO3ControlDepth);
1604     eLFO3Controller.set_value(d->LFO3Controller);
1605 schoenebeck 3624 eLFO3FlipPhase.set_value(d->LFO3FlipPhase);
1606 persson 1460 eLFO3Sync.set_value(d->LFO3Sync);
1607     eVCFEnabled.set_value(d->VCFEnabled);
1608     eVCFType.set_value(d->VCFType);
1609     eVCFCutoffController.set_value(d->VCFCutoffController);
1610     eVCFCutoffControllerInvert.set_value(d->VCFCutoffControllerInvert);
1611     eVCFCutoff.set_value(d->VCFCutoff);
1612     eVCFVelocityCurve.set_value(d->VCFVelocityCurve);
1613     eVCFVelocityScale.set_value(d->VCFVelocityScale);
1614     eVCFVelocityDynamicRange.set_value(d->VCFVelocityDynamicRange);
1615     eVCFResonance.set_value(d->VCFResonance);
1616     eVCFResonanceDynamic.set_value(d->VCFResonanceDynamic);
1617     eVCFResonanceController.set_value(d->VCFResonanceController);
1618     eVCFKeyboardTracking.set_value(d->VCFKeyboardTracking);
1619     eVCFKeyboardTrackingBreakpoint.set_value(d->VCFKeyboardTrackingBreakpoint);
1620     eVelocityResponseCurve.set_value(d->VelocityResponseCurve);
1621     eVelocityResponseDepth.set_value(d->VelocityResponseDepth);
1622     eVelocityResponseCurveScaling.set_value(d->VelocityResponseCurveScaling);
1623     eReleaseVelocityResponseCurve.set_value(d->ReleaseVelocityResponseCurve);
1624     eReleaseVelocityResponseDepth.set_value(d->ReleaseVelocityResponseDepth);
1625     eReleaseTriggerDecay.set_value(d->ReleaseTriggerDecay);
1626     eCrossfade_in_start.set_value(d->Crossfade.in_start);
1627     eCrossfade_in_end.set_value(d->Crossfade.in_end);
1628     eCrossfade_out_start.set_value(d->Crossfade.out_start);
1629     eCrossfade_out_end.set_value(d->Crossfade.out_end);
1630     ePitchTrack.set_value(d->PitchTrack);
1631 schoenebeck 3449 eSustainReleaseTrigger.set_value(d->SustainReleaseTrigger);
1632     eNoNoteOffReleaseTrigger.set_value(d->NoNoteOffReleaseTrigger);
1633 persson 1460 eDimensionBypass.set_value(d->DimensionBypass);
1634     ePan.set_value(d->Pan);
1635     eSelfMask.set_value(d->SelfMask);
1636     eAttenuationController.set_value(d->AttenuationController);
1637     eInvertAttenuationController.set_value(d->InvertAttenuationController);
1638     eAttenuationControllerThreshold.set_value(d->AttenuationControllerThreshold);
1639     eChannelOffset.set_value(d->ChannelOffset);
1640     eSustainDefeat.set_value(d->SustainDefeat);
1641     eMSDecode.set_value(d->MSDecode);
1642     eSampleStartOffset.set_value(d->SampleStartOffset);
1643     eUnityNote.set_value(d->UnityNote);
1644 schoenebeck 2991 // show sample group name
1645     {
1646     Glib::ustring s = "---";
1647     if (d->pSample && d->pSample->GetGroup())
1648     s = d->pSample->GetGroup()->Name;
1649     eSampleGroup.text.set_text(s);
1650     }
1651 schoenebeck 2690 // assemble sample format info string
1652     {
1653     Glib::ustring s;
1654     if (d->pSample) {
1655     switch (d->pSample->Channels) {
1656     case 1: s = _("Mono"); break;
1657     case 2: s = _("Stereo"); break;
1658     default:
1659     s = ToString(d->pSample->Channels) + _(" audio channels");
1660     break;
1661     }
1662     s += " " + ToString(d->pSample->BitDepth) + " Bits";
1663     s += " " + ToString(d->pSample->SamplesPerSecond/1000) + "."
1664     + ToString((d->pSample->SamplesPerSecond%1000)/100) + " kHz";
1665     } else {
1666     s = _("No sample assigned to this dimension region.");
1667     }
1668     eSampleFormatInfo.text.set_text(s);
1669     }
1670     // generate sample's memory address pointer string
1671     {
1672     Glib::ustring s;
1673     if (d->pSample) {
1674     char buf[64] = {};
1675     snprintf(buf, sizeof(buf), "%p", d->pSample);
1676     s = buf;
1677     } else {
1678     s = "---";
1679     }
1680     eSampleID.text.set_text(s);
1681     }
1682 schoenebeck 2991 // generate raw wave form data CRC-32 checksum string
1683     {
1684     Glib::ustring s = "---";
1685     if (d->pSample) {
1686     char buf[64] = {};
1687     snprintf(buf, sizeof(buf), "%x", d->pSample->GetWaveDataCRC32Checksum());
1688     s = buf;
1689     }
1690     eChecksum.text.set_text(s);
1691     }
1692 schoenebeck 2691 buttonSelectSample.set_sensitive(d && d->pSample);
1693 persson 1460 eFineTune.set_value(d->FineTune);
1694     eGain.set_value(d->Gain);
1695     eSampleLoopEnabled.set_value(d->SampleLoops);
1696     eSampleLoopType.set_value(
1697     d->SampleLoops ? d->pSampleLoops[0].LoopType : 0);
1698     eSampleLoopStart.set_value(
1699     d->SampleLoops ? d->pSampleLoops[0].LoopStart : 0);
1700     eSampleLoopLength.set_value(
1701     d->SampleLoops ? d->pSampleLoops[0].LoopLength : 0);
1702     eSampleLoopInfinite.set_value(
1703     d->pSample && d->pSample->LoopPlayCount == 0);
1704     eSampleLoopPlayCount.set_value(
1705     d->pSample ? d->pSample->LoopPlayCount : 0);
1706     update_model--;
1707 persson 1261
1708 persson 2446 wSample->set_text(d->pSample ? gig_to_utf8(d->pSample->pInfo->Name) :
1709     _("NULL"));
1710 schoenebeck 1225
1711 schoenebeck 3737 scriptVars.setInstrument(
1712     (gig::Instrument*) d->GetParent()->GetParent()
1713     );
1714    
1715 persson 1460 update_loop_elements();
1716 schoenebeck 1225 VCFEnabled_toggled();
1717     }
1718    
1719 persson 1460
1720 schoenebeck 1225 void DimRegionEdit::VCFEnabled_toggled()
1721     {
1722 persson 1460 bool sensitive = eVCFEnabled.get_value();
1723 schoenebeck 1225 eVCFType.set_sensitive(sensitive);
1724     eVCFCutoffController.set_sensitive(sensitive);
1725     eVCFVelocityCurve.set_sensitive(sensitive);
1726     eVCFVelocityScale.set_sensitive(sensitive);
1727     eVCFVelocityDynamicRange.set_sensitive(sensitive);
1728 persson 2430 cutoff_curve.set_sensitive(sensitive);
1729 schoenebeck 1225 eVCFResonance.set_sensitive(sensitive);
1730     eVCFResonanceController.set_sensitive(sensitive);
1731     eVCFKeyboardTracking.set_sensitive(sensitive);
1732     eVCFKeyboardTrackingBreakpoint.set_sensitive(sensitive);
1733 persson 1623 lEG2->set_sensitive(sensitive);
1734 schoenebeck 1225 eEG2PreAttack.set_sensitive(sensitive);
1735     eEG2Attack.set_sensitive(sensitive);
1736     eEG2Decay1.set_sensitive(sensitive);
1737     eEG2InfiniteSustain.set_sensitive(sensitive);
1738     eEG2Sustain.set_sensitive(sensitive);
1739     eEG2Release.set_sensitive(sensitive);
1740     eEG2Controller.set_sensitive(sensitive);
1741     eEG2ControllerAttackInfluence.set_sensitive(sensitive);
1742     eEG2ControllerDecayInfluence.set_sensitive(sensitive);
1743     eEG2ControllerReleaseInfluence.set_sensitive(sensitive);
1744 schoenebeck 3329 eEG2StateOptions.set_sensitive(sensitive);
1745 persson 1623 lLFO2->set_sensitive(sensitive);
1746 schoenebeck 3624 eLFO2Wave.set_sensitive(sensitive);
1747 schoenebeck 1225 eLFO2Frequency.set_sensitive(sensitive);
1748 schoenebeck 3624 eLFO2Phase.set_sensitive(sensitive);
1749 schoenebeck 1225 eLFO2InternalDepth.set_sensitive(sensitive);
1750     eLFO2ControlDepth.set_sensitive(sensitive);
1751     eLFO2Controller.set_sensitive(sensitive);
1752     eLFO2FlipPhase.set_sensitive(sensitive);
1753     eLFO2Sync.set_sensitive(sensitive);
1754 schoenebeck 3619 lfo2Graph.set_sensitive(sensitive);
1755 schoenebeck 1225 if (sensitive) {
1756     VCFCutoffController_changed();
1757     VCFResonanceController_changed();
1758     EG2InfiniteSustain_toggled();
1759     EG2Controller_changed();
1760     LFO2Controller_changed();
1761     } else {
1762     eVCFCutoffControllerInvert.set_sensitive(false);
1763     eVCFCutoff.set_sensitive(false);
1764     eVCFResonanceDynamic.set_sensitive(false);
1765     eVCFResonance.set_sensitive(false);
1766     eEG2Decay2.set_sensitive(false);
1767     eEG2ControllerInvert.set_sensitive(false);
1768     eLFO2InternalDepth.set_sensitive(false);
1769     eLFO2ControlDepth.set_sensitive(false);
1770     }
1771     }
1772    
1773     void DimRegionEdit::VCFCutoffController_changed()
1774     {
1775 persson 1460 gig::vcf_cutoff_ctrl_t ctrl = eVCFCutoffController.get_value();
1776     bool hasController = ctrl != gig::vcf_cutoff_ctrl_none && ctrl != gig::vcf_cutoff_ctrl_none2;
1777 schoenebeck 1225
1778     eVCFCutoffControllerInvert.set_sensitive(hasController);
1779     eVCFCutoff.set_sensitive(!hasController);
1780     eVCFResonanceDynamic.set_sensitive(!hasController);
1781 persson 1831 eVCFVelocityScale.label.set_text(hasController ? _("Minimum cutoff:") :
1782     _("Velocity scale:"));
1783 schoenebeck 1225 }
1784    
1785     void DimRegionEdit::VCFResonanceController_changed()
1786     {
1787 persson 1460 bool hasController = eVCFResonanceController.get_value() != gig::vcf_res_ctrl_none;
1788 schoenebeck 1225 eVCFResonance.set_sensitive(!hasController);
1789     }
1790    
1791     void DimRegionEdit::EG1InfiniteSustain_toggled()
1792     {
1793 persson 1460 bool infSus = eEG1InfiniteSustain.get_value();
1794 schoenebeck 1225 eEG1Decay2.set_sensitive(!infSus);
1795     }
1796    
1797     void DimRegionEdit::EG2InfiniteSustain_toggled()
1798     {
1799 persson 1460 bool infSus = eEG2InfiniteSustain.get_value();
1800 schoenebeck 1225 eEG2Decay2.set_sensitive(!infSus);
1801     }
1802    
1803     void DimRegionEdit::EG1Controller_changed()
1804     {
1805 persson 1460 bool hasController = eEG1Controller.get_value().type != gig::leverage_ctrl_t::type_none;
1806 schoenebeck 1225 eEG1ControllerInvert.set_sensitive(hasController);
1807     }
1808    
1809     void DimRegionEdit::EG2Controller_changed()
1810     {
1811 persson 1460 bool hasController = eEG2Controller.get_value().type != gig::leverage_ctrl_t::type_none;
1812 schoenebeck 1225 eEG2ControllerInvert.set_sensitive(hasController);
1813     }
1814    
1815     void DimRegionEdit::AttenuationController_changed()
1816     {
1817 persson 1460 bool hasController =
1818     eAttenuationController.get_value().type != gig::leverage_ctrl_t::type_none;
1819 schoenebeck 1225 eInvertAttenuationController.set_sensitive(hasController);
1820     eAttenuationControllerThreshold.set_sensitive(hasController);
1821     eCrossfade_in_start.set_sensitive(hasController);
1822     eCrossfade_in_end.set_sensitive(hasController);
1823     eCrossfade_out_start.set_sensitive(hasController);
1824     eCrossfade_out_end.set_sensitive(hasController);
1825 persson 2430 crossfade_curve.set_sensitive(hasController);
1826 schoenebeck 1225 }
1827    
1828     void DimRegionEdit::LFO1Controller_changed()
1829     {
1830 persson 1460 gig::lfo1_ctrl_t ctrl = eLFO1Controller.get_value();
1831     eLFO1ControlDepth.set_sensitive(ctrl != gig::lfo1_ctrl_internal);
1832     eLFO1InternalDepth.set_sensitive(ctrl != gig::lfo1_ctrl_modwheel &&
1833     ctrl != gig::lfo1_ctrl_breath);
1834 schoenebeck 1225 }
1835    
1836     void DimRegionEdit::LFO2Controller_changed()
1837     {
1838 persson 1460 gig::lfo2_ctrl_t ctrl = eLFO2Controller.get_value();
1839     eLFO2ControlDepth.set_sensitive(ctrl != gig::lfo2_ctrl_internal);
1840     eLFO2InternalDepth.set_sensitive(ctrl != gig::lfo2_ctrl_modwheel &&
1841     ctrl != gig::lfo2_ctrl_foot);
1842 schoenebeck 1225 }
1843    
1844     void DimRegionEdit::LFO3Controller_changed()
1845     {
1846 persson 1460 gig::lfo3_ctrl_t ctrl = eLFO3Controller.get_value();
1847     eLFO3ControlDepth.set_sensitive(ctrl != gig::lfo3_ctrl_internal);
1848     eLFO3InternalDepth.set_sensitive(ctrl != gig::lfo3_ctrl_modwheel &&
1849     ctrl != gig::lfo3_ctrl_aftertouch);
1850 schoenebeck 1225 }
1851    
1852     void DimRegionEdit::crossfade1_changed()
1853     {
1854 persson 1460 update_model++;
1855     eCrossfade_in_end.set_value(dimregion->Crossfade.in_end);
1856     eCrossfade_out_start.set_value(dimregion->Crossfade.out_start);
1857     eCrossfade_out_end.set_value(dimregion->Crossfade.out_end);
1858     update_model--;
1859 schoenebeck 1225 }
1860    
1861     void DimRegionEdit::crossfade2_changed()
1862     {
1863 persson 1460 update_model++;
1864     eCrossfade_in_start.set_value(dimregion->Crossfade.in_start);
1865     eCrossfade_out_start.set_value(dimregion->Crossfade.out_start);
1866     eCrossfade_out_end.set_value(dimregion->Crossfade.out_end);
1867     update_model--;
1868 schoenebeck 1225 }
1869    
1870     void DimRegionEdit::crossfade3_changed()
1871     {
1872 persson 1460 update_model++;
1873     eCrossfade_in_start.set_value(dimregion->Crossfade.in_start);
1874     eCrossfade_in_end.set_value(dimregion->Crossfade.in_end);
1875     eCrossfade_out_end.set_value(dimregion->Crossfade.out_end);
1876     update_model--;
1877 schoenebeck 1225 }
1878    
1879     void DimRegionEdit::crossfade4_changed()
1880     {
1881 persson 1460 update_model++;
1882     eCrossfade_in_start.set_value(dimregion->Crossfade.in_start);
1883     eCrossfade_in_end.set_value(dimregion->Crossfade.in_end);
1884     eCrossfade_out_start.set_value(dimregion->Crossfade.out_start);
1885     update_model--;
1886 schoenebeck 1225 }
1887    
1888 persson 1460 void DimRegionEdit::update_loop_elements()
1889 schoenebeck 1225 {
1890 persson 1460 update_model++;
1891     const bool active = eSampleLoopEnabled.get_value();
1892 schoenebeck 1225 eSampleLoopStart.set_sensitive(active);
1893     eSampleLoopLength.set_sensitive(active);
1894     eSampleLoopType.set_sensitive(active);
1895 persson 1303 eSampleLoopInfinite.set_sensitive(active && dimregion && dimregion->pSample);
1896 persson 1460 // sample loop shall never be longer than the actual sample size
1897     loop_start_changed();
1898     loop_length_changed();
1899     eSampleLoopStart.set_value(
1900     dimregion->SampleLoops ? dimregion->pSampleLoops[0].LoopStart : 0);
1901     eSampleLoopLength.set_value(
1902     dimregion->SampleLoops ? dimregion->pSampleLoops[0].LoopLength : 0);
1903 persson 1261
1904 persson 1460 eSampleLoopInfinite.set_value(
1905     dimregion->pSample && dimregion->pSample->LoopPlayCount == 0);
1906 persson 1261
1907 persson 1460 loop_infinite_toggled();
1908     update_model--;
1909     }
1910 persson 1261
1911 persson 1460 void DimRegionEdit::loop_start_changed() {
1912     if (dimregion && dimregion->SampleLoops) {
1913     eSampleLoopLength.set_upper(dimregion->pSample ?
1914     dimregion->pSample->SamplesTotal -
1915     dimregion->pSampleLoops[0].LoopStart : 0);
1916 schoenebeck 1225 }
1917     }
1918    
1919 persson 1460 void DimRegionEdit::loop_length_changed() {
1920     if (dimregion && dimregion->SampleLoops) {
1921     eSampleLoopStart.set_upper(dimregion->pSample ?
1922     dimregion->pSample->SamplesTotal -
1923     dimregion->pSampleLoops[0].LoopLength : 0);
1924     }
1925     }
1926    
1927 schoenebeck 1225 void DimRegionEdit::loop_infinite_toggled() {
1928     eSampleLoopPlayCount.set_sensitive(
1929 persson 1303 dimregion && dimregion->pSample &&
1930 persson 1460 !eSampleLoopInfinite.get_value() &&
1931     eSampleLoopEnabled.get_value()
1932 schoenebeck 1225 );
1933 persson 1460 update_model++;
1934     eSampleLoopPlayCount.set_value(
1935     dimregion->pSample ? dimregion->pSample->LoopPlayCount : 0);
1936     update_model--;
1937 schoenebeck 1225 }
1938 persson 1265
1939 schoenebeck 2464 bool DimRegionEdit::set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop)
1940 persson 1265 {
1941 schoenebeck 3070 bool result = false;
1942 schoenebeck 2925 for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimregs.begin();
1943     itDimReg != dimregs.end(); ++itDimReg)
1944     {
1945 schoenebeck 3070 result |= set_sample(*itDimReg, sample, copy_sample_unity, copy_sample_tune, copy_sample_loop);
1946 schoenebeck 2925 }
1947 schoenebeck 3070 return result;
1948 schoenebeck 2925 }
1949    
1950     bool DimRegionEdit::set_sample(gig::DimensionRegion* dimreg, gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop)
1951     {
1952 schoenebeck 2926 if (dimreg) {
1953 schoenebeck 1322 //TODO: we should better move the code from MainWindow::on_sample_label_drop_drag_data_received() here
1954    
1955     // currently commented because we're sending a similar signal in MainWindow::on_sample_label_drop_drag_data_received()
1956 schoenebeck 3177 //DimRegionChangeGuard(this, dimregion);
1957 schoenebeck 1322
1958 persson 1798 // make sure stereo samples always are the same in both
1959     // dimregs in the samplechannel dimension
1960     int nbDimregs = 1;
1961 schoenebeck 2926 gig::DimensionRegion* d[2] = { dimreg, 0 };
1962 persson 1798 if (sample->Channels == 2) {
1963 schoenebeck 2926 gig::Region* region = dimreg->GetParent();
1964 persson 1798
1965     int bitcount = 0;
1966     int stereo_bit = 0;
1967     for (int dim = 0 ; dim < region->Dimensions ; dim++) {
1968     if (region->pDimensionDefinitions[dim].dimension == gig::dimension_samplechannel) {
1969     stereo_bit = 1 << bitcount;
1970     break;
1971     }
1972     bitcount += region->pDimensionDefinitions[dim].bits;
1973     }
1974    
1975     if (stereo_bit) {
1976     int dimregno;
1977     for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
1978 schoenebeck 2926 if (region->pDimensionRegions[dimregno] == dimreg) {
1979 persson 1798 break;
1980     }
1981     }
1982     d[0] = region->pDimensionRegions[dimregno & ~stereo_bit];
1983     d[1] = region->pDimensionRegions[dimregno | stereo_bit];
1984     nbDimregs = 2;
1985     }
1986     }
1987    
1988 schoenebeck 2926 gig::Sample* oldref = dimreg->pSample;
1989 persson 1265
1990 persson 1798 for (int i = 0 ; i < nbDimregs ; i++) {
1991     d[i]->pSample = sample;
1992 persson 1265
1993 persson 1798 // copy sample information from Sample to DimensionRegion
1994 schoenebeck 2464 if (copy_sample_unity)
1995     d[i]->UnityNote = sample->MIDIUnityNote;
1996     if (copy_sample_tune)
1997     d[i]->FineTune = sample->FineTune;
1998     if (copy_sample_loop) {
1999     int loops = sample->Loops ? 1 : 0;
2000     while (d[i]->SampleLoops > loops) {
2001     d[i]->DeleteSampleLoop(&d[i]->pSampleLoops[0]);
2002     }
2003     while (d[i]->SampleLoops < sample->Loops) {
2004     DLS::sample_loop_t loop;
2005     d[i]->AddSampleLoop(&loop);
2006     }
2007     if (loops) {
2008     d[i]->pSampleLoops[0].Size = sizeof(DLS::sample_loop_t);
2009     d[i]->pSampleLoops[0].LoopType = sample->LoopType;
2010     d[i]->pSampleLoops[0].LoopStart = sample->LoopStart;
2011     d[i]->pSampleLoops[0].LoopLength = sample->LoopEnd - sample->LoopStart + 1;
2012     }
2013 persson 1798 }
2014 persson 1265 }
2015    
2016     // update ui
2017 persson 1460 update_model++;
2018 schoenebeck 2926 wSample->set_text(gig_to_utf8(dimreg->pSample->pInfo->Name));
2019     eUnityNote.set_value(dimreg->UnityNote);
2020     eFineTune.set_value(dimreg->FineTune);
2021     eSampleLoopEnabled.set_value(dimreg->SampleLoops);
2022 persson 1460 update_loop_elements();
2023     update_model--;
2024 persson 1265
2025 schoenebeck 1322 sample_ref_changed_signal.emit(oldref, sample);
2026 persson 1265 return true;
2027     }
2028     return false;
2029     }
2030 schoenebeck 1322
2031 schoenebeck 1339 sigc::signal<void, gig::DimensionRegion*>& DimRegionEdit::signal_dimreg_to_be_changed() {
2032 schoenebeck 1322 return dimreg_to_be_changed_signal;
2033     }
2034    
2035 schoenebeck 1339 sigc::signal<void, gig::DimensionRegion*>& DimRegionEdit::signal_dimreg_changed() {
2036 schoenebeck 1322 return dimreg_changed_signal;
2037     }
2038    
2039 schoenebeck 1339 sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& DimRegionEdit::signal_sample_ref_changed() {
2040 schoenebeck 1322 return sample_ref_changed_signal;
2041     }
2042 persson 1460
2043    
2044 persson 3461 void DimRegionEdit::set_UnityNote(gig::DimensionRegion& d, uint8_t value)
2045 persson 1460 {
2046 persson 3461 d.UnityNote = value;
2047 persson 1460 }
2048    
2049 persson 3461 void DimRegionEdit::set_FineTune(gig::DimensionRegion& d, int16_t value)
2050 persson 1460 {
2051 persson 3461 d.FineTune = value;
2052 persson 1460 }
2053    
2054 persson 3461 void DimRegionEdit::set_Crossfade_in_start(gig::DimensionRegion& d,
2055 persson 1460 uint8_t value)
2056     {
2057 persson 3461 d.Crossfade.in_start = value;
2058     if (d.Crossfade.in_end < value) set_Crossfade_in_end(d, value);
2059 persson 1460 }
2060    
2061 persson 3461 void DimRegionEdit::set_Crossfade_in_end(gig::DimensionRegion& d,
2062 persson 1460 uint8_t value)
2063     {
2064 persson 3461 d.Crossfade.in_end = value;
2065     if (value < d.Crossfade.in_start) set_Crossfade_in_start(d, value);
2066     if (value > d.Crossfade.out_start) set_Crossfade_out_start(d, value);
2067 persson 1460 }
2068    
2069 persson 3461 void DimRegionEdit::set_Crossfade_out_start(gig::DimensionRegion& d,
2070 persson 1460 uint8_t value)
2071     {
2072 persson 3461 d.Crossfade.out_start = value;
2073     if (value < d.Crossfade.in_end) set_Crossfade_in_end(d, value);
2074     if (value > d.Crossfade.out_end) set_Crossfade_out_end(d, value);
2075 persson 1460 }
2076    
2077 persson 3461 void DimRegionEdit::set_Crossfade_out_end(gig::DimensionRegion& d,
2078 persson 1460 uint8_t value)
2079     {
2080 persson 3461 d.Crossfade.out_end = value;
2081     if (value < d.Crossfade.out_start) set_Crossfade_out_start(d, value);
2082 persson 1460 }
2083    
2084 persson 3461 void DimRegionEdit::set_Gain(gig::DimensionRegion& d, int32_t value)
2085 persson 1460 {
2086 persson 3461 d.SetGain(value);
2087 persson 1460 }
2088    
2089 persson 3461 void DimRegionEdit::set_LoopEnabled(gig::DimensionRegion& d, bool value)
2090 persson 1460 {
2091     if (value) {
2092     // create a new sample loop in case there is none yet
2093 persson 3461 if (!d.SampleLoops) {
2094     DimRegionChangeGuard(this, &d);
2095 schoenebeck 3177
2096 persson 1460 DLS::sample_loop_t loop;
2097     loop.LoopType = gig::loop_type_normal;
2098     // loop the whole sample by default
2099     loop.LoopStart = 0;
2100     loop.LoopLength =
2101 persson 3461 (d.pSample) ? d.pSample->SamplesTotal : 0;
2102     d.AddSampleLoop(&loop);
2103 persson 1460 }
2104     } else {
2105 persson 3461 if (d.SampleLoops) {
2106     DimRegionChangeGuard(this, &d);
2107 schoenebeck 3177
2108 persson 1460 // delete ALL existing sample loops
2109 persson 3461 while (d.SampleLoops) {
2110     d.DeleteSampleLoop(&d.pSampleLoops[0]);
2111 persson 1460 }
2112     }
2113     }
2114     }
2115    
2116 persson 3461 void DimRegionEdit::set_LoopType(gig::DimensionRegion& d, uint32_t value)
2117 persson 1460 {
2118 persson 3461 if (d.SampleLoops) d.pSampleLoops[0].LoopType = value;
2119 persson 1460 }
2120    
2121 persson 3461 void DimRegionEdit::set_LoopStart(gig::DimensionRegion& d, uint32_t value)
2122 persson 1460 {
2123 persson 3461 if (d.SampleLoops) {
2124     d.pSampleLoops[0].LoopStart =
2125     d.pSample ?
2126     std::min(value, uint32_t(d.pSample->SamplesTotal -
2127     d.pSampleLoops[0].LoopLength)) :
2128 persson 1460 0;
2129     }
2130     }
2131    
2132 persson 3461 void DimRegionEdit::set_LoopLength(gig::DimensionRegion& d, uint32_t value)
2133 persson 1460 {
2134 persson 3461 if (d.SampleLoops) {
2135     d.pSampleLoops[0].LoopLength =
2136     d.pSample ?
2137     std::min(value, uint32_t(d.pSample->SamplesTotal -
2138     d.pSampleLoops[0].LoopStart)) :
2139 persson 1460 0;
2140     }
2141     }
2142    
2143 persson 3461 void DimRegionEdit::set_LoopInfinite(gig::DimensionRegion& d, bool value)
2144 persson 1460 {
2145 persson 3461 if (d.pSample) {
2146     if (value) d.pSample->LoopPlayCount = 0;
2147     else if (d.pSample->LoopPlayCount == 0) d.pSample->LoopPlayCount = 1;
2148 persson 1460 }
2149     }
2150    
2151 persson 3461 void DimRegionEdit::set_LoopPlayCount(gig::DimensionRegion& d, uint32_t value)
2152 persson 1460 {
2153 persson 3461 if (d.pSample) d.pSample->LoopPlayCount = value;
2154 persson 1460 }
2155 schoenebeck 2691
2156 schoenebeck 2720 void DimRegionEdit::nullOutSampleReference() {
2157     if (!dimregion) return;
2158     gig::Sample* oldref = dimregion->pSample;
2159     if (!oldref) return;
2160    
2161 schoenebeck 3177 DimRegionChangeGuard(this, dimregion);
2162 schoenebeck 2720
2163     // in case currently assigned sample is a stereo one, then remove both
2164     // references (expected to be due to a "stereo dimension")
2165     gig::DimensionRegion* d[2] = { dimregion, NULL };
2166     if (oldref->Channels == 2) {
2167     gig::Region* region = dimregion->GetParent();
2168     {
2169 persson 2841 int stereo_bit = 0;
2170 schoenebeck 2720 int bitcount = 0;
2171     for (int dim = 0 ; dim < region->Dimensions ; dim++) {
2172     if (region->pDimensionDefinitions[dim].dimension == gig::dimension_samplechannel) {
2173     stereo_bit = 1 << bitcount;
2174     break;
2175     }
2176     bitcount += region->pDimensionDefinitions[dim].bits;
2177     }
2178    
2179     if (stereo_bit) {
2180     int dimregno;
2181     for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
2182     if (region->pDimensionRegions[dimregno] == dimregion) {
2183     break;
2184     }
2185     }
2186     d[0] = region->pDimensionRegions[dimregno & ~stereo_bit