From bd85c8ec43b540ca5b98e61dee0c20f295be5b56 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 29 Nov 2014 22:57:46 +0100 Subject: fix ladpsa default value. because get_parameter_descriptor() is const, also wrap default_value() in a const function. --- libs/ardour/ardour/ladspa_plugin.h | 3 ++- libs/ardour/ladspa_plugin.cc | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'libs/ardour') diff --git a/libs/ardour/ardour/ladspa_plugin.h b/libs/ardour/ardour/ladspa_plugin.h index cdcd9dbc6e..f23517f108 100644 --- a/libs/ardour/ardour/ladspa_plugin.h +++ b/libs/ardour/ardour/ladspa_plugin.h @@ -49,7 +49,7 @@ class LIBARDOUR_API LadspaPlugin : public ARDOUR::Plugin const char* name() const { return _descriptor->Name; } const char* maker() const { return _descriptor->Maker; } uint32_t parameter_count() const { return _descriptor->PortCount; } - float default_value (uint32_t port); + float default_value (uint32_t port) { return _default_value (port); } framecnt_t signal_latency() const; void set_parameter (uint32_t port, float val); float get_parameter (uint32_t port) const; @@ -121,6 +121,7 @@ class LIBARDOUR_API LadspaPlugin : public ARDOUR::Plugin void connect_port (uint32_t port, float *ptr) { _descriptor->connect_port (_handle, port, ptr); } private: + float _default_value (uint32_t port) const; std::string _module_path; Glib::Module* _module; const LADSPA_Descriptor* _descriptor; diff --git a/libs/ardour/ladspa_plugin.cc b/libs/ardour/ladspa_plugin.cc index 4866516b1a..fca37441af 100644 --- a/libs/ardour/ladspa_plugin.cc +++ b/libs/ardour/ladspa_plugin.cc @@ -145,7 +145,7 @@ LadspaPlugin::init (string module_path, uint32_t index, framecnt_t rate) continue; } - _shadow_data[i] = default_value (i); + _shadow_data[i] = _default_value (i); } } @@ -173,7 +173,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; @@ -515,6 +515,17 @@ LadspaPlugin::get_parameter_descriptor (uint32_t which, ParameterDescriptor& des desc.largestep = delta/10.0f; } + + if (LADSPA_IS_HINT_HAS_DEFAULT (prh.HintDescriptor)) { + desc.normal = _default_value(which); + } else { + /* 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); desc.logarithmic = LADSPA_IS_HINT_LOGARITHMIC (prh.HintDescriptor); desc.sr_dependent = LADSPA_IS_HINT_SAMPLE_RATE (prh.HintDescriptor); -- cgit v1.2.3