/[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 1533 - (hide annotations) (download)
Sat Dec 1 10:21:07 2007 UTC (11 years, 6 months ago) by persson
File size: 44590 byte(s)
* parameter edits can now be applied to multiple regions and dimension
  regions simultaneously - three checkboxes were added that select
  if changes apply to all regions and/or all dimension regions

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

  ViewVC Help
Powered by ViewVC