/[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 3364 - (show annotations) (download)
Tue Nov 14 18:07:25 2017 UTC (6 years, 5 months ago) by schoenebeck
File size: 68691 byte(s)
* Added experimental support for upcoming GTK(MM)4
  (for now up to GTKMM 3.91.2 while still preserving backward compatibility
  down to GTKMM 2).
* Re-merged r2845 to compile now with and without Gtk "Stock ID" API
  (see also r3158).

1 /*
2 * Copyright (C) 2006-2017 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 VelocityCurve::VelocityCurve(double (gig::DimensionRegion::*getter)(uint8_t)) :
32 getter(getter), dimreg(0) {
33 set_size_request(80, 80);
34 }
35
36 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
37 bool VelocityCurve::on_expose_event(GdkEventExpose* e) {
38 const Cairo::RefPtr<Cairo::Context>& cr =
39 get_window()->create_cairo_context();
40 #if 0
41 }
42 #endif
43 #else
44 bool VelocityCurve::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
45 #endif
46 if (dimreg) {
47 int w = get_width();
48 int h = get_height();
49
50 for (int pass = 0 ; pass < 2 ; pass++) {
51 for (double x = 0 ; x <= w ; x++) {
52 int vel = int(x * (127 - 1e-10) / w + 1);
53 double y = (1 - (dimreg->*getter)(vel)) * (h - 3) + 1.5;
54
55 if (x < 1e-10) {
56 cr->move_to(x, y);
57 } else {
58 cr->line_to(x, y);
59 }
60 }
61 if (pass == 0) {
62 cr->line_to(w, h);
63 cr->line_to(0, h);
64 cr->set_source_rgba(0.5, 0.44, 1.0, is_sensitive() ? 0.2 : 0.1);
65 cr->fill();
66 } else {
67 cr->set_line_width(3);
68 cr->set_source_rgba(0.5, 0.44, 1.0, is_sensitive() ? 1.0 : 0.3);
69 cr->stroke();
70 }
71 }
72 }
73 return true;
74 }
75
76
77 CrossfadeCurve::CrossfadeCurve() : dimreg(0) {
78 set_size_request(280, 80);
79 }
80
81 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
82 bool CrossfadeCurve::on_expose_event(GdkEventExpose* e) {
83 const Cairo::RefPtr<Cairo::Context>& cr =
84 get_window()->create_cairo_context();
85 #if 0
86 }
87 #endif
88 #else
89 bool CrossfadeCurve::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
90 #endif
91 if (dimreg) {
92 cr->translate(1.5, 0);
93
94 // first, draw curves for the other layers
95 gig::Region* region = dimreg->GetParent();
96 int dimregno;
97 for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
98 if (region->pDimensionRegions[dimregno] == dimreg) {
99 break;
100 }
101 }
102 int bitcount = 0;
103 for (int dim = 0 ; dim < region->Dimensions ; dim++) {
104 if (region->pDimensionDefinitions[dim].dimension ==
105 gig::dimension_layer) {
106 int mask =
107 ~(((1 << region->pDimensionDefinitions[dim].bits) - 1) <<
108 bitcount);
109 int c = dimregno & mask; // mask away the layer dimension
110
111 for (int i = 0 ; i < region->pDimensionDefinitions[dim].zones ;
112 i++) {
113 gig::DimensionRegion* d =
114 region->pDimensionRegions[c + (i << bitcount)];
115 if (d != dimreg) {
116 draw_one_curve(cr, d, false);
117 }
118 }
119 break;
120 }
121 bitcount += region->pDimensionDefinitions[dim].bits;
122 }
123
124 // then, draw the currently selected layer
125 draw_one_curve(cr, dimreg, is_sensitive());
126 }
127 return true;
128 }
129
130 void CrossfadeCurve::draw_one_curve(const Cairo::RefPtr<Cairo::Context>& cr,
131 const gig::DimensionRegion* d,
132 bool sensitive) {
133 int w = get_width();
134 int h = get_height();
135
136 if (d->Crossfade.out_end) {
137 for (int pass = 0 ; pass < 2 ; pass++) {
138 cr->move_to(d->Crossfade.in_start / 127.0 * (w - 3), h);
139 cr->line_to(d->Crossfade.in_end / 127.0 * (w - 3), 1.5);
140 cr->line_to(d->Crossfade.out_start / 127.0 * (w - 3), 1.5);
141 cr->line_to(d->Crossfade.out_end / 127.0 * (w - 3), h);
142
143 if (pass == 0) {
144 cr->set_source_rgba(0.5, 0.44, 1.0, sensitive ? 0.2 : 0.1);
145 cr->fill();
146 } else {
147 cr->set_line_width(3);
148 cr->set_source_rgba(0.5, 0.44, 1.0, sensitive ? 1.0 : 0.3);
149 cr->stroke();
150 }
151 }
152 }
153 }
154
155
156 EGStateOptions::EGStateOptions() : HBox(),
157 label(_("May be cancelled: ")),
158 checkBoxAttack(_("Attack")),
159 checkBoxAttackHold(_("Attack Hold")),
160 checkBoxDecay1(_("Decay 1")),
161 checkBoxDecay2(_("Decay 2")),
162 checkBoxRelease(_("Release"))
163 {
164 set_spacing(6);
165
166 pack_start(label);
167 pack_start(checkBoxAttack, Gtk::PACK_SHRINK);
168 pack_start(checkBoxAttackHold, Gtk::PACK_SHRINK);
169 pack_start(checkBoxDecay1, Gtk::PACK_SHRINK);
170 pack_start(checkBoxDecay2, Gtk::PACK_SHRINK);
171 pack_start(checkBoxRelease, Gtk::PACK_SHRINK);
172
173 checkBoxAttack.set_tooltip_text(_(
174 "If checked: a note-off aborts the 'attack' stage."
175 ));
176 checkBoxAttackHold.set_tooltip_text(_(
177 "If checked: a note-off aborts the 'attack hold' stage."
178 ));
179 checkBoxDecay1.set_tooltip_text(_(
180 "If checked: a note-off aborts the 'decay 1' stage."
181 ));
182 checkBoxDecay2.set_tooltip_text(_(
183 "If checked: a note-off aborts the 'decay 2' stage."
184 ));
185 checkBoxRelease.set_tooltip_text(_(
186 "If checked: a note-on reverts back from the 'release' stage."
187 ));
188 }
189
190
191 DimRegionEdit::DimRegionEdit() :
192 velocity_curve(&gig::DimensionRegion::GetVelocityAttenuation),
193 release_curve(&gig::DimensionRegion::GetVelocityRelease),
194 cutoff_curve(&gig::DimensionRegion::GetVelocityCutoff),
195 eEG1PreAttack(_("Pre-attack Level (%)"), 0, 100, 2),
196 eEG1Attack(_("Attack Time (seconds)"), 0, 60, 3),
197 eEG1Decay1(_("Decay 1 Time (seconds)"), 0.005, 60, 3),
198 eEG1Decay2(_("Decay 2 Time (seconds)"), 0, 60, 3),
199 eEG1InfiniteSustain(_("Infinite sustain")),
200 eEG1Sustain(_("Sustain Level (%)"), 0, 100, 2),
201 eEG1Release(_("Release Time (seconds)"), 0, 60, 3),
202 eEG1Hold(_("Hold Attack Stage until Loop End")),
203 eEG1Controller(_("Controller")),
204 eEG1ControllerInvert(_("Controller invert")),
205 eEG1ControllerAttackInfluence(_("Controller attack influence"), 0, 3),
206 eEG1ControllerDecayInfluence(_("Controller decay influence"), 0, 3),
207 eEG1ControllerReleaseInfluence(_("Controller release influence"), 0, 3),
208 eLFO1Frequency(_("Frequency"), 0.1, 10, 2),
209 eLFO1InternalDepth(_("Internal depth"), 0, 1200),
210 eLFO1ControlDepth(_("Control depth"), 0, 1200),
211 eLFO1Controller(_("Controller")),
212 eLFO1FlipPhase(_("Flip phase")),
213 eLFO1Sync(_("Sync")),
214 eEG2PreAttack(_("Pre-attack Level (%)"), 0, 100, 2),
215 eEG2Attack(_("Attack Time (seconds)"), 0, 60, 3),
216 eEG2Decay1(_("Decay 1 Time (seconds)"), 0.005, 60, 3),
217 eEG2Decay2(_("Decay 2 Time (seconds)"), 0, 60, 3),
218 eEG2InfiniteSustain(_("Infinite sustain")),
219 eEG2Sustain(_("Sustain Level (%)"), 0, 100, 2),
220 eEG2Release(_("Release Time (seconds)"), 0, 60, 3),
221 eEG2Controller(_("Controller")),
222 eEG2ControllerInvert(_("Controller invert")),
223 eEG2ControllerAttackInfluence(_("Controller attack influence"), 0, 3),
224 eEG2ControllerDecayInfluence(_("Controller decay influence"), 0, 3),
225 eEG2ControllerReleaseInfluence(_("Controller release influence"), 0, 3),
226 eLFO2Frequency(_("Frequency"), 0.1, 10, 2),
227 eLFO2InternalDepth(_("Internal depth"), 0, 1200),
228 eLFO2ControlDepth(_("Control depth"), 0, 1200),
229 eLFO2Controller(_("Controller")),
230 eLFO2FlipPhase(_("Flip phase")),
231 eLFO2Sync(_("Sync")),
232 eEG3Attack(_("Attack"), 0, 10, 3),
233 eEG3Depth(_("Depth"), -1200, 1200),
234 eLFO3Frequency(_("Frequency"), 0.1, 10, 2),
235 eLFO3InternalDepth(_("Internal depth"), 0, 1200),
236 eLFO3ControlDepth(_("Control depth"), 0, 1200),
237 eLFO3Controller(_("Controller")),
238 eLFO3Sync(_("Sync")),
239 eVCFEnabled(_("Enabled")),
240 eVCFType(_("Type")),
241 eVCFCutoffController(_("Cutoff controller")),
242 eVCFCutoffControllerInvert(_("Cutoff controller invert")),
243 eVCFCutoff(_("Cutoff")),
244 eVCFVelocityCurve(_("Velocity curve")),
245 eVCFVelocityScale(_("Velocity scale")),
246 eVCFVelocityDynamicRange(_("Velocity dynamic range"), 0, 4),
247 eVCFResonance(_("Resonance")),
248 eVCFResonanceDynamic(_("Resonance dynamic")),
249 eVCFResonanceController(_("Resonance controller")),
250 eVCFKeyboardTracking(_("Keyboard tracking")),
251 eVCFKeyboardTrackingBreakpoint(_("Keyboard tracking breakpoint")),
252 eVelocityResponseCurve(_("Velocity response curve")),
253 eVelocityResponseDepth(_("Velocity response depth"), 0, 4),
254 eVelocityResponseCurveScaling(_("Velocity response curve scaling")),
255 eReleaseVelocityResponseCurve(_("Release velocity response curve")),
256 eReleaseVelocityResponseDepth(_("Release velocity response depth"), 0, 4),
257 eReleaseTriggerDecay(_("Release trigger decay"), 0, 8),
258 eCrossfade_in_start(_("Crossfade-in start")),
259 eCrossfade_in_end(_("Crossfade-in end")),
260 eCrossfade_out_start(_("Crossfade-out start")),
261 eCrossfade_out_end(_("Crossfade-out end")),
262 ePitchTrack(_("Pitch track")),
263 eDimensionBypass(_("Dimension bypass")),
264 ePan(_("Pan"), -64, 63),
265 eSelfMask(_("Kill lower velocity voices (a.k.a \"Self mask\")")),
266 eAttenuationController(_("Attenuation controller")),
267 eInvertAttenuationController(_("Invert attenuation controller")),
268 eAttenuationControllerThreshold(_("Attenuation controller threshold")),
269 eChannelOffset(_("Channel offset"), 0, 9),
270 eSustainDefeat(_("Ignore Hold Pedal (a.k.a. \"Sustain defeat\")")),
271 eMSDecode(_("Decode Mid/Side Recordings")),
272 eSampleStartOffset(_("Sample start offset"), 0, 2000),
273 eUnityNote(_("Unity note")),
274 eSampleGroup(_("Sample Group")),
275 eSampleFormatInfo(_("Sample Format")),
276 eSampleID("Sample ID"),
277 eChecksum("Wave Data CRC-32"),
278 eFineTune(_("Fine tune"), -49, 50),
279 eGain(_("Gain"), -96, 0, 2, -655360),
280 eGainPlus6(_("Gain +6dB"), eGain, 6 * -655360),
281 eSampleLoopEnabled(_("Enabled")),
282 eSampleLoopStart(_("Loop start positon")),
283 eSampleLoopLength(_("Loop size")),
284 eSampleLoopType(_("Loop type")),
285 eSampleLoopInfinite(_("Infinite loop")),
286 eSampleLoopPlayCount(_("Playback count"), 1),
287 buttonSelectSample(UNICODE_LEFT_ARROW + " " + _("Select Sample")),
288 update_model(0)
289 {
290 // make synthesis parameter page tabs scrollable
291 // (workaround for GTK3: default theme uses huge tabs which breaks layout)
292 set_scrollable();
293
294 connect(eEG1PreAttack, &gig::DimensionRegion::EG1PreAttack);
295 connect(eEG1Attack, &gig::DimensionRegion::EG1Attack);
296 connect(eEG1Decay1, &gig::DimensionRegion::EG1Decay1);
297 connect(eEG1Decay2, &gig::DimensionRegion::EG1Decay2);
298 connect(eEG1InfiniteSustain, &gig::DimensionRegion::EG1InfiniteSustain);
299 connect(eEG1Sustain, &gig::DimensionRegion::EG1Sustain);
300 connect(eEG1Release, &gig::DimensionRegion::EG1Release);
301 connect(eEG1Hold, &gig::DimensionRegion::EG1Hold);
302 connect(eEG1Controller, &gig::DimensionRegion::EG1Controller);
303 connect(eEG1ControllerInvert, &gig::DimensionRegion::EG1ControllerInvert);
304 connect(eEG1ControllerAttackInfluence,
305 &gig::DimensionRegion::EG1ControllerAttackInfluence);
306 connect(eEG1ControllerDecayInfluence,
307 &gig::DimensionRegion::EG1ControllerDecayInfluence);
308 connect(eEG1ControllerReleaseInfluence,
309 &gig::DimensionRegion::EG1ControllerReleaseInfluence);
310 {
311 ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG1Options.AttackCancel));
312 connect(eEG1StateOptions.checkBoxAttack, mp.pmember);
313 }
314 {
315 ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG1Options.AttackHoldCancel));
316 connect(eEG1StateOptions.checkBoxAttackHold, mp.pmember);
317 }
318 {
319 ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG1Options.Decay1Cancel));
320 connect(eEG1StateOptions.checkBoxDecay1, mp.pmember);
321 }
322 {
323 ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG1Options.Decay2Cancel));
324 connect(eEG1StateOptions.checkBoxDecay2, mp.pmember);
325 }
326 {
327 ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG1Options.ReleaseCancel));
328 connect(eEG1StateOptions.checkBoxRelease, mp.pmember);
329 }
330 connect(eLFO1Frequency, &gig::DimensionRegion::LFO1Frequency);
331 connect(eLFO1InternalDepth, &gig::DimensionRegion::LFO1InternalDepth);
332 connect(eLFO1ControlDepth, &gig::DimensionRegion::LFO1ControlDepth);
333 connect(eLFO1Controller, &gig::DimensionRegion::LFO1Controller);
334 connect(eLFO1FlipPhase, &gig::DimensionRegion::LFO1FlipPhase);
335 connect(eLFO1Sync, &gig::DimensionRegion::LFO1Sync);
336 connect(eEG2PreAttack, &gig::DimensionRegion::EG2PreAttack);
337 connect(eEG2Attack, &gig::DimensionRegion::EG2Attack);
338 connect(eEG2Decay1, &gig::DimensionRegion::EG2Decay1);
339 connect(eEG2Decay2, &gig::DimensionRegion::EG2Decay2);
340 connect(eEG2InfiniteSustain, &gig::DimensionRegion::EG2InfiniteSustain);
341 connect(eEG2Sustain, &gig::DimensionRegion::EG2Sustain);
342 connect(eEG2Release, &gig::DimensionRegion::EG2Release);
343 connect(eEG2Controller, &gig::DimensionRegion::EG2Controller);
344 connect(eEG2ControllerInvert, &gig::DimensionRegion::EG2ControllerInvert);
345 connect(eEG2ControllerAttackInfluence,
346 &gig::DimensionRegion::EG2ControllerAttackInfluence);
347 connect(eEG2ControllerDecayInfluence,
348 &gig::DimensionRegion::EG2ControllerDecayInfluence);
349 connect(eEG2ControllerReleaseInfluence,
350 &gig::DimensionRegion::EG2ControllerReleaseInfluence);
351 {
352 ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG2Options.AttackCancel));
353 connect(eEG2StateOptions.checkBoxAttack, mp.pmember);
354 }
355 {
356 ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG2Options.AttackHoldCancel));
357 connect(eEG2StateOptions.checkBoxAttackHold, mp.pmember);
358 }
359 {
360 ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG2Options.Decay1Cancel));
361 connect(eEG2StateOptions.checkBoxDecay1, mp.pmember);
362 }
363 {
364 ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG2Options.Decay2Cancel));
365 connect(eEG2StateOptions.checkBoxDecay2, mp.pmember);
366 }
367 {
368 ClassMemberPtr<gig::DimensionRegion, bool> mp(offsetof(gig::DimensionRegion, EG2Options.ReleaseCancel));
369 connect(eEG2StateOptions.checkBoxRelease, mp.pmember);
370 }
371 connect(eLFO2Frequency, &gig::DimensionRegion::LFO2Frequency);
372 connect(eLFO2InternalDepth, &gig::DimensionRegion::LFO2InternalDepth);
373 connect(eLFO2ControlDepth, &gig::DimensionRegion::LFO2ControlDepth);
374 connect(eLFO2Controller, &gig::DimensionRegion::LFO2Controller);
375 connect(eLFO2FlipPhase, &gig::DimensionRegion::LFO2FlipPhase);
376 connect(eLFO2Sync, &gig::DimensionRegion::LFO2Sync);
377 connect(eEG3Attack, &gig::DimensionRegion::EG3Attack);
378 connect(eEG3Depth, &gig::DimensionRegion::EG3Depth);
379 connect(eLFO3Frequency, &gig::DimensionRegion::LFO3Frequency);
380 connect(eLFO3InternalDepth, &gig::DimensionRegion::LFO3InternalDepth);
381 connect(eLFO3ControlDepth, &gig::DimensionRegion::LFO3ControlDepth);
382 connect(eLFO3Controller, &gig::DimensionRegion::LFO3Controller);
383 connect(eLFO3Sync, &gig::DimensionRegion::LFO3Sync);
384 connect(eVCFEnabled, &gig::DimensionRegion::VCFEnabled);
385 connect(eVCFType, &gig::DimensionRegion::VCFType);
386 connect(eVCFCutoffController,
387 &gig::DimensionRegion::SetVCFCutoffController);
388 connect(eVCFCutoffControllerInvert,
389 &gig::DimensionRegion::VCFCutoffControllerInvert);
390 connect(eVCFCutoff, &gig::DimensionRegion::VCFCutoff);
391 connect(eVCFVelocityCurve, &gig::DimensionRegion::SetVCFVelocityCurve);
392 connect(eVCFVelocityScale, &gig::DimensionRegion::SetVCFVelocityScale);
393 connect(eVCFVelocityDynamicRange,
394 &gig::DimensionRegion::SetVCFVelocityDynamicRange);
395 connect(eVCFResonance, &gig::DimensionRegion::VCFResonance);
396 connect(eVCFResonanceDynamic, &gig::DimensionRegion::VCFResonanceDynamic);
397 connect(eVCFResonanceController,
398 &gig::DimensionRegion::VCFResonanceController);
399 connect(eVCFKeyboardTracking, &gig::DimensionRegion::VCFKeyboardTracking);
400 connect(eVCFKeyboardTrackingBreakpoint,
401 &gig::DimensionRegion::VCFKeyboardTrackingBreakpoint);
402 connect(eVelocityResponseCurve,
403 &gig::DimensionRegion::SetVelocityResponseCurve);
404 connect(eVelocityResponseDepth,
405 &gig::DimensionRegion::SetVelocityResponseDepth);
406 connect(eVelocityResponseCurveScaling,
407 &gig::DimensionRegion::SetVelocityResponseCurveScaling);
408 connect(eReleaseVelocityResponseCurve,
409 &gig::DimensionRegion::SetReleaseVelocityResponseCurve);
410 connect(eReleaseVelocityResponseDepth,
411 &gig::DimensionRegion::SetReleaseVelocityResponseDepth);
412 connect(eReleaseTriggerDecay, &gig::DimensionRegion::ReleaseTriggerDecay);
413 connect(eCrossfade_in_start, &DimRegionEdit::set_Crossfade_in_start);
414 connect(eCrossfade_in_end, &DimRegionEdit::set_Crossfade_in_end);
415 connect(eCrossfade_out_start, &DimRegionEdit::set_Crossfade_out_start);
416 connect(eCrossfade_out_end, &DimRegionEdit::set_Crossfade_out_end);
417 connect(ePitchTrack, &gig::DimensionRegion::PitchTrack);
418 connect(eDimensionBypass, &gig::DimensionRegion::DimensionBypass);
419 connect(ePan, &gig::DimensionRegion::Pan);
420 connect(eSelfMask, &gig::DimensionRegion::SelfMask);
421 connect(eAttenuationController,
422 &gig::DimensionRegion::AttenuationController);
423 connect(eInvertAttenuationController,
424 &gig::DimensionRegion::InvertAttenuationController);
425 connect(eAttenuationControllerThreshold,
426 &gig::DimensionRegion::AttenuationControllerThreshold);
427 connect(eChannelOffset, &gig::DimensionRegion::ChannelOffset);
428 connect(eSustainDefeat, &gig::DimensionRegion::SustainDefeat);
429 connect(eMSDecode, &gig::DimensionRegion::MSDecode);
430 connect(eSampleStartOffset, &gig::DimensionRegion::SampleStartOffset);
431 connect(eUnityNote, &DimRegionEdit::set_UnityNote);
432 connect(eFineTune, &DimRegionEdit::set_FineTune);
433 connect(eGain, &DimRegionEdit::set_Gain);
434 connect(eGainPlus6, &DimRegionEdit::set_Gain);
435 connect(eSampleLoopEnabled, &DimRegionEdit::set_LoopEnabled);
436 connect(eSampleLoopType, &DimRegionEdit::set_LoopType);
437 connect(eSampleLoopStart, &DimRegionEdit::set_LoopStart);
438 connect(eSampleLoopLength, &DimRegionEdit::set_LoopLength);
439 connect(eSampleLoopInfinite, &DimRegionEdit::set_LoopInfinite);
440 connect(eSampleLoopPlayCount, &DimRegionEdit::set_LoopPlayCount);
441 buttonSelectSample.signal_clicked().connect(
442 sigc::mem_fun(*this, &DimRegionEdit::onButtonSelectSamplePressed)
443 );
444
445 for (int i = 0 ; i < 7 ; i++) {
446 #if USE_GTKMM_GRID
447 table[i] = new Gtk::Grid;
448 table[i]->set_column_spacing(7);
449 #else
450 table[i] = new Gtk::Table(3, 1);
451 table[i]->set_col_spacings(7);
452 #endif
453
454 }
455
456 // set tooltips
457 eUnityNote.set_tip(
458 _("Note this sample is associated with (a.k.a. 'root note')")
459 );
460 buttonSelectSample.set_tooltip_text(
461 _("Selects the sample of this dimension region on the left hand side's sample tree view.")
462 );
463 eSampleStartOffset.set_tip(_("Sample position at which playback should be started"));
464 ePan.set_tip(_("Stereo balance (left/right)"));
465 eChannelOffset.set_tip(
466 _("Output channel where the audio signal should be routed to (0 - 9)")
467 );
468 ePitchTrack.set_tip(
469 _("If true: sample will be pitched according to the key position "
470 "(this would be disabled for drums for example)")
471 );
472 eSampleLoopEnabled.set_tip(_("If enabled: repeats to playback the sample"));
473 eSampleLoopStart.set_tip(
474 _("Start position within the sample (in sample points) of the area to "
475 "be looped")
476 );
477 eSampleLoopLength.set_tip(
478 _("Duration (in sample points) of the area to be looped")
479 );
480 eSampleLoopType.set_tip(
481 _("Direction in which the loop area in the sample should be played back")
482 );
483 eSampleLoopInfinite.set_tip(
484 _("Whether the loop area should be played back forever\n"
485 "Caution: this setting is stored on Sample side, thus is shared "
486 "among all dimension regions that use this sample!")
487 );
488 eSampleLoopPlayCount.set_tip(
489 _("How many times the loop area should be played back\n"
490 "Caution: this setting is stored on Sample side, thus is shared "
491 "among all dimension regions that use this sample!")
492 );
493
494 eEG1PreAttack.set_tip(
495 "Very first level this EG starts with. It rises then in Attack Time "
496 "seconds from this initial level to 100%."
497 );
498 eEG1Attack.set_tip(
499 "Duration of the EG's Attack stage, which raises its level from "
500 "Pre-Attack Level to 100%."
501 );
502 eEG1Hold.set_tip(
503 "On looped sounds, enabling this will cause the Decay 1 stage not to "
504 "enter before the loop has been passed one time."
505 );
506 eAttenuationController.set_tip(_(
507 "If you are not using the 'Layer' dimension, then this controller "
508 "simply alters the volume. If you are using the 'Layer' dimension, "
509 "then this controller is controlling the crossfade between Layers in "
510 "real-time."
511 ));
512
513 eLFO1Sync.set_tip(
514 "If not checked, every voice will use its own LFO instance, which "
515 "causes voices triggered at different points in time to have different "
516 "LFO levels. By enabling 'Sync' here the voices will instead use and "
517 "share one single LFO, causing all voices to have the same LFO level, "
518 "no matter when the individual notes have been triggered."
519 );
520 eLFO2Sync.set_tip(
521 "If not checked, every voice will use its own LFO instance, which "
522 "causes voices triggered at different points in time to have different "
523 "LFO levels. By enabling 'Sync' here the voices will instead use and "
524 "share one single LFO, causing all voices to have the same LFO level, "
525 "no matter when the individual notes have been triggered."
526 );
527 eLFO3Sync.set_tip(
528 "If not checked, every voice will use its own LFO instance, which "
529 "causes voices triggered at different points in time to have different "
530 "LFO levels. By enabling 'Sync' here the voices will instead use and "
531 "share one single LFO, causing all voices to have the same LFO level, "
532 "no matter when the individual notes have been triggered."
533 );
534 eLFO1FlipPhase.set_tip(
535 "Inverts the LFO's generated wave vertically."
536 );
537 eLFO2FlipPhase.set_tip(
538 "Inverts the LFO's generated wave vertically."
539 );
540
541 pageno = 0;
542 rowno = 0;
543 firstRowInBlock = 0;
544
545 addHeader(_("Mandatory Settings"));
546 addString(_("Sample"), lSample, wSample, buttonNullSampleReference);
547 buttonNullSampleReference->set_label("X");
548 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."));
549 buttonNullSampleReference->signal_clicked().connect(
550 sigc::mem_fun(*this, &DimRegionEdit::nullOutSampleReference)
551 );
552 //TODO: the following would break drag&drop: wSample->property_editable().set_value(false); or this: wSample->set_editable(false);
553 #ifdef OLD_TOOLTIPS
554 tooltips.set_tip(*wSample, _("Drag & drop a sample here"));
555 #else
556 wSample->set_tooltip_text(_("Drag & drop a sample here"));
557 #endif
558 addProp(eUnityNote);
559 addProp(eSampleGroup);
560 addProp(eSampleFormatInfo);
561 addProp(eSampleID);
562 addProp(eChecksum);
563 addRightHandSide(buttonSelectSample);
564 addHeader(_("Optional Settings"));
565 addProp(eSampleStartOffset);
566 addProp(eChannelOffset);
567 addHeader(_("Loops"));
568 addProp(eSampleLoopEnabled);
569 addProp(eSampleLoopStart);
570 addProp(eSampleLoopLength);
571 {
572 const char* choices[] = { _("normal"), _("bidirectional"), _("backward"), 0 };
573 static const uint32_t values[] = {
574 gig::loop_type_normal,
575 gig::loop_type_bidirectional,
576 gig::loop_type_backward
577 };
578 eSampleLoopType.set_choices(choices, values);
579 }
580 addProp(eSampleLoopType);
581 addProp(eSampleLoopInfinite);
582 addProp(eSampleLoopPlayCount);
583
584 nextPage();
585
586 addHeader(_("General Amplitude Settings"));
587 addProp(eGain);
588 addProp(eGainPlus6);
589 addProp(ePan);
590 addHeader(_("Amplitude Envelope (EG1)"));
591 addProp(eEG1PreAttack);
592 addProp(eEG1Attack);
593 addProp(eEG1Hold);
594 addProp(eEG1Decay1);
595 addProp(eEG1Decay2);
596 addProp(eEG1InfiniteSustain);
597 addProp(eEG1Sustain);
598 addProp(eEG1Release);
599 addProp(eEG1Controller);
600 addProp(eEG1ControllerInvert);
601 addProp(eEG1ControllerAttackInfluence);
602 addProp(eEG1ControllerDecayInfluence);
603 addProp(eEG1ControllerReleaseInfluence);
604 addLine(eEG1StateOptions);
605
606 nextPage();
607
608 addHeader(_("Amplitude Oscillator (LFO1)"));
609 addProp(eLFO1Frequency);
610 addProp(eLFO1InternalDepth);
611 addProp(eLFO1ControlDepth);
612 {
613 const char* choices[] = { _("internal"), _("modwheel"), _("breath"),
614 _("internal+modwheel"), _("internal+breath"), 0 };
615 static const gig::lfo1_ctrl_t values[] = {
616 gig::lfo1_ctrl_internal,
617 gig::lfo1_ctrl_modwheel,
618 gig::lfo1_ctrl_breath,
619 gig::lfo1_ctrl_internal_modwheel,
620 gig::lfo1_ctrl_internal_breath
621 };
622 eLFO1Controller.set_choices(choices, values);
623 }
624 addProp(eLFO1Controller);
625 addProp(eLFO1FlipPhase);
626 addProp(eLFO1Sync);
627 addHeader(_("Crossfade"));
628 addProp(eAttenuationController);
629 addProp(eInvertAttenuationController);
630 addProp(eAttenuationControllerThreshold);
631 addProp(eCrossfade_in_start);
632 addProp(eCrossfade_in_end);
633 addProp(eCrossfade_out_start);
634 addProp(eCrossfade_out_end);
635
636 Gtk::Frame* frame = new Gtk::Frame;
637 frame->add(crossfade_curve);
638 #if USE_GTKMM_GRID
639 table[pageno]->attach(*frame, 1, rowno, 2);
640 #else
641 table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
642 Gtk::SHRINK, Gtk::SHRINK);
643 #endif
644 rowno++;
645
646 eCrossfade_in_start.signal_value_changed().connect(
647 sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
648 eCrossfade_in_end.signal_value_changed().connect(
649 sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
650 eCrossfade_out_start.signal_value_changed().connect(
651 sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
652 eCrossfade_out_end.signal_value_changed().connect(
653 sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
654
655 nextPage();
656
657 addHeader(_("General Filter Settings"));
658 addProp(eVCFEnabled);
659 {
660 const char* choices[] = { _("lowpass"), _("lowpassturbo"), _("bandpass"),
661 _("highpass"), _("bandreject"), 0 };
662 static const gig::vcf_type_t values[] = {
663 gig::vcf_type_lowpass,
664 gig::vcf_type_lowpassturbo,
665 gig::vcf_type_bandpass,
666 gig::vcf_type_highpass,
667 gig::vcf_type_bandreject
668 };
669 eVCFType.set_choices(choices, values);
670 }
671 addProp(eVCFType);
672 {
673 const char* choices[] = { _("none"), _("none2"), _("modwheel"), _("effect1"), _("effect2"),
674 _("breath"), _("foot"), _("sustainpedal"), _("softpedal"),
675 _("genpurpose7"), _("genpurpose8"), _("aftertouch"), 0 };
676 static const gig::vcf_cutoff_ctrl_t values[] = {
677 gig::vcf_cutoff_ctrl_none,
678 gig::vcf_cutoff_ctrl_none2,
679 gig::vcf_cutoff_ctrl_modwheel,
680 gig::vcf_cutoff_ctrl_effect1,
681 gig::vcf_cutoff_ctrl_effect2,
682 gig::vcf_cutoff_ctrl_breath,
683 gig::vcf_cutoff_ctrl_foot,
684 gig::vcf_cutoff_ctrl_sustainpedal,
685 gig::vcf_cutoff_ctrl_softpedal,
686 gig::vcf_cutoff_ctrl_genpurpose7,
687 gig::vcf_cutoff_ctrl_genpurpose8,
688 gig::vcf_cutoff_ctrl_aftertouch
689 };
690 eVCFCutoffController.set_choices(choices, values);
691 }
692 addProp(eVCFCutoffController);
693 addProp(eVCFCutoffControllerInvert);
694 addProp(eVCFCutoff);
695 const char* curve_type_texts[] = { _("nonlinear"), _("linear"), _("special"), 0 };
696 static const gig::curve_type_t curve_type_values[] = {
697 gig::curve_type_nonlinear,
698 gig::curve_type_linear,
699 gig::curve_type_special
700 };
701 eVCFVelocityCurve.set_choices(curve_type_texts, curve_type_values);
702 addProp(eVCFVelocityCurve);
703 addProp(eVCFVelocityScale);
704 addProp(eVCFVelocityDynamicRange);
705
706 eVCFCutoffController.signal_value_changed().connect(
707 sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
708 eVCFVelocityCurve.signal_value_changed().connect(
709 sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
710 eVCFVelocityScale.signal_value_changed().connect(
711 sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
712 eVCFVelocityDynamicRange.signal_value_changed().connect(
713 sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
714
715 frame = new Gtk::Frame;
716 frame->add(cutoff_curve);
717 #if USE_GTKMM_GRID
718 table[pageno]->attach(*frame, 1, rowno, 2);
719 #else
720 table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
721 Gtk::SHRINK, Gtk::SHRINK);
722 #endif
723 rowno++;
724
725 addProp(eVCFResonance);
726 addProp(eVCFResonanceDynamic);
727 {
728 const char* choices[] = { _("none"), _("genpurpose3"), _("genpurpose4"),
729 _("genpurpose5"), _("genpurpose6"), 0 };
730 static const gig::vcf_res_ctrl_t values[] = {
731 gig::vcf_res_ctrl_none,
732 gig::vcf_res_ctrl_genpurpose3,
733 gig::vcf_res_ctrl_genpurpose4,
734 gig::vcf_res_ctrl_genpurpose5,
735 gig::vcf_res_ctrl_genpurpose6
736 };
737 eVCFResonanceController.set_choices(choices, values);
738 }
739 addProp(eVCFResonanceController);
740 addProp(eVCFKeyboardTracking);
741 addProp(eVCFKeyboardTrackingBreakpoint);
742
743 nextPage();
744
745 lEG2 = addHeader(_("Filter Cutoff Envelope (EG2)"));
746 addProp(eEG2PreAttack);
747 addProp(eEG2Attack);
748 addProp(eEG2Decay1);
749 addProp(eEG2Decay2);
750 addProp(eEG2InfiniteSustain);
751 addProp(eEG2Sustain);
752 addProp(eEG2Release);
753 addProp(eEG2Controller);
754 addProp(eEG2ControllerInvert);
755 addProp(eEG2ControllerAttackInfluence);
756 addProp(eEG2ControllerDecayInfluence);
757 addProp(eEG2ControllerReleaseInfluence);
758 addLine(eEG2StateOptions);
759 lLFO2 = addHeader(_("Filter Cutoff Oscillator (LFO2)"));
760 addProp(eLFO2Frequency);
761 addProp(eLFO2InternalDepth);
762 addProp(eLFO2ControlDepth);
763 {
764 const char* choices[] = { _("internal"), _("modwheel"), _("foot"),
765 _("internal+modwheel"), _("internal+foot"), 0 };
766 static const gig::lfo2_ctrl_t values[] = {
767 gig::lfo2_ctrl_internal,
768 gig::lfo2_ctrl_modwheel,
769 gig::lfo2_ctrl_foot,
770 gig::lfo2_ctrl_internal_modwheel,
771 gig::lfo2_ctrl_internal_foot
772 };
773 eLFO2Controller.set_choices(choices, values);
774 }
775 addProp(eLFO2Controller);
776 addProp(eLFO2FlipPhase);
777 addProp(eLFO2Sync);
778
779 nextPage();
780
781 addHeader(_("General Pitch Settings"));
782 addProp(eFineTune);
783 addProp(ePitchTrack);
784 addHeader(_("Pitch Envelope (EG3)"));
785 addProp(eEG3Attack);
786 addProp(eEG3Depth);
787 addHeader(_("Pitch Oscillator (LFO3)"));
788 addProp(eLFO3Frequency);
789 addProp(eLFO3InternalDepth);
790 addProp(eLFO3ControlDepth);
791 {
792 const char* choices[] = { _("internal"), _("modwheel"), _("aftertouch"),
793 _("internal+modwheel"), _("internal+aftertouch"), 0 };
794 static const gig::lfo3_ctrl_t values[] = {
795 gig::lfo3_ctrl_internal,
796 gig::lfo3_ctrl_modwheel,
797 gig::lfo3_ctrl_aftertouch,
798 gig::lfo3_ctrl_internal_modwheel,
799 gig::lfo3_ctrl_internal_aftertouch
800 };
801 eLFO3Controller.set_choices(choices, values);
802 }
803 addProp(eLFO3Controller);
804 addProp(eLFO3Sync);
805
806 nextPage();
807
808 addHeader(_("Velocity Response"));
809 eVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values);
810 addProp(eVelocityResponseCurve);
811 addProp(eVelocityResponseDepth);
812 addProp(eVelocityResponseCurveScaling);
813
814 eVelocityResponseCurve.signal_value_changed().connect(
815 sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
816 eVelocityResponseDepth.signal_value_changed().connect(
817 sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
818 eVelocityResponseCurveScaling.signal_value_changed().connect(
819 sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
820
821 frame = new Gtk::Frame;
822 frame->add(velocity_curve);
823 #if USE_GTKMM_GRID
824 table[pageno]->attach(*frame, 1, rowno, 2);
825 #else
826 table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
827 Gtk::SHRINK, Gtk::SHRINK);
828 #endif
829 rowno++;
830
831 addHeader(_("Release Velocity Response"));
832 eReleaseVelocityResponseCurve.set_choices(curve_type_texts,
833 curve_type_values);
834 addProp(eReleaseVelocityResponseCurve);
835 addProp(eReleaseVelocityResponseDepth);
836
837 eReleaseVelocityResponseCurve.signal_value_changed().connect(
838 sigc::mem_fun(release_curve, &VelocityCurve::queue_draw));
839 eReleaseVelocityResponseDepth.signal_value_changed().connect(
840 sigc::mem_fun(release_curve, &VelocityCurve::queue_draw));
841 frame = new Gtk::Frame;
842 frame->add(release_curve);
843 #if USE_GTKMM_GRID
844 table[pageno]->attach(*frame, 1, rowno, 2);
845 #else
846 table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
847 Gtk::SHRINK, Gtk::SHRINK);
848 #endif
849 rowno++;
850
851 addProp(eReleaseTriggerDecay);
852 {
853 const char* choices[] = { _("none"), _("effect4depth"), _("effect5depth"), 0 };
854 static const gig::dim_bypass_ctrl_t values[] = {
855 gig::dim_bypass_ctrl_none,
856 gig::dim_bypass_ctrl_94,
857 gig::dim_bypass_ctrl_95
858 };
859 eDimensionBypass.set_choices(choices, values);
860 }
861 addProp(eDimensionBypass);
862 eSelfMask.widget.set_tooltip_text(_(
863 "If enabled: new notes with higher velocity value will stop older "
864 "notes with lower velocity values, that way you can save voices that "
865 "would barely be audible. This is also useful for certain drum sounds."
866 ));
867 addProp(eSelfMask);
868 eSustainDefeat.widget.set_tooltip_text(_(
869 "If enabled: sustain pedal will not hold a note. This way you can use "
870 "the sustain pedal for other purposes, for example to switch among "
871 "dimension regions."
872 ));
873 addProp(eSustainDefeat);
874 eMSDecode.widget.set_tooltip_text(_(
875 "Defines if Mid/Side Recordings should be decoded. Mid/Side Recordings "
876 "are an alternative way to record sounds in stereo. The sampler needs "
877 "to decode such samples to actually make use of them. Note: this "
878 "feature is currently not supported by LinuxSampler."
879 ));
880 addProp(eMSDecode);
881
882 nextPage();
883
884
885 eEG1InfiniteSustain.signal_value_changed().connect(
886 sigc::mem_fun(*this, &DimRegionEdit::EG1InfiniteSustain_toggled));
887 eEG2InfiniteSustain.signal_value_changed().connect(
888 sigc::mem_fun(*this, &DimRegionEdit::EG2InfiniteSustain_toggled));
889 eEG1Controller.signal_value_changed().connect(
890 sigc::mem_fun(*this, &DimRegionEdit::EG1Controller_changed));
891 eEG2Controller.signal_value_changed().connect(
892 sigc::mem_fun(*this, &DimRegionEdit::EG2Controller_changed));
893 eLFO1Controller.signal_value_changed().connect(
894 sigc::mem_fun(*this, &DimRegionEdit::LFO1Controller_changed));
895 eLFO2Controller.signal_value_changed().connect(
896 sigc::mem_fun(*this, &DimRegionEdit::LFO2Controller_changed));
897 eLFO3Controller.signal_value_changed().connect(
898 sigc::mem_fun(*this, &DimRegionEdit::LFO3Controller_changed));
899 eAttenuationController.signal_value_changed().connect(
900 sigc::mem_fun(*this, &DimRegionEdit::AttenuationController_changed));
901 eVCFEnabled.signal_value_changed().connect(
902 sigc::mem_fun(*this, &DimRegionEdit::VCFEnabled_toggled));
903 eVCFCutoffController.signal_value_changed().connect(
904 sigc::mem_fun(*this, &DimRegionEdit::VCFCutoffController_changed));
905 eVCFResonanceController.signal_value_changed().connect(
906 sigc::mem_fun(*this, &DimRegionEdit::VCFResonanceController_changed));
907
908 eCrossfade_in_start.signal_value_changed().connect(
909 sigc::mem_fun(*this, &DimRegionEdit::crossfade1_changed));
910 eCrossfade_in_end.signal_value_changed().connect(
911 sigc::mem_fun(*this, &DimRegionEdit::crossfade2_changed));
912 eCrossfade_out_start.signal_value_changed().connect(
913 sigc::mem_fun(*this, &DimRegionEdit::crossfade3_changed));
914 eCrossfade_out_end.signal_value_changed().connect(
915 sigc::mem_fun(*this, &DimRegionEdit::crossfade4_changed));
916
917 eSampleLoopEnabled.signal_value_changed().connect(
918 sigc::mem_fun(*this, &DimRegionEdit::update_loop_elements));
919 eSampleLoopStart.signal_value_changed().connect(
920 sigc::mem_fun(*this, &DimRegionEdit::loop_start_changed));
921 eSampleLoopLength.signal_value_changed().connect(
922 sigc::mem_fun(*this, &DimRegionEdit::loop_length_changed));
923 eSampleLoopInfinite.signal_value_changed().connect(
924 sigc::mem_fun(*this, &DimRegionEdit::loop_infinite_toggled));
925
926 append_page(*table[0], _("Sample"));
927 append_page(*table[1], _("Amplitude (1)"));
928 append_page(*table[2], _("Amplitude (2)"));
929 append_page(*table[3], _("Filter (1)"));
930 append_page(*table[4], _("Filter (2)"));
931 append_page(*table[5], _("Pitch"));
932 append_page(*table[6], _("Misc"));
933 }
934
935 DimRegionEdit::~DimRegionEdit()
936 {
937 }
938
939 void DimRegionEdit::addString(const char* labelText, Gtk::Label*& label,
940 Gtk::Entry*& widget)
941 {
942 label = new Gtk::Label(Glib::ustring(labelText) + ":");
943 #if HAS_GTKMM_ALIGNMENT
944 label->set_alignment(Gtk::ALIGN_START);
945 #else
946 label->set_halign(Gtk::Align::START);
947 #endif
948
949 #if USE_GTKMM_GRID
950 table[pageno]->attach(*label, 1, rowno);
951 #else
952 table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,
953 Gtk::FILL, Gtk::SHRINK);
954 #endif
955
956 widget = new Gtk::Entry();
957
958 #if USE_GTKMM_GRID
959 table[pageno]->attach(*widget, 2, rowno);
960 #else
961 table[pageno]->attach(*widget, 2, 3, rowno, rowno + 1,
962 Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
963 #endif
964
965 rowno++;
966 }
967
968 void DimRegionEdit::addString(const char* labelText, Gtk::Label*& label,
969 Gtk::Entry*& widget, Gtk::Button*& button)
970 {
971 label = new Gtk::Label(Glib::ustring(labelText) + ":");
972 #if HAS_GTKMM_ALIGNMENT
973 label->set_alignment(Gtk::ALIGN_START);
974 #else
975 label->set_halign(Gtk::Align::START);
976 #endif
977
978 #if USE_GTKMM_GRID
979 table[pageno]->attach(*label, 1, rowno);
980 #else
981 table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,
982 Gtk::FILL, Gtk::SHRINK);
983 #endif
984
985 widget = new Gtk::Entry();
986 button = new Gtk::Button();
987
988 HBox* hbox = new HBox;
989 hbox->pack_start(*widget);
990 hbox->pack_start(*button, Gtk::PACK_SHRINK);
991
992 #if USE_GTKMM_GRID
993 table[pageno]->attach(*hbox, 2, rowno);
994 #else
995 table[pageno]->attach(*hbox, 2, 3, rowno, rowno + 1,
996 Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
997 #endif
998
999 rowno++;
1000 }
1001
1002 Gtk::Label* DimRegionEdit::addHeader(const char* text)
1003 {
1004 if (firstRowInBlock < rowno - 1)
1005 {
1006 Gtk::Label* filler = new Gtk::Label(" ");
1007 #if USE_GTKMM_GRID
1008 table[pageno]->attach(*filler, 0, firstRowInBlock);
1009 #else
1010 table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,
1011 Gtk::FILL, Gtk::SHRINK);
1012 #endif
1013 }
1014 Glib::ustring str = "<b>";
1015 str += text;
1016 str += "</b>";
1017 Gtk::Label* label = new Gtk::Label(str);
1018 label->set_use_markup();
1019 #if HAS_GTKMM_ALIGNMENT
1020 label->set_alignment(Gtk::ALIGN_START);
1021 #else
1022 label->set_halign(Gtk::Align::START);
1023 #endif
1024 #if USE_GTKMM_GRID
1025 table[pageno]->attach(*label, 0, rowno, 3);
1026 #else
1027 table[pageno]->attach(*label, 0, 3, rowno, rowno + 1,
1028 Gtk::FILL, Gtk::SHRINK);
1029 #endif
1030 rowno++;
1031 firstRowInBlock = rowno;
1032 return label;
1033 }
1034
1035 void DimRegionEdit::nextPage()
1036 {
1037 if (firstRowInBlock < rowno - 1)
1038 {
1039 Gtk::Label* filler = new Gtk::Label(" ");
1040 #if USE_GTKMM_GRID
1041 table[pageno]->attach(*filler, 0, firstRowInBlock);
1042 #else
1043 table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,
1044 Gtk::FILL, Gtk::SHRINK);
1045 #endif
1046 }
1047 pageno++;
1048 rowno = 0;
1049 firstRowInBlock = 0;
1050 }
1051
1052 void DimRegionEdit::addProp(BoolEntry& boolentry)
1053 {
1054 #if USE_GTKMM_GRID
1055 table[pageno]->attach(boolentry.widget, 1, rowno, 2);
1056 #else
1057 table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1,
1058 Gtk::FILL, Gtk::SHRINK);
1059 #endif
1060 rowno++;
1061 }
1062
1063 void DimRegionEdit::addProp(BoolEntryPlus6& boolentry)
1064 {
1065 #if USE_GTKMM_GRID
1066 table[pageno]->attach(boolentry.widget, 1, rowno, 2);
1067 #else
1068 table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1,
1069 Gtk::FILL, Gtk::SHRINK);
1070 #endif
1071 rowno++;
1072 }
1073
1074 void DimRegionEdit::addProp(LabelWidget& prop)
1075 {
1076 #if USE_GTKMM_GRID
1077 table[pageno]->attach(prop.label, 1, rowno);
1078 table[pageno]->attach(prop.widget, 2, rowno);
1079 #else
1080 table[pageno]->attach(prop.label, 1, 2, rowno, rowno + 1,
1081 Gtk::FILL, Gtk::SHRINK);
1082 table[pageno]->attach(prop.widget, 2, 3, rowno, rowno + 1,
1083 Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
1084 #endif
1085 rowno++;
1086 }
1087
1088 void DimRegionEdit::addLine(HBox& line)
1089 {
1090 #if USE_GTKMM_GRID
1091 table[pageno]->attach(line, 1, rowno, 2);
1092 #else
1093 table[pageno]->attach(line, 1, 3, rowno, rowno + 1,
1094 Gtk::FILL, Gtk::SHRINK);
1095 #endif
1096 rowno++;
1097 }
1098
1099 void DimRegionEdit::addRightHandSide(Gtk::Widget& widget)
1100 {
1101 #if USE_GTKMM_GRID
1102 table[pageno]->attach(widget, 2, rowno);
1103 #else
1104 table[pageno]->attach(widget, 2, 3, rowno, rowno + 1,
1105 Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
1106 #endif
1107 rowno++;
1108 }
1109
1110 void DimRegionEdit::set_dim_region(gig::DimensionRegion* d)
1111 {
1112 dimregion = d;
1113 velocity_curve.set_dim_region(d);
1114 release_curve.set_dim_region(d);
1115 cutoff_curve.set_dim_region(d);
1116 crossfade_curve.set_dim_region(d);
1117
1118 set_sensitive(d);
1119 if (!d) return;
1120
1121 update_model++;
1122 eEG1PreAttack.set_value(d->EG1PreAttack);
1123 eEG1Attack.set_value(d->EG1Attack);
1124 eEG1Decay1.set_value(d->EG1Decay1);
1125 eEG1Decay2.set_value(d->EG1Decay2);
1126 eEG1InfiniteSustain.set_value(d->EG1InfiniteSustain);
1127 eEG1Sustain.set_value(d->EG1Sustain);
1128 eEG1Release.set_value(d->EG1Release);
1129 eEG1Hold.set_value(d->EG1Hold);
1130 eEG1Controller.set_value(d->EG1Controller);
1131 eEG1ControllerInvert.set_value(d->EG1ControllerInvert);
1132 eEG1ControllerAttackInfluence.set_value(d->EG1ControllerAttackInfluence);
1133 eEG1ControllerDecayInfluence.set_value(d->EG1ControllerDecayInfluence);
1134 eEG1ControllerReleaseInfluence.set_value(d->EG1ControllerReleaseInfluence);
1135 eEG1StateOptions.checkBoxAttack.set_value(d->EG1Options.AttackCancel);
1136 eEG1StateOptions.checkBoxAttackHold.set_value(d->EG1Options.AttackHoldCancel);
1137 eEG1StateOptions.checkBoxDecay1.set_value(d->EG1Options.Decay1Cancel);
1138 eEG1StateOptions.checkBoxDecay2.set_value(d->EG1Options.Decay2Cancel);
1139 eEG1StateOptions.checkBoxRelease.set_value(d->EG1Options.ReleaseCancel);
1140 eLFO1Frequency.set_value(d->LFO1Frequency);
1141 eLFO1InternalDepth.set_value(d->LFO1InternalDepth);
1142 eLFO1ControlDepth.set_value(d->LFO1ControlDepth);
1143 eLFO1Controller.set_value(d->LFO1Controller);
1144 eLFO1FlipPhase.set_value(d->LFO1FlipPhase);
1145 eLFO1Sync.set_value(d->LFO1Sync);
1146 eEG2PreAttack.set_value(d->EG2PreAttack);
1147 eEG2Attack.set_value(d->EG2Attack);
1148 eEG2Decay1.set_value(d->EG2Decay1);
1149 eEG2Decay2.set_value(d->EG2Decay2);
1150 eEG2InfiniteSustain.set_value(d->EG2InfiniteSustain);
1151 eEG2Sustain.set_value(d->EG2Sustain);
1152 eEG2Release.set_value(d->EG2Release);
1153 eEG2Controller.set_value(d->EG2Controller);
1154 eEG2ControllerInvert.set_value(d->EG2ControllerInvert);
1155 eEG2ControllerAttackInfluence.set_value(d->EG2ControllerAttackInfluence);
1156 eEG2ControllerDecayInfluence.set_value(d->EG2ControllerDecayInfluence);
1157 eEG2ControllerReleaseInfluence.set_value(d->EG2ControllerReleaseInfluence);
1158 eEG2StateOptions.checkBoxAttack.set_value(d->EG2Options.AttackCancel);
1159 eEG2StateOptions.checkBoxAttackHold.set_value(d->EG2Options.AttackHoldCancel);
1160 eEG2StateOptions.checkBoxDecay1.set_value(d->EG2Options.Decay1Cancel);
1161 eEG2StateOptions.checkBoxDecay2.set_value(d->EG2Options.Decay2Cancel);
1162 eEG2StateOptions.checkBoxRelease.set_value(d->EG2Options.ReleaseCancel);
1163 eLFO2Frequency.set_value(d->LFO2Frequency);
1164 eLFO2InternalDepth.set_value(d->LFO2InternalDepth);
1165 eLFO2ControlDepth.set_value(d->LFO2ControlDepth);
1166 eLFO2Controller.set_value(d->LFO2Controller);
1167 eLFO2FlipPhase.set_value(d->LFO2FlipPhase);
1168 eLFO2Sync.set_value(d->LFO2Sync);
1169 eEG3Attack.set_value(d->EG3Attack);
1170 eEG3Depth.set_value(d->EG3Depth);
1171 eLFO3Frequency.set_value(d->LFO3Frequency);
1172 eLFO3InternalDepth.set_value(d->LFO3InternalDepth);
1173 eLFO3ControlDepth.set_value(d->LFO3ControlDepth);
1174 eLFO3Controller.set_value(d->LFO3Controller);
1175 eLFO3Sync.set_value(d->LFO3Sync);
1176 eVCFEnabled.set_value(d->VCFEnabled);
1177 eVCFType.set_value(d->VCFType);
1178 eVCFCutoffController.set_value(d->VCFCutoffController);
1179 eVCFCutoffControllerInvert.set_value(d->VCFCutoffControllerInvert);
1180 eVCFCutoff.set_value(d->VCFCutoff);
1181 eVCFVelocityCurve.set_value(d->VCFVelocityCurve);
1182 eVCFVelocityScale.set_value(d->VCFVelocityScale);
1183 eVCFVelocityDynamicRange.set_value(d->VCFVelocityDynamicRange);
1184 eVCFResonance.set_value(d->VCFResonance);
1185 eVCFResonanceDynamic.set_value(d->VCFResonanceDynamic);
1186 eVCFResonanceController.set_value(d->VCFResonanceController);
1187 eVCFKeyboardTracking.set_value(d->VCFKeyboardTracking);
1188 eVCFKeyboardTrackingBreakpoint.set_value(d->VCFKeyboardTrackingBreakpoint);
1189 eVelocityResponseCurve.set_value(d->VelocityResponseCurve);
1190 eVelocityResponseDepth.set_value(d->VelocityResponseDepth);
1191 eVelocityResponseCurveScaling.set_value(d->VelocityResponseCurveScaling);
1192 eReleaseVelocityResponseCurve.set_value(d->ReleaseVelocityResponseCurve);
1193 eReleaseVelocityResponseDepth.set_value(d->ReleaseVelocityResponseDepth);
1194 eReleaseTriggerDecay.set_value(d->ReleaseTriggerDecay);
1195 eCrossfade_in_start.set_value(d->Crossfade.in_start);
1196 eCrossfade_in_end.set_value(d->Crossfade.in_end);
1197 eCrossfade_out_start.set_value(d->Crossfade.out_start);
1198 eCrossfade_out_end.set_value(d->Crossfade.out_end);
1199 ePitchTrack.set_value(d->PitchTrack);
1200 eDimensionBypass.set_value(d->DimensionBypass);
1201 ePan.set_value(d->Pan);
1202 eSelfMask.set_value(d->SelfMask);
1203 eAttenuationController.set_value(d->AttenuationController);
1204 eInvertAttenuationController.set_value(d->InvertAttenuationController);
1205 eAttenuationControllerThreshold.set_value(d->AttenuationControllerThreshold);
1206 eChannelOffset.set_value(d->ChannelOffset);
1207 eSustainDefeat.set_value(d->SustainDefeat);
1208 eMSDecode.set_value(d->MSDecode);
1209 eSampleStartOffset.set_value(d->SampleStartOffset);
1210 eUnityNote.set_value(d->UnityNote);
1211 // show sample group name
1212 {
1213 Glib::ustring s = "---";
1214 if (d->pSample && d->pSample->GetGroup())
1215 s = d->pSample->GetGroup()->Name;
1216 eSampleGroup.text.set_text(s);
1217 }
1218 // assemble sample format info string
1219 {
1220 Glib::ustring s;
1221 if (d->pSample) {
1222 switch (d->pSample->Channels) {
1223 case 1: s = _("Mono"); break;
1224 case 2: s = _("Stereo"); break;
1225 default:
1226 s = ToString(d->pSample->Channels) + _(" audio channels");
1227 break;
1228 }
1229 s += " " + ToString(d->pSample->BitDepth) + " Bits";
1230 s += " " + ToString(d->pSample->SamplesPerSecond/1000) + "."
1231 + ToString((d->pSample->SamplesPerSecond%1000)/100) + " kHz";
1232 } else {
1233 s = _("No sample assigned to this dimension region.");
1234 }
1235 eSampleFormatInfo.text.set_text(s);
1236 }
1237 // generate sample's memory address pointer string
1238 {
1239 Glib::ustring s;
1240 if (d->pSample) {
1241 char buf[64] = {};
1242 snprintf(buf, sizeof(buf), "%p", d->pSample);
1243 s = buf;
1244 } else {
1245 s = "---";
1246 }
1247 eSampleID.text.set_text(s);
1248 }
1249 // generate raw wave form data CRC-32 checksum string
1250 {
1251 Glib::ustring s = "---";
1252 if (d->pSample) {
1253 char buf[64] = {};
1254 snprintf(buf, sizeof(buf), "%x", d->pSample->GetWaveDataCRC32Checksum());
1255 s = buf;
1256 }
1257 eChecksum.text.set_text(s);
1258 }
1259 buttonSelectSample.set_sensitive(d && d->pSample);
1260 eFineTune.set_value(d->FineTune);
1261 eGain.set_value(d->Gain);
1262 eGainPlus6.set_value(d->Gain);
1263 eSampleLoopEnabled.set_value(d->SampleLoops);
1264 eSampleLoopType.set_value(
1265 d->SampleLoops ? d->pSampleLoops[0].LoopType : 0);
1266 eSampleLoopStart.set_value(
1267 d->SampleLoops ? d->pSampleLoops[0].LoopStart : 0);
1268 eSampleLoopLength.set_value(
1269 d->SampleLoops ? d->pSampleLoops[0].LoopLength : 0);
1270 eSampleLoopInfinite.set_value(
1271 d->pSample && d->pSample->LoopPlayCount == 0);
1272 eSampleLoopPlayCount.set_value(
1273 d->pSample ? d->pSample->LoopPlayCount : 0);
1274 update_model--;
1275
1276 wSample->set_text(d->pSample ? gig_to_utf8(d->pSample->pInfo->Name) :
1277 _("NULL"));
1278
1279 update_loop_elements();
1280 VCFEnabled_toggled();
1281 }
1282
1283
1284 void DimRegionEdit::VCFEnabled_toggled()
1285 {
1286 bool sensitive = eVCFEnabled.get_value();
1287 eVCFType.set_sensitive(sensitive);
1288 eVCFCutoffController.set_sensitive(sensitive);
1289 eVCFVelocityCurve.set_sensitive(sensitive);
1290 eVCFVelocityScale.set_sensitive(sensitive);
1291 eVCFVelocityDynamicRange.set_sensitive(sensitive);
1292 cutoff_curve.set_sensitive(sensitive);
1293 eVCFResonance.set_sensitive(sensitive);
1294 eVCFResonanceController.set_sensitive(sensitive);
1295 eVCFKeyboardTracking.set_sensitive(sensitive);
1296 eVCFKeyboardTrackingBreakpoint.set_sensitive(sensitive);
1297 lEG2->set_sensitive(sensitive);
1298 eEG2PreAttack.set_sensitive(sensitive);
1299 eEG2Attack.set_sensitive(sensitive);
1300 eEG2Decay1.set_sensitive(sensitive);
1301 eEG2InfiniteSustain.set_sensitive(sensitive);
1302 eEG2Sustain.set_sensitive(sensitive);
1303 eEG2Release.set_sensitive(sensitive);
1304 eEG2Controller.set_sensitive(sensitive);
1305 eEG2ControllerAttackInfluence.set_sensitive(sensitive);
1306 eEG2ControllerDecayInfluence.set_sensitive(sensitive);
1307 eEG2ControllerReleaseInfluence.set_sensitive(sensitive);
1308 eEG2StateOptions.set_sensitive(sensitive);
1309 lLFO2->set_sensitive(sensitive);
1310 eLFO2Frequency.set_sensitive(sensitive);
1311 eLFO2InternalDepth.set_sensitive(sensitive);
1312 eLFO2ControlDepth.set_sensitive(sensitive);
1313 eLFO2Controller.set_sensitive(sensitive);
1314 eLFO2FlipPhase.set_sensitive(sensitive);
1315 eLFO2Sync.set_sensitive(sensitive);
1316 if (sensitive) {
1317 VCFCutoffController_changed();
1318 VCFResonanceController_changed();
1319 EG2InfiniteSustain_toggled();
1320 EG2Controller_changed();
1321 LFO2Controller_changed();
1322 } else {
1323 eVCFCutoffControllerInvert.set_sensitive(false);
1324 eVCFCutoff.set_sensitive(false);
1325 eVCFResonanceDynamic.set_sensitive(false);
1326 eVCFResonance.set_sensitive(false);
1327 eEG2Decay2.set_sensitive(false);
1328 eEG2ControllerInvert.set_sensitive(false);
1329 eLFO2InternalDepth.set_sensitive(false);
1330 eLFO2ControlDepth.set_sensitive(false);
1331 }
1332 }
1333
1334 void DimRegionEdit::VCFCutoffController_changed()
1335 {
1336 gig::vcf_cutoff_ctrl_t ctrl = eVCFCutoffController.get_value();
1337 bool hasController = ctrl != gig::vcf_cutoff_ctrl_none && ctrl != gig::vcf_cutoff_ctrl_none2;
1338
1339 eVCFCutoffControllerInvert.set_sensitive(hasController);
1340 eVCFCutoff.set_sensitive(!hasController);
1341 eVCFResonanceDynamic.set_sensitive(!hasController);
1342 eVCFVelocityScale.label.set_text(hasController ? _("Minimum cutoff:") :
1343 _("Velocity scale:"));
1344 }
1345
1346 void DimRegionEdit::VCFResonanceController_changed()
1347 {
1348 bool hasController = eVCFResonanceController.get_value() != gig::vcf_res_ctrl_none;
1349 eVCFResonance.set_sensitive(!hasController);
1350 }
1351
1352 void DimRegionEdit::EG1InfiniteSustain_toggled()
1353 {
1354 bool infSus = eEG1InfiniteSustain.get_value();
1355 eEG1Decay2.set_sensitive(!infSus);
1356 }
1357
1358 void DimRegionEdit::EG2InfiniteSustain_toggled()
1359 {
1360 bool infSus = eEG2InfiniteSustain.get_value();
1361 eEG2Decay2.set_sensitive(!infSus);
1362 }
1363
1364 void DimRegionEdit::EG1Controller_changed()
1365 {
1366 bool hasController = eEG1Controller.get_value().type != gig::leverage_ctrl_t::type_none;
1367 eEG1ControllerInvert.set_sensitive(hasController);
1368 }
1369
1370 void DimRegionEdit::EG2Controller_changed()
1371 {
1372 bool hasController = eEG2Controller.get_value().type != gig::leverage_ctrl_t::type_none;
1373 eEG2ControllerInvert.set_sensitive(hasController);
1374 }
1375
1376 void DimRegionEdit::AttenuationController_changed()
1377 {
1378 bool hasController =
1379 eAttenuationController.get_value().type != gig::leverage_ctrl_t::type_none;
1380 eInvertAttenuationController.set_sensitive(hasController);
1381 eAttenuationControllerThreshold.set_sensitive(hasController);
1382 eCrossfade_in_start.set_sensitive(hasController);
1383 eCrossfade_in_end.set_sensitive(hasController);
1384 eCrossfade_out_start.set_sensitive(hasController);
1385 eCrossfade_out_end.set_sensitive(hasController);
1386 crossfade_curve.set_sensitive(hasController);
1387 }
1388
1389 void DimRegionEdit::LFO1Controller_changed()
1390 {
1391 gig::lfo1_ctrl_t ctrl = eLFO1Controller.get_value();
1392 eLFO1ControlDepth.set_sensitive(ctrl != gig::lfo1_ctrl_internal);
1393 eLFO1InternalDepth.set_sensitive(ctrl != gig::lfo1_ctrl_modwheel &&
1394 ctrl != gig::lfo1_ctrl_breath);
1395 }
1396
1397 void DimRegionEdit::LFO2Controller_changed()
1398 {
1399 gig::lfo2_ctrl_t ctrl = eLFO2Controller.get_value();
1400 eLFO2ControlDepth.set_sensitive(ctrl != gig::lfo2_ctrl_internal);
1401 eLFO2InternalDepth.set_sensitive(ctrl != gig::lfo2_ctrl_modwheel &&
1402 ctrl != gig::lfo2_ctrl_foot);
1403 }
1404
1405 void DimRegionEdit::LFO3Controller_changed()
1406 {
1407 gig::lfo3_ctrl_t ctrl = eLFO3Controller.get_value();
1408 eLFO3ControlDepth.set_sensitive(ctrl != gig::lfo3_ctrl_internal);
1409 eLFO3InternalDepth.set_sensitive(ctrl != gig::lfo3_ctrl_modwheel &&
1410 ctrl != gig::lfo3_ctrl_aftertouch);
1411 }
1412
1413 void DimRegionEdit::crossfade1_changed()
1414 {
1415 update_model++;
1416 eCrossfade_in_end.set_value(dimregion->Crossfade.in_end);
1417 eCrossfade_out_start.set_value(dimregion->Crossfade.out_start);
1418 eCrossfade_out_end.set_value(dimregion->Crossfade.out_end);
1419 update_model--;
1420 }
1421
1422 void DimRegionEdit::crossfade2_changed()
1423 {
1424 update_model++;
1425 eCrossfade_in_start.set_value(dimregion->Crossfade.in_start);
1426 eCrossfade_out_start.set_value(dimregion->Crossfade.out_start);
1427 eCrossfade_out_end.set_value(dimregion->Crossfade.out_end);
1428 update_model--;
1429 }
1430
1431 void DimRegionEdit::crossfade3_changed()
1432 {
1433 update_model++;
1434 eCrossfade_in_start.set_value(dimregion->Crossfade.in_start);
1435 eCrossfade_in_end.set_value(dimregion->Crossfade.in_end);
1436 eCrossfade_out_end.set_value(dimregion->Crossfade.out_end);
1437 update_model--;
1438 }
1439
1440 void DimRegionEdit::crossfade4_changed()
1441 {
1442 update_model++;
1443 eCrossfade_in_start.set_value(dimregion->Crossfade.in_start);
1444 eCrossfade_in_end.set_value(dimregion->Crossfade.in_end);
1445 eCrossfade_out_start.set_value(dimregion->Crossfade.out_start);
1446 update_model--;
1447 }
1448
1449 void DimRegionEdit::update_loop_elements()
1450 {
1451 update_model++;
1452 const bool active = eSampleLoopEnabled.get_value();
1453 eSampleLoopStart.set_sensitive(active);
1454 eSampleLoopLength.set_sensitive(active);
1455 eSampleLoopType.set_sensitive(active);
1456 eSampleLoopInfinite.set_sensitive(active && dimregion && dimregion->pSample);
1457 // sample loop shall never be longer than the actual sample size
1458 loop_start_changed();
1459 loop_length_changed();
1460 eSampleLoopStart.set_value(
1461 dimregion->SampleLoops ? dimregion->pSampleLoops[0].LoopStart : 0);
1462 eSampleLoopLength.set_value(
1463 dimregion->SampleLoops ? dimregion->pSampleLoops[0].LoopLength : 0);
1464
1465 eSampleLoopInfinite.set_value(
1466 dimregion->pSample && dimregion->pSample->LoopPlayCount == 0);
1467
1468 loop_infinite_toggled();
1469 update_model--;
1470 }
1471
1472 void DimRegionEdit::loop_start_changed() {
1473 if (dimregion && dimregion->SampleLoops) {
1474 eSampleLoopLength.set_upper(dimregion->pSample ?
1475 dimregion->pSample->SamplesTotal -
1476 dimregion->pSampleLoops[0].LoopStart : 0);
1477 }
1478 }
1479
1480 void DimRegionEdit::loop_length_changed() {
1481 if (dimregion && dimregion->SampleLoops) {
1482 eSampleLoopStart.set_upper(dimregion->pSample ?
1483 dimregion->pSample->SamplesTotal -
1484 dimregion->pSampleLoops[0].LoopLength : 0);
1485 }
1486 }
1487
1488 void DimRegionEdit::loop_infinite_toggled() {
1489 eSampleLoopPlayCount.set_sensitive(
1490 dimregion && dimregion->pSample &&
1491 !eSampleLoopInfinite.get_value() &&
1492 eSampleLoopEnabled.get_value()
1493 );
1494 update_model++;
1495 eSampleLoopPlayCount.set_value(
1496 dimregion->pSample ? dimregion->pSample->LoopPlayCount : 0);
1497 update_model--;
1498 }
1499
1500 bool DimRegionEdit::set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop)
1501 {
1502 bool result = false;
1503 for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimregs.begin();
1504 itDimReg != dimregs.end(); ++itDimReg)
1505 {
1506 result |= set_sample(*itDimReg, sample, copy_sample_unity, copy_sample_tune, copy_sample_loop);
1507 }
1508 return result;
1509 }
1510
1511 bool DimRegionEdit::set_sample(gig::DimensionRegion* dimreg, gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop)
1512 {
1513 if (dimreg) {
1514 //TODO: we should better move the code from MainWindow::on_sample_label_drop_drag_data_received() here
1515
1516 // currently commented because we're sending a similar signal in MainWindow::on_sample_label_drop_drag_data_received()
1517 //DimRegionChangeGuard(this, dimregion);
1518
1519 // make sure stereo samples always are the same in both
1520 // dimregs in the samplechannel dimension
1521 int nbDimregs = 1;
1522 gig::DimensionRegion* d[2] = { dimreg, 0 };
1523 if (sample->Channels == 2) {
1524 gig::Region* region = dimreg->GetParent();
1525
1526 int bitcount = 0;
1527 int stereo_bit = 0;
1528 for (int dim = 0 ; dim < region->Dimensions ; dim++) {
1529 if (region->pDimensionDefinitions[dim].dimension == gig::dimension_samplechannel) {
1530 stereo_bit = 1 << bitcount;
1531 break;
1532 }
1533 bitcount += region->pDimensionDefinitions[dim].bits;
1534 }
1535
1536 if (stereo_bit) {
1537 int dimregno;
1538 for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
1539 if (region->pDimensionRegions[dimregno] == dimreg) {
1540 break;
1541 }
1542 }
1543 d[0] = region->pDimensionRegions[dimregno & ~stereo_bit];
1544 d[1] = region->pDimensionRegions[dimregno | stereo_bit];
1545 nbDimregs = 2;
1546 }
1547 }
1548
1549 gig::Sample* oldref = dimreg->pSample;
1550
1551 for (int i = 0 ; i < nbDimregs ; i++) {
1552 d[i]->pSample = sample;
1553
1554 // copy sample information from Sample to DimensionRegion
1555 if (copy_sample_unity)
1556 d[i]->UnityNote = sample->MIDIUnityNote;
1557 if (copy_sample_tune)
1558 d[i]->FineTune = sample->FineTune;
1559 if (copy_sample_loop) {
1560 int loops = sample->Loops ? 1 : 0;
1561 while (d[i]->SampleLoops > loops) {
1562 d[i]->DeleteSampleLoop(&d[i]->pSampleLoops[0]);
1563 }
1564 while (d[i]->SampleLoops < sample->Loops) {
1565 DLS::sample_loop_t loop;
1566 d[i]->AddSampleLoop(&loop);
1567 }
1568 if (loops) {
1569 d[i]->pSampleLoops[0].Size = sizeof(DLS::sample_loop_t);
1570 d[i]->pSampleLoops[0].LoopType = sample->LoopType;
1571 d[i]->pSampleLoops[0].LoopStart = sample->LoopStart;
1572 d[i]->pSampleLoops[0].LoopLength = sample->LoopEnd - sample->LoopStart + 1;
1573 }
1574 }
1575 }
1576
1577 // update ui
1578 update_model++;
1579 wSample->set_text(gig_to_utf8(dimreg->pSample->pInfo->Name));
1580 eUnityNote.set_value(dimreg->UnityNote);
1581 eFineTune.set_value(dimreg->FineTune);
1582 eSampleLoopEnabled.set_value(dimreg->SampleLoops);
1583 update_loop_elements();
1584 update_model--;
1585
1586 sample_ref_changed_signal.emit(oldref, sample);
1587 return true;
1588 }
1589 return false;
1590 }
1591
1592 sigc::signal<void, gig::DimensionRegion*>& DimRegionEdit::signal_dimreg_to_be_changed() {
1593 return dimreg_to_be_changed_signal;
1594 }
1595
1596 sigc::signal<void, gig::DimensionRegion*>& DimRegionEdit::signal_dimreg_changed() {
1597 return dimreg_changed_signal;
1598 }
1599
1600 sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& DimRegionEdit::signal_sample_ref_changed() {
1601 return sample_ref_changed_signal;
1602 }
1603
1604
1605 void DimRegionEdit::set_UnityNote(gig::DimensionRegion* d, uint8_t value)
1606 {
1607 d->UnityNote = value;
1608 }
1609
1610 void DimRegionEdit::set_FineTune(gig::DimensionRegion* d, int16_t value)
1611 {
1612 d->FineTune = value;
1613 }
1614
1615 void DimRegionEdit::set_Crossfade_in_start(gig::DimensionRegion* d,
1616 uint8_t value)
1617 {
1618 d->Crossfade.in_start = value;
1619 if (d->Crossfade.in_end < value) set_Crossfade_in_end(d, value);
1620 }
1621
1622 void DimRegionEdit::set_Crossfade_in_end(gig::DimensionRegion* d,
1623 uint8_t value)
1624 {
1625 d->Crossfade.in_end = value;
1626 if (value < d->Crossfade.in_start) set_Crossfade_in_start(d, value);
1627 if (value > d->Crossfade.out_start) set_Crossfade_out_start(d, value);
1628 }
1629
1630 void DimRegionEdit::set_Crossfade_out_start(gig::DimensionRegion* d,
1631 uint8_t value)
1632 {
1633 d->Crossfade.out_start = value;
1634 if (value < d->Crossfade.in_end) set_Crossfade_in_end(d, value);
1635 if (value > d->Crossfade.out_end) set_Crossfade_out_end(d, value);
1636 }
1637
1638 void DimRegionEdit::set_Crossfade_out_end(gig::DimensionRegion* d,
1639 uint8_t value)
1640 {
1641 d->Crossfade.out_end = value;
1642 if (value < d->Crossfade.out_start) set_Crossfade_out_start(d, value);
1643 }
1644
1645 void DimRegionEdit::set_Gain(gig::DimensionRegion* d, int32_t value)
1646 {
1647 d->SetGain(value);
1648 }
1649
1650 void DimRegionEdit::set_LoopEnabled(gig::DimensionRegion* d, bool value)
1651 {
1652 if (value) {
1653 // create a new sample loop in case there is none yet
1654 if (!d->SampleLoops) {
1655 DimRegionChangeGuard(this, d);
1656
1657 DLS::sample_loop_t loop;
1658 loop.LoopType = gig::loop_type_normal;
1659 // loop the whole sample by default
1660 loop.LoopStart = 0;
1661 loop.LoopLength =
1662 (d->pSample) ? d->pSample->SamplesTotal : 0;
1663 d->AddSampleLoop(&loop);
1664 }
1665 } else {
1666 if (d->SampleLoops) {
1667 DimRegionChangeGuard(this, d);
1668
1669 // delete ALL existing sample loops
1670 while (d->SampleLoops) {
1671 d->DeleteSampleLoop(&d->pSampleLoops[0]);
1672 }
1673 }
1674 }
1675 }
1676
1677 void DimRegionEdit::set_LoopType(gig::DimensionRegion* d, uint32_t value)
1678 {
1679 if (d->SampleLoops) d->pSampleLoops[0].LoopType = value;
1680 }
1681
1682 void DimRegionEdit::set_LoopStart(gig::DimensionRegion* d, uint32_t value)
1683 {
1684 if (d->SampleLoops) {
1685 d->pSampleLoops[0].LoopStart =
1686 d->pSample ?
1687 std::min(value, uint32_t(d->pSample->SamplesTotal -
1688 d->pSampleLoops[0].LoopLength)) :
1689 0;
1690 }
1691 }
1692
1693 void DimRegionEdit::set_LoopLength(gig::DimensionRegion* d, uint32_t value)
1694 {
1695 if (d->SampleLoops) {
1696 d->pSampleLoops[0].LoopLength =
1697 d->pSample ?
1698 std::min(value, uint32_t(d->pSample->SamplesTotal -
1699 d->pSampleLoops[0].LoopStart)) :
1700 0;
1701 }
1702 }
1703
1704 void DimRegionEdit::set_LoopInfinite(gig::DimensionRegion* d, bool value)
1705 {
1706 if (d->pSample) {
1707 if (value) d->pSample->LoopPlayCount = 0;
1708 else if (d->pSample->LoopPlayCount == 0) d->pSample->LoopPlayCount = 1;
1709 }
1710 }
1711
1712 void DimRegionEdit::set_LoopPlayCount(gig::DimensionRegion* d, uint32_t value)
1713 {
1714 if (d->pSample) d->pSample->LoopPlayCount = value;
1715 }
1716
1717 void DimRegionEdit::nullOutSampleReference() {
1718 if (!dimregion) return;
1719 gig::Sample* oldref = dimregion->pSample;
1720 if (!oldref) return;
1721
1722 DimRegionChangeGuard(this, dimregion);
1723
1724 // in case currently assigned sample is a stereo one, then remove both
1725 // references (expected to be due to a "stereo dimension")
1726 gig::DimensionRegion* d[2] = { dimregion, NULL };
1727 if (oldref->Channels == 2) {
1728 gig::Region* region = dimregion->GetParent();
1729 {
1730 int stereo_bit = 0;
1731 int bitcount = 0;
1732 for (int dim = 0 ; dim < region->Dimensions ; dim++) {
1733 if (region->pDimensionDefinitions[dim].dimension == gig::dimension_samplechannel) {
1734 stereo_bit = 1 << bitcount;
1735 break;
1736 }
1737 bitcount += region->pDimensionDefinitions[dim].bits;
1738 }
1739
1740 if (stereo_bit) {
1741 int dimregno;
1742 for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
1743 if (region->pDimensionRegions[dimregno] == dimregion) {
1744 break;
1745 }
1746 }
1747 d[0] = region->pDimensionRegions[dimregno & ~stereo_bit];
1748 d[1] = region->pDimensionRegions[dimregno | stereo_bit];
1749 }
1750 }
1751 }
1752
1753 if (d[0]) d[0]->pSample = NULL;
1754 if (d[1]) d[1]->pSample = NULL;
1755
1756 // update UI elements
1757 set_dim_region(dimregion);
1758
1759 sample_ref_changed_signal.emit(oldref, NULL);
1760 }
1761
1762 void DimRegionEdit::onButtonSelectSamplePressed() {
1763 if (!dimregion) return;
1764 if (!dimregion->pSample) return;
1765 select_sample_signal.emit(dimregion->pSample);
1766 }
1767
1768 sigc::signal<void, gig::Sample*>& DimRegionEdit::signal_select_sample() {
1769 return select_sample_signal;
1770 }

  ViewVC Help
Powered by ViewVC