/[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 1359 - (show annotations) (download)
Sun Sep 30 18:30:52 2007 UTC (12 years, 2 months ago) by schoenebeck
File size: 37699 byte(s)
* fixed couple other parameters which were silently ignored by the sampler
  on a live-editing session with LS (parameter "Gain" and various velocity
  response parameters for attenuation, filter cutoff frequency and EG
  release time)

1 /*
2 * Copyright (C) 2006, 2007 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 "dimregionedit.h"
21
22 #include <libintl.h>
23 #define _(String) gettext(String)
24
25 DimRegionEdit::DimRegionEdit() :
26 eEG1PreAttack("Pre-attack", 0, 100, 2),
27 eEG1Attack("Attack", 0, 60, 3),
28 eEG1Decay1("Decay 1", 0.005, 60, 3),
29 eEG1Decay2("Decay 2", 0, 60, 3),
30 eEG1InfiniteSustain("Infinite sustain"),
31 eEG1Sustain("Sustain", 0, 100, 2),
32 eEG1Release("Release", 0, 60, 3),
33 eEG1Hold("Hold"),
34 eEG1Controller("Controller"),
35 eEG1ControllerInvert("Controller invert"),
36 eEG1ControllerAttackInfluence("Controller attack influence", 0, 3),
37 eEG1ControllerDecayInfluence("Controller decay influence", 0, 3),
38 eEG1ControllerReleaseInfluence("Controller release influence", 0, 3),
39 eLFO1Frequency("Frequency", 0.1, 10, 2),
40 eLFO1InternalDepth("Internal depth", 0, 1200),
41 eLFO1ControlDepth("Control depth", 0, 1200),
42 eLFO1Controller("Controller"),
43 eLFO1FlipPhase("Flip phase"),
44 eLFO1Sync("Sync"),
45 eEG2PreAttack("Pre-attack", 0, 100, 2),
46 eEG2Attack("Attack", 0, 60, 3),
47 eEG2Decay1("Decay 1", 0.005, 60, 3),
48 eEG2Decay2("Decay 2", 0, 60, 3),
49 eEG2InfiniteSustain("Infinite sustain"),
50 eEG2Sustain("Sustain", 0, 100, 2),
51 eEG2Release("Release", 0, 60, 3),
52 eEG2Controller("Controller"),
53 eEG2ControllerInvert("Controller invert"),
54 eEG2ControllerAttackInfluence("Controller attack influence", 0, 3),
55 eEG2ControllerDecayInfluence("Controller decay influence", 0, 3),
56 eEG2ControllerReleaseInfluence("Controller release influence", 0, 3),
57 eLFO2Frequency("Frequency", 0.1, 10, 2),
58 eLFO2InternalDepth("Internal depth", 0, 1200),
59 eLFO2ControlDepth("Control depth", 0, 1200),
60 eLFO2Controller("Controller"),
61 eLFO2FlipPhase("Flip phase"),
62 eLFO2Sync("Sync"),
63 eEG3Attack("Attack", 0, 10, 3),
64 eEG3Depth("Depth", -1200, 1200),
65 eLFO3Frequency("Frequency", 0.1, 10, 2),
66 eLFO3InternalDepth("Internal depth", 0, 1200),
67 eLFO3ControlDepth("Control depth", 0, 1200),
68 eLFO3Controller("Controller"),
69 eLFO3Sync("Sync"),
70 eVCFEnabled("Enabled"),
71 eVCFType("Type"),
72 eVCFCutoffController("Cutoff controller"),
73 eVCFCutoffControllerInvert("Cutoff controller invert"),
74 eVCFCutoff("Cutoff"),
75 eVCFVelocityCurve("Velocity curve"),
76 eVCFVelocityScale("Velocity scale"),
77 eVCFVelocityDynamicRange("Velocity dynamic range", 0, 4),
78 eVCFResonance("Resonance"),
79 eVCFResonanceDynamic("Resonance dynamic"),
80 eVCFResonanceController("Resonance controller"),
81 eVCFKeyboardTracking("Keyboard tracking"),
82 eVCFKeyboardTrackingBreakpoint("Keyboard tracking breakpoint"),
83 eVelocityResponseCurve("Velocity response curve"),
84 eVelocityResponseDepth("Velocity response depth", 0, 4),
85 eVelocityResponseCurveScaling("Velocity response curve scaling"),
86 eReleaseVelocityResponseCurve("Release velocity response curve"),
87 eReleaseVelocityResponseDepth("Release velocity response depth", 0, 4),
88 eReleaseTriggerDecay("Release trigger decay", 0, 8),
89 eCrossfade_in_start("Crossfade-in start"),
90 eCrossfade_in_end("Crossfade-in end"),
91 eCrossfade_out_start("Crossfade-out start"),
92 eCrossfade_out_end("Crossfade-out end"),
93 ePitchTrack("Pitch track"),
94 eDimensionBypass("Dimension bypass"),
95 ePan("Pan", -64, 63),
96 eSelfMask("Self mask"),
97 eAttenuationController("Attenuation controller"),
98 eInvertAttenuationController("Invert attenuation controller"),
99 eAttenuationControllerThreshold("Attenuation controller threshold"),
100 eChannelOffset("Channel offset", 0, 9),
101 eSustainDefeat("Sustain defeat"),
102 eMSDecode("MS decode"),
103 eSampleStartOffset("Sample start offset", 0, 2000),
104 eUnityNote("Unity note"),
105 eFineTune("Fine tune", -49, 50),
106 eGain("Gain", -96, 0, 2, -655360),
107 eGainPlus6("Gain +6dB", eGain, 6 * -655360),
108 eSampleLoopEnabled("Enabled"),
109 eSampleLoopStart("Loop start positon"),
110 eSampleLoopLength("Loop size"),
111 eSampleLoopType("Loop type"),
112 eSampleLoopInfinite("Infinite loop"),
113 eSampleLoopPlayCount("Playback count")
114 {
115 for (int i = 0 ; i < 7 ; i++) {
116 table[i] = new Gtk::Table(3, 1);
117 table[i]->set_col_spacings(7);
118 }
119
120 // set tooltips
121 eUnityNote.set_tip(
122 _("Note this sample is associated with (a.k.a. 'root note')")
123 );
124 eSampleStartOffset.set_tip(_("Sample position at which playback should be started"));
125 ePan.set_tip(_("Stereo balance (left/right)"));
126 eChannelOffset.set_tip(
127 _("Output channel where the audio signal should be routed to (0 - 9)")
128 );
129 ePitchTrack.set_tip(
130 _("If true: sample will be pitched according to the key position "
131 "(this would be disabled for drums for example)")
132 );
133 eSampleLoopEnabled.set_tip(_("If enabled: repeats to playback the sample"));
134 eSampleLoopStart.set_tip(
135 _("Start position within the sample (in sample points) of the area to "
136 "be looped")
137 );
138 eSampleLoopLength.set_tip(
139 _("Duration (in sample points) of the area to be looped")
140 );
141 eSampleLoopType.set_tip(
142 _("Direction in which the loop area in the sample should be played back")
143 );
144 eSampleLoopInfinite.set_tip(
145 _("Whether the loop area should be played back forever\n"
146 "Caution: this setting is stored on Sample side, thus is shared "
147 "among all dimension regions that use this sample!")
148 );
149 eSampleLoopPlayCount.set_tip(
150 _("How many times the loop area should be played back\n"
151 "Caution: this setting is stored on Sample side, thus is shared "
152 "among all dimension regions that use this sample!")
153 );
154
155 pageno = 0;
156 rowno = 0;
157 firstRowInBlock = 0;
158
159 addHeader(_("Mandatory Settings"));
160 addString("Sample", lSample, wSample);
161 //TODO: the following would break drag&drop: wSample->property_editable().set_value(false); or this: wSample->set_editable(false);
162 tooltips.set_tip(*wSample, _("Drop a sample here"));
163 addProp(eUnityNote);
164 addHeader(_("Optional Settings"));
165 addProp(eSampleStartOffset);
166 addProp(eChannelOffset);
167 addHeader("Loops");
168 addProp(eSampleLoopEnabled);
169 addProp(eSampleLoopStart);
170 addProp(eSampleLoopLength);
171 {
172 const char* choices[] = { "normal", "bidirectional", "backward", 0 };
173 static const uint32_t values[] = {
174 gig::loop_type_normal,
175 gig::loop_type_bidirectional,
176 gig::loop_type_backward
177 };
178 eSampleLoopType.set_choices(choices, values);
179 }
180 addProp(eSampleLoopType);
181 addProp(eSampleLoopInfinite);
182 addProp(eSampleLoopPlayCount);
183
184 nextPage();
185
186 addHeader(_("General Amplitude Settings"));
187 addProp(eGain);
188 addProp(eGainPlus6);
189 addProp(ePan);
190 addHeader(_("Amplitude Envelope (EG1)"));
191 addProp(eEG1PreAttack);
192 addProp(eEG1Attack);
193 addProp(eEG1Decay1);
194 addProp(eEG1Decay2);
195 addProp(eEG1InfiniteSustain);
196 addProp(eEG1Sustain);
197 addProp(eEG1Release);
198 addProp(eEG1Hold);
199 addProp(eEG1Controller);
200 addProp(eEG1ControllerInvert);
201 addProp(eEG1ControllerAttackInfluence);
202 addProp(eEG1ControllerDecayInfluence);
203 addProp(eEG1ControllerReleaseInfluence);
204
205 nextPage();
206
207 addHeader(_("Amplitude Oscillator (LFO1)"));
208 addProp(eLFO1Frequency);
209 addProp(eLFO1InternalDepth);
210 addProp(eLFO1ControlDepth);
211 {
212 const char* choices[] = { "internal", "modwheel", "breath",
213 "internal+modwheel", "internal+breath", 0 };
214 static const gig::lfo1_ctrl_t values[] = {
215 gig::lfo1_ctrl_internal,
216 gig::lfo1_ctrl_modwheel,
217 gig::lfo1_ctrl_breath,
218 gig::lfo1_ctrl_internal_modwheel,
219 gig::lfo1_ctrl_internal_breath
220 };
221 eLFO1Controller.set_choices(choices, values);
222 }
223 addProp(eLFO1Controller);
224 addProp(eLFO1FlipPhase);
225 addProp(eLFO1Sync);
226 addHeader("Crossfade");
227 addProp(eAttenuationController);
228 addProp(eInvertAttenuationController);
229 addProp(eAttenuationControllerThreshold);
230 addProp(eCrossfade_in_start);
231 addProp(eCrossfade_in_end);
232 addProp(eCrossfade_out_start);
233 addProp(eCrossfade_out_end);
234
235 nextPage();
236
237 addHeader(_("General Filter Settings"));
238 addProp(eVCFEnabled);
239 {
240 const char* choices[] = { "lowpass", "lowpassturbo", "bandpass",
241 "highpass", "bandreject", 0 };
242 static const gig::vcf_type_t values[] = {
243 gig::vcf_type_lowpass,
244 gig::vcf_type_lowpassturbo,
245 gig::vcf_type_bandpass,
246 gig::vcf_type_highpass,
247 gig::vcf_type_bandreject
248 };
249 eVCFType.set_choices(choices, values);
250 }
251 addProp(eVCFType);
252 {
253 const char* choices[] = { "none", "none2", "modwheel", "effect1", "effect2",
254 "breath", "foot", "sustainpedal", "softpedal",
255 "genpurpose7", "genpurpose8", "aftertouch", 0 };
256 static const gig::vcf_cutoff_ctrl_t values[] = {
257 gig::vcf_cutoff_ctrl_none,
258 gig::vcf_cutoff_ctrl_none2,
259 gig::vcf_cutoff_ctrl_modwheel,
260 gig::vcf_cutoff_ctrl_effect1,
261 gig::vcf_cutoff_ctrl_effect2,
262 gig::vcf_cutoff_ctrl_breath,
263 gig::vcf_cutoff_ctrl_foot,
264 gig::vcf_cutoff_ctrl_sustainpedal,
265 gig::vcf_cutoff_ctrl_softpedal,
266 gig::vcf_cutoff_ctrl_genpurpose7,
267 gig::vcf_cutoff_ctrl_genpurpose8,
268 gig::vcf_cutoff_ctrl_aftertouch
269 };
270 eVCFCutoffController.set_choices(choices, values);
271 }
272 addProp(eVCFCutoffController);
273 addProp(eVCFCutoffControllerInvert);
274 addProp(eVCFCutoff);
275 const char* curve_type_texts[] = { "nonlinear", "linear", "special", 0 };
276 static const gig::curve_type_t curve_type_values[] = {
277 gig::curve_type_nonlinear,
278 gig::curve_type_linear,
279 gig::curve_type_special
280 };
281 eVCFVelocityCurve.set_choices(curve_type_texts, curve_type_values);
282 addProp(eVCFVelocityCurve);
283 addProp(eVCFVelocityScale);
284 addProp(eVCFVelocityDynamicRange);
285 addProp(eVCFResonance);
286 addProp(eVCFResonanceDynamic);
287 {
288 const char* choices[] = { "none", "genpurpose3", "genpurpose4",
289 "genpurpose5", "genpurpose6", 0 };
290 static const gig::vcf_res_ctrl_t values[] = {
291 gig::vcf_res_ctrl_none,
292 gig::vcf_res_ctrl_genpurpose3,
293 gig::vcf_res_ctrl_genpurpose4,
294 gig::vcf_res_ctrl_genpurpose5,
295 gig::vcf_res_ctrl_genpurpose6
296 };
297 eVCFResonanceController.set_choices(choices, values);
298 }
299 addProp(eVCFResonanceController);
300 addProp(eVCFKeyboardTracking);
301 addProp(eVCFKeyboardTrackingBreakpoint);
302
303 nextPage();
304
305 addHeader(_("Filter Cutoff Envelope (EG2)"));
306 addProp(eEG2PreAttack);
307 addProp(eEG2Attack);
308 addProp(eEG2Decay1);
309 addProp(eEG2Decay2);
310 addProp(eEG2InfiniteSustain);
311 addProp(eEG2Sustain);
312 addProp(eEG2Release);
313 addProp(eEG2Controller);
314 addProp(eEG2ControllerInvert);
315 addProp(eEG2ControllerAttackInfluence);
316 addProp(eEG2ControllerDecayInfluence);
317 addProp(eEG2ControllerReleaseInfluence);
318 addHeader(_("Filter Cutoff Oscillator (LFO2)"));
319 addProp(eLFO2Frequency);
320 addProp(eLFO2InternalDepth);
321 addProp(eLFO2ControlDepth);
322 {
323 const char* choices[] = { "internal", "modwheel", "foot",
324 "internal+modwheel", "internal+foot", 0 };
325 static const gig::lfo2_ctrl_t values[] = {
326 gig::lfo2_ctrl_internal,
327 gig::lfo2_ctrl_modwheel,
328 gig::lfo2_ctrl_foot,
329 gig::lfo2_ctrl_internal_modwheel,
330 gig::lfo2_ctrl_internal_foot
331 };
332 eLFO2Controller.set_choices(choices, values);
333 }
334 addProp(eLFO2Controller);
335 addProp(eLFO2FlipPhase);
336 addProp(eLFO2Sync);
337
338 nextPage();
339
340 addHeader(_("General Pitch Settings"));
341 addProp(eFineTune);
342 addProp(ePitchTrack);
343 addHeader(_("Pitch Envelope (EG3)"));
344 addProp(eEG3Attack);
345 addProp(eEG3Depth);
346 addHeader(_("Pitch Oscillator (LFO3)"));
347 addProp(eLFO3Frequency);
348 addProp(eLFO3InternalDepth);
349 addProp(eLFO3ControlDepth);
350 {
351 const char* choices[] = { "internal", "modwheel", "aftertouch",
352 "internal+modwheel", "internal+aftertouch", 0 };
353 static const gig::lfo3_ctrl_t values[] = {
354 gig::lfo3_ctrl_internal,
355 gig::lfo3_ctrl_modwheel,
356 gig::lfo3_ctrl_aftertouch,
357 gig::lfo3_ctrl_internal_modwheel,
358 gig::lfo3_ctrl_internal_aftertouch
359 };
360 eLFO3Controller.set_choices(choices, values);
361 }
362 addProp(eLFO3Controller);
363 addProp(eLFO3Sync);
364
365 nextPage();
366
367 eVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values);
368 addProp(eVelocityResponseCurve);
369 addProp(eVelocityResponseDepth);
370 addProp(eVelocityResponseCurveScaling);
371 eReleaseVelocityResponseCurve.set_choices(curve_type_texts,
372 curve_type_values);
373 addProp(eReleaseVelocityResponseCurve);
374 addProp(eReleaseVelocityResponseDepth);
375 addProp(eReleaseTriggerDecay);
376 {
377 const char* choices[] = { "none", "effect4depth", "effect5depth", 0 };
378 static const gig::dim_bypass_ctrl_t values[] = {
379 gig::dim_bypass_ctrl_none,
380 gig::dim_bypass_ctrl_94,
381 gig::dim_bypass_ctrl_95
382 };
383 eDimensionBypass.set_choices(choices, values);
384 }
385 addProp(eDimensionBypass);
386 addProp(eSelfMask);
387 addProp(eSustainDefeat);
388 addProp(eMSDecode);
389
390 nextPage();
391
392
393 eEG1InfiniteSustain.signal_toggled().connect(
394 sigc::mem_fun(*this, &DimRegionEdit::EG1InfiniteSustain_toggled) );
395 eEG2InfiniteSustain.signal_toggled().connect(
396 sigc::mem_fun(*this, &DimRegionEdit::EG2InfiniteSustain_toggled) );
397 eEG1Controller.signal_changed().connect(
398 sigc::mem_fun(*this, &DimRegionEdit::EG1Controller_changed) );
399 eEG2Controller.signal_changed().connect(
400 sigc::mem_fun(*this, &DimRegionEdit::EG2Controller_changed) );
401 eLFO1Controller.signal_changed().connect(
402 sigc::mem_fun(*this, &DimRegionEdit::LFO1Controller_changed) );
403 eLFO2Controller.signal_changed().connect(
404 sigc::mem_fun(*this, &DimRegionEdit::LFO2Controller_changed) );
405 eLFO3Controller.signal_changed().connect(
406 sigc::mem_fun(*this, &DimRegionEdit::LFO3Controller_changed) );
407 eAttenuationController.signal_changed().connect(
408 sigc::mem_fun(*this, &DimRegionEdit::AttenuationController_changed) );
409 eVCFEnabled.signal_toggled().connect(
410 sigc::mem_fun(*this, &DimRegionEdit::VCFEnabled_toggled) );
411 eVCFCutoffController.signal_changed().connect(
412 sigc::mem_fun(*this, &DimRegionEdit::VCFCutoffController_changed) );
413 eVCFResonanceController.signal_changed().connect(
414 sigc::mem_fun(*this, &DimRegionEdit::VCFResonanceController_changed) );
415
416 eCrossfade_in_start.signal_changed_by_user().connect(
417 sigc::mem_fun(*this, &DimRegionEdit::crossfade1_changed));
418 eCrossfade_in_end.signal_changed_by_user().connect(
419 sigc::mem_fun(*this, &DimRegionEdit::crossfade2_changed));
420 eCrossfade_out_start.signal_changed_by_user().connect(
421 sigc::mem_fun(*this, &DimRegionEdit::crossfade3_changed));
422 eCrossfade_out_end.signal_changed_by_user().connect(
423 sigc::mem_fun(*this, &DimRegionEdit::crossfade4_changed));
424
425 eSampleLoopEnabled.signal_toggled().connect(
426 sigc::mem_fun(*this, &DimRegionEdit::loop_enabled_toggled));
427 eSampleLoopStart.signal_changed_by_user().connect(
428 sigc::mem_fun(*this, &DimRegionEdit::updateLoopElements));
429 eSampleLoopLength.signal_changed_by_user().connect(
430 sigc::mem_fun(*this, &DimRegionEdit::updateLoopElements));
431 eSampleLoopInfinite.signal_toggled().connect(
432 sigc::mem_fun(*this, &DimRegionEdit::loop_infinite_toggled));
433
434 append_page(*table[0], "Sample");
435 append_page(*table[1], "Amplitude (1)");
436 append_page(*table[2], "Amplitude (2)");
437 append_page(*table[3], "Filter (1)");
438 append_page(*table[4], "Filter (2)");
439 append_page(*table[5], "Pitch");
440 append_page(*table[6], "Misc");
441 }
442
443 DimRegionEdit::~DimRegionEdit()
444 {
445 }
446
447 void DimRegionEdit::addString(const char* labelText, Gtk::Label*& label,
448 Gtk::Entry*& widget)
449 {
450 label = new Gtk::Label(Glib::ustring(labelText) + ":");
451 label->set_alignment(Gtk::ALIGN_LEFT);
452
453 table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,
454 Gtk::FILL, Gtk::SHRINK);
455
456 widget = new Gtk::Entry();
457
458 table[pageno]->attach(*widget, 2, 3, rowno, rowno + 1,
459 Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
460
461 rowno++;
462 }
463
464 void DimRegionEdit::addHeader(const char* text)
465 {
466 if (firstRowInBlock < rowno - 1)
467 {
468 Gtk::Label* filler = new Gtk::Label(" ");
469 table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,
470 Gtk::FILL, Gtk::SHRINK);
471 }
472 Glib::ustring str = "<b>";
473 str += text;
474 str += "</b>";
475 Gtk::Label* label = new Gtk::Label(str);
476 label->set_use_markup();
477 label->set_alignment(Gtk::ALIGN_LEFT);
478 table[pageno]->attach(*label, 0, 3, rowno, rowno + 1,
479 Gtk::FILL, Gtk::SHRINK);
480 rowno++;
481 firstRowInBlock = rowno;
482 }
483
484 void DimRegionEdit::nextPage()
485 {
486 if (firstRowInBlock < rowno - 1)
487 {
488 Gtk::Label* filler = new Gtk::Label(" ");
489 table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,
490 Gtk::FILL, Gtk::SHRINK);
491 }
492 pageno++;
493 rowno = 0;
494 firstRowInBlock = 0;
495 }
496
497 void DimRegionEdit::addProp(BoolEntry& boolentry)
498 {
499 table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1,
500 Gtk::FILL, Gtk::SHRINK);
501 rowno++;
502 boolentry.signal_changed_by_user().connect(
503 sigc::bind(dimreg_changed_signal.make_slot(), sigc::ref(this->dimregion))
504 );
505 }
506
507 void DimRegionEdit::addProp(BoolEntryPlus6& boolentry)
508 {
509 table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1,
510 Gtk::FILL, Gtk::SHRINK);
511 rowno++;
512 boolentry.signal_changed_by_user().connect(
513 sigc::bind(dimreg_changed_signal.make_slot(), sigc::ref(this->dimregion))
514 );
515 }
516
517 void DimRegionEdit::addProp(LabelWidget& prop)
518 {
519 table[pageno]->attach(prop.label, 1, 2, rowno, rowno + 1,
520 Gtk::FILL, Gtk::SHRINK);
521 table[pageno]->attach(prop.widget, 2, 3, rowno, rowno + 1,
522 Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
523 rowno++;
524 prop.signal_changed_by_user().connect(
525 sigc::bind(dimreg_changed_signal.make_slot(), sigc::ref(this->dimregion))
526 );
527 }
528
529
530 void DimRegionEdit::set_dim_region(gig::DimensionRegion* d)
531 {
532 dimregion = d;
533
534 // disconnect connections to old dimregion, to avoid segfaults
535 connection_eVCFCutoffController.disconnect();
536 connection_eVCFVelocityCurve.disconnect();
537 connection_eVCFVelocityScale.disconnect();
538 connection_eVCFVelocityDynamicRange.disconnect();
539 connection_eVelocityResponseCurve.disconnect();
540 connection_eVelocityResponseDepth.disconnect();
541 connection_eVelocityResponseCurveScaling.disconnect();
542 connection_eReleaseVelocityResponseCurve.disconnect();
543 connection_eReleaseVelocityResponseDepth.disconnect();
544 connection_eGain.disconnect();
545
546 set_sensitive(d);
547 if (!d) return;
548
549 wSample->set_text(d->pSample ? d->pSample->pInfo->Name.c_str() : "NULL");
550 eEG1PreAttack.set_ptr(&d->EG1PreAttack);
551 eEG1Attack.set_ptr(&d->EG1Attack);
552 eEG1Decay1.set_ptr(&d->EG1Decay1);
553 eEG1Decay2.set_ptr(&d->EG1Decay2);
554 eEG1InfiniteSustain.set_ptr(&d->EG1InfiniteSustain);
555 eEG1Sustain.set_ptr(&d->EG1Sustain);
556 eEG1Release.set_ptr(&d->EG1Release);
557 eEG1Hold.set_ptr(&d->EG1Hold);
558 eEG1Controller.set_ptr(&d->EG1Controller);
559 eEG1ControllerInvert.set_ptr(&d->EG1ControllerInvert);
560 eEG1ControllerAttackInfluence.set_ptr(&d->EG1ControllerAttackInfluence);
561 eEG1ControllerDecayInfluence.set_ptr(&d->EG1ControllerDecayInfluence);
562 eEG1ControllerReleaseInfluence.set_ptr(&d->EG1ControllerReleaseInfluence);
563 eLFO1Frequency.set_ptr(&d->LFO1Frequency);
564 eLFO1InternalDepth.set_ptr(&d->LFO1InternalDepth);
565 eLFO1ControlDepth.set_ptr(&d->LFO1ControlDepth);
566 eLFO1Controller.set_ptr(&d->LFO1Controller);
567 eLFO1FlipPhase.set_ptr(&d->LFO1FlipPhase);
568 eLFO1Sync.set_ptr(&d->LFO1Sync);
569 eEG2PreAttack.set_ptr(&d->EG2PreAttack);
570 eEG2Attack.set_ptr(&d->EG2Attack);
571 eEG2Decay1.set_ptr(&d->EG2Decay1);
572 eEG2Decay2.set_ptr(&d->EG2Decay2);
573 eEG2InfiniteSustain.set_ptr(&d->EG2InfiniteSustain);
574 eEG2Sustain.set_ptr(&d->EG2Sustain);
575 eEG2Release.set_ptr(&d->EG2Release);
576 eEG2Controller.set_ptr(&d->EG2Controller);
577 eEG2ControllerInvert.set_ptr(&d->EG2ControllerInvert);
578 eEG2ControllerAttackInfluence.set_ptr(&d->EG2ControllerAttackInfluence);
579 eEG2ControllerDecayInfluence.set_ptr(&d->EG2ControllerDecayInfluence);
580 eEG2ControllerReleaseInfluence.set_ptr(&d->EG2ControllerReleaseInfluence);
581 eLFO2Frequency.set_ptr(&d->LFO2Frequency);
582 eLFO2InternalDepth.set_ptr(&d->LFO2InternalDepth);
583 eLFO2ControlDepth.set_ptr(&d->LFO2ControlDepth);
584 eLFO2Controller.set_ptr(&d->LFO2Controller);
585 eLFO2FlipPhase.set_ptr(&d->LFO2FlipPhase);
586 eLFO2Sync.set_ptr(&d->LFO2Sync);
587 eEG3Attack.set_ptr(&d->EG3Attack);
588 eEG3Depth.set_ptr(&d->EG3Depth);
589 eLFO3Frequency.set_ptr(&d->LFO3Frequency);
590 eLFO3InternalDepth.set_ptr(&d->LFO3InternalDepth);
591 eLFO3ControlDepth.set_ptr(&d->LFO3ControlDepth);
592 eLFO3Controller.set_ptr(&d->LFO3Controller);
593 eLFO3Sync.set_ptr(&d->LFO3Sync);
594 eVCFEnabled.set_ptr(&d->VCFEnabled);
595 eVCFType.set_ptr(&d->VCFType);
596 eVCFCutoffController.set_ptr(&d->VCFCutoffController);
597 connection_eVCFCutoffController =
598 eVCFCutoffController.signal_value_changed().connect(
599 sigc::mem_fun(d, &gig::DimensionRegion::SetVCFCutoffController)
600 );
601 eVCFCutoffControllerInvert.set_ptr(&d->VCFCutoffControllerInvert);
602 eVCFCutoff.set_ptr(&d->VCFCutoff);
603 eVCFVelocityCurve.set_ptr(&d->VCFVelocityCurve);
604 connection_eVCFVelocityCurve =
605 eVCFVelocityCurve.signal_value_changed().connect(
606 sigc::mem_fun(d, &gig::DimensionRegion::SetVCFVelocityCurve)
607 );
608 eVCFVelocityScale.set_ptr(&d->VCFVelocityScale);
609 connection_eVCFVelocityScale =
610 eVCFVelocityScale.signal_value_changed().connect(
611 sigc::mem_fun(d, &gig::DimensionRegion::SetVCFVelocityScale)
612 );
613 eVCFVelocityDynamicRange.set_ptr(&d->VCFVelocityDynamicRange);
614 connection_eVCFVelocityDynamicRange =
615 eVCFVelocityDynamicRange.signal_value_changed().connect(
616 sigc::mem_fun(d, &gig::DimensionRegion::SetVCFVelocityDynamicRange)
617 );
618 eVCFResonance.set_ptr(&d->VCFResonance);
619 eVCFResonanceDynamic.set_ptr(&d->VCFResonanceDynamic);
620 eVCFResonanceController.set_ptr(&d->VCFResonanceController);
621 eVCFKeyboardTracking.set_ptr(&d->VCFKeyboardTracking);
622 eVCFKeyboardTrackingBreakpoint.set_ptr(&d->VCFKeyboardTrackingBreakpoint);
623 eVelocityResponseCurve.set_ptr(&d->VelocityResponseCurve);
624 connection_eVelocityResponseCurve =
625 eVelocityResponseCurve.signal_value_changed().connect(
626 sigc::mem_fun(d, &gig::DimensionRegion::SetVelocityResponseCurve)
627 );
628 eVelocityResponseDepth.set_ptr(&d->VelocityResponseDepth);
629 connection_eVelocityResponseDepth =
630 eVelocityResponseDepth.signal_value_changed().connect(
631 sigc::mem_fun(d, &gig::DimensionRegion::SetVelocityResponseDepth)
632 );
633 eVelocityResponseCurveScaling.set_ptr(&d->VelocityResponseCurveScaling);
634 connection_eVelocityResponseCurveScaling =
635 eVelocityResponseCurveScaling.signal_value_changed().connect(
636 sigc::mem_fun(d, &gig::DimensionRegion::SetVelocityResponseCurveScaling)
637 );
638 eReleaseVelocityResponseCurve.set_ptr(&d->ReleaseVelocityResponseCurve);
639 connection_eReleaseVelocityResponseCurve =
640 eReleaseVelocityResponseCurve.signal_value_changed().connect(
641 sigc::mem_fun(d, &gig::DimensionRegion::SetReleaseVelocityResponseCurve)
642 );
643 eReleaseVelocityResponseDepth.set_ptr(&d->ReleaseVelocityResponseDepth);
644 connection_eReleaseVelocityResponseDepth =
645 eReleaseVelocityResponseDepth.signal_value_changed().connect(
646 sigc::mem_fun(d, &gig::DimensionRegion::SetReleaseVelocityResponseDepth)
647 );
648 eReleaseTriggerDecay.set_ptr(&d->ReleaseTriggerDecay);
649
650 eCrossfade_in_start.set_ptr(0);
651 eCrossfade_in_end.set_ptr(0);
652 eCrossfade_out_start.set_ptr(0);
653 eCrossfade_out_end.set_ptr(0);
654 eCrossfade_in_start.set_ptr(&d->Crossfade.in_start);
655 eCrossfade_in_end.set_ptr(&d->Crossfade.in_end);
656 eCrossfade_out_start.set_ptr(&d->Crossfade.out_start);
657 eCrossfade_out_end.set_ptr(&d->Crossfade.out_end);
658
659 ePitchTrack.set_ptr(&d->PitchTrack);
660 eDimensionBypass.set_ptr(&d->DimensionBypass);
661 ePan.set_ptr(&d->Pan);
662 eSelfMask.set_ptr(&d->SelfMask);
663 eAttenuationController.set_ptr(&d->AttenuationController);
664 eInvertAttenuationController.set_ptr(&d->InvertAttenuationController);
665 eAttenuationControllerThreshold.set_ptr(&d->AttenuationControllerThreshold);
666 eChannelOffset.set_ptr(&d->ChannelOffset);
667 eSustainDefeat.set_ptr(&d->SustainDefeat);
668 eMSDecode.set_ptr(&d->MSDecode);
669 eSampleStartOffset.set_ptr(&d->SampleStartOffset);
670 eUnityNote.set_ptr(&d->UnityNote);
671 eFineTune.set_ptr(&d->FineTune);
672 eGain.set_ptr(&d->Gain);
673 connection_eGain =
674 eGain.signal_value_changed().connect(
675 sigc::mem_fun(d, &gig::DimensionRegion::SetGain)
676 );
677 eGainPlus6.set_ptr(&d->Gain);
678
679 eSampleLoopEnabled.set_active(d->SampleLoops);
680 updateLoopElements();
681
682 VCFEnabled_toggled();
683 }
684
685 void DimRegionEdit::VCFEnabled_toggled()
686 {
687 bool sensitive = eVCFEnabled.get_active();
688 eVCFType.set_sensitive(sensitive);
689 eVCFCutoffController.set_sensitive(sensitive);
690 eVCFVelocityCurve.set_sensitive(sensitive);
691 eVCFVelocityScale.set_sensitive(sensitive);
692 eVCFVelocityDynamicRange.set_sensitive(sensitive);
693 eVCFResonance.set_sensitive(sensitive);
694 eVCFResonanceController.set_sensitive(sensitive);
695 eVCFKeyboardTracking.set_sensitive(sensitive);
696 eVCFKeyboardTrackingBreakpoint.set_sensitive(sensitive);
697 eEG2PreAttack.set_sensitive(sensitive);
698 eEG2Attack.set_sensitive(sensitive);
699 eEG2Decay1.set_sensitive(sensitive);
700 eEG2InfiniteSustain.set_sensitive(sensitive);
701 eEG2Sustain.set_sensitive(sensitive);
702 eEG2Release.set_sensitive(sensitive);
703 eEG2Controller.set_sensitive(sensitive);
704 eEG2ControllerAttackInfluence.set_sensitive(sensitive);
705 eEG2ControllerDecayInfluence.set_sensitive(sensitive);
706 eEG2ControllerReleaseInfluence.set_sensitive(sensitive);
707 eLFO2Frequency.set_sensitive(sensitive);
708 eLFO2InternalDepth.set_sensitive(sensitive);
709 eLFO2ControlDepth.set_sensitive(sensitive);
710 eLFO2Controller.set_sensitive(sensitive);
711 eLFO2FlipPhase.set_sensitive(sensitive);
712 eLFO2Sync.set_sensitive(sensitive);
713 if (sensitive) {
714 VCFCutoffController_changed();
715 VCFResonanceController_changed();
716 EG2InfiniteSustain_toggled();
717 EG2Controller_changed();
718 LFO2Controller_changed();
719 } else {
720 eVCFCutoffControllerInvert.set_sensitive(false);
721 eVCFCutoff.set_sensitive(false);
722 eVCFResonanceDynamic.set_sensitive(false);
723 eVCFResonance.set_sensitive(false);
724 eEG2Decay2.set_sensitive(false);
725 eEG2ControllerInvert.set_sensitive(false);
726 eLFO2InternalDepth.set_sensitive(false);
727 eLFO2ControlDepth.set_sensitive(false);
728 }
729 }
730
731 void DimRegionEdit::VCFCutoffController_changed()
732 {
733 int rowno = eVCFCutoffController.get_active_row_number();
734 bool hasController = rowno != 0 && rowno != 1;
735
736 eVCFCutoffControllerInvert.set_sensitive(hasController);
737 eVCFCutoff.set_sensitive(!hasController);
738 eVCFResonanceDynamic.set_sensitive(!hasController);
739 eVCFVelocityScale.label.set_text(hasController ? "Minimum cutoff:" :
740 "Velocity scale:");
741 }
742
743 void DimRegionEdit::VCFResonanceController_changed()
744 {
745 bool hasController = eVCFResonanceController.get_active_row_number() != 0;
746 eVCFResonance.set_sensitive(!hasController);
747 }
748
749 void DimRegionEdit::EG1InfiniteSustain_toggled()
750 {
751 bool infSus = eEG1InfiniteSustain.get_active();
752 eEG1Decay2.set_sensitive(!infSus);
753 }
754
755 void DimRegionEdit::EG2InfiniteSustain_toggled()
756 {
757 bool infSus = eEG2InfiniteSustain.get_active();
758 eEG2Decay2.set_sensitive(!infSus);
759 }
760
761 void DimRegionEdit::EG1Controller_changed()
762 {
763 bool hasController = eEG1Controller.get_active_row_number() != 0;
764 eEG1ControllerInvert.set_sensitive(hasController);
765 }
766
767 void DimRegionEdit::EG2Controller_changed()
768 {
769 bool hasController = eEG2Controller.get_active_row_number() != 0;
770 eEG2ControllerInvert.set_sensitive(hasController);
771 }
772
773 void DimRegionEdit::AttenuationController_changed()
774 {
775 bool hasController = eAttenuationController.get_active_row_number() != 0;
776 eInvertAttenuationController.set_sensitive(hasController);
777 eAttenuationControllerThreshold.set_sensitive(hasController);
778 eCrossfade_in_start.set_sensitive(hasController);
779 eCrossfade_in_end.set_sensitive(hasController);
780 eCrossfade_out_start.set_sensitive(hasController);
781 eCrossfade_out_end.set_sensitive(hasController);
782 }
783
784 void DimRegionEdit::LFO1Controller_changed()
785 {
786 int rowno = eLFO1Controller.get_active_row_number();
787 eLFO1ControlDepth.set_sensitive(rowno != 0);
788 eLFO1InternalDepth.set_sensitive(rowno != 1 && rowno != 2);
789 }
790
791 void DimRegionEdit::LFO2Controller_changed()
792 {
793 int rowno = eLFO2Controller.get_active_row_number();
794 eLFO2ControlDepth.set_sensitive(rowno != 0);
795 eLFO2InternalDepth.set_sensitive(rowno != 1 && rowno != 2);
796 }
797
798 void DimRegionEdit::LFO3Controller_changed()
799 {
800 int rowno = eLFO3Controller.get_active_row_number();
801 eLFO3ControlDepth.set_sensitive(rowno != 0);
802 eLFO3InternalDepth.set_sensitive(rowno != 1 && rowno != 2);
803 }
804
805 void DimRegionEdit::crossfade1_changed()
806 {
807 double c1 = eCrossfade_in_start.get_value();
808 double c2 = eCrossfade_in_end.get_value();
809 if (c1 > c2) eCrossfade_in_end.set_value(c1);
810 }
811
812 void DimRegionEdit::crossfade2_changed()
813 {
814 double c1 = eCrossfade_in_start.get_value();
815 double c2 = eCrossfade_in_end.get_value();
816 double c3 = eCrossfade_out_start.get_value();
817
818 if (c2 < c1) eCrossfade_in_start.set_value(c2);
819 if (c2 > c3) eCrossfade_out_start.set_value(c2);
820 }
821
822 void DimRegionEdit::crossfade3_changed()
823 {
824 double c2 = eCrossfade_in_end.get_value();
825 double c3 = eCrossfade_out_start.get_value();
826 double c4 = eCrossfade_out_end.get_value();
827
828 if (c3 < c2) eCrossfade_in_end.set_value(c3);
829 if (c3 > c4) eCrossfade_out_end.set_value(c3);
830 }
831
832 void DimRegionEdit::crossfade4_changed()
833 {
834 double c3 = eCrossfade_out_start.get_value();
835 double c4 = eCrossfade_out_end.get_value();
836
837 if (c4 < c3) eCrossfade_out_start.set_value(c4);
838 }
839
840 void DimRegionEdit::loop_enabled_toggled()
841 {
842 const bool active = eSampleLoopEnabled.get_active();
843 if (active) {
844 // create a new sample loop in case there is none yet
845 if (!dimregion->SampleLoops) {
846 DLS::sample_loop_t loop;
847 loop.LoopType = gig::loop_type_normal;
848 // loop the whole sample by default
849 loop.LoopStart = 0;
850 loop.LoopLength =
851 (dimregion->pSample) ? dimregion->pSample->GetSize() : 0;
852 dimreg_to_be_changed_signal.emit(dimregion);
853 dimregion->AddSampleLoop(&loop);
854 dimreg_changed_signal.emit(dimregion);
855 }
856 } else {
857 if (dimregion->SampleLoops) {
858 dimreg_to_be_changed_signal.emit(dimregion);
859 // delete ALL existing sample loops
860 while (dimregion->SampleLoops) {
861 dimregion->DeleteSampleLoop(&dimregion->pSampleLoops[0]);
862 }
863 dimreg_changed_signal.emit(dimregion);
864 }
865 }
866 updateLoopElements();
867 }
868
869 void DimRegionEdit::updateLoopElements()
870 {
871 const bool active = eSampleLoopEnabled.get_active();
872 eSampleLoopStart.set_sensitive(active);
873 eSampleLoopLength.set_sensitive(active);
874 eSampleLoopType.set_sensitive(active);
875 eSampleLoopInfinite.set_sensitive(active && dimregion && dimregion->pSample);
876 eSampleLoopStart.set_ptr(0);
877 eSampleLoopLength.set_ptr(0);
878 eSampleLoopPlayCount.set_ptr(0);
879
880 if (dimregion && dimregion->SampleLoops) {
881 eSampleLoopStart.set_ptr(&dimregion->pSampleLoops[0].LoopStart);
882 eSampleLoopLength.set_ptr(&dimregion->pSampleLoops[0].LoopLength);
883 eSampleLoopType.set_ptr(&dimregion->pSampleLoops[0].LoopType);
884 eSampleLoopInfinite.set_active(
885 dimregion->pSample && !dimregion->pSample->LoopPlayCount
886 );
887 // updated enabled state of loop play count widget
888 loop_infinite_toggled();
889
890 eSampleLoopPlayCount.set_ptr(
891 (dimregion->pSample) ? &dimregion->pSample->LoopPlayCount : 0
892 );
893
894 // sample loop shall never be longer than the actual sample size
895 eSampleLoopStart.set_upper(
896 (dimregion->pSample)
897 ? dimregion->pSample->SamplesTotal -
898 dimregion->pSampleLoops[0].LoopLength
899 : 0
900 );
901 eSampleLoopLength.set_upper(
902 (dimregion->pSample)
903 ? dimregion->pSample->SamplesTotal -
904 dimregion->pSampleLoops[0].LoopStart
905 : 0
906 );
907 } else { // no sample loop(s)
908 eSampleLoopType.set_ptr(0);
909 // updated enabled state of loop play count widget
910 loop_infinite_toggled();
911 }
912 }
913
914 void DimRegionEdit::loop_infinite_toggled() {
915 eSampleLoopPlayCount.set_sensitive(
916 dimregion && dimregion->pSample &&
917 !eSampleLoopInfinite.get_active() &&
918 eSampleLoopEnabled.get_active()
919 );
920 if (eSampleLoopInfinite.get_active())
921 eSampleLoopPlayCount.set_value(0);
922 else if (!eSampleLoopPlayCount.get_value())
923 eSampleLoopPlayCount.set_value(1);
924 }
925
926 bool DimRegionEdit::set_sample(gig::Sample* sample)
927 {
928 if (dimregion) {
929 //TODO: we should better move the code from MainWindow::on_sample_label_drop_drag_data_received() here
930
931 // currently commented because we're sending a similar signal in MainWindow::on_sample_label_drop_drag_data_received()
932 //dimreg_to_be_changed_signal.emit(dimregion);
933
934 gig::Sample* oldref = dimregion->pSample;
935 dimregion->pSample = sample;
936
937 // copy sample information from Sample to DimensionRegion
938
939 dimregion->UnityNote = sample->MIDIUnityNote;
940 dimregion->FineTune = sample->FineTune;
941
942 int loops = sample->Loops ? 1 : 0;
943 while (dimregion->SampleLoops > loops) {
944 dimregion->DeleteSampleLoop(&dimregion->pSampleLoops[0]);
945 }
946 while (dimregion->SampleLoops < sample->Loops) {
947 DLS::sample_loop_t loop;
948 dimregion->AddSampleLoop(&loop);
949 }
950 if (loops) {
951 dimregion->pSampleLoops[0].Size = sizeof(DLS::sample_loop_t);
952 dimregion->pSampleLoops[0].LoopType = sample->LoopType;
953 dimregion->pSampleLoops[0].LoopStart = sample->LoopStart;
954 dimregion->pSampleLoops[0].LoopLength = sample->LoopEnd - sample->LoopStart + 1;
955 }
956
957 // update ui
958 wSample->set_text(dimregion->pSample->pInfo->Name);
959 eUnityNote.set_ptr(&dimregion->UnityNote);
960 eFineTune.set_ptr(&dimregion->FineTune);
961 eSampleLoopEnabled.set_active(dimregion->SampleLoops);
962 updateLoopElements();
963
964 sample_ref_changed_signal.emit(oldref, sample);
965 // currently commented because we're sending a similar signal in MainWindow::on_sample_label_drop_drag_data_received()
966 //dimreg_changed_signal.emit(dimregion);
967 return true;
968 }
969 return false;
970 }
971
972 sigc::signal<void, gig::DimensionRegion*>& DimRegionEdit::signal_dimreg_to_be_changed() {
973 return dimreg_to_be_changed_signal;
974 }
975
976 sigc::signal<void, gig::DimensionRegion*>& DimRegionEdit::signal_dimreg_changed() {
977 return dimreg_changed_signal;
978 }
979
980 sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& DimRegionEdit::signal_sample_ref_changed() {
981 return sample_ref_changed_signal;
982 }

  ViewVC Help
Powered by ViewVC