Guitarix
gx_parameter.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2009, 2010 Hermann Meyer, James Warden, Andreas Degert
3 * Copyright (C) 2011 Pete Shorthose
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 * --------------------------------------------------------------------------
19 *
20 * This file is part of the guitarix GUI main class
21 * Note: this header file depends on gx_system.h
22 *
23 * ----------------------------------------------------------------------------
24 */
25
26#pragma once
27
28#ifndef SRC_HEADERS_GX_PARAMETER_H_
29#define SRC_HEADERS_GX_PARAMETER_H_
30
31namespace gx_system { class JsonWriter; class JsonParser; }
32
33namespace gx_engine {
34
35#ifndef NDEBUG
36#define debug_check(func, ...) func(__VA_ARGS__)
37#else
38#define debug_check(...)
39#endif
40
41/****************************************************************
42 **
43 ** Parameter
44 **
45 */
46
48 private:
49 map<string, string> groups;
50
51#ifndef NDEBUG
52 map<string, bool> used;
53 void group_exists(const string& id);
54 void group_is_new(const string& id);
55 friend string param_group(const string& group_id, bool nowarn);
56#endif
57
58 public:
61
62 inline string get(const string& id) { return groups[id]; }
63 inline string operator[](const string& id) {
65 return groups[id];
66 }
67 inline void insert(const string& id, const string& group) {
69 groups.insert(pair<string, string>(id, group));
70 }
71 bool group_exist(const string& id);
72 inline void erase(const string& id) {
73#ifndef NDEBUG // avoid unused variable warning in release mode
74 size_t n = groups.erase(id);
75 assert(n == 1);
76#else
77 groups.erase(id);
78#endif
79 }
80#ifndef NDEBUG
81 void dump();
82#endif
83};
84
85
87string param_group(const string& group_id, bool nowarn = false);
88
89/****************************************************************
90 ** Parameter
91 */
92
93template <class T> class ParameterV;
94
99
101class EnumParameter;
102class FileParameter;
103
104/****************************************************************/
105
106class Parameter: boost::noncopyable {
107public:
109 enum toggle_type { OnOff = 0, Constant = 1, Toggle = 2, Commander = 3, _Count = 4 };
110private:
111 virtual bool midi_set(float n, float high, float llimit, float ulimit); //RT
112 virtual bool midi_set_bpm(float n, float high, float llimit, float ulimit); //RT
113 friend class MidiController;
114protected:
117 string _id;
121 unsigned int d_flags : 2;
123 bool controllable : 1;
124 bool do_not_save : 1;
125 bool blocked : 1;
126 bool midi_blocked : 1;
127 bool output : 1;
128 bool maxlevel : 1;
129 bool nowarn : 1;
130 bool used : 1; // debug
131protected:
132 void range_warning(float value, float lower, float upper);
134public:
135 inline std::string group_id() const { return _id.substr(0, _id.find_last_of(".")); }
136 Parameter(const string& id, const string& name, value_type vtp, ctrl_type ctp, bool preset,
137 bool ctrl):
138 boost::noncopyable(),
139 _id(id),
140 _name(name),
142 _desc(),
143 v_type(vtp),
144 c_type(ctp),
145 d_flags(0),
146 save_in_preset(preset),
147 controllable(ctrl),
148 do_not_save(false),
149 blocked(false),
150 midi_blocked(false),
151 output(false),
152 maxlevel(false),
153 used(false) {}
155 virtual ~Parameter();
157 virtual void trigger_changed();
158
159#ifndef NDEBUG
160 bool isUsed() const { return used; }
161 void setUsed() { used = true; }
162 friend void compare_parameter(const char* title, Parameter* p1,
163 Parameter* p2, bool all);
165#endif
166
167 const char *get_typename() const;
168 bool isFloat() const { return v_type == tp_float; }
169 bool isInt() const { return v_type == tp_int; }
170 bool isBool() const { return v_type == tp_bool; }
171 bool isFile() const { return v_type == tp_file; }
172 bool isString() const { return v_type == tp_string; }
173 ctrl_type getControlType() const { return c_type; }
174 bool isControllable() const { return controllable; }
175 bool isInPreset() const { return save_in_preset; }
176 bool isSavable() const { return !do_not_save; }
177 void setSavable(bool v) { do_not_save = !v; }
178 bool isOutput() const { return output; }
179 void setOutput(bool v) { output = v; }
180 bool isMaxlevel() const { return maxlevel; }
181 void setMaxlevel(bool v) { maxlevel = v; }
182 bool isNoWarning() const { return nowarn; }
183 void setNoWarning(bool v) { nowarn = v; }
184 const string& id() const { return _id; }
185 const string& group() const { return _group; }
186 string l_group() const { return gettext(_group.c_str()); }
187 const string& name() const { return _name; }
188 string l_name() const { return gettext(_name.c_str()); }
189 const string& desc() const { return _desc; }
190 void set_desc(const string& desc) { _desc = desc; }
191 string l_desc() const { return gettext(_desc.c_str()); }
193 bool is_log_display() const { return d_flags & dtp_log; }
194 void set_blocked(bool v) { blocked = v; }
195 bool get_blocked() const { return blocked; }
196 void set_midi_blocked(bool v) { midi_blocked = v; }
197 bool get_midi_blocked() const { return midi_blocked; }
198 bool operator==(const Parameter& p) const { return &p == this; }
199 virtual void stdJSON_value() = 0;
200 virtual bool on_off_value() = 0; //RT
201 virtual void writeJSON(gx_system::JsonWriter& jw) const = 0;
203 virtual void setJSON_value() = 0;
204 virtual bool compareJSON_value() = 0;
205 virtual bool hasRange() const;
206 virtual float getLowerAsFloat() const;
207 virtual float getUpperAsFloat() const;
208 virtual float getStepAsFloat() const;
209 virtual const value_pair *getValueNames() const;
210 static inline const char *value_label(const value_pair& vp) {
211 return gettext(vp.value_label ? vp.value_label : vp.value_id);
212 }
219 sigc::signal<void, float>& signal_changed_float();
220 sigc::signal<void, int>& signal_changed_int();
221 sigc::signal<void, bool>& signal_changed_bool();
222 sigc::signal<void, const Glib::ustring&>& signal_changed_string();
223};
224
225#ifndef NDEBUG
226void compare_parameter(const char* title, Parameter* p1,
227 Parameter* p2, bool all = false);
228#endif
229
230/****************************************************************/
231
232typedef list<Parameter*> paramlist;
233
234/****************************************************************/
235
236template<class T>
237class ParameterV: public Parameter {
238};
239
240template<>
241class ParameterV<float>: public Parameter {
242private:
243 virtual bool midi_set(float n, float high, float llimit, float ulimit); //RT
244 virtual bool midi_set_bpm(float n, float high, float llimit, float ulimit); //RT
245 virtual void trigger_changed();
246protected:
248 float *value;
250 float lower, upper, step;
251 sigc::signal<void, float> changed;
253 friend class ParamRegImpl;
254 friend class GxMachine;
255public:
256 bool set(float val) const;
257 bool ramp_value(float val);
258 float get_value() const { return *value; }
259 void convert_from_range(float low, float up);
260 void set_zero() { *value = 0; }
261 virtual void stdJSON_value();
262 virtual bool on_off_value();
263 virtual void writeJSON(gx_system::JsonWriter& jw) const;
266 virtual bool compareJSON_value();
267 virtual void setJSON_value();
268 virtual bool hasRange() const;
269 virtual float getLowerAsFloat() const;
270 virtual float getUpperAsFloat() const;
271 virtual float getStepAsFloat() const;
272 virtual float idx_from_id(string v_id);
273 ParameterV(const string& id, const string& name, ctrl_type ctp, bool preset,
274 float *v, float sv, float lv, float uv, float tv, bool ctrl, bool no_init):
275 Parameter(id, name, tp_float, ctp, preset, ctrl),
276 value(v ? v : &value_storage), std_value(sv),lower(lv),upper(uv),step(tv) {
277 assert(lv <= sv && sv <= uv);
278 if (!no_init) {
279 *value = sv;
280 }
281 }
282#ifndef NDEBUG
283 friend void compare_parameter(const char* title, Parameter* p1,
284 Parameter* p2, bool all);
285#endif
289 sigc::signal<void, float>& signal_changed() { return changed; }
290};
291
292/****************************************************************/
293
295protected:
298public:
299 virtual void writeJSON(gx_system::JsonWriter& jw) const;
301 virtual const value_pair *getValueNames() const;
302 FloatEnumParameter(const string& id, const string& name, const value_pair* vn, bool preset, float *v,
303 int sv, int low, bool ctrl, bool no_init);
305 virtual float idx_from_id(string v_id);
306};
307
308/****************************************************************/
309
310template<>
311class ParameterV<int>: public Parameter {
312private:
313 virtual bool midi_set(float n, float high, float llimit, float ulimit); //RT
314 virtual void trigger_changed();
315protected:
317 int *value;
319 int lower, upper;
320 sigc::signal<void, int> changed;
322 friend class ParamRegImpl;
323public:
324 bool set(int val) const;
325 int get_value() const { return *value; }
326 virtual void stdJSON_value();
327 virtual bool on_off_value();
328 virtual void writeJSON(gx_system::JsonWriter& jw) const;
330 virtual bool compareJSON_value();
331 virtual void setJSON_value();
332 virtual bool hasRange() const;
333 virtual float getLowerAsFloat() const;
334 virtual float getUpperAsFloat() const;
335 virtual int idx_from_id(string v_id);
336 ParameterV(const string& id, const string& name, ctrl_type ctp, bool preset,
337 int *v, int sv, int lv, int uv, bool ctrl):
338 Parameter(id, name, tp_int, ctp, preset, ctrl),
339 value(v ? v : &value_storage), std_value(sv), lower(lv), upper(uv) {
340 *value = sv;
341 }
345 sigc::signal<void, int>& signal_changed() { return changed; }
346};
347
348/****************************************************************/
349
351protected:
354public:
355 virtual void writeJSON(gx_system::JsonWriter& jw) const;
357 virtual const value_pair *getValueNames() const;
358 virtual int idx_from_id(string v_id);
359 const value_pair& get_pair() { return getValueNames()[get_value()]; }
360 EnumParameter(const string& id, const string& name, const value_pair* vn, bool preset, int *v,
361 int sv, bool ctrl);
363};
364
365/****************************************************************/
366
367template<>
368class ParameterV<bool>: public Parameter {
369private:
370 virtual bool midi_set(float n, float high, float llimit, float ulimit); //RT
371 virtual void trigger_changed();
372protected:
374 bool *value;
376 sigc::signal<void, bool> changed;
378 friend class ParamRegImpl;
379public:
380 bool set(bool val) const;
381 virtual void stdJSON_value();
382 bool get_value() const { return *value; }
383 virtual bool on_off_value();
384 virtual void writeJSON(gx_system::JsonWriter& jw) const;
385 virtual bool compareJSON_value();
386 virtual void setJSON_value();
388 ParameterV(const string& id, const string& name, ctrl_type ctp, bool preset,
389 bool *v, bool sv, bool ctrl):
390 Parameter(id, name, tp_bool, ctp, preset, ctrl),
391 value(v ? v : &value_storage), std_value(sv) {
392 *value = sv;
393 }
397 sigc::signal<void, bool>& signal_changed() { return changed; }
398};
399
400/****************************************************************/
401
402/****************************************************************/
403
405protected:
406 Glib::RefPtr<Gio::File> value;
407 Glib::RefPtr<Gio::File> std_value;
408 Glib::RefPtr<Gio::File> json_value;
409 sigc::signal<void> changed;
410public:
411 sigc::signal<void>& signal_changed() { return changed; }
412 bool set(const Glib::RefPtr<Gio::File>& val);
413 void set_path(const string& path);
414 const Glib::RefPtr<Gio::File>& get() const { return value; }
415 virtual void stdJSON_value();
416 virtual bool on_off_value();
417 virtual void writeJSON(gx_system::JsonWriter& jw) const;
419 virtual bool compareJSON_value();
420 virtual void setJSON_value();
421 FileParameter(const string& id, const string& filename, bool preset = false):
422 Parameter(id, "", tp_file, None, preset, false),
423 value(Gio::File::create_for_path(filename)),
424 std_value(value->dup()) {}
425 FileParameter(const string& id, bool preset = false):
426 Parameter(id, "", tp_file, None, preset, false),
427 value(0),
428 std_value(0) {}
431 void set_standard(const string& filename);
432 bool is_equal(const Glib::RefPtr<Gio::File>& v) const;
433 bool is_standard() const { return is_equal(std_value); }
434 string get_path() const;
435 string get_directory_path() const;
436 string get_parse_name() const;
437 string get_display_name() const;
438 void copy(const string& destination) const;
439};
440
441/****************************************************************/
442
443template<>
444class ParameterV<Glib::ustring>: public Parameter {
445protected:
446 Glib::ustring json_value;
447 Glib::ustring *value;
448 Glib::ustring std_value;
449 sigc::signal<void, const Glib::ustring&> changed;
450 Glib::ustring value_storage;
451public:
452 bool set(const Glib::ustring& val) const;
453 const Glib::ustring& get_value() const { return *value; }
454 virtual void stdJSON_value();
455 virtual bool on_off_value();
456 virtual void writeJSON(gx_system::JsonWriter& jw) const;
457 virtual bool compareJSON_value();
458 virtual void setJSON_value();
460 ParameterV(const string& id, const string& name, Glib::ustring *v, const Glib::ustring& sv, bool preset = false)
461 : Parameter(id, name, tp_string, None, preset, false),
462 value(v ? v : &value_storage), std_value(sv) {
463 }
467 sigc::signal<void, const Glib::ustring&>& signal_changed() { return changed; }
468 Glib::ustring& get_json_value() { return json_value; }
469};
470
471
472/****************************************************************/
473
475 assert(isFloat());
476 return static_cast<FloatParameter&>(*this);
477}
478
480 assert(isInt());
481 return static_cast<IntParameter&>(*this);
482}
483
485 EnumParameter *p = dynamic_cast<EnumParameter*>(this);
486 assert(p);
487 return *p;
488}
489
491 assert(isBool());
492 return static_cast<BoolParameter&>(*this);
493}
494
496 assert(isFile());
497 return static_cast<FileParameter&>(*this);
498}
499
501 assert(isString());
502 return static_cast<StringParameter&>(*this);
503}
504
505inline sigc::signal<void, float>& Parameter::signal_changed_float() {
506 FloatParameter *p = dynamic_cast<FloatParameter*>(this);
507 assert(p);
508 return p->signal_changed();
509}
510
511inline sigc::signal<void, int>& Parameter::signal_changed_int() {
512 IntParameter *p = dynamic_cast<IntParameter*>(this);
513 assert(p);
514 return p->signal_changed();
515}
516
517inline sigc::signal<void, bool>& Parameter::signal_changed_bool() {
518 BoolParameter *p = dynamic_cast<BoolParameter*>(this);
519 assert(p);
520 return p->signal_changed();
521}
522
523inline sigc::signal<void, const Glib::ustring&>& Parameter::signal_changed_string() {
524 StringParameter *p = dynamic_cast<StringParameter*>(this);
525 assert(p);
526 return p->signal_changed();
527}
528
529
530/****************************************************************
531 ** ParamMap
532 */
533
534class ParamMap: boost::noncopyable {
535 private:
536 map<string, Parameter*> id_map;
538 sigc::signal<void,Parameter*,bool> insert_remove;
539#ifndef NDEBUG
540 void unique_id(Parameter* param);
541 void check_id(const string& id);
542 void check_p(const char *p);
543#endif
544 Parameter *insert(Parameter* param); // private so we can make sure parameters are owned
545
546 public:
547 template<class T> friend class ParameterV;
554 typedef map<string, Parameter*>::const_iterator iterator;
555 iterator begin() const { return id_map.begin(); }
556 iterator end() const { return id_map.end(); }
557 bool hasId(const string& id) const { return id_map.find(id) != id_map.end(); }
558 bool hasId(const char *p) const { return id_map.find(p) != id_map.end(); }
559 void set_replace_mode(bool mode) { replace_mode = mode; }
560 Parameter& operator[](const string& id) {
562 return *id_map[id];
563 }
564 Parameter& operator[](const char *p) {
566 return *id_map[p];
567 }
569 void reset_unit(const PluginDef *pdef) const;
570 bool unit_has_std_values(const PluginDef *pdef) const;
571 sigc::signal<void,Parameter*,bool> signal_insert_remove() { return insert_remove; }
573 void unregister(const string& id);
574 inline FloatParameter *reg_par(const string& id, const string& name, float *var, float std,
575 float lower, float upper, float step, bool midi=true) {
576 FloatParameter *p = new FloatParameter(id, name, Parameter::Continuous, true, var, std, lower, upper, step, midi, replace_mode);
577 insert(p);
578 return p;
579 }
581 const string& id, const string& name, float *var, float std, float lower, float upper, float step) {
582 FloatParameter *p = new FloatParameter(id, name, Parameter::Continuous, false, var, std, lower, upper, step, false, replace_mode);
583 insert(p);
584 return p;
585 }
586 inline FloatParameter *reg_par(const string& id, const string& name, float *var, float std = 0, bool midi = true) {
587 FloatParameter *p = new FloatParameter(id, name, Parameter::Switch, true, var, std, 0, 1, 1, midi, replace_mode);
588 insert(p);
589 return p;
590 }
591 inline BoolParameter *reg_par(const string& id, const string& name, bool *var, bool std=false, bool preset=true, bool midi=true) {
592 BoolParameter * p = new BoolParameter(id, name, Parameter::Switch, preset, var, std, midi);
593 insert(p);
594 return p;
595 }
596 inline EnumParameter *reg_enum_par(const string& id, const string& name,
597 const value_pair *vl, int *var, int std = 0, bool midi=true) {
598 EnumParameter *p = new EnumParameter(id, name, vl, true, var, std, midi);
599 insert(p);
600 return p;
601 }
603 const string& id, const string& name, const value_pair *vl,
604 int *var, bool preset, int std = 0) {
605 EnumParameter *p = new EnumParameter(id, name, vl, preset, var, std, false);
606 insert(p);
607 return p;
608 }
609 inline FloatEnumParameter *reg_enum_par(const string& id, const string& name,
610 const value_pair *vl, float *var,
611 int std = 0, int low = 0, bool midi=true) {
612 FloatEnumParameter *p = new FloatEnumParameter(id, name, vl, true, var, std, low, midi, replace_mode);
613 insert(p);
614 return p;
615 }
616 inline BoolParameter *reg_non_midi_par(const string& id, bool *var, bool preset, bool std = false) {
617 BoolParameter *p = new BoolParameter(id, "", Parameter::Switch, preset, var, std, false);
618 insert(p);
619 return p;
620 }
621 inline IntParameter *reg_par(const string& id, const string& name, int *var, int std,
622 int lower, int upper, bool midi) {
623 IntParameter *p = new IntParameter(id, name, Parameter::Continuous, true, var, std, lower, upper, midi);
624 insert(p);
625 return p;
626 }
627 inline IntParameter *reg_par(const string& id, const string& name, int *var, int std, bool midi) {
628 IntParameter *p = new IntParameter(id, name, Parameter::Switch, true, var, std, 0, 1, midi);
629 insert(p);
630 return p;
631 }
632 inline IntParameter *reg_non_midi_par(const string& id, int *var, bool preset, int std, int lower, int upper) {
633 IntParameter *p = new IntParameter(id, "", Parameter::None, preset, var, std, lower, upper, false);
634 insert(p);
635 return p;
636 }
637 inline FloatParameter *reg_non_midi_par(const string& id, float *val, bool preset,
638 float std = 0, float lower = 0, float upper = 1, float step = 0) {
639 FloatParameter *p = new FloatParameter(id, "", Parameter::Continuous, preset, val, std, lower, upper, step, false, replace_mode);
640 insert(p);
641 return p;
642 }
643 inline FileParameter *reg_filepar(const string& id, bool preset = false) {
644 FileParameter *p = new FileParameter(id, preset);
645 insert(p);
646 return p;
647 }
648 inline StringParameter *reg_string(const string& id, const string& name, Glib::ustring *var, const string& sv, bool preset=false) {
649 StringParameter *p = new StringParameter(id, name, var, sv, preset);
650 insert(p);
651 return p;
652 }
653 inline StringParameter *reg_preset_string(const string& id, const string& name, Glib::ustring *var, const string& sv, bool preset=true) {
654 StringParameter *p = new StringParameter(id, name, var, sv, preset);
655 insert(p);
656 return p;
657 }
658
659#ifndef NDEBUG
660 void dump(const string& fmt);
661#endif
662};
663
664/****************************************************************
665 **
666 ** Midi
667 **
668 */
669
670
671/*
672** MidiStandardControllers
673*/
674
675/****************************************************************/
676
678 private:
679 struct modstring {
680 string name;
682 const char *std;
683 modstring(const string& n, bool m, const char* s): name(n), modified(m), std(s) {}
684 explicit modstring(const char* n): name(n), modified(false), std(n) {}
685 modstring(): name(""), modified(false), std(0) {}
686 };
687 map<int, modstring> m;
688 string midi_to_note(int ctr);
689 string ctr_desc(int ctr);
690 public:
692 const string operator[](int ctr) { return m[ctr].name; }
693 void replace(int ctr, const string& name);
696};
697
698extern MidiStandardControllers midi_std_ctr; // map ctrl num -> standard name
699
700/****************************************************************
701**
702** MidiController
703**/
704
706 private:
708 float _lower, _upper; //RT
709 bool toggle; //RT
711
712 public:
713 MidiController(Parameter& p, float l, float u, bool t=false, int tt=0):
714 param(&p), _lower(l), _upper(u), toggle(t), _toggle_behaviour(tt) {}
715 float lower() const { return _lower; }
716 float upper() const { return _upper; }
717 bool is_toggle() const { return toggle; }
718 int toggle_behaviour() const { return _toggle_behaviour; }
719 bool hasParameter(const Parameter& p) const { return *param == p; }
720 Parameter& getParameter() const { return *param; }
722 bool set_midi(int n, int last_value, int *value_set, bool update); //RT
723 bool set_bpm(int n, int last_value); //RT
724 bool set_trans(int n, int last_value); //RT
725 void set(float v, float high) { param->midi_set(v, high, _lower, _upper); }
728};
729
730typedef list<MidiController> midi_controller_list;
731
732/****************************************************************
733**
734** MidiControllerList
735**/
736
737
739private:
740 double time1;
741 double time_diff;
744 double bpm;
745 double bpm_new;
746 bool ret;
747
748public:
751 unsigned int rounded(float f);
752 bool time_to_bpm(double time, unsigned int* bpm_);
753};
754
755
756class ControllerArray: public vector<midi_controller_list> {
757public:
758 enum { array_size = 328 };
765};
766
767class MidiControllerList: public sigc::trackable {
768public:
769private:
774 volatile gint program_change; //RT
775 volatile gint mute_change; //RT
776 volatile gint bank_change; //RT
779 timespec ts1;
780 double time0;
781 unsigned int bpm_;
783 Glib::Dispatcher pgm_chg;
784 Glib::Dispatcher mute_chg;
785 Glib::Dispatcher bank_chg;
786 Glib::Dispatcher val_chg;
787 sigc::signal<void> changed;
788 sigc::signal<void,int> new_program;
789 sigc::signal<void,int> new_mute_state;
790 sigc::signal<void,int> new_bank;
791 sigc::signal<void, int, int> midi_value_changed;
792private:
798public:
800 midi_controller_list& operator[](int n) { return map[n]; }
801 int size() { return map.size(); }
802 void set_config_mode(bool mode, int ctl=-1);
803 bool get_config_mode() { return last_midi_control != -2; }
805 void set_current_control(int ctl) { last_midi_control = ctl; }
806 void set_ctr_val(int ctr, int val); //RT
807 void set_bpm_val(unsigned int val); //RT
809 void modifyCurrent(Parameter& param, float lower, float upper, bool toggle, int toggle_behaviour);
811 return map.param2controller(param, p); }
813 int get_last_midi_control_value(unsigned int n) {
814 assert(n < ControllerArray::array_size); return last_midi_control_value[n]; } //RT
815 void set_last_midi_control_value(unsigned int n, int v) {
819 sigc::signal<void>& signal_changed() { return changed; }
820 sigc::signal<void,int>& signal_new_program() { return new_program; }
821 sigc::signal<void,int>& signal_new_mute_state() { return new_mute_state; }
822 sigc::signal<void,int>& signal_new_bank() { return new_bank; }
823 void compute_midi_in(void* midi_input_port_buf, void *arg); //RT
824 void process_trans(int transport_state); //RT
827 void set_midi_channel(int s);
829 sigc::signal<void, int, int>& signal_midi_value_changed() { return midi_value_changed; }
830 sigc::signal<void, int, int> trigger_midi_feedback;
831 sigc::signal<void, int, int>& signal_trigger_midi_feedback() { return trigger_midi_feedback; }
833};
834
835} // namespace gx_gui
836
837#endif // SRC_HEADERS_GX_PARAMETER_H_
838
void writeJSON(gx_system::JsonWriter &jw) const
int param2controller(Parameter &param, const MidiController **p)
void readJSON(gx_system::JsonParser &jp, ParamMap &param)
bool deleteParameter(Parameter &p)
virtual const value_pair * getValueNames() const
const value_pair * value_names
Definition: gx_parameter.h:352
virtual void serializeJSON(gx_system::JsonWriter &jw)
EnumParameter(gx_system::JsonParser &jp)
Definition: gx_parameter.h:353
virtual void readJSON_value(gx_system::JsonParser &jp)
const value_pair & get_pair()
Definition: gx_parameter.h:359
EnumParameter(const string &id, const string &name, const value_pair *vn, bool preset, int *v, int sv, bool ctrl)
virtual int idx_from_id(string v_id)
virtual void writeJSON(gx_system::JsonWriter &jw) const
Glib::RefPtr< Gio::File > value
Definition: gx_parameter.h:406
FileParameter(const string &id, const string &filename, bool preset=false)
Definition: gx_parameter.h:421
sigc::signal< void > & signal_changed()
Definition: gx_parameter.h:411
bool set(const Glib::RefPtr< Gio::File > &val)
void set_path(const string &path)
virtual void setJSON_value()
virtual void stdJSON_value()
FileParameter(gx_system::JsonParser &jp)
void set_standard(const string &filename)
virtual void serializeJSON(gx_system::JsonWriter &jw)
string get_parse_name() const
Glib::RefPtr< Gio::File > json_value
Definition: gx_parameter.h:408
void copy(const string &destination) const
string get_path() const
virtual bool on_off_value()
string get_display_name() const
bool is_equal(const Glib::RefPtr< Gio::File > &v) const
virtual void readJSON_value(gx_system::JsonParser &jp)
Glib::RefPtr< Gio::File > std_value
Definition: gx_parameter.h:407
virtual void writeJSON(gx_system::JsonWriter &jw) const
sigc::signal< void > changed
Definition: gx_parameter.h:409
virtual bool compareJSON_value()
FileParameter(const string &id, bool preset=false)
Definition: gx_parameter.h:425
string get_directory_path() const
const Glib::RefPtr< Gio::File > & get() const
Definition: gx_parameter.h:414
virtual void serializeJSON(gx_system::JsonWriter &jw)
const value_pair * value_names
Definition: gx_parameter.h:296
virtual const value_pair * getValueNames() const
FloatEnumParameter(const string &id, const string &name, const value_pair *vn, bool preset, float *v, int sv, int low, bool ctrl, bool no_init)
FloatEnumParameter(gx_system::JsonParser &jp)
Definition: gx_parameter.h:297
virtual void writeJSON(gx_system::JsonWriter &jw) const
virtual void readJSON_value(gx_system::JsonParser &jp)
virtual float idx_from_id(string v_id)
unsigned int rounded(float f)
bool time_to_bpm(double time, unsigned int *bpm_)
bool set_trans(int n, int last_value)
Parameter & getParameter() const
Definition: gx_parameter.h:720
MidiController(Parameter &p, float l, float u, bool t=false, int tt=0)
Definition: gx_parameter.h:713
bool set_bpm(int n, int last_value)
bool set_midi(int n, int last_value, int *value_set, bool update)
bool hasParameter(const Parameter &p) const
Definition: gx_parameter.h:719
void set(float v, float high)
Definition: gx_parameter.h:725
static MidiController * readJSON(gx_system::JsonParser &jp, ParamMap &param)
void writeJSON(gx_system::JsonWriter &jw) const
sigc::signal< void, int, int > & signal_trigger_midi_feedback()
Definition: gx_parameter.h:831
sigc::signal< void, int, int > & signal_midi_value_changed()
Definition: gx_parameter.h:829
int changed_midi_control_value[ControllerArray::array_size]
Definition: gx_parameter.h:773
sigc::signal< void > changed
Definition: gx_parameter.h:787
void set_bpm_val(unsigned int val)
void set_config_mode(bool mode, int ctl=-1)
void deleteParameter(Parameter &param)
midi_controller_list & operator[](int n)
Definition: gx_parameter.h:800
sigc::signal< void, int > & signal_new_mute_state()
Definition: gx_parameter.h:821
void writeJSON(gx_system::JsonWriter &jw) const
Definition: gx_parameter.h:812
void compute_midi_in(void *midi_input_port_buf, void *arg)
int last_midi_control_value[ControllerArray::array_size]
Definition: gx_parameter.h:771
void modifyCurrent(Parameter &param, float lower, float upper, bool toggle, int toggle_behaviour)
void set_last_midi_control_value(unsigned int n, int v)
Definition: gx_parameter.h:815
sigc::signal< void, int > new_bank
Definition: gx_parameter.h:790
sigc::signal< void, int > new_mute_state
Definition: gx_parameter.h:789
void process_trans(int transport_state)
sigc::signal< void, int > & signal_new_program()
Definition: gx_parameter.h:820
sigc::signal< void > & signal_changed()
Definition: gx_parameter.h:819
sigc::signal< void, int > & signal_new_bank()
Definition: gx_parameter.h:822
void remove_controlled_parameters(paramlist &plist, const ControllerArray *m)
sigc::signal< void, int, int > midi_value_changed
Definition: gx_parameter.h:791
void update_from_controller(int ctr)
int param2controller(Parameter &param, const MidiController **p)
Definition: gx_parameter.h:810
sigc::signal< void, int > new_program
Definition: gx_parameter.h:788
void set_ctr_val(int ctr, int val)
int get_last_midi_control_value(unsigned int n)
Definition: gx_parameter.h:813
void set_controller_array(const ControllerArray &m)
sigc::signal< void, int, int > trigger_midi_feedback
Definition: gx_parameter.h:830
void replace(int ctr, const string &name)
void writeJSON(gx_system::JsonWriter &jw) const
const string operator[](int ctr)
Definition: gx_parameter.h:692
void readJSON(gx_system::JsonParser &jp)
sigc::signal< void, Parameter *, bool > insert_remove
Definition: gx_parameter.h:538
Parameter & operator[](const char *p)
Definition: gx_parameter.h:564
sigc::signal< void, Parameter *, bool > signal_insert_remove()
Definition: gx_parameter.h:571
bool hasId(const char *p) const
Definition: gx_parameter.h:558
EnumParameter * reg_enum_par(const string &id, const string &name, const value_pair *vl, int *var, int std=0, bool midi=true)
Definition: gx_parameter.h:596
void dump(const string &fmt)
EnumParameter * reg_non_midi_enum_par(const string &id, const string &name, const value_pair *vl, int *var, bool preset, int std=0)
Definition: gx_parameter.h:602
map< string, Parameter * >::const_iterator iterator
Definition: gx_parameter.h:554
IntParameter * reg_par(const string &id, const string &name, int *var, int std, int lower, int upper, bool midi)
Definition: gx_parameter.h:621
Parameter * readJSON_one(gx_system::JsonParser &jp)
void writeJSON(gx_system::JsonWriter &jw)
void unregister(const string &id)
FloatParameter * reg_non_midi_par(const string &id, float *val, bool preset, float std=0, float lower=0, float upper=1, float step=0)
Definition: gx_parameter.h:637
FloatEnumParameter * reg_enum_par(const string &id, const string &name, const value_pair *vl, float *var, int std=0, int low=0, bool midi=true)
Definition: gx_parameter.h:609
FloatParameter * reg_par(const string &id, const string &name, float *var, float std, float lower, float upper, float step, bool midi=true)
Definition: gx_parameter.h:574
bool unit_has_std_values(const PluginDef *pdef) const
map< string, Parameter * > id_map
Definition: gx_parameter.h:536
Parameter & operator[](const string &id)
Definition: gx_parameter.h:560
FileParameter * reg_filepar(const string &id, bool preset=false)
Definition: gx_parameter.h:643
void check_p(const char *p)
StringParameter * reg_preset_string(const string &id, const string &name, Glib::ustring *var, const string &sv, bool preset=true)
Definition: gx_parameter.h:653
StringParameter * reg_string(const string &id, const string &name, Glib::ustring *var, const string &sv, bool preset=false)
Definition: gx_parameter.h:648
BoolParameter * reg_par(const string &id, const string &name, bool *var, bool std=false, bool preset=true, bool midi=true)
Definition: gx_parameter.h:591
void set_replace_mode(bool mode)
Definition: gx_parameter.h:559
BoolParameter * reg_non_midi_par(const string &id, bool *var, bool preset, bool std=false)
Definition: gx_parameter.h:616
IntParameter * reg_par(const string &id, const string &name, int *var, int std, bool midi)
Definition: gx_parameter.h:627
void readJSON(gx_system::JsonParser &jp)
bool hasId(const string &id) const
Definition: gx_parameter.h:557
Parameter * insert(Parameter *param)
void check_id(const string &id)
void reset_unit(const PluginDef *pdef) const
FloatParameter * reg_par(const string &id, const string &name, float *var, float std=0, bool midi=true)
Definition: gx_parameter.h:586
void unregister(Parameter *p)
IntParameter * reg_non_midi_par(const string &id, int *var, bool preset, int std, int lower, int upper)
Definition: gx_parameter.h:632
iterator begin() const
Definition: gx_parameter.h:555
void writeJSON_one(gx_system::JsonWriter &jw, Parameter *p)
FloatParameter * reg_par_non_preset(const string &id, const string &name, float *var, float std, float lower, float upper, float step)
Definition: gx_parameter.h:580
iterator end() const
Definition: gx_parameter.h:556
void unique_id(Parameter *param)
void group_is_new(const string &id)
friend string param_group(const string &group_id, bool nowarn)
void group_exists(const string &id)
map< string, string > groups
Definition: gx_parameter.h:49
bool group_exist(const string &id)
string get(const string &id)
Definition: gx_parameter.h:62
void erase(const string &id)
Definition: gx_parameter.h:72
void insert(const string &id, const string &group)
Definition: gx_parameter.h:67
string operator[](const string &id)
Definition: gx_parameter.h:63
map< string, bool > used
Definition: gx_parameter.h:52
bool isString() const
Definition: gx_parameter.h:172
EnumParameter & getEnum()
Definition: gx_parameter.h:484
bool operator==(const Parameter &p) const
Definition: gx_parameter.h:198
void dump(gx_system::JsonWriter *jw)
StringParameter & getString()
Definition: gx_parameter.h:500
const char * get_typename() const
Parameter(gx_system::JsonParser &jp)
void setNoWarning(bool v)
Definition: gx_parameter.h:183
virtual bool midi_set_bpm(float n, float high, float llimit, float ulimit)
virtual bool hasRange() const
enum value_type v_type
Definition: gx_parameter.h:119
std::string group_id() const
Definition: gx_parameter.h:135
FileParameter & getFile()
Definition: gx_parameter.h:495
bool isInt() const
Definition: gx_parameter.h:169
bool get_midi_blocked() const
Definition: gx_parameter.h:197
virtual float getUpperAsFloat() const
bool isOutput() const
Definition: gx_parameter.h:178
sigc::signal< void, bool > & signal_changed_bool()
Definition: gx_parameter.h:517
virtual bool compareJSON_value()=0
const string & desc() const
Definition: gx_parameter.h:189
virtual const value_pair * getValueNames() const
bool isMaxlevel() const
Definition: gx_parameter.h:180
const string & group() const
Definition: gx_parameter.h:185
IntParameter & getInt()
Definition: gx_parameter.h:479
bool get_blocked() const
Definition: gx_parameter.h:195
bool isNoWarning() const
Definition: gx_parameter.h:182
bool isFloat() const
Definition: gx_parameter.h:168
const string & id() const
Definition: gx_parameter.h:184
virtual void serializeJSON(gx_system::JsonWriter &jw)
static gx_system::JsonParser & jp_next(gx_system::JsonParser &jp, const char *key)
const string & name() const
Definition: gx_parameter.h:187
FloatParameter & getFloat()
Definition: gx_parameter.h:474
bool isFile() const
Definition: gx_parameter.h:171
sigc::signal< void, float > & signal_changed_float()
Definition: gx_parameter.h:505
BoolParameter & getBool()
Definition: gx_parameter.h:490
virtual void stdJSON_value()=0
string l_name() const
Definition: gx_parameter.h:188
bool isControllable() const
Definition: gx_parameter.h:174
virtual void readJSON_value(gx_system::JsonParser &jp)=0
virtual bool on_off_value()=0
bool isInPreset() const
Definition: gx_parameter.h:175
sigc::signal< void, int > & signal_changed_int()
Definition: gx_parameter.h:511
void range_warning(float value, float lower, float upper)
virtual bool midi_set(float n, float high, float llimit, float ulimit)
Parameter(const string &id, const string &name, value_type vtp, ctrl_type ctp, bool preset, bool ctrl)
Definition: gx_parameter.h:136
void set_midi_blocked(bool v)
Definition: gx_parameter.h:196
void set_desc(const string &desc)
Definition: gx_parameter.h:190
static const char * value_label(const value_pair &vp)
Definition: gx_parameter.h:210
ctrl_type getControlType() const
Definition: gx_parameter.h:173
virtual float getLowerAsFloat() const
bool is_log_display() const
Definition: gx_parameter.h:193
void setOutput(bool v)
Definition: gx_parameter.h:179
friend void compare_parameter(const char *title, Parameter *p1, Parameter *p2, bool all)
enum ctrl_type c_type
Definition: gx_parameter.h:120
virtual void trigger_changed()
string l_group() const
Definition: gx_parameter.h:186
bool isSavable() const
Definition: gx_parameter.h:176
bool isBool() const
Definition: gx_parameter.h:170
bool isUsed() const
Definition: gx_parameter.h:160
string l_desc() const
Definition: gx_parameter.h:191
void setMaxlevel(bool v)
Definition: gx_parameter.h:181
void setSavable(bool v)
Definition: gx_parameter.h:177
virtual float getStepAsFloat() const
unsigned int d_flags
Definition: gx_parameter.h:121
sigc::signal< void, const Glib::ustring & > & signal_changed_string()
Definition: gx_parameter.h:523
virtual void writeJSON(gx_system::JsonWriter &jw) const =0
void set_blocked(bool v)
Definition: gx_parameter.h:194
virtual void setJSON_value()=0
ParameterV(gx_system::JsonParser &jp)
bool set(const Glib::ustring &val) const
const Glib::ustring & get_value() const
Definition: gx_parameter.h:453
sigc::signal< void, const Glib::ustring & > & signal_changed()
Definition: gx_parameter.h:467
virtual void readJSON_value(gx_system::JsonParser &jp)
virtual void serializeJSON(gx_system::JsonWriter &jw)
virtual void writeJSON(gx_system::JsonWriter &jw) const
sigc::signal< void, const Glib::ustring & > changed
Definition: gx_parameter.h:449
ParameterV(const string &id, const string &name, Glib::ustring *v, const Glib::ustring &sv, bool preset=false)
Definition: gx_parameter.h:460
sigc::signal< void, bool > & signal_changed()
Definition: gx_parameter.h:397
virtual void serializeJSON(gx_system::JsonWriter &jw)
virtual bool midi_set(float n, float high, float llimit, float ulimit)
virtual bool compareJSON_value()
bool set(bool val) const
sigc::signal< void, bool > changed
Definition: gx_parameter.h:376
ParameterV(gx_system::JsonParser &jp)
virtual void readJSON_value(gx_system::JsonParser &jp)
ParameterV(const string &id, const string &name, ctrl_type ctp, bool preset, bool *v, bool sv, bool ctrl)
Definition: gx_parameter.h:388
virtual void writeJSON(gx_system::JsonWriter &jw) const
virtual float getUpperAsFloat() const
virtual void writeJSON(gx_system::JsonWriter &jw) const
ParameterV(const string &id, const string &name, ctrl_type ctp, bool preset, float *v, float sv, float lv, float uv, float tv, bool ctrl, bool no_init)
Definition: gx_parameter.h:273
virtual bool midi_set_bpm(float n, float high, float llimit, float ulimit)
bool set(float val) const
virtual void serializeJSON(gx_system::JsonWriter &jw)
void convert_from_range(float low, float up)
virtual void rampJSON_value(gx_system::JsonParser &jp)
virtual bool midi_set(float n, float high, float llimit, float ulimit)
ParameterV(gx_system::JsonParser &jp)
sigc::signal< void, float > & signal_changed()
Definition: gx_parameter.h:289
virtual float getLowerAsFloat() const
virtual bool hasRange() const
sigc::signal< void, float > changed
Definition: gx_parameter.h:251
virtual void readJSON_value(gx_system::JsonParser &jp)
friend void compare_parameter(const char *title, Parameter *p1, Parameter *p2, bool all)
virtual float idx_from_id(string v_id)
virtual float getStepAsFloat() const
sigc::signal< void, int > & signal_changed()
Definition: gx_parameter.h:345
ParameterV(gx_system::JsonParser &jp)
virtual void serializeJSON(gx_system::JsonWriter &jw)
virtual bool compareJSON_value()
virtual bool hasRange() const
virtual void readJSON_value(gx_system::JsonParser &jp)
virtual float getLowerAsFloat() const
virtual void writeJSON(gx_system::JsonWriter &jw) const
ParameterV(const string &id, const string &name, ctrl_type ctp, bool preset, int *v, int sv, int lv, int uv, bool ctrl)
Definition: gx_parameter.h:336
sigc::signal< void, int > changed
Definition: gx_parameter.h:320
virtual int idx_from_id(string v_id)
virtual float getUpperAsFloat() const
bool set(int val) const
virtual void trigger_changed()
virtual bool midi_set(float n, float high, float llimit, float ulimit)
#define debug_check(func,...)
Definition: gx_parameter.h:36
MidiStandardControllers midi_std_ctr
ParameterV< Glib::ustring > StringParameter
Definition: gx_parameter.h:98
list< MidiController > midi_controller_list
Definition: gx_parameter.h:730
ParameterV< float > FloatParameter
Definition: gx_parameter.h:95
void compare_parameter(const char *title, Parameter *p1, Parameter *p2, bool all=false)
string param_group(const string &group_id, bool nowarn=false)
list< Parameter * > paramlist
Definition: gx_parameter.h:232
ParameterV< int > IntParameter
Definition: gx_parameter.h:96
ParameterGroups & get_group_table()
ParameterV< bool > BoolParameter
Definition: gx_parameter.h:97
modstring(const string &n, bool m, const char *s)
Definition: gx_parameter.h:683
const char * value_label
Definition: gx_plugin.h:119
const char * value_id
Definition: gx_plugin.h:118