X-Git-Url: https://main.carlh.net/gitweb/?p=ardour.git;a=blobdiff_plain;f=libs%2Fardour%2Fladspa_plugin.cc;h=7ca6929112d12417e41304c230ef55c994270009;hp=8b089929b50c53ff021e59f64ea6b90de332d8d2;hb=c8c6bca6587450ff64303dbc994a4cd28d6ce7aa;hpb=efff843f0537df84e22af5f6f6e8e6d6a305a5a9 diff --git a/libs/ardour/ladspa_plugin.cc b/libs/ardour/ladspa_plugin.cc index 8b089929b5..7ca6929112 100644 --- a/libs/ardour/ladspa_plugin.cc +++ b/libs/ardour/ladspa_plugin.cc @@ -51,7 +51,7 @@ #include "pbd/stl_delete.h" -#include "i18n.h" +#include "pbd/i18n.h" #include using namespace std; @@ -141,11 +141,8 @@ LadspaPlugin::init (string module_path, uint32_t index, framecnt_t rate) *_latency_control_port = 0; } - if (!LADSPA_IS_PORT_INPUT(port_descriptor (i))) { - continue; - } - - _shadow_data[i] = default_value (i); + _shadow_data[i] = _default_value (i); + _control_data[i] = _shadow_data[i]; } } @@ -173,7 +170,7 @@ LadspaPlugin::unique_id() const } float -LadspaPlugin::default_value (uint32_t port) +LadspaPlugin::_default_value (uint32_t port) const { const LADSPA_PortRangeHint *prh = port_range_hints(); float ret = 0.0f; @@ -350,8 +347,8 @@ void LadspaPlugin::add_state (XMLNode* root) const { XMLNode *child; - char buf[16]; - LocaleGuard lg (X_("POSIX")); + char buf[32]; + LocaleGuard lg; for (uint32_t i = 0; i < parameter_count(); ++i){ @@ -377,14 +374,14 @@ LadspaPlugin::set_state (const XMLNode& node, int version) #ifndef NO_PLUGIN_STATE XMLNodeList nodes; - XMLProperty *prop; + XMLProperty const * prop; XMLNodeConstIterator iter; XMLNode *child; const char *port; const char *data; uint32_t port_id; #endif - LocaleGuard lg (X_("POSIX")); + LocaleGuard lg; if (node.name() != state_node_name()) { error << _("Bad node sent to LadspaPlugin::set_state") << endmsg; @@ -427,14 +424,14 @@ LadspaPlugin::set_state_2X (const XMLNode& node, int /* version */) { #ifndef NO_PLUGIN_STATE XMLNodeList nodes; - XMLProperty *prop; + XMLProperty const * prop; XMLNodeConstIterator iter; XMLNode *child; const char *port; const char *data; uint32_t port_id; #endif - LocaleGuard lg (X_("POSIX")); + LocaleGuard lg; if (node.name() != state_node_name()) { error << _("Bad node sent to LadspaPlugin::set_state") << endmsg; @@ -504,15 +501,14 @@ LadspaPlugin::get_parameter_descriptor (uint32_t which, ParameterDescriptor& des desc.upper = 4; /* completely arbitrary */ } - if (LADSPA_IS_HINT_INTEGER (prh.HintDescriptor)) { - desc.step = 1.0; - desc.smallstep = 0.1; - desc.largestep = 10.0; + if (LADSPA_IS_HINT_HAS_DEFAULT (prh.HintDescriptor)) { + desc.normal = _default_value(which); } else { - float delta = desc.upper - desc.lower; - desc.step = delta / 1000.0f; - desc.smallstep = delta / 10000.0f; - desc.largestep = delta/10.0f; + /* if there is no explicit hint for the default + * value, use lower bound. This is not great but + * better than just assuming '0' which may be out-of range. + */ + desc.normal = desc.lower; } desc.toggled = LADSPA_IS_HINT_TOGGLED (prh.HintDescriptor); @@ -522,6 +518,9 @@ LadspaPlugin::get_parameter_descriptor (uint32_t which, ParameterDescriptor& des desc.label = port_names()[which]; + desc.scale_points = get_scale_points(which); + desc.update_steps(); + return 0; } @@ -567,10 +566,11 @@ LadspaPlugin::automatable () const int LadspaPlugin::connect_and_run (BufferSet& bufs, + framepos_t start, framepos_t end, double speed, ChanMapping in_map, ChanMapping out_map, pframes_t nframes, framecnt_t offset) { - Plugin::connect_and_run (bufs, in_map, out_map, nframes, offset); + Plugin::connect_and_run (bufs, start, end, speed, in_map, out_map, nframes, offset); cycles_t now; cycles_t then = get_cycles (); @@ -640,10 +640,10 @@ LadspaPlugin::print_parameter (uint32_t param, char *buf, uint32_t len) const } } -boost::shared_ptr +boost::shared_ptr LadspaPlugin::get_scale_points(uint32_t port_index) const { - boost::shared_ptr ret; + boost::shared_ptr ret; #ifdef HAVE_LRDF const uint32_t id = atol(unique_id().c_str()); lrdf_defaults* points = lrdf_get_scale_values(id, port_index); @@ -652,7 +652,7 @@ LadspaPlugin::get_scale_points(uint32_t port_index) const return ret; } - ret = boost::shared_ptr(new ScalePoints()); + ret = boost::shared_ptr(new ScalePoints()); for (uint32_t i = 0; i < points->count; ++i) { ret->insert(make_pair(points->items[i].label, @@ -736,6 +736,29 @@ LadspaPluginInfo::load (Session& session) } } +std::vector +LadspaPluginInfo::get_presets (bool /*user_only*/) const +{ + std::vector p; +#if (defined HAVE_LRDF && !defined NO_PLUGIN_STATE) + if (!isdigit (unique_id[0])) { + return p; + } + uint32_t id = atol (unique_id); + lrdf_uris* set_uris = lrdf_get_setting_uris(id); + + if (set_uris) { + for (uint32_t i = 0; i < (uint32_t) set_uris->count; ++i) { + if (char* label = lrdf_get_label (set_uris->items[i])) { + p.push_back (Plugin::PresetRecord (set_uris->items[i], label)); + } + } + lrdf_free_uris(set_uris); + } +#endif + return p; +} + LadspaPluginInfo::LadspaPluginInfo() { type = ARDOUR::LADSPA; @@ -790,11 +813,11 @@ LadspaPlugin::load_preset (PresetRecord r) return true; } +#ifdef HAVE_LRDF /* XXX: should be in liblrdf */ static void lrdf_remove_preset (const char* /*source*/, const char *setting_uri) { -#ifdef HAVE_LRDF lrdf_statement p; lrdf_statement *q; lrdf_statement *i; @@ -828,8 +851,8 @@ lrdf_remove_preset (const char* /*source*/, const char *setting_uri) p.predicate = NULL; p.object = NULL; lrdf_remove_matches (&p); -#endif } +#endif void LadspaPlugin::do_remove_preset (string name) @@ -954,13 +977,13 @@ LadspaPlugin::do_save_preset (string name) LADSPA_PortDescriptor LadspaPlugin::port_descriptor (uint32_t i) const { - if (i < _descriptor->PortCount) { + if (i < _descriptor->PortCount) { return _descriptor->PortDescriptors[i]; } - + warning << "LADSPA plugin port index " << i << " out of range." << endmsg; return 0; } - - + +