/[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 3177 - (hide annotations) (download) (as text)
Thu May 11 20:59:46 2017 UTC (6 years, 10 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 12583 byte(s)
* Live mode performance optimization: fixed the editor to be non-responsive
  for a very long time, which happened if changing instrument parameters of
  a very large amount of dimension regions was requested.
* Bumped version (1.0.0.svn45).

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 1225 class DimRegionEdit : public Gtk::Notebook
79     {
80     public:
81     DimRegionEdit();
82     virtual ~DimRegionEdit();
83     void set_dim_region(gig::DimensionRegion* d);
84 schoenebeck 2464 bool set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop);
85 schoenebeck 2925 bool set_sample(gig::DimensionRegion* dimreg, gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop);
86 schoenebeck 1225 Gtk::Entry* wSample;
87 schoenebeck 2720 Gtk::Button* buttonNullSampleReference;
88 schoenebeck 1339 sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_to_be_changed();
89     sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_changed();
90     sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& signal_sample_ref_changed();
91 schoenebeck 2691 sigc::signal<void, gig::Sample*>& signal_select_sample();
92 schoenebeck 1225
93 persson 1533 std::set<gig::DimensionRegion*> dimregs;
94    
95 schoenebeck 1225 protected:
96 schoenebeck 1322 sigc::signal<void, gig::DimensionRegion*> dimreg_to_be_changed_signal;
97     sigc::signal<void, gig::DimensionRegion*> dimreg_changed_signal;
98     sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/> sample_ref_changed_signal;
99 persson 1261 sigc::signal<void> instrument_changed;
100 schoenebeck 2691 sigc::signal<void, gig::Sample*> select_sample_signal;
101 persson 1261
102 schoenebeck 3177 /**
103     * Ensures that the 2 signals DimRegionEdit::dimreg_to_be_changed_signal and
104     * DimRegionEdit::dimreg_changed_signal are always triggered correctly as a
105     * pair. It behaves similar to a "mutex lock guard" design pattern.
106     */
107     class DimRegionChangeGuard : public SignalGuard<gig::DimensionRegion*> {
108     public:
109     DimRegionChangeGuard(DimRegionEdit* edit, gig::DimensionRegion* pDimReg) :
110     SignalGuard<gig::DimensionRegion*>(edit->dimreg_to_be_changed_signal, edit->dimreg_changed_signal, pDimReg)
111     {
112     }
113     };
114    
115 schoenebeck 1225 gig::DimensionRegion* dimregion;
116    
117 persson 2151 #ifdef OLD_TOOLTIPS
118 schoenebeck 1225 Gtk::Tooltips tooltips;
119 persson 2151 #endif
120 schoenebeck 1225
121     Gtk::Table* table[7];
122    
123     Gtk::Label* lSample;
124    
125 persson 2392 VelocityCurve velocity_curve;
126     VelocityCurve release_curve;
127     VelocityCurve cutoff_curve;
128     CrossfadeCurve crossfade_curve;
129    
130 schoenebeck 1225 NumEntryPermille eEG1PreAttack;
131     NumEntryTemp<double> eEG1Attack;
132     NumEntryTemp<double> eEG1Decay1;
133     NumEntryTemp<double> eEG1Decay2;
134     BoolEntry eEG1InfiniteSustain;
135     NumEntryPermille eEG1Sustain;
136     NumEntryTemp<double> eEG1Release;
137     BoolEntry eEG1Hold;
138     ChoiceEntryLeverageCtrl eEG1Controller;
139     BoolEntry eEG1ControllerInvert;
140     NumEntryTemp<uint8_t> eEG1ControllerAttackInfluence;
141     NumEntryTemp<uint8_t> eEG1ControllerDecayInfluence;
142     NumEntryTemp<uint8_t> eEG1ControllerReleaseInfluence;
143     NumEntryTemp<double> eLFO1Frequency;
144     NumEntryTemp<uint16_t> eLFO1InternalDepth;
145     NumEntryTemp<uint16_t> eLFO1ControlDepth;
146     ChoiceEntry<gig::lfo1_ctrl_t> eLFO1Controller;
147     BoolEntry eLFO1FlipPhase;
148     BoolEntry eLFO1Sync;
149     NumEntryPermille eEG2PreAttack;
150     NumEntryTemp<double> eEG2Attack;
151     NumEntryTemp<double> eEG2Decay1;
152     NumEntryTemp<double> eEG2Decay2;
153     BoolEntry eEG2InfiniteSustain;
154     NumEntryPermille eEG2Sustain;
155     NumEntryTemp<double> eEG2Release;
156     ChoiceEntryLeverageCtrl eEG2Controller;
157     BoolEntry eEG2ControllerInvert;
158     NumEntryTemp<uint8_t> eEG2ControllerAttackInfluence;
159     NumEntryTemp<uint8_t> eEG2ControllerDecayInfluence;
160     NumEntryTemp<uint8_t> eEG2ControllerReleaseInfluence;
161     NumEntryTemp<double> eLFO2Frequency;
162     NumEntryTemp<uint16_t> eLFO2InternalDepth;
163     NumEntryTemp<uint16_t> eLFO2ControlDepth;
164     ChoiceEntry<gig::lfo2_ctrl_t> eLFO2Controller;
165     BoolEntry eLFO2FlipPhase;
166     BoolEntry eLFO2Sync;
167     NumEntryTemp<double> eEG3Attack;
168     NumEntryTemp<int16_t> eEG3Depth;
169     NumEntryTemp<double> eLFO3Frequency;
170     NumEntryTemp<int16_t> eLFO3InternalDepth;
171     NumEntryTemp<int16_t> eLFO3ControlDepth;
172     ChoiceEntry<gig::lfo3_ctrl_t> eLFO3Controller;
173     BoolEntry eLFO3Sync;
174     BoolEntry eVCFEnabled;
175     ChoiceEntry<gig::vcf_type_t> eVCFType;
176     ChoiceEntry<gig::vcf_cutoff_ctrl_t> eVCFCutoffController;
177     BoolEntry eVCFCutoffControllerInvert;
178     NumEntryTemp<uint8_t> eVCFCutoff;
179     ChoiceEntry<gig::curve_type_t> eVCFVelocityCurve;
180     NumEntryTemp<uint8_t> eVCFVelocityScale;
181     NumEntryTemp<uint8_t> eVCFVelocityDynamicRange;
182     NumEntryTemp<uint8_t> eVCFResonance;
183     BoolEntry eVCFResonanceDynamic;
184     ChoiceEntry<gig::vcf_res_ctrl_t> eVCFResonanceController;
185     BoolEntry eVCFKeyboardTracking;
186     NumEntryTemp<uint8_t> eVCFKeyboardTrackingBreakpoint;
187     ChoiceEntry<gig::curve_type_t> eVelocityResponseCurve;
188     NumEntryTemp<uint8_t> eVelocityResponseDepth;
189     NumEntryTemp<uint8_t> eVelocityResponseCurveScaling;
190     ChoiceEntry<gig::curve_type_t> eReleaseVelocityResponseCurve;
191     NumEntryTemp<uint8_t> eReleaseVelocityResponseDepth;
192     NumEntryTemp<uint8_t> eReleaseTriggerDecay;
193     NumEntryTemp<uint8_t> eCrossfade_in_start;
194     NumEntryTemp<uint8_t> eCrossfade_in_end;
195     NumEntryTemp<uint8_t> eCrossfade_out_start;
196     NumEntryTemp<uint8_t> eCrossfade_out_end;
197     BoolEntry ePitchTrack;
198     ChoiceEntry<gig::dim_bypass_ctrl_t> eDimensionBypass;
199     NumEntryTemp<int8_t> ePan;
200     BoolEntry eSelfMask;
201     ChoiceEntryLeverageCtrl eAttenuationController;
202     BoolEntry eInvertAttenuationController;
203     NumEntryTemp<uint8_t> eAttenuationControllerThreshold;
204     NumEntryTemp<uint8_t> eChannelOffset;
205     BoolEntry eSustainDefeat;
206     BoolEntry eMSDecode;
207     NumEntryTemp<uint16_t> eSampleStartOffset;
208     NoteEntry eUnityNote;
209 schoenebeck 2991 ReadOnlyLabelWidget eSampleGroup;
210 schoenebeck 2690 ReadOnlyLabelWidget eSampleFormatInfo;
211     ReadOnlyLabelWidget eSampleID;
212 schoenebeck 2991 ReadOnlyLabelWidget eChecksum;
213 schoenebeck 1225 NumEntryTemp<int16_t> eFineTune;
214     NumEntryGain eGain;
215     BoolEntryPlus6 eGainPlus6;
216     BoolEntry eSampleLoopEnabled;
217     NumEntryTemp<uint32_t> eSampleLoopStart;
218     NumEntryTemp<uint32_t> eSampleLoopLength;
219     ChoiceEntry<uint32_t> eSampleLoopType;
220     BoolEntry eSampleLoopInfinite;
221     NumEntryTemp<uint32_t> eSampleLoopPlayCount;
222 persson 1623 Gtk::Label* lEG2;
223     Gtk::Label* lLFO2;
224 schoenebeck 1225
225 schoenebeck 2691 Gtk::Button buttonSelectSample;
226    
227 schoenebeck 1225 int rowno;
228     int pageno;
229     int firstRowInBlock;
230    
231    
232     void addProp(BoolEntry& boolentry);
233 persson 1262 void addProp(BoolEntryPlus6& boolentry);
234 schoenebeck 1225 void addProp(LabelWidget& labelwidget);
235     void addString(const char* labelText, Gtk::Label*& label,
236     Gtk::Entry*& widget);
237 schoenebeck 2720 void addString(const char* labelText, Gtk::Label*& label,
238     Gtk::Entry*& widget, Gtk::Button*& button);
239 persson 1623 Gtk::Label* addHeader(const char* text);
240 schoenebeck 2691 void addRightHandSide(Gtk::Widget& widget);
241 schoenebeck 1225 void nextPage();
242    
243     void VCFEnabled_toggled();
244     void VCFCutoffController_changed();
245     void VCFResonanceController_changed();
246     void EG1InfiniteSustain_toggled();
247     void EG2InfiniteSustain_toggled();
248     void EG1Controller_changed();
249     void EG2Controller_changed();
250     void AttenuationController_changed();
251     void LFO1Controller_changed();
252     void LFO2Controller_changed();
253     void LFO3Controller_changed();
254     void crossfade1_changed();
255     void crossfade2_changed();
256     void crossfade3_changed();
257     void crossfade4_changed();
258 persson 1460 void update_loop_elements();
259     void loop_start_changed();
260     void loop_length_changed();
261 schoenebeck 1225 void loop_infinite_toggled();
262 schoenebeck 2720 void nullOutSampleReference();
263 schoenebeck 1225
264 persson 1460 int update_model;
265    
266     // connect a widget to a setter function in DimRegionEdit
267     template<typename C, typename T>
268     void connect(C& widget,
269     void (DimRegionEdit::*setter)(gig::DimensionRegion*, T)) {
270     connect<C, T>(widget,
271     sigc::mem_fun(setter));
272     }
273    
274     // connect a widget to a member variable in gig::DimensionRegion
275     template<typename C, typename T>
276     void connect(C& widget, T gig::DimensionRegion::* member) {
277     connect<C, T>(widget,
278     sigc::bind(sigc::mem_fun(&DimRegionEdit::set_member<T>), member));
279     }
280    
281     // connect a widget to a setter function in gig::DimensionRegion
282     template<typename C, typename T>
283     void connect(C& widget,
284     void (gig::DimensionRegion::*setter)(T)) {
285     connect<C, T>(widget,
286     sigc::hide<0>(sigc::mem_fun(setter)));
287     }
288    
289     // helper function for the connect functions above
290     template<typename C, typename T>
291     void connect(C& widget,
292     sigc::slot<void, DimRegionEdit*, gig::DimensionRegion*, T> setter) {
293     widget.signal_value_changed().connect(
294     sigc::compose(sigc::bind(sigc::mem_fun(*this, &DimRegionEdit::set_many<T>), setter),
295     sigc::mem_fun(widget, &C::get_value)));
296     }
297    
298 schoenebeck 2925 // loop through all dimregions being edited and set a value in
299 persson 1460 // each of them
300     template<typename T>
301     void set_many(T value,
302     sigc::slot<void, DimRegionEdit*, gig::DimensionRegion*, T> setter) {
303     if (update_model == 0) {
304     for (std::set<gig::DimensionRegion*>::iterator i = dimregs.begin() ;
305 persson 2841 i != dimregs.end() ; ++i)
306 persson 1460 {
307 schoenebeck 3177 DimRegionChangeGuard(this, *i);
308 persson 1460 setter(this, *i, value);
309     }
310     }
311     }
312    
313     // set a value of a member variable in the given dimregion
314     template<typename T>
315     void set_member(gig::DimensionRegion* d, T value,
316     T gig::DimensionRegion::* member) {
317     d->*member = value;
318     }
319    
320     // setters for specific dimregion parameters
321    
322     void set_UnityNote(gig::DimensionRegion* d, uint8_t value);
323     void set_FineTune(gig::DimensionRegion* d, int16_t value);
324     void set_Crossfade_in_start(gig::DimensionRegion* d, uint8_t value);
325     void set_Crossfade_in_end(gig::DimensionRegion* d, uint8_t value);
326     void set_Crossfade_out_start(gig::DimensionRegion* d, uint8_t value);
327     void set_Crossfade_out_end(gig::DimensionRegion* d, uint8_t value);
328     void set_Gain(gig::DimensionRegion* d, int32_t value);
329     void set_LoopEnabled(gig::DimensionRegion* d, bool value);
330     void set_LoopType(gig::DimensionRegion* d, uint32_t value);
331     void set_LoopStart(gig::DimensionRegion* d, uint32_t value);
332     void set_LoopLength(gig::DimensionRegion* d, uint32_t value);
333     void set_LoopInfinite(gig::DimensionRegion* d, bool value);
334     void set_LoopPlayCount(gig::DimensionRegion* d, uint32_t value);
335 schoenebeck 2691
336     void onButtonSelectSamplePressed();
337 schoenebeck 1225 };
338    
339     #endif

  ViewVC Help
Powered by ViewVC