Loading...
Searching...
No Matches
gx_pluginloader.h
Go to the documentation of this file.
/*
* Copyright (C) 2011 Hermann Meyer, James Warden, Andreas Degert, Pete Shorthose
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
// utility class
// FIXME should be moved somewhere else
struct stringcomp {
inline bool operator() (const char* lhs, const char* rhs) const {
return strcmp(lhs, rhs) < 0;
}
};
namespace gx_engine {
class EngineControl;
/****************************************************************
** class Plugin
** Defines audio processing module and variables for
** user interface
*/
enum { // additional flags for PluginDef (used internally)
PGNI_DYN_POSITION = 0x10000, // plugin is part of dynamically ordered rack
PGNI_NOT_OWN = 0x20000, // not owned by PluginList
PGNI_UI_REG = 0x40000, // Plugin registered in user interface
PGNI_IS_LV2 = 0x80000, // Plugin is in LV2 format
PGNI_IS_LADSPA = 0x100000, // Plugin is in LADSPA format
};
class Plugin {
private:
PluginDef *pdef;
BoolParameter *p_box_visible;
BoolParameter *p_plug_visible;
BoolParameter *p_on_off;
IntParameter *p_position;
IntParameter *p_effect_post_pre;
int pos_tmp;
void set_midi_on_off_blocked(bool v);
public:
PluginDef *get_pdef() { return pdef; }
void set_pdef(PluginDef *p) { pdef = p; }
enum { POST_WEIGHT = 2000 };
Plugin(PluginDef *pl=0);
Plugin(gx_system::JsonParser& jp, ParamMap& pmap);
void writeJSON(gx_system::JsonWriter& jw);
bool get_box_visible() const { return p_box_visible && p_box_visible->get_value(); }
bool get_plug_visible() const { return p_plug_visible && p_plug_visible->get_value(); }
bool get_on_off() const { return p_on_off->get_value(); }
int get_position() const { return p_position->get_value(); }
int get_effect_post_pre() const { return p_effect_post_pre->get_value(); }
void set_box_visible(bool v) const { if (p_box_visible) p_box_visible->set(v); }
void set_plug_visible(bool v) const { if (p_plug_visible) p_plug_visible->set(v); }
void set_on_off(bool v) const { p_on_off->set(v); }
void set_position(int v) const { p_position->set(v); }
void set_effect_post_pre(int v) const { p_effect_post_pre->set(v); }
const std::string& id_box_visible() const { return p_box_visible->id(); }
const std::string& id_plug_visible() const { return p_plug_visible->id(); }
const std::string& id_on_off() const { return p_on_off->id(); }
const std::string& id_position() const { return p_position->id(); }
const std::string& id_effect_post_pre() const { return p_effect_post_pre->id(); }
inline int position_weight() { return get_effect_post_pre() ? get_position() : get_position() + POST_WEIGHT; }
void register_vars(ParamMap& param, EngineControl& seq);
void copy_position(const Plugin& plugin);
friend class PluginListBase;
friend class PluginList;
friend void printlist(const char *title, const list<Plugin*>& modules, bool header);
};
/****************************************************************
** class UiBuilderBase
*/
class UiBuilderBase: public UiBuilder {
public:
virtual bool load(Plugin *p) = 0;
};
/****************************************************************
** class ParamRegImpl
*/
class ParamRegImpl: public ParamReg {
private:
static ParamMap *pmap;
static float *registerFloatVar_(
const char* id, const char* name, const char* tp,
const char* tooltip, float* var, float val,
float low, float up, float step, const value_pair* values=0);
static int *registerIntVar_(
const char* id, const char* name, const char* tp,
const char* tooltip, int* var, int val,
int low, int up, const value_pair* values=0);
static bool *registerBoolVar_(
const char* id, const char* name, const char* tp,
const char* tooltip, bool* var, bool val);
public:
ParamRegImpl(ParamMap* pm);
};
/****************************************************************
** class PluginList
** container of plugins for all processing chains
*/
enum PluginPos { // where to add a plugin (per processing chain)
PLUGIN_POS_START,
PLUGIN_POS_RACK,
PLUGIN_POS_END // keep last one
};
typedef PluginDef *(*plugindef_creator)();
class PluginListBase {
public:
typedef pair<const std::string, Plugin*> map_pair;
typedef map<const std::string, Plugin*> pluginmap;
protected:
enum PluginPosInternal {
PLUGIN_POS_RACK_STEREO = PLUGIN_POS_END+1,
PLUGIN_POS_COUNT // keep last one
};
pluginmap pmap;
sigc::signal<void,const char*,bool> insert_remove;
public:
PluginListBase();
~PluginListBase();
void cleanup();
Plugin *find_plugin(const std::string& id) const;
Plugin *lookup_plugin(const std::string& id) const;
void append_rack(UiBuilderBase& ui);
void writeJSON(gx_system::JsonWriter& jw);
void readJSON(gx_system::JsonParser& jp, ParamMap& pmap);
pluginmap::iterator begin() { return pmap.begin(); }
pluginmap::iterator end() { return pmap.end(); }
int insert_plugin(Plugin *pvars);
void update_plugin(Plugin *pvars);
void delete_module(Plugin *pl);
};
class PluginList: public PluginListBase {
EngineControl& seq;
int plugin_pos[PLUGIN_POS_COUNT];
int add_module(Plugin *pl, PluginPos pos, int flags);
public:
PluginList(EngineControl& seq);
~PluginList();
void set_samplerate(int samplerate); // call set_samplerate of all plugins
int load_from_path(const string& path, PluginPos pos = PLUGIN_POS_RACK);
int load_library(const string& path, PluginPos pos = PLUGIN_POS_RACK);
int add(Plugin *pl, PluginPos pos, int flags);
Plugin *add(PluginDef *p, PluginPos pos = PLUGIN_POS_RACK, int flags=0);
int add(PluginDef **p, PluginPos pos = PLUGIN_POS_RACK, int flags=0);
int add(plugindef_creator *p, PluginPos pos = PLUGIN_POS_RACK, int flags=0);
int check_version(PluginDef *p);
void registerGroup(PluginDef *pd, ParameterGroups& groups);
void registerParameter(Plugin *pl, ParamMap& param, ParamRegImpl& preg);
void registerPlugin(Plugin *pl, ParamMap& param, ParameterGroups& groups);
void unregisterGroup(PluginDef *pd, ParameterGroups& groups);
void unregisterParameter(Plugin *pl, ParamMap& param);
void rescueParameter(Plugin *pl, ParamMap& param);
void unregisterPlugin(Plugin *pl, ParamMap& param, ParameterGroups& groups);
void registerAllPlugins(ParamMap& param, ParameterGroups& groups);
void ordered_mono_list(list<Plugin*>& mono, int mode);
void ordered_stereo_list(list<Plugin*>& stereo, int mode);
void ordered_list(list<Plugin*>& l, bool stereo, int flagmask, int flagvalue);
sigc::signal<void,const char*,bool>& signal_insert_remove() { return insert_remove; }
#ifndef NDEBUG
void printlist(bool ordered = true);
#endif
};
#ifndef NDEBUG
void printlist(const char *title, const list<Plugin*>& modules, bool header=true);
#else
inline void printlist(const char *, const list<Plugin*>&, bool=true) {}
#endif
} // !namespace gx_engine
gx_engine::EngineControl
Definition gx_modulesequencer.h:245
gx_engine::ParamMap
Definition gx_parameter.h:535
gx_engine::ParamRegImpl
Definition gx_pluginloader.h:98
gx_engine::ParamRegImpl::pmap
static ParamMap * pmap
Definition gx_pluginloader.h:100
gx_engine::ParamRegImpl::registerFloatVar_
static float * registerFloatVar_(const char *id, const char *name, const char *tp, const char *tooltip, float *var, float val, float low, float up, float step, const value_pair *values=0)
gx_engine::ParamRegImpl::registerIntVar_
static int * registerIntVar_(const char *id, const char *name, const char *tp, const char *tooltip, int *var, int val, int low, int up, const value_pair *values=0)
gx_engine::ParamRegImpl::ParamRegImpl
ParamRegImpl(ParamMap *pm)
gx_engine::ParamRegImpl::registerBoolVar_
static bool * registerBoolVar_(const char *id, const char *name, const char *tp, const char *tooltip, bool *var, bool val)
gx_engine::ParameterGroups
Definition gx_parameter.h:47
gx_engine::Plugin
Definition gx_pluginloader.h:45
gx_engine::Plugin::id_box_visible
const std::string & id_box_visible() const
Definition gx_pluginloader.h:72
gx_engine::Plugin::set_plug_visible
void set_plug_visible(bool v) const
Definition gx_pluginloader.h:68
gx_engine::Plugin::get_box_visible
bool get_box_visible() const
Definition gx_pluginloader.h:62
gx_engine::Plugin::id_effect_post_pre
const std::string & id_effect_post_pre() const
Definition gx_pluginloader.h:76
gx_engine::Plugin::p_position
IntParameter * p_position
Position in Rack / Audio Processing Chain.
Definition gx_pluginloader.h:51
gx_engine::Plugin::Plugin
Plugin(PluginDef *pl=0)
gx_engine::Plugin::position_weight
int position_weight()
Definition gx_pluginloader.h:77
gx_engine::Plugin::id_position
const std::string & id_position() const
Definition gx_pluginloader.h:75
gx_engine::Plugin::PluginListBase
friend class PluginListBase
Definition gx_pluginloader.h:80
gx_engine::Plugin::id_plug_visible
const std::string & id_plug_visible() const
Definition gx_pluginloader.h:73
gx_engine::Plugin::get_on_off
bool get_on_off() const
Definition gx_pluginloader.h:64
gx_engine::Plugin::p_plug_visible
BoolParameter * p_plug_visible
minibox visible (false: full box)
Definition gx_pluginloader.h:49
gx_engine::Plugin::p_effect_post_pre
IntParameter * p_effect_post_pre
pre/post amp position (post = 0)
Definition gx_pluginloader.h:52
gx_engine::Plugin::Plugin
Plugin(gx_system::JsonParser &jp, ParamMap &pmap)
gx_engine::Plugin::get_plug_visible
bool get_plug_visible() const
Definition gx_pluginloader.h:63
gx_engine::Plugin::p_on_off
BoolParameter * p_on_off
Audio Processing.
Definition gx_pluginloader.h:50
gx_engine::Plugin::set_midi_on_off_blocked
void set_midi_on_off_blocked(bool v)
gx_engine::Plugin::set_on_off
void set_on_off(bool v) const
Definition gx_pluginloader.h:69
gx_engine::Plugin::register_vars
void register_vars(ParamMap &param, EngineControl &seq)
gx_engine::Plugin::printlist
friend void printlist(const char *title, const list< Plugin * > &modules, bool header)
gx_engine::Plugin::set_pdef
void set_pdef(PluginDef *p)
Definition gx_pluginloader.h:57
gx_engine::Plugin::get_position
int get_position() const
Definition gx_pluginloader.h:65
gx_engine::Plugin::get_pdef
PluginDef * get_pdef()
Definition gx_pluginloader.h:56
gx_engine::Plugin::set_effect_post_pre
void set_effect_post_pre(int v) const
Definition gx_pluginloader.h:71
gx_engine::Plugin::pos_tmp
int pos_tmp
Definition gx_pluginloader.h:53
gx_engine::Plugin::set_position
void set_position(int v) const
Definition gx_pluginloader.h:70
gx_engine::Plugin::id_on_off
const std::string & id_on_off() const
Definition gx_pluginloader.h:74
gx_engine::Plugin::POST_WEIGHT
@ POST_WEIGHT
Definition gx_pluginloader.h:58
gx_engine::Plugin::copy_position
void copy_position(const Plugin &plugin)
gx_engine::Plugin::writeJSON
void writeJSON(gx_system::JsonWriter &jw)
gx_engine::Plugin::p_box_visible
BoolParameter * p_box_visible
In Rack: UI Interface Box visible.
Definition gx_pluginloader.h:48
gx_engine::Plugin::get_effect_post_pre
int get_effect_post_pre() const
Definition gx_pluginloader.h:66
gx_engine::Plugin::PluginList
friend class PluginList
Definition gx_pluginloader.h:81
gx_engine::Plugin::pdef
PluginDef * pdef
Definition gx_pluginloader.h:47
gx_engine::Plugin::set_box_visible
void set_box_visible(bool v) const
Definition gx_pluginloader.h:67
gx_engine::PluginListBase::pluginmap
map< const std::string, Plugin * > pluginmap
Definition gx_pluginloader.h:132
gx_engine::PluginListBase::update_plugin
void update_plugin(Plugin *pvars)
gx_engine::PluginListBase::find_plugin
Plugin * find_plugin(const std::string &id) const
gx_engine::PluginListBase::insert_plugin
int insert_plugin(Plugin *pvars)
gx_engine::PluginListBase::~PluginListBase
~PluginListBase()
gx_engine::PluginListBase::PluginPosInternal
PluginPosInternal
Definition gx_pluginloader.h:134
gx_engine::PluginListBase::PLUGIN_POS_COUNT
@ PLUGIN_POS_COUNT
Definition gx_pluginloader.h:136
gx_engine::PluginListBase::PLUGIN_POS_RACK_STEREO
@ PLUGIN_POS_RACK_STEREO
Definition gx_pluginloader.h:135
gx_engine::PluginListBase::delete_module
void delete_module(Plugin *pl)
gx_engine::PluginListBase::append_rack
void append_rack(UiBuilderBase &ui)
gx_engine::PluginListBase::begin
pluginmap::iterator begin()
Definition gx_pluginloader.h:149
gx_engine::PluginListBase::map_pair
pair< const std::string, Plugin * > map_pair
Definition gx_pluginloader.h:131
gx_engine::PluginListBase::PluginListBase
PluginListBase()
gx_engine::PluginListBase::readJSON
void readJSON(gx_system::JsonParser &jp, ParamMap &pmap)
gx_engine::PluginListBase::cleanup
void cleanup()
gx_engine::PluginListBase::insert_remove
sigc::signal< void, const char *, bool > insert_remove
Definition gx_pluginloader.h:139
gx_engine::PluginListBase::lookup_plugin
Plugin * lookup_plugin(const std::string &id) const
gx_engine::PluginListBase::writeJSON
void writeJSON(gx_system::JsonWriter &jw)
gx_engine::PluginListBase::pmap
pluginmap pmap
Definition gx_pluginloader.h:138
gx_engine::PluginListBase::end
pluginmap::iterator end()
Definition gx_pluginloader.h:150
gx_engine::PluginList::ordered_list
void ordered_list(list< Plugin * > &l, bool stereo, int flagmask, int flagvalue)
gx_engine::PluginList::registerPlugin
void registerPlugin(Plugin *pl, ParamMap &param, ParameterGroups &groups)
gx_engine::PluginList::registerParameter
void registerParameter(Plugin *pl, ParamMap &param, ParamRegImpl &preg)
gx_engine::PluginList::ordered_stereo_list
void ordered_stereo_list(list< Plugin * > &stereo, int mode)
gx_engine::PluginList::check_version
int check_version(PluginDef *p)
gx_engine::PluginList::seq
EngineControl & seq
Definition gx_pluginloader.h:157
gx_engine::PluginList::ordered_mono_list
void ordered_mono_list(list< Plugin * > &mono, int mode)
gx_engine::PluginList::load_library
int load_library(const string &path, PluginPos pos=PLUGIN_POS_RACK)
gx_engine::PluginList::signal_insert_remove
sigc::signal< void, const char *, bool > & signal_insert_remove()
Definition gx_pluginloader.h:182
gx_engine::PluginList::plugin_pos
int plugin_pos[PLUGIN_POS_COUNT]
Definition gx_pluginloader.h:158
gx_engine::PluginList::add
int add(PluginDef **p, PluginPos pos=PLUGIN_POS_RACK, int flags=0)
gx_engine::PluginList::set_samplerate
void set_samplerate(int samplerate)
gx_engine::PluginList::add
Plugin * add(PluginDef *p, PluginPos pos=PLUGIN_POS_RACK, int flags=0)
gx_engine::PluginList::unregisterParameter
void unregisterParameter(Plugin *pl, ParamMap &param)
gx_engine::PluginList::unregisterGroup
void unregisterGroup(PluginDef *pd, ParameterGroups &groups)
gx_engine::PluginList::add
int add(plugindef_creator *p, PluginPos pos=PLUGIN_POS_RACK, int flags=0)
gx_engine::PluginList::registerAllPlugins
void registerAllPlugins(ParamMap &param, ParameterGroups &groups)
gx_engine::PluginList::load_from_path
int load_from_path(const string &path, PluginPos pos=PLUGIN_POS_RACK)
gx_engine::PluginList::add_module
int add_module(Plugin *pl, PluginPos pos, int flags)
gx_engine::PluginList::rescueParameter
void rescueParameter(Plugin *pl, ParamMap &param)
gx_engine::PluginList::printlist
void printlist(bool ordered=true)
gx_engine::PluginList::add
int add(Plugin *pl, PluginPos pos, int flags)
gx_engine::PluginList::~PluginList
~PluginList()
gx_engine::PluginList::registerGroup
void registerGroup(PluginDef *pd, ParameterGroups &groups)
gx_engine::PluginList::PluginList
PluginList(EngineControl &seq)
gx_engine::PluginList::unregisterPlugin
void unregisterPlugin(Plugin *pl, ParamMap &param, ParameterGroups &groups)
gx_engine::UiBuilderBase
Definition gx_pluginloader.h:89
gx_engine::UiBuilderBase::load
virtual bool load(Plugin *p)=0
gx_system::JsonParser
Definition gx_json.h:112
gx_system::JsonWriter
Definition gx_json.h:55
gx_engine
Definition gx_convolver.h:37
gx_engine::PGNI_IS_LADSPA
@ PGNI_IS_LADSPA
Definition gx_pluginloader.h:42
gx_engine::PGNI_NOT_OWN
@ PGNI_NOT_OWN
Definition gx_pluginloader.h:39
gx_engine::PGNI_UI_REG
@ PGNI_UI_REG
Definition gx_pluginloader.h:40
gx_engine::PGNI_IS_LV2
@ PGNI_IS_LV2
Definition gx_pluginloader.h:41
gx_engine::PGNI_DYN_POSITION
@ PGNI_DYN_POSITION
Definition gx_pluginloader.h:38
gx_engine::printlist
void printlist(const char *title, const list< Plugin * > &modules, bool header=true)
gx_engine::plugindef_creator
PluginDef *(* plugindef_creator)()
Definition gx_pluginloader.h:127
gx_engine::PluginPos
PluginPos
Definition gx_pluginloader.h:121
gx_engine::PLUGIN_POS_END
@ PLUGIN_POS_END
Definition gx_pluginloader.h:124
gx_engine::PLUGIN_POS_RACK
@ PLUGIN_POS_RACK
Definition gx_pluginloader.h:123
gx_engine::PLUGIN_POS_START
@ PLUGIN_POS_START
Definition gx_pluginloader.h:122
gx_engine::IntParameter
ParameterV< int > IntParameter
Definition gx_parameter.h:97
gx_engine::BoolParameter
ParameterV< bool > BoolParameter
Definition gx_parameter.h:98
ParamReg
Parameter registration function pointers.
Definition gx_plugin.h:141
PluginDef
Definition gx_plugin.h:195
UiBuilder
Definition gx_plugin.h:63
stringcomp
Definition gx_pluginloader.h:21
stringcomp::operator()
bool operator()(const char *lhs, const char *rhs) const
Definition gx_pluginloader.h:22
value_pair
Definition gx_plugin.h:117