13
0

fix ladpsa default value.

because get_parameter_descriptor() is const, also wrap
default_value() in a const function.
This commit is contained in:
Robin Gareus 2014-11-29 22:57:46 +01:00
parent cf859270e0
commit bd85c8ec43
2 changed files with 15 additions and 3 deletions

View File

@ -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;

View File

@ -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);