/[svn]/gigedit/trunk/src/gigedit/dimregionedit.cpp
ViewVC logotype

Annotation of /gigedit/trunk/src/gigedit/dimregionedit.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2690 - (hide annotations) (download)
Sun Jan 4 18:36:42 2015 UTC (4 years, 5 months ago) by schoenebeck
File size: 58388 byte(s)
* Dimension Region Editor: Show coarse sample format info (audio channels,
  bit depth, sample rate) and unique sample ID (since the gig format allows
  different samples to have the same name).

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

  ViewVC Help
Powered by ViewVC