/[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 3738 - (show annotations) (download)
Mon Feb 3 18:47:02 2020 UTC (19 months, 3 weeks ago) by schoenebeck
File size: 84956 byte(s)
* Use more appropriate stepping/paging increments/decrements for spinboxes'
  plus/minus buttons (depending on the individual parameter spinbutton
  actually controls).

* Bumped version (1.1.1.svn15).

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

  ViewVC Help
Powered by ViewVC