/[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 2464 - (hide annotations) (download)
Thu Sep 5 00:49:13 2013 UTC (6 years, 3 months ago) by schoenebeck
File size: 53918 byte(s)
* copying sample informations automatically may now be disabled from the
  new "Edit" main menu

1 schoenebeck 1225 /*
2 persson 2392 * Copyright (C) 2006-2013 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     int layer_bit = 0;
98     for (int dim = 0 ; dim < region->Dimensions ; dim++) {
99     if (region->pDimensionDefinitions[dim].dimension ==
100     gig::dimension_layer) {
101     layer_bit = 1 << bitcount;
102    
103     int mask =
104     ~(((1 << region->pDimensionDefinitions[dim].bits) - 1) <<
105     bitcount);
106     int c = dimregno & mask; // mask away the layer dimension
107    
108     for (int i = 0 ; i < region->pDimensionDefinitions[dim].zones ;
109     i++) {
110     gig::DimensionRegion* d =
111     region->pDimensionRegions[c + (i << bitcount)];
112     if (d != dimreg) {
113     draw_one_curve(cr, d, false);
114     }
115     }
116     break;
117     }
118     bitcount += region->pDimensionDefinitions[dim].bits;
119     }
120    
121     // then, draw the currently selected layer
122     draw_one_curve(cr, dimreg, is_sensitive());
123     }
124     return true;
125     }
126    
127     void CrossfadeCurve::draw_one_curve(const Cairo::RefPtr<Cairo::Context>& cr,
128     const gig::DimensionRegion* d,
129     bool sensitive) {
130     int w = get_width();
131     int h = get_height();
132    
133     if (d->Crossfade.out_end) {
134 persson 2392 for (int pass = 0 ; pass < 2 ; pass++) {
135 persson 2430 cr->move_to(d->Crossfade.in_start / 127.0 * (w - 3), h);
136     cr->line_to(d->Crossfade.in_end / 127.0 * (w - 3), 1.5);
137     cr->line_to(d->Crossfade.out_start / 127.0 * (w - 3), 1.5);
138     cr->line_to(d->Crossfade.out_end / 127.0 * (w - 3), h);
139 persson 2392
140     if (pass == 0) {
141 persson 2430 cr->set_source_rgba(0.5, 0.44, 1.0, sensitive ? 0.2 : 0.1);
142 persson 2392 cr->fill();
143     } else {
144     cr->set_line_width(3);
145 persson 2430 cr->set_source_rgba(0.5, 0.44, 1.0, sensitive ? 1.0 : 0.3);
146 persson 2392 cr->stroke();
147     }
148     }
149     }
150     }
151    
152    
153 schoenebeck 1225 DimRegionEdit::DimRegionEdit() :
154 persson 2392 velocity_curve(&gig::DimensionRegion::GetVelocityAttenuation),
155     release_curve(&gig::DimensionRegion::GetVelocityRelease),
156     cutoff_curve(&gig::DimensionRegion::GetVelocityCutoff),
157 persson 1831 eEG1PreAttack(_("Pre-attack"), 0, 100, 2),
158     eEG1Attack(_("Attack"), 0, 60, 3),
159     eEG1Decay1(_("Decay 1"), 0.005, 60, 3),
160     eEG1Decay2(_("Decay 2"), 0, 60, 3),
161     eEG1InfiniteSustain(_("Infinite sustain")),
162     eEG1Sustain(_("Sustain"), 0, 100, 2),
163     eEG1Release(_("Release"), 0, 60, 3),
164     eEG1Hold(_("Hold")),
165     eEG1Controller(_("Controller")),
166     eEG1ControllerInvert(_("Controller invert")),
167     eEG1ControllerAttackInfluence(_("Controller attack influence"), 0, 3),
168     eEG1ControllerDecayInfluence(_("Controller decay influence"), 0, 3),
169     eEG1ControllerReleaseInfluence(_("Controller release influence"), 0, 3),
170     eLFO1Frequency(_("Frequency"), 0.1, 10, 2),
171     eLFO1InternalDepth(_("Internal depth"), 0, 1200),
172     eLFO1ControlDepth(_("Control depth"), 0, 1200),
173     eLFO1Controller(_("Controller")),
174     eLFO1FlipPhase(_("Flip phase")),
175     eLFO1Sync(_("Sync")),
176     eEG2PreAttack(_("Pre-attack"), 0, 100, 2),
177     eEG2Attack(_("Attack"), 0, 60, 3),
178     eEG2Decay1(_("Decay 1"), 0.005, 60, 3),
179     eEG2Decay2(_("Decay 2"), 0, 60, 3),
180     eEG2InfiniteSustain(_("Infinite sustain")),
181     eEG2Sustain(_("Sustain"), 0, 100, 2),
182     eEG2Release(_("Release"), 0, 60, 3),
183     eEG2Controller(_("Controller")),
184     eEG2ControllerInvert(_("Controller invert")),
185     eEG2ControllerAttackInfluence(_("Controller attack influence"), 0, 3),
186     eEG2ControllerDecayInfluence(_("Controller decay influence"), 0, 3),
187     eEG2ControllerReleaseInfluence(_("Controller release influence"), 0, 3),
188     eLFO2Frequency(_("Frequency"), 0.1, 10, 2),
189     eLFO2InternalDepth(_("Internal depth"), 0, 1200),
190     eLFO2ControlDepth(_("Control depth"), 0, 1200),
191     eLFO2Controller(_("Controller")),
192     eLFO2FlipPhase(_("Flip phase")),
193     eLFO2Sync(_("Sync")),
194     eEG3Attack(_("Attack"), 0, 10, 3),
195     eEG3Depth(_("Depth"), -1200, 1200),
196     eLFO3Frequency(_("Frequency"), 0.1, 10, 2),
197     eLFO3InternalDepth(_("Internal depth"), 0, 1200),
198     eLFO3ControlDepth(_("Control depth"), 0, 1200),
199     eLFO3Controller(_("Controller")),
200     eLFO3Sync(_("Sync")),
201     eVCFEnabled(_("Enabled")),
202     eVCFType(_("Type")),
203     eVCFCutoffController(_("Cutoff controller")),
204     eVCFCutoffControllerInvert(_("Cutoff controller invert")),
205     eVCFCutoff(_("Cutoff")),
206     eVCFVelocityCurve(_("Velocity curve")),
207     eVCFVelocityScale(_("Velocity scale")),
208     eVCFVelocityDynamicRange(_("Velocity dynamic range"), 0, 4),
209     eVCFResonance(_("Resonance")),
210     eVCFResonanceDynamic(_("Resonance dynamic")),
211     eVCFResonanceController(_("Resonance controller")),
212     eVCFKeyboardTracking(_("Keyboard tracking")),
213     eVCFKeyboardTrackingBreakpoint(_("Keyboard tracking breakpoint")),
214     eVelocityResponseCurve(_("Velocity response curve")),
215     eVelocityResponseDepth(_("Velocity response depth"), 0, 4),
216     eVelocityResponseCurveScaling(_("Velocity response curve scaling")),
217     eReleaseVelocityResponseCurve(_("Release velocity response curve")),
218     eReleaseVelocityResponseDepth(_("Release velocity response depth"), 0, 4),
219     eReleaseTriggerDecay(_("Release trigger decay"), 0, 8),
220     eCrossfade_in_start(_("Crossfade-in start")),
221     eCrossfade_in_end(_("Crossfade-in end")),
222     eCrossfade_out_start(_("Crossfade-out start")),
223     eCrossfade_out_end(_("Crossfade-out end")),
224     ePitchTrack(_("Pitch track")),
225     eDimensionBypass(_("Dimension bypass")),
226     ePan(_("Pan"), -64, 63),
227     eSelfMask(_("Self mask")),
228     eAttenuationController(_("Attenuation controller")),
229     eInvertAttenuationController(_("Invert attenuation controller")),
230     eAttenuationControllerThreshold(_("Attenuation controller threshold")),
231     eChannelOffset(_("Channel offset"), 0, 9),
232     eSustainDefeat(_("Sustain defeat")),
233     eMSDecode(_("MS decode")),
234     eSampleStartOffset(_("Sample start offset"), 0, 2000),
235     eUnityNote(_("Unity note")),
236     eFineTune(_("Fine tune"), -49, 50),
237     eGain(_("Gain"), -96, 0, 2, -655360),
238     eGainPlus6(_("Gain +6dB"), eGain, 6 * -655360),
239     eSampleLoopEnabled(_("Enabled")),
240     eSampleLoopStart(_("Loop start positon")),
241     eSampleLoopLength(_("Loop size")),
242     eSampleLoopType(_("Loop type")),
243     eSampleLoopInfinite(_("Infinite loop")),
244     eSampleLoopPlayCount(_("Playback count"), 1),
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    
355 schoenebeck 1225 for (int i = 0 ; i < 7 ; i++) {
356     table[i] = new Gtk::Table(3, 1);
357     table[i]->set_col_spacings(7);
358     }
359    
360     // set tooltips
361     eUnityNote.set_tip(
362     _("Note this sample is associated with (a.k.a. 'root note')")
363     );
364     eSampleStartOffset.set_tip(_("Sample position at which playback should be started"));
365     ePan.set_tip(_("Stereo balance (left/right)"));
366     eChannelOffset.set_tip(
367     _("Output channel where the audio signal should be routed to (0 - 9)")
368     );
369     ePitchTrack.set_tip(
370     _("If true: sample will be pitched according to the key position "
371     "(this would be disabled for drums for example)")
372     );
373     eSampleLoopEnabled.set_tip(_("If enabled: repeats to playback the sample"));
374     eSampleLoopStart.set_tip(
375     _("Start position within the sample (in sample points) of the area to "
376     "be looped")
377     );
378     eSampleLoopLength.set_tip(
379     _("Duration (in sample points) of the area to be looped")
380     );
381     eSampleLoopType.set_tip(
382     _("Direction in which the loop area in the sample should be played back")
383     );
384     eSampleLoopInfinite.set_tip(
385     _("Whether the loop area should be played back forever\n"
386     "Caution: this setting is stored on Sample side, thus is shared "
387     "among all dimension regions that use this sample!")
388     );
389     eSampleLoopPlayCount.set_tip(
390     _("How many times the loop area should be played back\n"
391     "Caution: this setting is stored on Sample side, thus is shared "
392     "among all dimension regions that use this sample!")
393     );
394    
395     pageno = 0;
396     rowno = 0;
397     firstRowInBlock = 0;
398    
399     addHeader(_("Mandatory Settings"));
400 persson 1831 addString(_("Sample"), lSample, wSample);
401 schoenebeck 1225 //TODO: the following would break drag&drop: wSample->property_editable().set_value(false); or this: wSample->set_editable(false);
402 persson 2151 #ifdef OLD_TOOLTIPS
403 schoenebeck 1225 tooltips.set_tip(*wSample, _("Drop a sample here"));
404 persson 2151 #else
405     wSample->set_tooltip_text(_("Drop a sample here"));
406     #endif
407 schoenebeck 1225 addProp(eUnityNote);
408     addHeader(_("Optional Settings"));
409     addProp(eSampleStartOffset);
410     addProp(eChannelOffset);
411 persson 1831 addHeader(_("Loops"));
412 schoenebeck 1225 addProp(eSampleLoopEnabled);
413     addProp(eSampleLoopStart);
414     addProp(eSampleLoopLength);
415     {
416 persson 1831 const char* choices[] = { _("normal"), _("bidirectional"), _("backward"), 0 };
417 schoenebeck 1225 static const uint32_t values[] = {
418     gig::loop_type_normal,
419     gig::loop_type_bidirectional,
420     gig::loop_type_backward
421     };
422     eSampleLoopType.set_choices(choices, values);
423     }
424     addProp(eSampleLoopType);
425     addProp(eSampleLoopInfinite);
426     addProp(eSampleLoopPlayCount);
427    
428     nextPage();
429    
430     addHeader(_("General Amplitude Settings"));
431     addProp(eGain);
432     addProp(eGainPlus6);
433     addProp(ePan);
434     addHeader(_("Amplitude Envelope (EG1)"));
435     addProp(eEG1PreAttack);
436     addProp(eEG1Attack);
437     addProp(eEG1Decay1);
438     addProp(eEG1Decay2);
439     addProp(eEG1InfiniteSustain);
440     addProp(eEG1Sustain);
441     addProp(eEG1Release);
442     addProp(eEG1Hold);
443     addProp(eEG1Controller);
444     addProp(eEG1ControllerInvert);
445     addProp(eEG1ControllerAttackInfluence);
446     addProp(eEG1ControllerDecayInfluence);
447     addProp(eEG1ControllerReleaseInfluence);
448    
449     nextPage();
450    
451     addHeader(_("Amplitude Oscillator (LFO1)"));
452     addProp(eLFO1Frequency);
453     addProp(eLFO1InternalDepth);
454     addProp(eLFO1ControlDepth);
455     {
456 persson 1831 const char* choices[] = { _("internal"), _("modwheel"), _("breath"),
457     _("internal+modwheel"), _("internal+breath"), 0 };
458 schoenebeck 1225 static const gig::lfo1_ctrl_t values[] = {
459     gig::lfo1_ctrl_internal,
460     gig::lfo1_ctrl_modwheel,
461     gig::lfo1_ctrl_breath,
462     gig::lfo1_ctrl_internal_modwheel,
463     gig::lfo1_ctrl_internal_breath
464     };
465     eLFO1Controller.set_choices(choices, values);
466     }
467     addProp(eLFO1Controller);
468     addProp(eLFO1FlipPhase);
469     addProp(eLFO1Sync);
470 persson 1831 addHeader(_("Crossfade"));
471 schoenebeck 1225 addProp(eAttenuationController);
472     addProp(eInvertAttenuationController);
473     addProp(eAttenuationControllerThreshold);
474     addProp(eCrossfade_in_start);
475     addProp(eCrossfade_in_end);
476     addProp(eCrossfade_out_start);
477     addProp(eCrossfade_out_end);
478    
479 persson 2392 Gtk::Frame* frame = new Gtk::Frame;
480     frame->add(crossfade_curve);
481     table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
482     Gtk::SHRINK, Gtk::SHRINK);
483     rowno++;
484    
485     eCrossfade_in_start.signal_value_changed().connect(
486     sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
487     eCrossfade_in_end.signal_value_changed().connect(
488     sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
489     eCrossfade_out_start.signal_value_changed().connect(
490     sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
491     eCrossfade_out_end.signal_value_changed().connect(
492     sigc::mem_fun(crossfade_curve, &CrossfadeCurve::queue_draw));
493    
494 schoenebeck 1225 nextPage();
495    
496     addHeader(_("General Filter Settings"));
497     addProp(eVCFEnabled);
498     {
499 persson 1831 const char* choices[] = { _("lowpass"), _("lowpassturbo"), _("bandpass"),
500     _("highpass"), _("bandreject"), 0 };
501 schoenebeck 1225 static const gig::vcf_type_t values[] = {
502     gig::vcf_type_lowpass,
503     gig::vcf_type_lowpassturbo,
504     gig::vcf_type_bandpass,
505     gig::vcf_type_highpass,
506     gig::vcf_type_bandreject
507     };
508     eVCFType.set_choices(choices, values);
509     }
510     addProp(eVCFType);
511     {
512 persson 1831 const char* choices[] = { _("none"), _("none2"), _("modwheel"), _("effect1"), _("effect2"),
513     _("breath"), _("foot"), _("sustainpedal"), _("softpedal"),
514     _("genpurpose7"), _("genpurpose8"), _("aftertouch"), 0 };
515 schoenebeck 1225 static const gig::vcf_cutoff_ctrl_t values[] = {
516     gig::vcf_cutoff_ctrl_none,
517     gig::vcf_cutoff_ctrl_none2,
518     gig::vcf_cutoff_ctrl_modwheel,
519     gig::vcf_cutoff_ctrl_effect1,
520     gig::vcf_cutoff_ctrl_effect2,
521     gig::vcf_cutoff_ctrl_breath,
522     gig::vcf_cutoff_ctrl_foot,
523     gig::vcf_cutoff_ctrl_sustainpedal,
524     gig::vcf_cutoff_ctrl_softpedal,
525     gig::vcf_cutoff_ctrl_genpurpose7,
526     gig::vcf_cutoff_ctrl_genpurpose8,
527     gig::vcf_cutoff_ctrl_aftertouch
528     };
529     eVCFCutoffController.set_choices(choices, values);
530     }
531     addProp(eVCFCutoffController);
532     addProp(eVCFCutoffControllerInvert);
533     addProp(eVCFCutoff);
534 persson 1831 const char* curve_type_texts[] = { _("nonlinear"), _("linear"), _("special"), 0 };
535 schoenebeck 1225 static const gig::curve_type_t curve_type_values[] = {
536     gig::curve_type_nonlinear,
537     gig::curve_type_linear,
538     gig::curve_type_special
539     };
540     eVCFVelocityCurve.set_choices(curve_type_texts, curve_type_values);
541     addProp(eVCFVelocityCurve);
542     addProp(eVCFVelocityScale);
543     addProp(eVCFVelocityDynamicRange);
544 persson 2392
545     eVCFCutoffController.signal_value_changed().connect(
546     sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
547     eVCFVelocityCurve.signal_value_changed().connect(
548     sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
549     eVCFVelocityScale.signal_value_changed().connect(
550     sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
551     eVCFVelocityDynamicRange.signal_value_changed().connect(
552     sigc::mem_fun(cutoff_curve, &VelocityCurve::queue_draw));
553    
554     frame = new Gtk::Frame;
555     frame->add(cutoff_curve);
556     table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
557     Gtk::SHRINK, Gtk::SHRINK);
558     rowno++;
559    
560 schoenebeck 1225 addProp(eVCFResonance);
561     addProp(eVCFResonanceDynamic);
562     {
563 persson 1831 const char* choices[] = { _("none"), _("genpurpose3"), _("genpurpose4"),
564     _("genpurpose5"), _("genpurpose6"), 0 };
565 schoenebeck 1225 static const gig::vcf_res_ctrl_t values[] = {
566     gig::vcf_res_ctrl_none,
567     gig::vcf_res_ctrl_genpurpose3,
568     gig::vcf_res_ctrl_genpurpose4,
569     gig::vcf_res_ctrl_genpurpose5,
570     gig::vcf_res_ctrl_genpurpose6
571     };
572     eVCFResonanceController.set_choices(choices, values);
573     }
574     addProp(eVCFResonanceController);
575     addProp(eVCFKeyboardTracking);
576     addProp(eVCFKeyboardTrackingBreakpoint);
577    
578     nextPage();
579    
580 persson 1623 lEG2 = addHeader(_("Filter Cutoff Envelope (EG2)"));
581 schoenebeck 1225 addProp(eEG2PreAttack);
582     addProp(eEG2Attack);
583     addProp(eEG2Decay1);
584     addProp(eEG2Decay2);
585     addProp(eEG2InfiniteSustain);
586     addProp(eEG2Sustain);
587     addProp(eEG2Release);
588     addProp(eEG2Controller);
589     addProp(eEG2ControllerInvert);
590     addProp(eEG2ControllerAttackInfluence);
591     addProp(eEG2ControllerDecayInfluence);
592     addProp(eEG2ControllerReleaseInfluence);
593 persson 1623 lLFO2 = addHeader(_("Filter Cutoff Oscillator (LFO2)"));
594 schoenebeck 1225 addProp(eLFO2Frequency);
595     addProp(eLFO2InternalDepth);
596     addProp(eLFO2ControlDepth);
597     {
598 persson 1831 const char* choices[] = { _("internal"), _("modwheel"), _("foot"),
599     _("internal+modwheel"), _("internal+foot"), 0 };
600 schoenebeck 1225 static const gig::lfo2_ctrl_t values[] = {
601     gig::lfo2_ctrl_internal,
602     gig::lfo2_ctrl_modwheel,
603     gig::lfo2_ctrl_foot,
604     gig::lfo2_ctrl_internal_modwheel,
605     gig::lfo2_ctrl_internal_foot
606     };
607     eLFO2Controller.set_choices(choices, values);
608     }
609     addProp(eLFO2Controller);
610     addProp(eLFO2FlipPhase);
611     addProp(eLFO2Sync);
612    
613     nextPage();
614    
615     addHeader(_("General Pitch Settings"));
616     addProp(eFineTune);
617     addProp(ePitchTrack);
618     addHeader(_("Pitch Envelope (EG3)"));
619     addProp(eEG3Attack);
620     addProp(eEG3Depth);
621     addHeader(_("Pitch Oscillator (LFO3)"));
622     addProp(eLFO3Frequency);
623     addProp(eLFO3InternalDepth);
624     addProp(eLFO3ControlDepth);
625     {
626 persson 1831 const char* choices[] = { _("internal"), _("modwheel"), _("aftertouch"),
627     _("internal+modwheel"), _("internal+aftertouch"), 0 };
628 schoenebeck 1225 static const gig::lfo3_ctrl_t values[] = {
629     gig::lfo3_ctrl_internal,
630     gig::lfo3_ctrl_modwheel,
631     gig::lfo3_ctrl_aftertouch,
632     gig::lfo3_ctrl_internal_modwheel,
633     gig::lfo3_ctrl_internal_aftertouch
634     };
635     eLFO3Controller.set_choices(choices, values);
636     }
637     addProp(eLFO3Controller);
638     addProp(eLFO3Sync);
639    
640     nextPage();
641    
642 persson 2392 addHeader(_("Velocity Reponse"));
643 schoenebeck 1225 eVelocityResponseCurve.set_choices(curve_type_texts, curve_type_values);
644     addProp(eVelocityResponseCurve);
645     addProp(eVelocityResponseDepth);
646     addProp(eVelocityResponseCurveScaling);
647 persson 2392
648     eVelocityResponseCurve.signal_value_changed().connect(
649     sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
650     eVelocityResponseDepth.signal_value_changed().connect(
651     sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
652     eVelocityResponseCurveScaling.signal_value_changed().connect(
653     sigc::mem_fun(velocity_curve, &VelocityCurve::queue_draw));
654    
655     frame = new Gtk::Frame;
656     frame->add(velocity_curve);
657     table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
658     Gtk::SHRINK, Gtk::SHRINK);
659     rowno++;
660    
661     addHeader(_("Release Velocity Reponse"));
662 schoenebeck 1225 eReleaseVelocityResponseCurve.set_choices(curve_type_texts,
663     curve_type_values);
664     addProp(eReleaseVelocityResponseCurve);
665     addProp(eReleaseVelocityResponseDepth);
666 persson 2392
667     eReleaseVelocityResponseCurve.signal_value_changed().connect(
668     sigc::mem_fun(release_curve, &VelocityCurve::queue_draw));
669     eReleaseVelocityResponseDepth.signal_value_changed().connect(
670     sigc::mem_fun(release_curve, &VelocityCurve::queue_draw));
671     frame = new Gtk::Frame;
672     frame->add(release_curve);
673     table[pageno]->attach(*frame, 1, 3, rowno, rowno + 1,
674     Gtk::SHRINK, Gtk::SHRINK);
675     rowno++;
676    
677 schoenebeck 1225 addProp(eReleaseTriggerDecay);
678     {
679 persson 1831 const char* choices[] = { _("none"), _("effect4depth"), _("effect5depth"), 0 };
680 schoenebeck 1225 static const gig::dim_bypass_ctrl_t values[] = {
681     gig::dim_bypass_ctrl_none,
682     gig::dim_bypass_ctrl_94,
683     gig::dim_bypass_ctrl_95
684     };
685     eDimensionBypass.set_choices(choices, values);
686     }
687     addProp(eDimensionBypass);
688     addProp(eSelfMask);
689     addProp(eSustainDefeat);
690     addProp(eMSDecode);
691    
692     nextPage();
693    
694    
695 persson 1460 eEG1InfiniteSustain.signal_value_changed().connect(
696     sigc::mem_fun(*this, &DimRegionEdit::EG1InfiniteSustain_toggled));
697     eEG2InfiniteSustain.signal_value_changed().connect(
698     sigc::mem_fun(*this, &DimRegionEdit::EG2InfiniteSustain_toggled));
699     eEG1Controller.signal_value_changed().connect(
700     sigc::mem_fun(*this, &DimRegionEdit::EG1Controller_changed));
701     eEG2Controller.signal_value_changed().connect(
702     sigc::mem_fun(*this, &DimRegionEdit::EG2Controller_changed));
703     eLFO1Controller.signal_value_changed().connect(
704     sigc::mem_fun(*this, &DimRegionEdit::LFO1Controller_changed));
705     eLFO2Controller.signal_value_changed().connect(
706     sigc::mem_fun(*this, &DimRegionEdit::LFO2Controller_changed));
707     eLFO3Controller.signal_value_changed().connect(
708     sigc::mem_fun(*this, &DimRegionEdit::LFO3Controller_changed));
709     eAttenuationController.signal_value_changed().connect(
710     sigc::mem_fun(*this, &DimRegionEdit::AttenuationController_changed));
711     eVCFEnabled.signal_value_changed().connect(
712     sigc::mem_fun(*this, &DimRegionEdit::VCFEnabled_toggled));
713     eVCFCutoffController.signal_value_changed().connect(
714     sigc::mem_fun(*this, &DimRegionEdit::VCFCutoffController_changed));
715     eVCFResonanceController.signal_value_changed().connect(
716     sigc::mem_fun(*this, &DimRegionEdit::VCFResonanceController_changed));
717 schoenebeck 1225
718 persson 1460 eCrossfade_in_start.signal_value_changed().connect(
719 schoenebeck 1225 sigc::mem_fun(*this, &DimRegionEdit::crossfade1_changed));
720 persson 1460 eCrossfade_in_end.signal_value_changed().connect(
721 schoenebeck 1225 sigc::mem_fun(*this, &DimRegionEdit::crossfade2_changed));
722 persson 1460 eCrossfade_out_start.signal_value_changed().connect(
723 schoenebeck 1225 sigc::mem_fun(*this, &DimRegionEdit::crossfade3_changed));
724 persson 1460 eCrossfade_out_end.signal_value_changed().connect(
725 schoenebeck 1225 sigc::mem_fun(*this, &DimRegionEdit::crossfade4_changed));
726    
727 persson 1460 eSampleLoopEnabled.signal_value_changed().connect(
728     sigc::mem_fun(*this, &DimRegionEdit::update_loop_elements));
729     eSampleLoopStart.signal_value_changed().connect(
730     sigc::mem_fun(*this, &DimRegionEdit::loop_start_changed));
731     eSampleLoopLength.signal_value_changed().connect(
732     sigc::mem_fun(*this, &DimRegionEdit::loop_length_changed));
733     eSampleLoopInfinite.signal_value_changed().connect(
734 schoenebeck 1225 sigc::mem_fun(*this, &DimRegionEdit::loop_infinite_toggled));
735    
736 persson 1831 append_page(*table[0], _("Sample"));
737     append_page(*table[1], _("Amplitude (1)"));
738     append_page(*table[2], _("Amplitude (2)"));
739     append_page(*table[3], _("Filter (1)"));
740     append_page(*table[4], _("Filter (2)"));
741     append_page(*table[5], _("Pitch"));
742     append_page(*table[6], _("Misc"));
743 schoenebeck 1225 }
744    
745     DimRegionEdit::~DimRegionEdit()
746     {
747     }
748    
749     void DimRegionEdit::addString(const char* labelText, Gtk::Label*& label,
750     Gtk::Entry*& widget)
751     {
752     label = new Gtk::Label(Glib::ustring(labelText) + ":");
753 persson 2169 label->set_alignment(Gtk::ALIGN_START);
754 schoenebeck 1225
755     table[pageno]->attach(*label, 1, 2, rowno, rowno + 1,
756     Gtk::FILL, Gtk::SHRINK);
757    
758     widget = new Gtk::Entry();
759    
760     table[pageno]->attach(*widget, 2, 3, rowno, rowno + 1,
761     Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
762    
763     rowno++;
764     }
765    
766 persson 1623 Gtk::Label* DimRegionEdit::addHeader(const char* text)
767 schoenebeck 1225 {
768     if (firstRowInBlock < rowno - 1)
769     {
770     Gtk::Label* filler = new Gtk::Label(" ");
771     table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,
772     Gtk::FILL, Gtk::SHRINK);
773     }
774     Glib::ustring str = "<b>";
775     str += text;
776     str += "</b>";
777     Gtk::Label* label = new Gtk::Label(str);
778     label->set_use_markup();
779 persson 2169 label->set_alignment(Gtk::ALIGN_START);
780 schoenebeck 1225 table[pageno]->attach(*label, 0, 3, rowno, rowno + 1,
781     Gtk::FILL, Gtk::SHRINK);
782     rowno++;
783     firstRowInBlock = rowno;
784 persson 1623 return label;
785 schoenebeck 1225 }
786    
787     void DimRegionEdit::nextPage()
788     {
789     if (firstRowInBlock < rowno - 1)
790     {
791     Gtk::Label* filler = new Gtk::Label(" ");
792     table[pageno]->attach(*filler, 0, 1, firstRowInBlock, rowno,
793     Gtk::FILL, Gtk::SHRINK);
794     }
795     pageno++;
796     rowno = 0;
797     firstRowInBlock = 0;
798     }
799    
800     void DimRegionEdit::addProp(BoolEntry& boolentry)
801     {
802     table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1,
803     Gtk::FILL, Gtk::SHRINK);
804     rowno++;
805     }
806    
807 persson 1262 void DimRegionEdit::addProp(BoolEntryPlus6& boolentry)
808     {
809     table[pageno]->attach(boolentry.widget, 1, 3, rowno, rowno + 1,
810     Gtk::FILL, Gtk::SHRINK);
811     rowno++;
812     }
813    
814 schoenebeck 1225 void DimRegionEdit::addProp(LabelWidget& prop)
815     {
816     table[pageno]->attach(prop.label, 1, 2, rowno, rowno + 1,
817     Gtk::FILL, Gtk::SHRINK);
818     table[pageno]->attach(prop.widget, 2, 3, rowno, rowno + 1,
819     Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
820     rowno++;
821     }
822    
823    
824     void DimRegionEdit::set_dim_region(gig::DimensionRegion* d)
825     {
826     dimregion = d;
827 persson 2392 velocity_curve.set_dim_region(d);
828     release_curve.set_dim_region(d);
829     cutoff_curve.set_dim_region(d);
830     crossfade_curve.set_dim_region(d);
831 schoenebeck 1225
832     set_sensitive(d);
833     if (!d) return;
834    
835 persson 1460 update_model++;
836     eEG1PreAttack.set_value(d->EG1PreAttack);
837     eEG1Attack.set_value(d->EG1Attack);
838     eEG1Decay1.set_value(d->EG1Decay1);
839     eEG1Decay2.set_value(d->EG1Decay2);
840     eEG1InfiniteSustain.set_value(d->EG1InfiniteSustain);
841     eEG1Sustain.set_value(d->EG1Sustain);
842     eEG1Release.set_value(d->EG1Release);
843     eEG1Hold.set_value(d->EG1Hold);
844     eEG1Controller.set_value(d->EG1Controller);
845     eEG1ControllerInvert.set_value(d->EG1ControllerInvert);
846     eEG1ControllerAttackInfluence.set_value(d->EG1ControllerAttackInfluence);
847     eEG1ControllerDecayInfluence.set_value(d->EG1ControllerDecayInfluence);
848     eEG1ControllerReleaseInfluence.set_value(d->EG1ControllerReleaseInfluence);
849     eLFO1Frequency.set_value(d->LFO1Frequency);
850     eLFO1InternalDepth.set_value(d->LFO1InternalDepth);
851     eLFO1ControlDepth.set_value(d->LFO1ControlDepth);
852     eLFO1Controller.set_value(d->LFO1Controller);
853     eLFO1FlipPhase.set_value(d->LFO1FlipPhase);
854     eLFO1Sync.set_value(d->LFO1Sync);
855     eEG2PreAttack.set_value(d->EG2PreAttack);
856     eEG2Attack.set_value(d->EG2Attack);
857     eEG2Decay1.set_value(d->EG2Decay1);
858     eEG2Decay2.set_value(d->EG2Decay2);
859     eEG2InfiniteSustain.set_value(d->EG2InfiniteSustain);
860     eEG2Sustain.set_value(d->EG2Sustain);
861     eEG2Release.set_value(d->EG2Release);
862     eEG2Controller.set_value(d->EG2Controller);
863     eEG2ControllerInvert.set_value(d->EG2ControllerInvert);
864     eEG2ControllerAttackInfluence.set_value(d->EG2ControllerAttackInfluence);
865     eEG2ControllerDecayInfluence.set_value(d->EG2ControllerDecayInfluence);
866     eEG2ControllerReleaseInfluence.set_value(d->EG2ControllerReleaseInfluence);
867     eLFO2Frequency.set_value(d->LFO2Frequency);
868     eLFO2InternalDepth.set_value(d->LFO2InternalDepth);
869     eLFO2ControlDepth.set_value(d->LFO2ControlDepth);
870     eLFO2Controller.set_value(d->LFO2Controller);
871     eLFO2FlipPhase.set_value(d->LFO2FlipPhase);
872     eLFO2Sync.set_value(d->LFO2Sync);
873     eEG3Attack.set_value(d->EG3Attack);
874     eEG3Depth.set_value(d->EG3Depth);
875     eLFO3Frequency.set_value(d->LFO3Frequency);
876     eLFO3InternalDepth.set_value(d->LFO3InternalDepth);
877     eLFO3ControlDepth.set_value(d->LFO3ControlDepth);
878     eLFO3Controller.set_value(d->LFO3Controller);
879     eLFO3Sync.set_value(d->LFO3Sync);
880     eVCFEnabled.set_value(d->VCFEnabled);
881     eVCFType.set_value(d->VCFType);
882     eVCFCutoffController.set_value(d->VCFCutoffController);
883     eVCFCutoffControllerInvert.set_value(d->VCFCutoffControllerInvert);
884     eVCFCutoff.set_value(d->VCFCutoff);
885     eVCFVelocityCurve.set_value(d->VCFVelocityCurve);
886     eVCFVelocityScale.set_value(d->VCFVelocityScale);
887     eVCFVelocityDynamicRange.set_value(d->VCFVelocityDynamicRange);
888     eVCFResonance.set_value(d->VCFResonance);
889     eVCFResonanceDynamic.set_value(d->VCFResonanceDynamic);
890     eVCFResonanceController.set_value(d->VCFResonanceController);
891     eVCFKeyboardTracking.set_value(d->VCFKeyboardTracking);
892     eVCFKeyboardTrackingBreakpoint.set_value(d->VCFKeyboardTrackingBreakpoint);
893     eVelocityResponseCurve.set_value(d->VelocityResponseCurve);
894     eVelocityResponseDepth.set_value(d->VelocityResponseDepth);
895     eVelocityResponseCurveScaling.set_value(d->VelocityResponseCurveScaling);
896     eReleaseVelocityResponseCurve.set_value(d->ReleaseVelocityResponseCurve);
897     eReleaseVelocityResponseDepth.set_value(d->ReleaseVelocityResponseDepth);
898     eReleaseTriggerDecay.set_value(d->ReleaseTriggerDecay);
899     eCrossfade_in_start.set_value(d->Crossfade.in_start);
900     eCrossfade_in_end.set_value(d->Crossfade.in_end);
901     eCrossfade_out_start.set_value(d->Crossfade.out_start);
902     eCrossfade_out_end.set_value(d->Crossfade.out_end);
903     ePitchTrack.set_value(d->PitchTrack);
904     eDimensionBypass.set_value(d->DimensionBypass);
905     ePan.set_value(d->Pan);
906     eSelfMask.set_value(d->SelfMask);
907     eAttenuationController.set_value(d->AttenuationController);
908     eInvertAttenuationController.set_value(d->InvertAttenuationController);
909     eAttenuationControllerThreshold.set_value(d->AttenuationControllerThreshold);
910     eChannelOffset.set_value(d->ChannelOffset);
911     eSustainDefeat.set_value(d->SustainDefeat);
912     eMSDecode.set_value(d->MSDecode);
913     eSampleStartOffset.set_value(d->SampleStartOffset);
914     eUnityNote.set_value(d->UnityNote);
915     eFineTune.set_value(d->FineTune);
916     eGain.set_value(d->Gain);
917     eGainPlus6.set_value(d->Gain);
918     eSampleLoopEnabled.set_value(d->SampleLoops);
919     eSampleLoopType.set_value(
920     d->SampleLoops ? d->pSampleLoops[0].LoopType : 0);
921     eSampleLoopStart.set_value(
922     d->SampleLoops ? d->pSampleLoops[0].LoopStart : 0);
923     eSampleLoopLength.set_value(
924     d->SampleLoops ? d->pSampleLoops[0].LoopLength : 0);
925     eSampleLoopInfinite.set_value(
926     d->pSample && d->pSample->LoopPlayCount == 0);
927     eSampleLoopPlayCount.set_value(
928     d->pSample ? d->pSample->LoopPlayCount : 0);
929     update_model--;
930 persson 1261
931 persson 2446 wSample->set_text(d->pSample ? gig_to_utf8(d->pSample->pInfo->Name) :
932     _("NULL"));
933 schoenebeck 1225
934 persson 1460 update_loop_elements();
935 schoenebeck 1225 VCFEnabled_toggled();
936     }
937    
938 persson 1460
939 schoenebeck 1225 void DimRegionEdit::VCFEnabled_toggled()
940     {
941 persson 1460 bool sensitive = eVCFEnabled.get_value();
942 schoenebeck 1225 eVCFType.set_sensitive(sensitive);
943     eVCFCutoffController.set_sensitive(sensitive);
944     eVCFVelocityCurve.set_sensitive(sensitive);
945     eVCFVelocityScale.set_sensitive(sensitive);
946     eVCFVelocityDynamicRange.set_sensitive(sensitive);
947 persson 2430 cutoff_curve.set_sensitive(sensitive);
948 schoenebeck 1225 eVCFResonance.set_sensitive(sensitive);
949     eVCFResonanceController.set_sensitive(sensitive);
950     eVCFKeyboardTracking.set_sensitive(sensitive);
951     eVCFKeyboardTrackingBreakpoint.set_sensitive(sensitive);
952 persson 1623 lEG2->set_sensitive(sensitive);
953 schoenebeck 1225 eEG2PreAttack.set_sensitive(sensitive);
954     eEG2Attack.set_sensitive(sensitive);
955     eEG2Decay1.set_sensitive(sensitive);
956     eEG2InfiniteSustain.set_sensitive(sensitive);
957     eEG2Sustain.set_sensitive(sensitive);
958     eEG2Release.set_sensitive(sensitive);
959     eEG2Controller.set_sensitive(sensitive);
960     eEG2ControllerAttackInfluence.set_sensitive(sensitive);
961     eEG2ControllerDecayInfluence.set_sensitive(sensitive);
962     eEG2ControllerReleaseInfluence.set_sensitive(sensitive);
963 persson 1623 lLFO2->set_sensitive(sensitive);
964 schoenebeck 1225 eLFO2Frequency.set_sensitive(sensitive);
965     eLFO2InternalDepth.set_sensitive(sensitive);
966     eLFO2ControlDepth.set_sensitive(sensitive);
967     eLFO2Controller.set_sensitive(sensitive);
968     eLFO2FlipPhase.set_sensitive(sensitive);
969     eLFO2Sync.set_sensitive(sensitive);
970     if (sensitive) {
971     VCFCutoffController_changed();
972     VCFResonanceController_changed();
973     EG2InfiniteSustain_toggled();
974     EG2Controller_changed();
975     LFO2Controller_changed();
976     } else {
977     eVCFCutoffControllerInvert.set_sensitive(false);
978     eVCFCutoff.set_sensitive(false);
979     eVCFResonanceDynamic.set_sensitive(false);
980     eVCFResonance.set_sensitive(false);
981     eEG2Decay2.set_sensitive(false);
982     eEG2ControllerInvert.set_sensitive(false);
983     eLFO2InternalDepth.set_sensitive(false);
984     eLFO2ControlDepth.set_sensitive(false);
985     }
986     }
987    
988     void DimRegionEdit::VCFCutoffController_changed()
989     {
990 persson 1460 gig::vcf_cutoff_ctrl_t ctrl = eVCFCutoffController.get_value();
991     bool hasController = ctrl != gig::vcf_cutoff_ctrl_none && ctrl != gig::vcf_cutoff_ctrl_none2;
992 schoenebeck 1225
993     eVCFCutoffControllerInvert.set_sensitive(hasController);
994     eVCFCutoff.set_sensitive(!hasController);
995     eVCFResonanceDynamic.set_sensitive(!hasController);
996 persson 1831 eVCFVelocityScale.label.set_text(hasController ? _("Minimum cutoff:") :
997     _("Velocity scale:"));
998 schoenebeck 1225 }
999    
1000     void DimRegionEdit::VCFResonanceController_changed()
1001     {
1002 persson 1460 bool hasController = eVCFResonanceController.get_value() != gig::vcf_res_ctrl_none;
1003 schoenebeck 1225 eVCFResonance.set_sensitive(!hasController);
1004     }
1005    
1006     void DimRegionEdit::EG1InfiniteSustain_toggled()
1007     {
1008 persson 1460 bool infSus = eEG1InfiniteSustain.get_value();
1009 schoenebeck 1225 eEG1Decay2.set_sensitive(!infSus);
1010     }
1011    
1012     void DimRegionEdit::EG2InfiniteSustain_toggled()
1013     {
1014 persson 1460 bool infSus = eEG2InfiniteSustain.get_value();
1015 schoenebeck 1225 eEG2Decay2.set_sensitive(!infSus);
1016     }
1017    
1018     void DimRegionEdit::EG1Controller_changed()
1019     {
1020 persson 1460 bool hasController = eEG1Controller.get_value().type != gig::leverage_ctrl_t::type_none;
1021 schoenebeck 1225 eEG1ControllerInvert.set_sensitive(hasController);
1022     }
1023    
1024     void DimRegionEdit::EG2Controller_changed()
1025     {
1026 persson 1460 bool hasController = eEG2Controller.get_value().type != gig::leverage_ctrl_t::type_none;
1027 schoenebeck 1225 eEG2ControllerInvert.set_sensitive(hasController);
1028     }
1029    
1030     void DimRegionEdit::AttenuationController_changed()
1031     {
1032 persson 1460 bool hasController =
1033     eAttenuationController.get_value().type != gig::leverage_ctrl_t::type_none;
1034 schoenebeck 1225 eInvertAttenuationController.set_sensitive(hasController);
1035     eAttenuationControllerThreshold.set_sensitive(hasController);
1036     eCrossfade_in_start.set_sensitive(hasController);
1037     eCrossfade_in_end.set_sensitive(hasController);
1038     eCrossfade_out_start.set_sensitive(hasController);
1039     eCrossfade_out_end.set_sensitive(hasController);
1040 persson 2430 crossfade_curve.set_sensitive(hasController);
1041 schoenebeck 1225 }
1042    
1043     void DimRegionEdit::LFO1Controller_changed()
1044     {
1045 persson 1460 gig::lfo1_ctrl_t ctrl = eLFO1Controller.get_value();
1046     eLFO1ControlDepth.set_sensitive(ctrl != gig::lfo1_ctrl_internal);
1047     eLFO1InternalDepth.set_sensitive(ctrl != gig::lfo1_ctrl_modwheel &&
1048     ctrl != gig::lfo1_ctrl_breath);
1049 schoenebeck 1225 }
1050    
1051     void DimRegionEdit::LFO2Controller_changed()
1052     {
1053 persson 1460 gig::lfo2_ctrl_t ctrl = eLFO2Controller.get_value();
1054     eLFO2ControlDepth.set_sensitive(ctrl != gig::lfo2_ctrl_internal);
1055     eLFO2InternalDepth.set_sensitive(ctrl != gig::lfo2_ctrl_modwheel &&
1056     ctrl != gig::lfo2_ctrl_foot);
1057 schoenebeck 1225 }
1058    
1059     void DimRegionEdit::LFO3Controller_changed()
1060     {
1061 persson 1460 gig::lfo3_ctrl_t ctrl = eLFO3Controller.get_value();
1062     eLFO3ControlDepth.set_sensitive(ctrl != gig::lfo3_ctrl_internal);
1063     eLFO3InternalDepth.set_sensitive(ctrl != gig::lfo3_ctrl_modwheel &&
1064     ctrl != gig::lfo3_ctrl_aftertouch);
1065 schoenebeck 1225 }
1066    
1067     void DimRegionEdit::crossfade1_changed()
1068     {
1069 persson 1460 update_model++;
1070     eCrossfade_in_end.set_value(dimregion->Crossfade.in_end);
1071     eCrossfade_out_start.set_value(dimregion->Crossfade.out_start);
1072     eCrossfade_out_end.set_value(dimregion->Crossfade.out_end);
1073     update_model--;
1074 schoenebeck 1225 }
1075    
1076     void DimRegionEdit::crossfade2_changed()
1077     {
1078 persson 1460 update_model++;
1079     eCrossfade_in_start.set_value(dimregion->Crossfade.in_start);
1080     eCrossfade_out_start.set_value(dimregion->Crossfade.out_start);
1081     eCrossfade_out_end.set_value(dimregion->Crossfade.out_end);
1082     update_model--;
1083 schoenebeck 1225 }
1084    
1085     void DimRegionEdit::crossfade3_changed()
1086     {
1087 persson 1460 update_model++;
1088     eCrossfade_in_start.set_value(dimregion->Crossfade.in_start);
1089     eCrossfade_in_end.set_value(dimregion->Crossfade.in_end);
1090     eCrossfade_out_end.set_value(dimregion->Crossfade.out_end);
1091     update_model--;
1092 schoenebeck 1225 }
1093    
1094     void DimRegionEdit::crossfade4_changed()
1095     {
1096 persson 1460 update_model++;
1097     eCrossfade_in_start.set_value(dimregion->Crossfade.in_start);
1098     eCrossfade_in_end.set_value(dimregion->Crossfade.in_end);
1099     eCrossfade_out_start.set_value(dimregion->Crossfade.out_start);
1100     update_model--;
1101 schoenebeck 1225 }
1102    
1103 persson 1460 void DimRegionEdit::update_loop_elements()
1104 schoenebeck 1225 {
1105 persson 1460 update_model++;
1106     const bool active = eSampleLoopEnabled.get_value();
1107 schoenebeck 1225 eSampleLoopStart.set_sensitive(active);
1108     eSampleLoopLength.set_sensitive(active);
1109     eSampleLoopType.set_sensitive(active);
1110 persson 1303 eSampleLoopInfinite.set_sensitive(active && dimregion && dimregion->pSample);
1111 persson 1460 // sample loop shall never be longer than the actual sample size
1112     loop_start_changed();
1113     loop_length_changed();
1114     eSampleLoopStart.set_value(
1115     dimregion->SampleLoops ? dimregion->pSampleLoops[0].LoopStart : 0);
1116     eSampleLoopLength.set_value(
1117     dimregion->SampleLoops ? dimregion->pSampleLoops[0].LoopLength : 0);
1118 persson 1261
1119 persson 1460 eSampleLoopInfinite.set_value(
1120     dimregion->pSample && dimregion->pSample->LoopPlayCount == 0);
1121 persson 1261
1122 persson 1460 loop_infinite_toggled();
1123     update_model--;
1124     }
1125 persson 1261
1126 persson 1460 void DimRegionEdit::loop_start_changed() {
1127     if (dimregion && dimregion->SampleLoops) {
1128     eSampleLoopLength.set_upper(dimregion->pSample ?
1129     dimregion->pSample->SamplesTotal -
1130     dimregion->pSampleLoops[0].LoopStart : 0);
1131 schoenebeck 1225 }
1132     }
1133    
1134 persson 1460 void DimRegionEdit::loop_length_changed() {
1135     if (dimregion && dimregion->SampleLoops) {
1136     eSampleLoopStart.set_upper(dimregion->pSample ?
1137     dimregion->pSample->SamplesTotal -
1138     dimregion->pSampleLoops[0].LoopLength : 0);
1139     }
1140     }
1141    
1142 schoenebeck 1225 void DimRegionEdit::loop_infinite_toggled() {
1143     eSampleLoopPlayCount.set_sensitive(
1144 persson 1303 dimregion && dimregion->pSample &&
1145 persson 1460 !eSampleLoopInfinite.get_value() &&
1146     eSampleLoopEnabled.get_value()
1147 schoenebeck 1225 );
1148 persson 1460 update_model++;
1149     eSampleLoopPlayCount.set_value(
1150     dimregion->pSample ? dimregion->pSample->LoopPlayCount : 0);
1151     update_model--;
1152 schoenebeck 1225 }
1153 persson 1265
1154 schoenebeck 2464 bool DimRegionEdit::set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop)
1155 persson 1265 {
1156     if (dimregion) {
1157 schoenebeck 1322 //TODO: we should better move the code from MainWindow::on_sample_label_drop_drag_data_received() here
1158    
1159     // currently commented because we're sending a similar signal in MainWindow::on_sample_label_drop_drag_data_received()
1160     //dimreg_to_be_changed_signal.emit(dimregion);
1161    
1162 persson 1798 // make sure stereo samples always are the same in both
1163     // dimregs in the samplechannel dimension
1164     int nbDimregs = 1;
1165     gig::DimensionRegion* d[2] = { dimregion, 0 };
1166     if (sample->Channels == 2) {
1167     gig::Region* region = dimregion->GetParent();
1168    
1169     int bitcount = 0;
1170     int stereo_bit = 0;
1171     for (int dim = 0 ; dim < region->Dimensions ; dim++) {
1172     if (region->pDimensionDefinitions[dim].dimension == gig::dimension_samplechannel) {
1173     stereo_bit = 1 << bitcount;
1174     break;
1175     }
1176     bitcount += region->pDimensionDefinitions[dim].bits;
1177     }
1178    
1179     if (stereo_bit) {
1180     int dimregno;
1181     for (dimregno = 0 ; dimregno < region->DimensionRegions ; dimregno++) {
1182     if (region->pDimensionRegions[dimregno] == dimregion) {
1183     break;
1184     }
1185     }
1186     d[0] = region->pDimensionRegions[dimregno & ~stereo_bit];
1187     d[1] = region->pDimensionRegions[dimregno | stereo_bit];
1188     nbDimregs = 2;
1189     }
1190     }
1191    
1192 schoenebeck 1322 gig::Sample* oldref = dimregion->pSample;
1193 persson 1265
1194 persson 1798 for (int i = 0 ; i < nbDimregs ; i++) {
1195     d[i]->pSample = sample;
1196 persson 1265
1197 persson 1798 // copy sample information from Sample to DimensionRegion
1198 schoenebeck 2464 if (copy_sample_unity)
1199     d[i]->UnityNote = sample->MIDIUnityNote;
1200     if (copy_sample_tune)
1201     d[i]->FineTune = sample->FineTune;
1202     if (copy_sample_loop) {
1203     int loops = sample->Loops ? 1 : 0;
1204     while (d[i]->SampleLoops > loops) {
1205     d[i]->DeleteSampleLoop(&d[i]->pSampleLoops[0]);
1206     }
1207     while (d[i]->SampleLoops < sample->Loops) {
1208     DLS::sample_loop_t loop;
1209     d[i]->AddSampleLoop(&loop);
1210     }
1211     if (loops) {
1212     d[i]->pSampleLoops[0].Size = sizeof(DLS::sample_loop_t);
1213     d[i]->pSampleLoops[0].LoopType = sample->LoopType;
1214     d[i]->pSampleLoops[0].LoopStart = sample->LoopStart;
1215     d[i]->pSampleLoops[0].LoopLength = sample->LoopEnd - sample->LoopStart + 1;
1216     }
1217 persson 1798 }
1218 persson 1265 }
1219    
1220     // update ui
1221 persson 1460 update_model++;
1222 persson 2446 wSample->set_text(gig_to_utf8(dimregion->pSample->pInfo->Name));
1223 persson 1460 eUnityNote.set_value(dimregion->UnityNote);
1224     eFineTune.set_value(dimregion->FineTune);
1225     eSampleLoopEnabled.set_value(dimregion->SampleLoops);
1226     update_loop_elements();
1227     update_model--;
1228 persson 1265
1229 schoenebeck 1322 sample_ref_changed_signal.emit(oldref, sample);
1230     // currently commented because we're sending a similar signal in MainWindow::on_sample_label_drop_drag_data_received()
1231     //dimreg_changed_signal.emit(dimregion);
1232 persson 1265 return true;
1233     }
1234     return false;
1235     }
1236 schoenebeck 1322
1237 schoenebeck 1339 sigc::signal<void, gig::DimensionRegion*>& DimRegionEdit::signal_dimreg_to_be_changed() {
1238 schoenebeck 1322 return dimreg_to_be_changed_signal;
1239     }
1240    
1241 schoenebeck 1339 sigc::signal<void, gig::DimensionRegion*>& DimRegionEdit::signal_dimreg_changed() {
1242 schoenebeck 1322 return dimreg_changed_signal;
1243     }
1244    
1245 schoenebeck 1339 sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& DimRegionEdit::signal_sample_ref_changed() {
1246 schoenebeck 1322 return sample_ref_changed_signal;
1247     }
1248 persson 1460
1249    
1250     void DimRegionEdit::set_UnityNote(gig::DimensionRegion* d, uint8_t value)
1251     {
1252     d->UnityNote = value;
1253     }
1254    
1255     void DimRegionEdit::set_FineTune(gig::DimensionRegion* d, int16_t value)
1256     {
1257     d->FineTune = value;
1258     }
1259    
1260     void DimRegionEdit::set_Crossfade_in_start(gig::DimensionRegion* d,
1261     uint8_t value)
1262     {
1263     d->Crossfade.in_start = value;
1264     if (d->Crossfade.in_end < value) set_Crossfade_in_end(d, value);
1265     }
1266    
1267     void DimRegionEdit::set_Crossfade_in_end(gig::DimensionRegion* d,
1268     uint8_t value)
1269     {
1270     d->Crossfade.in_end = value;
1271     if (value < d->Crossfade.in_start) set_Crossfade_in_start(d, value);
1272     if (value > d->Crossfade.out_start) set_Crossfade_out_start(d, value);
1273     }
1274    
1275     void DimRegionEdit::set_Crossfade_out_start(gig::DimensionRegion* d,
1276     uint8_t value)
1277     {
1278     d->Crossfade.out_start = value;
1279     if (value < d->Crossfade.in_end) set_Crossfade_in_end(d, value);
1280     if (value > d->Crossfade.out_end) set_Crossfade_out_end(d, value);
1281     }
1282    
1283     void DimRegionEdit::set_Crossfade_out_end(gig::DimensionRegion* d,
1284     uint8_t value)
1285     {
1286     d->Crossfade.out_end = value;
1287     if (value < d->Crossfade.out_start) set_Crossfade_out_start(d, value);
1288     }
1289    
1290     void DimRegionEdit::set_Gain(gig::DimensionRegion* d, int32_t value)
1291     {
1292     d->SetGain(value);
1293     }
1294    
1295     void DimRegionEdit::set_LoopEnabled(gig::DimensionRegion* d, bool value)
1296     {
1297     if (value) {
1298     // create a new sample loop in case there is none yet
1299     if (!d->SampleLoops) {
1300     DLS::sample_loop_t loop;
1301     loop.LoopType = gig::loop_type_normal;
1302     // loop the whole sample by default
1303     loop.LoopStart = 0;
1304     loop.LoopLength =
1305     (d->pSample) ? d->pSample->SamplesTotal : 0;
1306     dimreg_to_be_changed_signal.emit(d);
1307     d->AddSampleLoop(&loop);
1308     dimreg_changed_signal.emit(d);
1309     }
1310     } else {
1311     if (d->SampleLoops) {
1312     dimreg_to_be_changed_signal.emit(d);
1313     // delete ALL existing sample loops
1314     while (d->SampleLoops) {
1315     d->DeleteSampleLoop(&d->pSampleLoops[0]);
1316     }
1317     dimreg_changed_signal.emit(d);
1318     }
1319     }
1320     }
1321    
1322     void DimRegionEdit::set_LoopType(gig::DimensionRegion* d, uint32_t value)
1323     {
1324     if (d->SampleLoops) d->pSampleLoops[0].LoopType = value;
1325     }
1326    
1327     void DimRegionEdit::set_LoopStart(gig::DimensionRegion* d, uint32_t value)
1328     {
1329     if (d->SampleLoops) {
1330     d->pSampleLoops[0].LoopStart =
1331     d->pSample ?
1332     std::min(value, uint32_t(d->pSample->SamplesTotal -
1333     d->pSampleLoops[0].LoopLength)) :
1334     0;
1335     }
1336     }
1337    
1338     void DimRegionEdit::set_LoopLength(gig::DimensionRegion* d, uint32_t value)
1339     {
1340     if (d->SampleLoops) {
1341     d->pSampleLoops[0].LoopLength =
1342     d->pSample ?
1343     std::min(value, uint32_t(d->pSample->SamplesTotal -
1344     d->pSampleLoops[0].LoopStart)) :
1345     0;
1346     }
1347     }
1348    
1349     void DimRegionEdit::set_LoopInfinite(gig::DimensionRegion* d, bool value)
1350     {
1351     if (d->pSample) {
1352     if (value) d->pSample->LoopPlayCount = 0;
1353     else if (d->pSample->LoopPlayCount == 0) d->pSample->LoopPlayCount = 1;
1354     }
1355     }
1356    
1357     void DimRegionEdit::set_LoopPlayCount(gig::DimensionRegion* d, uint32_t value)
1358     {
1359     if (d->pSample) d->pSample->LoopPlayCount = value;
1360     }

  ViewVC Help
Powered by ViewVC