/[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 2691 - (hide annotations) (download)
Sun Jan 4 19:46:54 2015 UTC (4 years, 5 months ago) by schoenebeck
File size: 59308 byte(s)
* Dimension Region Editor: Added button "Select Sample" on the sample tab,
  which allows to conveniently select the dimension region's sample on the
  left hand side's samples tree view.

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

  ViewVC Help
Powered by ViewVC