ofxPDSP
Parameter.h
1 
2 // Parameter.h
3 // ofxPDSP
4 // Nicola Pisanti, MIT License, 2016-2018
5 
6 #ifndef OFXPDSP_PDSPPARAMETER_H_INCLUDED
7 #define OFXPDSP_PDSPPARAMETER_H_INCLUDED
8 
9 #include "../DSP/pdspCore.h"
10 #include "../DSP/helpers/UsesSlew.h"
11 #include "../DSP/control/ValueControl.h"
12 
13 #include "ofMain.h"
14 
15 //-------------------------------------------------------------------------------------------------
16 
24 namespace pdsp{
25 
26 class Parameter : public pdsp::Patchable {
27  friend class ParameterAmp; // those friendships can be removed
28  friend class ParameterGain; // when the setv method is removed from API
29 
30 public:
31  Parameter();
32  Parameter(const Parameter & other);
33  Parameter& operator=(const Parameter & other);
34 
35  ~Parameter();
36 
44  ofParameter<float>& set(const char * name, float value, float min, float max);
45 
53  ofParameter<int>& set(const char * name, int value, int min, int max);
54 
55 
62  ofParameter<float>& set(const char * name, float min, float max);
63 
70  ofParameter<int>& set(const char * name, int min, int max);
71 
79  ofParameter<float>& set( std::string name, float value, float min, float max);
80 
88  ofParameter<int>& set( std::string name, int value, int min, int max);
89 
90 
97  ofParameter<float>& set( std::string name, float min, float max);
98 
105  ofParameter<int>& set( std::string name, int min, int max);
106 
114  ofParameter<bool>& set( std::string name, bool value, float min=0.0f, float max=1.0f );
115 
123  ofParameter<bool>& set( const char * name, bool value, float min=0.0f, float max=1.0f );
124 
128  ofParameter<float>& getOFParameterFloat();
129 
133  ofParameter<int>& getOFParameterInt();
134 
138  ofParameter<bool>& getOFParameterBool();
139 
144  void enableSmoothing(float timeMs);
145 
149  void disableSmoothing();
150 
156  void set( float value );
157 
161  float get() const { return valueControl.get(); }
162 
166  float meter_output() const{ return valueControl.meter_output(); }
167 
168 
169  ofParameter<float>& set(const char * name, double value, double min, double max);
170  ofParameter<float>& set(const char * name, double min, double max);
171  ofParameter<float>& set( std::string name, double value, double min, double max);
172  ofParameter<float>& set( std::string name, double min, double max);
173 
174 
175  [[deprecated("setv(float value) method deprecated, use the set(float value) method that also updates the ofParameters or use the pdsp::ValueControl class with its set() method if you don't need ofParameters")]]
176  void setv(float value){ valueControl.set(value); }
177 
178 
179 private:
180 
181  ofParameter<float> parameter;
182  ofParameter<int> parameter_i;
183  ofParameter<bool> parameter_b;
184 
185  void onSet(float &newValue);
186  void onSetI(int &newValue);
187  void onSetB(bool &newValue);
188 
189  float boolmin;
190  float boolmax;
191 
192  ValueControl valueControl;
193 
194  int mode;
195  std::atomic<bool> bCanUpdate;
196 
197  static const int modeUnsetted = 0;
198  static const int modeFloat = 1;
199  static const int modeInt = 2;
200  static const int modeCombined = 3;
201  static const int modeBool = 4;
202 };
203 
204 }
205 
206 #endif //OFXPDSP_PDSPPARAMETER_H_INCLUDED
float meter_output() const
returns the actual output value. Thread-safe.
Definition: ValueControl.h:59
ofParameter< float > & getOFParameterFloat()
returns the ofParameter ready to be added to the UI
Definition: Parameter.cpp:93
Definition: ValueControl.h:25
void enableSmoothing(float timeMs)
enables the smoothing of the setted values
Definition: Parameter.cpp:105
float get() const
gets the value
Definition: ValueControl.h:43
Definition: Parameter.h:26
void set(float value)
sets the value, thread safe.
Definition: ValueControl.h:38
void disableSmoothing()
disable the smoothing of the setted values. smoothing is disabled by default
Definition: Parameter.cpp:110
Abstract class for implementing Units and Modules.
Definition: BasicNodes.h:82
Definition: ParameterAmp.h:24
Thread-safe value control with smoothing.
Definition: SequencerBridge.h:11
float meter_output() const
returns the actual output value. Thread-safe.
Definition: Parameter.h:166
Definition: ParameterGain.h:25
ofParameter< bool > & getOFParameterBool()
returns the ofParameter ready to be added to the UI
Definition: Parameter.cpp:101
ofParameter< int > & getOFParameterInt()
returns the ofParameter ready to be added to the UI
Definition: Parameter.cpp:97