/[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 3177 - (show annotations) (download)
Thu May 11 20:59:46 2017 UTC (2 years, 6 months ago) by schoenebeck
File size: 62870 byte(s)
* Live mode performance optimization: fixed the editor to be non-responsive
  for a very long time, which happened if changing instrument parameters of
  a very large amount of dimension regions was requested.
* Bumped version (1.0.0.svn45).

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

  ViewVC Help
Powered by ViewVC