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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2841 by persson, Sun Aug 30 10:00:49 2015 UTC revision 3619 by schoenebeck, Tue Oct 1 16:21:28 2019 UTC
# Line 1  Line 1 
1  /*                                                         -*- c++ -*-  /*                                                         -*- c++ -*-
2   * Copyright (C) 2006-2015 Andreas Persson   * Copyright (C) 2006-2019 Andreas Persson
3   *   *
4   * This program is free software; you can redistribute it and/or   * This program is free software; you can redistribute it and/or
5   * modify it under the terms of the GNU General Public License as   * modify it under the terms of the GNU General Public License as
# Line 20  Line 20 
20  #ifndef GIGEDIT_DIMREGIONEDIT_H  #ifndef GIGEDIT_DIMREGIONEDIT_H
21  #define GIGEDIT_DIMREGIONEDIT_H  #define GIGEDIT_DIMREGIONEDIT_H
22    
23  #include <gig.h>  #ifdef LIBGIG_HEADER_FILE
24    # include LIBGIG_HEADER_FILE(gig.h)
25    #else
26    # include <gig.h>
27    #endif
28    
29    #include "compat.h"
30    
31  #include <cairomm/context.h>  #include <cairomm/context.h>
32    #include <gtkmm/box.h>
33  #include <gtkmm/drawingarea.h>  #include <gtkmm/drawingarea.h>
34  #include <gtkmm/entry.h>  #include <gtkmm/entry.h>
35  #include <gtkmm/label.h>  #include <gtkmm/label.h>
36  #include <gtkmm/notebook.h>  #include <gtkmm/notebook.h>
37  #include <gtkmm/table.h>  #if USE_GTKMM_GRID
38    # include <gtkmm/grid.h>
39    #else
40    # include <gtkmm/table.h>
41    #endif
42    
43    #ifdef LIBLINUXSAMPLER_HEADER_FILE
44    # include LIBLINUXSAMPLER_HEADER_FILE(engines/LFO.h)
45    #else
46    # include <linuxsampler/engines/LFO.h>
47    #endif
48    
49  #include <set>  #include <set>
50    
51  #include "paramedit.h"  #include "paramedit.h"
52    #include "global.h"
53    
54  class VelocityCurve : public Gtk::DrawingArea {  class VelocityCurve : public Gtk::DrawingArea {
55  public:  public:
# Line 69  private: Line 87  private:
87                          bool sensitive);                          bool sensitive);
88  };  };
89    
90    class LFOGraph : public Gtk::DrawingArea {
91    public:
92        LFOGraph();
93        void set_dim_region(gig::DimensionRegion* d) { dimreg = d; }
94    
95    protected:
96    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
97        bool on_expose_event(GdkEventExpose* e);
98    #else
99        bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
100    #endif
101    
102        virtual float frequency() const = 0;
103        virtual uint internalDepth() const = 0;
104        virtual uint controllerDepth() const = 0;
105        virtual bool flipPolarity() const = 0;
106        virtual bool signedRange() const = 0;
107        virtual LinuxSampler::LFO::start_level_t startLevel() const = 0;
108        virtual bool hasControllerAssigned() const = 0;
109    
110        gig::DimensionRegion* dimreg;
111        LinuxSampler::LFO lfo;
112    };
113    
114    class LFO1Graph : public LFOGraph {
115    public:
116        float frequency() const OVERRIDE { return dimreg->LFO1Frequency; }
117        uint internalDepth() const OVERRIDE {
118            const gig::lfo1_ctrl_t ctrl = dimreg->LFO1Controller;
119            const bool hasInternalDepth = (
120                ctrl != gig::lfo1_ctrl_modwheel && ctrl != gig::lfo1_ctrl_breath
121            );
122            return (hasInternalDepth) ? dimreg->LFO1InternalDepth : 0;
123        }
124        uint controllerDepth() const OVERRIDE { return dimreg->LFO1ControlDepth; }
125        bool flipPolarity() const OVERRIDE { return dimreg->LFO1FlipPhase; }
126        bool signedRange() const OVERRIDE { return false; }
127        virtual LinuxSampler::LFO::start_level_t startLevel() const OVERRIDE { return LinuxSampler::LFO::start_level_mid; } // see https://sourceforge.net/p/linuxsampler/mailman/linuxsampler-devel/thread/2189307.cNP0Xbctxq%40silver/#msg36774029
128        bool hasControllerAssigned() const OVERRIDE { return dimreg->LFO1Controller; }
129    };
130    
131    class LFO2Graph : public LFOGraph {
132    public:
133        float frequency() const OVERRIDE { return dimreg->LFO2Frequency; }
134        uint internalDepth() const OVERRIDE {
135            const gig::lfo2_ctrl_t ctrl = dimreg->LFO2Controller;
136            const bool hasInternalDepth = (
137                ctrl != gig::lfo2_ctrl_modwheel && ctrl != gig::lfo2_ctrl_foot
138            );
139            return (hasInternalDepth) ? dimreg->LFO2InternalDepth : 0;
140        }
141        uint controllerDepth() const OVERRIDE { return dimreg->LFO2ControlDepth; }
142        bool flipPolarity() const OVERRIDE { return dimreg->LFO2FlipPhase; }
143        bool signedRange() const OVERRIDE { return false; }
144        virtual LinuxSampler::LFO::start_level_t startLevel() const OVERRIDE { return LinuxSampler::LFO::start_level_mid; } // see https://sourceforge.net/p/linuxsampler/mailman/linuxsampler-devel/thread/2189307.cNP0Xbctxq%40silver/#msg36774029
145        bool hasControllerAssigned() const OVERRIDE { return dimreg->LFO2Controller; }
146    };
147    
148    class LFO3Graph : public LFOGraph {
149    public:
150        float frequency() const OVERRIDE { return dimreg->LFO3Frequency; }
151        uint internalDepth() const OVERRIDE {
152            const gig::lfo3_ctrl_t ctrl = dimreg->LFO3Controller;
153            const bool hasInternalDepth = (
154                ctrl != gig::lfo3_ctrl_modwheel && ctrl != gig::lfo3_ctrl_aftertouch
155            );
156            return (hasInternalDepth) ? dimreg->LFO3InternalDepth : 0;
157        }
158        uint controllerDepth() const OVERRIDE { return dimreg->LFO3ControlDepth; }
159        bool flipPolarity() const OVERRIDE { return false; }
160        bool signedRange() const OVERRIDE { return true; }
161        virtual LinuxSampler::LFO::start_level_t startLevel() const OVERRIDE { return LinuxSampler::LFO::start_level_max; } // see https://sourceforge.net/p/linuxsampler/mailman/linuxsampler-devel/thread/2189307.cNP0Xbctxq%40silver/#msg36774029
162        bool hasControllerAssigned() const OVERRIDE { return dimreg->LFO3Controller; }
163    };
164    
165    class EGStateOptions : public HBox {
166    public:
167        Gtk::Label label;
168        BoolBox checkBoxAttack;
169        BoolBox checkBoxAttackHold;
170        BoolBox checkBoxDecay1;
171        BoolBox checkBoxDecay2;
172        BoolBox checkBoxRelease;
173    
174        EGStateOptions();
175        void on_show_tooltips_changed();
176    };
177    
178  class DimRegionEdit : public Gtk::Notebook  class DimRegionEdit : public Gtk::Notebook
179  {  {
180  public:  public:
# Line 76  public: Line 182  public:
182      virtual ~DimRegionEdit();      virtual ~DimRegionEdit();
183      void set_dim_region(gig::DimensionRegion* d);      void set_dim_region(gig::DimensionRegion* d);
184      bool set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop);      bool set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop);
185        bool set_sample(gig::DimensionRegion* dimreg, gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop);
186      Gtk::Entry* wSample;      Gtk::Entry* wSample;
187      Gtk::Button* buttonNullSampleReference;      Gtk::Button* buttonNullSampleReference;
188      sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_to_be_changed();      sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_to_be_changed();
# Line 92  protected: Line 199  protected:
199      sigc::signal<void> instrument_changed;      sigc::signal<void> instrument_changed;
200      sigc::signal<void, gig::Sample*> select_sample_signal;      sigc::signal<void, gig::Sample*> select_sample_signal;
201    
202        /**
203         * Ensures that the 2 signals DimRegionEdit::dimreg_to_be_changed_signal and
204         * DimRegionEdit::dimreg_changed_signal are always triggered correctly as a
205         * pair. It behaves similar to a "mutex lock guard" design pattern.
206         */
207        class DimRegionChangeGuard : public SignalGuard<gig::DimensionRegion*> {
208        public:
209            DimRegionChangeGuard(DimRegionEdit* edit, gig::DimensionRegion* pDimReg) :
210                SignalGuard<gig::DimensionRegion*>(edit->dimreg_to_be_changed_signal, edit->dimreg_changed_signal, pDimReg)
211            {
212            }
213        };
214    
215      gig::DimensionRegion* dimregion;      gig::DimensionRegion* dimregion;
216    
217  #ifdef OLD_TOOLTIPS  #ifdef OLD_TOOLTIPS
218      Gtk::Tooltips tooltips;      Gtk::Tooltips tooltips;
219  #endif  #endif
220    
221      Gtk::Table* table[7];  #if USE_GTKMM_GRID
222        Gtk::Grid* table[9];
223    #else
224        Gtk::Table* table[9];
225    #endif
226    
227      Gtk::Label* lSample;      Gtk::Label* lSample;
228    
# Line 106  protected: Line 230  protected:
230      VelocityCurve release_curve;      VelocityCurve release_curve;
231      VelocityCurve cutoff_curve;      VelocityCurve cutoff_curve;
232      CrossfadeCurve crossfade_curve;      CrossfadeCurve crossfade_curve;
233        LFO1Graph lfo1Graph; ///< Graphic of Amplitude (Volume) LFO waveform.
234        LFO2Graph lfo2Graph; ///< Graphic of Filter Cutoff LFO waveform.
235        LFO3Graph lfo3Graph; ///< Graphic of Pitch LFO waveform.
236    
237      NumEntryPermille eEG1PreAttack;      NumEntryPermille eEG1PreAttack;
238      NumEntryTemp<double> eEG1Attack;      NumEntryTemp<double> eEG1Attack;
# Line 120  protected: Line 247  protected:
247      NumEntryTemp<uint8_t> eEG1ControllerAttackInfluence;      NumEntryTemp<uint8_t> eEG1ControllerAttackInfluence;
248      NumEntryTemp<uint8_t> eEG1ControllerDecayInfluence;      NumEntryTemp<uint8_t> eEG1ControllerDecayInfluence;
249      NumEntryTemp<uint8_t> eEG1ControllerReleaseInfluence;      NumEntryTemp<uint8_t> eEG1ControllerReleaseInfluence;
250        EGStateOptions eEG1StateOptions;
251      NumEntryTemp<double> eLFO1Frequency;      NumEntryTemp<double> eLFO1Frequency;
252      NumEntryTemp<uint16_t> eLFO1InternalDepth;      NumEntryTemp<uint16_t> eLFO1InternalDepth;
253      NumEntryTemp<uint16_t> eLFO1ControlDepth;      NumEntryTemp<uint16_t> eLFO1ControlDepth;
# Line 138  protected: Line 266  protected:
266      NumEntryTemp<uint8_t> eEG2ControllerAttackInfluence;      NumEntryTemp<uint8_t> eEG2ControllerAttackInfluence;
267      NumEntryTemp<uint8_t> eEG2ControllerDecayInfluence;      NumEntryTemp<uint8_t> eEG2ControllerDecayInfluence;
268      NumEntryTemp<uint8_t> eEG2ControllerReleaseInfluence;      NumEntryTemp<uint8_t> eEG2ControllerReleaseInfluence;
269        EGStateOptions eEG2StateOptions;
270      NumEntryTemp<double> eLFO2Frequency;      NumEntryTemp<double> eLFO2Frequency;
271      NumEntryTemp<uint16_t> eLFO2InternalDepth;      NumEntryTemp<uint16_t> eLFO2InternalDepth;
272      NumEntryTemp<uint16_t> eLFO2ControlDepth;      NumEntryTemp<uint16_t> eLFO2ControlDepth;
# Line 175  protected: Line 304  protected:
304      NumEntryTemp<uint8_t> eCrossfade_out_start;      NumEntryTemp<uint8_t> eCrossfade_out_start;
305      NumEntryTemp<uint8_t> eCrossfade_out_end;      NumEntryTemp<uint8_t> eCrossfade_out_end;
306      BoolEntry ePitchTrack;      BoolEntry ePitchTrack;
307        ChoiceEntry<gig::sust_rel_trg_t> eSustainReleaseTrigger;
308        BoolEntry eNoNoteOffReleaseTrigger;
309      ChoiceEntry<gig::dim_bypass_ctrl_t> eDimensionBypass;      ChoiceEntry<gig::dim_bypass_ctrl_t> eDimensionBypass;
310      NumEntryTemp<int8_t> ePan;      NumEntryTemp<int8_t> ePan;
311      BoolEntry eSelfMask;      BoolEntry eSelfMask;
# Line 186  protected: Line 317  protected:
317      BoolEntry eMSDecode;      BoolEntry eMSDecode;
318      NumEntryTemp<uint16_t> eSampleStartOffset;      NumEntryTemp<uint16_t> eSampleStartOffset;
319      NoteEntry eUnityNote;      NoteEntry eUnityNote;
320        ReadOnlyLabelWidget eSampleGroup;
321      ReadOnlyLabelWidget eSampleFormatInfo;      ReadOnlyLabelWidget eSampleFormatInfo;
322      ReadOnlyLabelWidget eSampleID;      ReadOnlyLabelWidget eSampleID;
323        ReadOnlyLabelWidget eChecksum;
324      NumEntryTemp<int16_t> eFineTune;      NumEntryTemp<int16_t> eFineTune;
325      NumEntryGain eGain;      NumEntryGain eGain;
326      BoolEntryPlus6 eGainPlus6;      BoolEntryPlus6 eGainPlus6;
# Line 210  protected: Line 343  protected:
343      void addProp(BoolEntry& boolentry);      void addProp(BoolEntry& boolentry);
344      void addProp(BoolEntryPlus6& boolentry);      void addProp(BoolEntryPlus6& boolentry);
345      void addProp(LabelWidget& labelwidget);      void addProp(LabelWidget& labelwidget);
346        void addLine(HBox& line);
347      void addString(const char* labelText, Gtk::Label*& label,      void addString(const char* labelText, Gtk::Label*& label,
348                     Gtk::Entry*& widget);                     Gtk::Entry*& widget);
349      void addString(const char* labelText, Gtk::Label*& label,      void addString(const char* labelText, Gtk::Label*& label,
# Line 238  protected: Line 372  protected:
372      void loop_length_changed();      void loop_length_changed();
373      void loop_infinite_toggled();      void loop_infinite_toggled();
374      void nullOutSampleReference();      void nullOutSampleReference();
375        void on_show_tooltips_changed();
376    
377      int update_model;      int update_model;
378    
379      // connect a widget to a setter function in DimRegionEdit      // connect a widget to a setter function in DimRegionEdit
380      template<typename C, typename T>      template<typename C, typename T>
381      void connect(C& widget,      void connect(C& widget,
382                   void (DimRegionEdit::*setter)(gig::DimensionRegion*, T)) {                   void (DimRegionEdit::*setter)(gig::DimensionRegion&, T)) {
383          connect<C, T>(widget,          connect<C, T>(widget,
384                        sigc::mem_fun(setter));                        sigc::mem_fun(setter));
385      }      }
# Line 256  protected: Line 391  protected:
391                        sigc::bind(sigc::mem_fun(&DimRegionEdit::set_member<T>), member));                        sigc::bind(sigc::mem_fun(&DimRegionEdit::set_member<T>), member));
392      }      }
393    
394        // connect a widget to a member of a struct member in gig::DimensionRegion
395        template<typename C, typename T, typename S>
396        void connect(C& widget, S gig::DimensionRegion::* member, T S::* member2) {
397            connect<C, T>(widget,
398                          sigc::bind(sigc::mem_fun(&DimRegionEdit::set_sub_member<T, S>), member, member2));
399        }
400    
401      // connect a widget to a setter function in gig::DimensionRegion      // connect a widget to a setter function in gig::DimensionRegion
402      template<typename C, typename T>      template<typename C, typename T>
403      void connect(C& widget,      void connect(C& widget,
# Line 267  protected: Line 409  protected:
409      // helper function for the connect functions above      // helper function for the connect functions above
410      template<typename C, typename T>      template<typename C, typename T>
411      void connect(C& widget,      void connect(C& widget,
412                   sigc::slot<void, DimRegionEdit*, gig::DimensionRegion*, T> setter) {                   sigc::slot<void, DimRegionEdit&, gig::DimensionRegion&, T> setter) {
413          widget.signal_value_changed().connect(          widget.signal_value_changed().connect(
414              sigc::compose(sigc::bind(sigc::mem_fun(*this, &DimRegionEdit::set_many<T>), setter),              sigc::compose(sigc::bind(sigc::mem_fun(*this, &DimRegionEdit::set_many<T>), setter),
415                            sigc::mem_fun(widget, &C::get_value)));                            sigc::mem_fun(widget, &C::get_value)));
416      }      }
417    
418      // loop through all dimregions being edited ant set a value in      // loop through all dimregions being edited and set a value in
419      // each of them      // each of them
420      template<typename T>      template<typename T>
421      void set_many(T value,      void set_many(T value,
422                    sigc::slot<void, DimRegionEdit*, gig::DimensionRegion*, T> setter) {                    sigc::slot<void, DimRegionEdit&, gig::DimensionRegion&, T> setter) {
423          if (update_model == 0) {          if (update_model == 0) {
424              for (std::set<gig::DimensionRegion*>::iterator i = dimregs.begin() ;              for (std::set<gig::DimensionRegion*>::iterator i = dimregs.begin() ;
425                   i != dimregs.end() ; ++i)                   i != dimregs.end() ; ++i)
426              {              {
427                  dimreg_changed_signal(*i);                  DimRegionChangeGuard(this, *i);
428                  setter(this, *i, value);                  setter(*this, **i, value);
429              }              }
430          }          }
431      }      }
432    
433      // set a value of a member variable in the given dimregion      // set a value of a member variable in the given dimregion
434      template<typename T>      template<typename T>
435      void set_member(gig::DimensionRegion* d, T value,      void set_member(gig::DimensionRegion& d, T value,
436                      T gig::DimensionRegion::* member) {                      T gig::DimensionRegion::* member) {
437          d->*member = value;          d.*member = value;
438        }
439    
440        // set a value of a member of a struct member variable in the given dimregion
441        template<typename T, typename S>
442        void set_sub_member(gig::DimensionRegion& d, T value,
443                            S gig::DimensionRegion::* member, T S::* member2) {
444            d.*member.*member2 = value;
445      }      }
446    
447      // setters for specific dimregion parameters      // setters for specific dimregion parameters
448    
449      void set_UnityNote(gig::DimensionRegion* d, uint8_t value);      void set_UnityNote(gig::DimensionRegion& d, uint8_t value);
450      void set_FineTune(gig::DimensionRegion* d, int16_t value);      void set_FineTune(gig::DimensionRegion& d, int16_t value);
451      void set_Crossfade_in_start(gig::DimensionRegion* d, uint8_t value);      void set_Crossfade_in_start(gig::DimensionRegion& d, uint8_t value);
452      void set_Crossfade_in_end(gig::DimensionRegion* d, uint8_t value);      void set_Crossfade_in_end(gig::DimensionRegion& d, uint8_t value);
453      void set_Crossfade_out_start(gig::DimensionRegion* d, uint8_t value);      void set_Crossfade_out_start(gig::DimensionRegion& d, uint8_t value);
454      void set_Crossfade_out_end(gig::DimensionRegion* d, uint8_t value);      void set_Crossfade_out_end(gig::DimensionRegion& d, uint8_t value);
455      void set_Gain(gig::DimensionRegion* d, int32_t value);      void set_Gain(gig::DimensionRegion& d, int32_t value);
456      void set_LoopEnabled(gig::DimensionRegion* d, bool value);      void set_LoopEnabled(gig::DimensionRegion& d, bool value);
457      void set_LoopType(gig::DimensionRegion* d, uint32_t value);      void set_LoopType(gig::DimensionRegion& d, uint32_t value);
458      void set_LoopStart(gig::DimensionRegion* d, uint32_t value);      void set_LoopStart(gig::DimensionRegion& d, uint32_t value);
459      void set_LoopLength(gig::DimensionRegion* d, uint32_t value);      void set_LoopLength(gig::DimensionRegion& d, uint32_t value);
460      void set_LoopInfinite(gig::DimensionRegion* d, bool value);      void set_LoopInfinite(gig::DimensionRegion& d, bool value);
461      void set_LoopPlayCount(gig::DimensionRegion* d, uint32_t value);      void set_LoopPlayCount(gig::DimensionRegion& d, uint32_t value);
462    
463      void onButtonSelectSamplePressed();      void onButtonSelectSamplePressed();
464  };  };

Legend:
Removed from v.2841  
changed lines
  Added in v.3619

  ViewVC Help
Powered by ViewVC