/[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 2392 - (hide annotations) (download)
Mon Jan 7 20:41:16 2013 UTC (8 years, 8 months ago) by persson
File size: 51983 byte(s)
* added graphical curves for velocity response and crossfade

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

  ViewVC Help
Powered by ViewVC