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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3632 - (show annotations) (download)
Wed Oct 16 17:56:41 2019 UTC (4 years, 6 months ago) by schoenebeck
File size: 82344 byte(s)
* Fixed LFO curve previews not being redrawn on UI control changes with
  certain window managers and/or Gtk versions (patch by Ivan Maguidhir).

* Bumped version (1.1.1.svn4).

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

  ViewVC Help
Powered by ViewVC