/[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 1396 - (show annotations) (download)
Wed Oct 10 15:48:54 2007 UTC (12 years, 6 months ago) by schoenebeck
File size: 37664 byte(s)
* gettext is now an optional dependency
* added Dev-C++ project files for Windows

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

  ViewVC Help
Powered by ViewVC