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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3329 - (hide annotations) (download) (as text)
Sun Jul 23 18:31:53 2017 UTC (6 years, 8 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 13289 byte(s)
* Added EG state machine options for EG1 and EG2, which may be used
  to configure whether the individual EG stages may be cancelled.
* Bumped version (1.0.0.svn60).

1 schoenebeck 1225 /* -*- c++ -*-
2 schoenebeck 3068 * Copyright (C) 2006-2017 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     #ifndef GIGEDIT_DIMREGIONEDIT_H
21     #define GIGEDIT_DIMREGIONEDIT_H
22    
23 schoenebeck 3068 #ifdef LIBGIG_HEADER_FILE
24     # include LIBGIG_HEADER_FILE(gig.h)
25     #else
26     # include <gig.h>
27     #endif
28 schoenebeck 1225
29 persson 2442 #include <cairomm/context.h>
30 persson 2844 #include <gtkmm/box.h>
31 persson 2392 #include <gtkmm/drawingarea.h>
32 schoenebeck 1225 #include <gtkmm/entry.h>
33     #include <gtkmm/label.h>
34     #include <gtkmm/notebook.h>
35     #include <gtkmm/table.h>
36    
37 persson 1460 #include <set>
38    
39 schoenebeck 1225 #include "paramedit.h"
40 schoenebeck 3177 #include "global.h"
41 schoenebeck 1225
42 persson 2392 class VelocityCurve : public Gtk::DrawingArea {
43     public:
44     VelocityCurve(double (gig::DimensionRegion::*getter)(uint8_t));
45     void set_dim_region(gig::DimensionRegion* d) { dimreg = d; }
46    
47     protected:
48     #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
49     bool on_expose_event(GdkEventExpose* e);
50     #else
51     bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
52     #endif
53    
54     private:
55     double (gig::DimensionRegion::* const getter)(uint8_t);
56     gig::DimensionRegion* dimreg;
57     };
58    
59     class CrossfadeCurve : public Gtk::DrawingArea {
60     public:
61     CrossfadeCurve();
62     void set_dim_region(gig::DimensionRegion* d) { dimreg = d; }
63    
64     protected:
65     #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
66     bool on_expose_event(GdkEventExpose* e);
67     #else
68     bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
69     #endif
70    
71     private:
72     gig::DimensionRegion* dimreg;
73 persson 2430 void draw_one_curve(const Cairo::RefPtr<Cairo::Context>& cr,
74     const gig::DimensionRegion* d,
75     bool sensitive);
76 persson 2392 };
77    
78 schoenebeck 3329 class EGStateOptions : public Gtk::HBox {
79     public:
80     Gtk::Label label;
81     BoolBox checkBoxAttack;
82     BoolBox checkBoxAttackHold;
83     BoolBox checkBoxDecay1;
84     BoolBox checkBoxDecay2;
85     BoolBox checkBoxRelease;
86    
87     EGStateOptions();
88     };
89    
90 schoenebeck 1225 class DimRegionEdit : public Gtk::Notebook
91     {
92     public:
93     DimRegionEdit();
94     virtual ~DimRegionEdit();
95     void set_dim_region(gig::DimensionRegion* d);
96 schoenebeck 2464 bool set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop);
97 schoenebeck 2925 bool set_sample(gig::DimensionRegion* dimreg, gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop);
98 schoenebeck 1225 Gtk::Entry* wSample;
99 schoenebeck 2720 Gtk::Button* buttonNullSampleReference;
100 schoenebeck 1339 sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_to_be_changed();
101     sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_changed();
102     sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& signal_sample_ref_changed();
103 schoenebeck 2691 sigc::signal<void, gig::Sample*>& signal_select_sample();
104 schoenebeck 1225
105 persson 1533 std::set<gig::DimensionRegion*> dimregs;
106    
107 schoenebeck 1225 protected:
108 schoenebeck 1322 sigc::signal<void, gig::DimensionRegion*> dimreg_to_be_changed_signal;
109     sigc::signal<void, gig::DimensionRegion*> dimreg_changed_signal;
110     sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/> sample_ref_changed_signal;
111 persson 1261 sigc::signal<void> instrument_changed;
112 schoenebeck 2691 sigc::signal<void, gig::Sample*> select_sample_signal;
113 persson 1261
114 schoenebeck 3177 /**
115     * Ensures that the 2 signals DimRegionEdit::dimreg_to_be_changed_signal and
116     * DimRegionEdit::dimreg_changed_signal are always triggered correctly as a
117     * pair. It behaves similar to a "mutex lock guard" design pattern.
118     */
119     class DimRegionChangeGuard : public SignalGuard<gig::DimensionRegion*> {
120     public:
121     DimRegionChangeGuard(DimRegionEdit* edit, gig::DimensionRegion* pDimReg) :
122     SignalGuard<gig::DimensionRegion*>(edit->dimreg_to_be_changed_signal, edit->dimreg_changed_signal, pDimReg)
123     {
124     }
125     };
126    
127 schoenebeck 1225 gig::DimensionRegion* dimregion;
128    
129 persson 2151 #ifdef OLD_TOOLTIPS
130 schoenebeck 1225 Gtk::Tooltips tooltips;
131 persson 2151 #endif
132 schoenebeck 1225
133     Gtk::Table* table[7];
134    
135     Gtk::Label* lSample;
136    
137 persson 2392 VelocityCurve velocity_curve;
138     VelocityCurve release_curve;
139     VelocityCurve cutoff_curve;
140     CrossfadeCurve crossfade_curve;
141    
142 schoenebeck 1225 NumEntryPermille eEG1PreAttack;
143     NumEntryTemp<double> eEG1Attack;
144     NumEntryTemp<double> eEG1Decay1;
145     NumEntryTemp<double> eEG1Decay2;
146     BoolEntry eEG1InfiniteSustain;
147     NumEntryPermille eEG1Sustain;
148     NumEntryTemp<double> eEG1Release;
149     BoolEntry eEG1Hold;
150     ChoiceEntryLeverageCtrl eEG1Controller;
151     BoolEntry eEG1ControllerInvert;
152     NumEntryTemp<uint8_t> eEG1ControllerAttackInfluence;
153     NumEntryTemp<uint8_t> eEG1ControllerDecayInfluence;
154     NumEntryTemp<uint8_t> eEG1ControllerReleaseInfluence;
155 schoenebeck 3329 EGStateOptions eEG1StateOptions;
156 schoenebeck 1225 NumEntryTemp<double> eLFO1Frequency;
157     NumEntryTemp<uint16_t> eLFO1InternalDepth;
158     NumEntryTemp<uint16_t> eLFO1ControlDepth;
159     ChoiceEntry<gig::lfo1_ctrl_t> eLFO1Controller;
160     BoolEntry eLFO1FlipPhase;
161     BoolEntry eLFO1Sync;
162     NumEntryPermille eEG2PreAttack;
163     NumEntryTemp<double> eEG2Attack;
164     NumEntryTemp<double> eEG2Decay1;
165     NumEntryTemp<double> eEG2Decay2;
166     BoolEntry eEG2InfiniteSustain;
167     NumEntryPermille eEG2Sustain;
168     NumEntryTemp<double> eEG2Release;
169     ChoiceEntryLeverageCtrl eEG2Controller;
170     BoolEntry eEG2ControllerInvert;
171     NumEntryTemp<uint8_t> eEG2ControllerAttackInfluence;
172     NumEntryTemp<uint8_t> eEG2ControllerDecayInfluence;
173     NumEntryTemp<uint8_t> eEG2ControllerReleaseInfluence;
174 schoenebeck 3329 EGStateOptions eEG2StateOptions;
175 schoenebeck 1225 NumEntryTemp<double> eLFO2Frequency;
176     NumEntryTemp<uint16_t> eLFO2InternalDepth;
177     NumEntryTemp<uint16_t> eLFO2ControlDepth;
178     ChoiceEntry<gig::lfo2_ctrl_t> eLFO2Controller;
179     BoolEntry eLFO2FlipPhase;
180     BoolEntry eLFO2Sync;
181     NumEntryTemp<double> eEG3Attack;
182     NumEntryTemp<int16_t> eEG3Depth;
183     NumEntryTemp<double> eLFO3Frequency;
184     NumEntryTemp<int16_t> eLFO3InternalDepth;
185     NumEntryTemp<int16_t> eLFO3ControlDepth;
186     ChoiceEntry<gig::lfo3_ctrl_t> eLFO3Controller;
187     BoolEntry eLFO3Sync;
188     BoolEntry eVCFEnabled;
189     ChoiceEntry<gig::vcf_type_t> eVCFType;
190     ChoiceEntry<gig::vcf_cutoff_ctrl_t> eVCFCutoffController;
191     BoolEntry eVCFCutoffControllerInvert;
192     NumEntryTemp<uint8_t> eVCFCutoff;
193     ChoiceEntry<gig::curve_type_t> eVCFVelocityCurve;
194     NumEntryTemp<uint8_t> eVCFVelocityScale;
195     NumEntryTemp<uint8_t> eVCFVelocityDynamicRange;
196     NumEntryTemp<uint8_t> eVCFResonance;
197     BoolEntry eVCFResonanceDynamic;
198     ChoiceEntry<gig::vcf_res_ctrl_t> eVCFResonanceController;
199     BoolEntry eVCFKeyboardTracking;
200     NumEntryTemp<uint8_t> eVCFKeyboardTrackingBreakpoint;
201     ChoiceEntry<gig::curve_type_t> eVelocityResponseCurve;
202     NumEntryTemp<uint8_t> eVelocityResponseDepth;
203     NumEntryTemp<uint8_t> eVelocityResponseCurveScaling;
204     ChoiceEntry<gig::curve_type_t> eReleaseVelocityResponseCurve;
205     NumEntryTemp<uint8_t> eReleaseVelocityResponseDepth;
206     NumEntryTemp<uint8_t> eReleaseTriggerDecay;
207     NumEntryTemp<uint8_t> eCrossfade_in_start;
208     NumEntryTemp<uint8_t> eCrossfade_in_end;
209     NumEntryTemp<uint8_t> eCrossfade_out_start;
210     NumEntryTemp<uint8_t> eCrossfade_out_end;
211     BoolEntry ePitchTrack;
212     ChoiceEntry<gig::dim_bypass_ctrl_t> eDimensionBypass;
213     NumEntryTemp<int8_t> ePan;
214     BoolEntry eSelfMask;
215     ChoiceEntryLeverageCtrl eAttenuationController;
216     BoolEntry eInvertAttenuationController;
217     NumEntryTemp<uint8_t> eAttenuationControllerThreshold;
218     NumEntryTemp<uint8_t> eChannelOffset;
219     BoolEntry eSustainDefeat;
220     BoolEntry eMSDecode;
221     NumEntryTemp<uint16_t> eSampleStartOffset;
222     NoteEntry eUnityNote;
223 schoenebeck 2991 ReadOnlyLabelWidget eSampleGroup;
224 schoenebeck 2690 ReadOnlyLabelWidget eSampleFormatInfo;
225     ReadOnlyLabelWidget eSampleID;
226 schoenebeck 2991 ReadOnlyLabelWidget eChecksum;
227 schoenebeck 1225 NumEntryTemp<int16_t> eFineTune;
228     NumEntryGain eGain;
229     BoolEntryPlus6 eGainPlus6;
230     BoolEntry eSampleLoopEnabled;
231     NumEntryTemp<uint32_t> eSampleLoopStart;
232     NumEntryTemp<uint32_t> eSampleLoopLength;
233     ChoiceEntry<uint32_t> eSampleLoopType;
234     BoolEntry eSampleLoopInfinite;
235     NumEntryTemp<uint32_t> eSampleLoopPlayCount;
236 persson 1623 Gtk::Label* lEG2;
237     Gtk::Label* lLFO2;
238 schoenebeck 1225
239 schoenebeck 2691 Gtk::Button buttonSelectSample;
240    
241 schoenebeck 1225 int rowno;
242     int pageno;
243     int firstRowInBlock;
244    
245    
246     void addProp(BoolEntry& boolentry);
247 persson 1262 void addProp(BoolEntryPlus6& boolentry);
248 schoenebeck 1225 void addProp(LabelWidget& labelwidget);
249 schoenebeck 3329 void addLine(Gtk::HBox& line);
250 schoenebeck 1225 void addString(const char* labelText, Gtk::Label*& label,
251     Gtk::Entry*& widget);
252 schoenebeck 2720 void addString(const char* labelText, Gtk::Label*& label,
253     Gtk::Entry*& widget, Gtk::Button*& button);
254 persson 1623 Gtk::Label* addHeader(const char* text);
255 schoenebeck 2691 void addRightHandSide(Gtk::Widget& widget);
256 schoenebeck 1225 void nextPage();
257    
258     void VCFEnabled_toggled();
259     void VCFCutoffController_changed();
260     void VCFResonanceController_changed();
261     void EG1InfiniteSustain_toggled();
262     void EG2InfiniteSustain_toggled();
263     void EG1Controller_changed();
264     void EG2Controller_changed();
265     void AttenuationController_changed();
266     void LFO1Controller_changed();
267     void LFO2Controller_changed();
268     void LFO3Controller_changed();
269     void crossfade1_changed();
270     void crossfade2_changed();
271     void crossfade3_changed();
272     void crossfade4_changed();
273 persson 1460 void update_loop_elements();
274     void loop_start_changed();
275     void loop_length_changed();
276 schoenebeck 1225 void loop_infinite_toggled();
277 schoenebeck 2720 void nullOutSampleReference();
278 schoenebeck 1225
279 persson 1460 int update_model;
280    
281 schoenebeck 3329 /**
282     * Workaround for the circumstance that C++ does not allow to cast to
283     * member pointers.
284     */
285     template<typename classT, typename memberT>
286     union ClassMemberPtr {
287     memberT classT::*pmember;
288     void* pvoid;
289    
290     ClassMemberPtr(size_t s) : pvoid((void*)s) {}
291     ClassMemberPtr(void* p) : pvoid(p) {}
292     };
293    
294 persson 1460 // connect a widget to a setter function in DimRegionEdit
295     template<typename C, typename T>
296     void connect(C& widget,
297     void (DimRegionEdit::*setter)(gig::DimensionRegion*, T)) {
298     connect<C, T>(widget,
299     sigc::mem_fun(setter));
300     }
301    
302     // connect a widget to a member variable in gig::DimensionRegion
303     template<typename C, typename T>
304     void connect(C& widget, T gig::DimensionRegion::* member) {
305     connect<C, T>(widget,
306     sigc::bind(sigc::mem_fun(&DimRegionEdit::set_member<T>), member));
307     }
308    
309     // connect a widget to a setter function in gig::DimensionRegion
310     template<typename C, typename T>
311     void connect(C& widget,
312     void (gig::DimensionRegion::*setter)(T)) {
313     connect<C, T>(widget,
314     sigc::hide<0>(sigc::mem_fun(setter)));
315     }
316    
317     // helper function for the connect functions above
318     template<typename C, typename T>
319     void connect(C& widget,
320     sigc::slot<void, DimRegionEdit*, gig::DimensionRegion*, T> setter) {
321     widget.signal_value_changed().connect(
322     sigc::compose(sigc::bind(sigc::mem_fun(*this, &DimRegionEdit::set_many<T>), setter),
323     sigc::mem_fun(widget, &C::get_value)));
324     }
325    
326 schoenebeck 2925 // loop through all dimregions being edited and set a value in
327 persson 1460 // each of them
328     template<typename T>
329     void set_many(T value,
330     sigc::slot<void, DimRegionEdit*, gig::DimensionRegion*, T> setter) {
331     if (update_model == 0) {
332     for (std::set<gig::DimensionRegion*>::iterator i = dimregs.begin() ;
333 persson 2841 i != dimregs.end() ; ++i)
334 persson 1460 {
335 schoenebeck 3177 DimRegionChangeGuard(this, *i);
336 persson 1460 setter(this, *i, value);
337     }
338     }
339     }
340    
341     // set a value of a member variable in the given dimregion
342     template<typename T>
343     void set_member(gig::DimensionRegion* d, T value,
344     T gig::DimensionRegion::* member) {
345     d->*member = value;
346     }
347    
348     // setters for specific dimregion parameters
349    
350     void set_UnityNote(gig::DimensionRegion* d, uint8_t value);
351     void set_FineTune(gig::DimensionRegion* d, int16_t value);
352     void set_Crossfade_in_start(gig::DimensionRegion* d, uint8_t value);
353     void set_Crossfade_in_end(gig::DimensionRegion* d, uint8_t value);
354     void set_Crossfade_out_start(gig::DimensionRegion* d, uint8_t value);
355     void set_Crossfade_out_end(gig::DimensionRegion* d, uint8_t value);
356     void set_Gain(gig::DimensionRegion* d, int32_t value);
357     void set_LoopEnabled(gig::DimensionRegion* d, bool value);
358     void set_LoopType(gig::DimensionRegion* d, uint32_t value);
359     void set_LoopStart(gig::DimensionRegion* d, uint32_t value);
360     void set_LoopLength(gig::DimensionRegion* d, uint32_t value);
361     void set_LoopInfinite(gig::DimensionRegion* d, bool value);
362     void set_LoopPlayCount(gig::DimensionRegion* d, uint32_t value);
363 schoenebeck 2691
364     void onButtonSelectSamplePressed();
365 schoenebeck 1225 };
366    
367     #endif

  ViewVC Help
Powered by ViewVC