28#ifndef SRC_HEADERS_GX_PARAMETER_H_
29#define SRC_HEADERS_GX_PARAMETER_H_
31namespace gx_system {
class JsonWriter;
class JsonParser; }
36#define debug_check(func, ...) func(__VA_ARGS__)
38#define debug_check(...)
55 friend string param_group(
const string& group_id,
bool nowarn);
62 inline string get(
const string&
id) {
return groups[id]; }
67 inline void insert(
const string&
id,
const string& group) {
69 groups.insert(pair<string, string>(
id, group));
72 inline void erase(
const string&
id) {
74 size_t n =
groups.erase(
id);
87string param_group(
const string& group_id,
bool nowarn =
false);
111 virtual bool midi_set(
float n,
float high,
float llimit,
float ulimit);
112 virtual bool midi_set_bpm(
float n,
float high,
float llimit,
float ulimit);
135 inline std::string
group_id()
const {
return _id.substr(0,
_id.find_last_of(
".")); }
138 boost::noncopyable(),
184 const string&
id()
const {
return _id; }
243 virtual bool midi_set(
float n,
float high,
float llimit,
float ulimit);
244 virtual bool midi_set_bpm(
float n,
float high,
float llimit,
float ulimit);
256 bool set(
float val)
const;
274 float *v,
float sv,
float lv,
float uv,
float tv,
bool ctrl,
bool no_init):
276 value(v ? v : &value_storage), std_value(sv),lower(lv),upper(uv),step(tv) {
277 assert(lv <= sv && sv <= uv);
303 int sv,
int low,
bool ctrl,
bool no_init);
313 virtual bool midi_set(
float n,
float high,
float llimit,
float ulimit);
337 int *v,
int sv,
int lv,
int uv,
bool ctrl):
339 value(v ? v : &value_storage), std_value(sv), lower(lv), upper(uv) {
370 virtual bool midi_set(
float n,
float high,
float llimit,
float ulimit);
389 bool *v,
bool sv,
bool ctrl):
391 value(v ? v : &value_storage), std_value(sv) {
412 bool set(
const Glib::RefPtr<Gio::File>& val);
414 const Glib::RefPtr<Gio::File>&
get()
const {
return value; }
421 FileParameter(
const string&
id,
const string& filename,
bool preset =
false):
423 value(Gio::File::create_for_path(filename)),
432 bool is_equal(
const Glib::RefPtr<Gio::File>& v)
const;
438 void copy(
const string& destination)
const;
449 sigc::signal<void, const Glib::ustring&>
changed;
452 bool set(
const Glib::ustring& val)
const;
453 const Glib::ustring&
get_value()
const {
return *value; }
460 ParameterV(
const string&
id,
const string&
name, Glib::ustring *v,
const Glib::ustring& sv,
bool preset =
false)
462 value(v ? v : &value_storage), std_value(sv) {
554 typedef map<string, Parameter*>::const_iterator
iterator;
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);
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);
587 FloatParameter *p =
new FloatParameter(
id, name,
Parameter::Switch,
true, var, std, 0, 1, 1, midi,
replace_mode);
591 inline BoolParameter *
reg_par(
const string&
id,
const string& name,
bool *var,
bool std=
false,
bool preset=
true,
bool midi=
true) {
597 const value_pair *vl,
int *var,
int std = 0,
bool midi=
true) {
603 const string&
id,
const string& name,
const value_pair *vl,
604 int *var,
bool preset,
int std = 0) {
611 int std = 0,
int low = 0,
bool midi=
true) {
622 int lower,
int upper,
bool midi) {
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);
687 map<int, modstring>
m;
722 bool set_midi(
int n,
int last_value,
int *value_set,
bool update);
void writeJSON(gx_system::JsonWriter &jw) const
int param2controller(Parameter ¶m, const MidiController **p)
void readJSON(gx_system::JsonParser &jp, ParamMap ¶m)
bool deleteParameter(Parameter &p)
virtual const value_pair * getValueNames() const
const value_pair * value_names
virtual void serializeJSON(gx_system::JsonWriter &jw)
EnumParameter(gx_system::JsonParser &jp)
virtual void readJSON_value(gx_system::JsonParser &jp)
const value_pair & get_pair()
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
FileParameter(const string &id, const string &filename, bool preset=false)
sigc::signal< void > & signal_changed()
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
void copy(const string &destination) 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
virtual void writeJSON(gx_system::JsonWriter &jw) const
sigc::signal< void > changed
virtual bool compareJSON_value()
FileParameter(const string &id, bool preset=false)
string get_directory_path() const
const Glib::RefPtr< Gio::File > & get() const
virtual void serializeJSON(gx_system::JsonWriter &jw)
const value_pair * value_names
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)
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
MidiController(Parameter &p, float l, float u, bool t=false, int tt=0)
bool set_bpm(int n, int last_value)
int toggle_behaviour() const
bool set_midi(int n, int last_value, int *value_set, bool update)
bool hasParameter(const Parameter &p) const
void set(float v, float high)
static MidiController * readJSON(gx_system::JsonParser &jp, ParamMap ¶m)
void writeJSON(gx_system::JsonWriter &jw) const
sigc::signal< void, int, int > & signal_trigger_midi_feedback()
sigc::signal< void, int, int > & signal_midi_value_changed()
void set_current_control(int ctl)
int changed_midi_control_value[ControllerArray::array_size]
sigc::signal< void > changed
void update_from_controllers()
Glib::Dispatcher mute_chg
void request_midi_value_update()
void set_bpm_val(unsigned int val)
void set_config_mode(bool mode, int ctl=-1)
void deleteParameter(Parameter ¶m)
midi_controller_list & operator[](int n)
volatile gint mute_change
volatile gint bank_change
volatile gint program_change
sigc::signal< void, int > & signal_new_mute_state()
void writeJSON(gx_system::JsonWriter &jw) const
void compute_midi_in(void *midi_input_port_buf, void *arg)
int get_current_control()
int last_midi_control_value[ControllerArray::array_size]
Glib::Dispatcher bank_chg
void modifyCurrent(Parameter ¶m, float lower, float upper, bool toggle, int toggle_behaviour)
void set_last_midi_control_value(unsigned int n, int v)
void set_midi_channel(int s)
sigc::signal< void, int > new_bank
sigc::signal< void, int > new_mute_state
void process_trans(int transport_state)
sigc::signal< void, int > & signal_new_program()
sigc::signal< void > & signal_changed()
sigc::signal< void, int > & signal_new_bank()
void remove_controlled_parameters(paramlist &plist, const ControllerArray *m)
sigc::signal< void, int, int > midi_value_changed
void update_from_controller(int ctr)
int param2controller(Parameter ¶m, const MidiController **p)
sigc::signal< void, int > new_program
void set_ctr_val(int ctr, int val)
int get_last_midi_control_value(unsigned int n)
void set_controller_array(const ControllerArray &m)
sigc::signal< void, int, int > trigger_midi_feedback
void replace(int ctr, const string &name)
string midi_to_note(int ctr)
MidiStandardControllers()
void writeJSON(gx_system::JsonWriter &jw) const
const string operator[](int ctr)
void readJSON(gx_system::JsonParser &jp)
sigc::signal< void, Parameter *, bool > insert_remove
Parameter & operator[](const char *p)
sigc::signal< void, Parameter *, bool > signal_insert_remove()
bool hasId(const char *p) const
EnumParameter * reg_enum_par(const string &id, const string &name, const value_pair *vl, int *var, int std=0, bool midi=true)
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)
map< string, Parameter * >::const_iterator iterator
IntParameter * reg_par(const string &id, const string &name, int *var, int std, int lower, int upper, bool midi)
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)
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)
FloatParameter * reg_par(const string &id, const string &name, float *var, float std, float lower, float upper, float step, bool midi=true)
bool unit_has_std_values(const PluginDef *pdef) const
map< string, Parameter * > id_map
Parameter & operator[](const string &id)
FileParameter * reg_filepar(const string &id, bool preset=false)
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)
StringParameter * reg_string(const string &id, const string &name, Glib::ustring *var, const string &sv, bool preset=false)
BoolParameter * reg_par(const string &id, const string &name, bool *var, bool std=false, bool preset=true, bool midi=true)
void set_replace_mode(bool mode)
BoolParameter * reg_non_midi_par(const string &id, bool *var, bool preset, bool std=false)
IntParameter * reg_par(const string &id, const string &name, int *var, int std, bool midi)
void readJSON(gx_system::JsonParser &jp)
bool hasId(const string &id) const
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)
void unregister(Parameter *p)
IntParameter * reg_non_midi_par(const string &id, int *var, bool preset, int std, int lower, int upper)
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)
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
bool group_exist(const string &id)
string get(const string &id)
void erase(const string &id)
void insert(const string &id, const string &group)
string operator[](const string &id)
EnumParameter & getEnum()
bool operator==(const Parameter &p) const
void dump(gx_system::JsonWriter *jw)
StringParameter & getString()
const char * get_typename() const
Parameter(gx_system::JsonParser &jp)
void setNoWarning(bool v)
virtual bool midi_set_bpm(float n, float high, float llimit, float ulimit)
virtual bool hasRange() const
std::string group_id() const
FileParameter & getFile()
bool get_midi_blocked() const
virtual float getUpperAsFloat() const
sigc::signal< void, bool > & signal_changed_bool()
virtual bool compareJSON_value()=0
const string & desc() const
virtual const value_pair * getValueNames() const
const string & group() const
const string & id() const
virtual void serializeJSON(gx_system::JsonWriter &jw)
static gx_system::JsonParser & jp_next(gx_system::JsonParser &jp, const char *key)
const string & name() const
FloatParameter & getFloat()
sigc::signal< void, float > & signal_changed_float()
BoolParameter & getBool()
virtual void stdJSON_value()=0
bool isControllable() const
virtual void readJSON_value(gx_system::JsonParser &jp)=0
virtual bool on_off_value()=0
sigc::signal< void, int > & signal_changed_int()
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)
void set_midi_blocked(bool v)
void set_desc(const string &desc)
static const char * value_label(const value_pair &vp)
ctrl_type getControlType() const
virtual float getLowerAsFloat() const
bool is_log_display() const
friend void compare_parameter(const char *title, Parameter *p1, Parameter *p2, bool all)
virtual void trigger_changed()
virtual float getStepAsFloat() const
sigc::signal< void, const Glib::ustring & > & signal_changed_string()
virtual void writeJSON(gx_system::JsonWriter &jw) const =0
virtual void setJSON_value()=0
ParameterV(gx_system::JsonParser &jp)
bool set(const Glib::ustring &val) const
Glib::ustring & get_json_value()
const Glib::ustring & get_value() const
sigc::signal< void, const Glib::ustring & > & signal_changed()
virtual void setJSON_value()
virtual void readJSON_value(gx_system::JsonParser &jp)
virtual void serializeJSON(gx_system::JsonWriter &jw)
virtual void stdJSON_value()
virtual bool on_off_value()
virtual void writeJSON(gx_system::JsonWriter &jw) const
sigc::signal< void, const Glib::ustring & > changed
Glib::ustring value_storage
ParameterV(const string &id, const string &name, Glib::ustring *v, const Glib::ustring &sv, bool preset=false)
virtual bool compareJSON_value()
sigc::signal< void, bool > & signal_changed()
virtual void serializeJSON(gx_system::JsonWriter &jw)
virtual bool midi_set(float n, float high, float llimit, float ulimit)
virtual bool compareJSON_value()
sigc::signal< void, bool > changed
virtual void stdJSON_value()
ParameterV(gx_system::JsonParser &jp)
virtual void readJSON_value(gx_system::JsonParser &jp)
virtual bool on_off_value()
ParameterV(const string &id, const string &name, ctrl_type ctp, bool preset, bool *v, bool sv, bool ctrl)
virtual void writeJSON(gx_system::JsonWriter &jw) const
virtual void setJSON_value()
virtual void trigger_changed()
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)
virtual void setJSON_value()
virtual bool compareJSON_value()
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 bool on_off_value()
virtual void stdJSON_value()
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()
virtual float getLowerAsFloat() const
bool ramp_value(float val)
virtual void trigger_changed()
virtual bool hasRange() const
sigc::signal< void, float > changed
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
virtual void stdJSON_value()
sigc::signal< void, int > & signal_changed()
ParameterV(gx_system::JsonParser &jp)
virtual void serializeJSON(gx_system::JsonWriter &jw)
virtual void setJSON_value()
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)
sigc::signal< void, int > changed
virtual int idx_from_id(string v_id)
virtual float getUpperAsFloat() const
virtual void trigger_changed()
virtual bool midi_set(float n, float high, float llimit, float ulimit)
virtual bool on_off_value()
#define debug_check(func,...)
MidiStandardControllers midi_std_ctr
ParameterV< Glib::ustring > StringParameter
list< MidiController > midi_controller_list
ParameterV< float > FloatParameter
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
ParameterV< int > IntParameter
ParameterGroups & get_group_table()
ParameterV< bool > BoolParameter
modstring(const string &n, bool m, const char *s)