diff options
author | David Robillard <d@drobilla.net> | 2011-05-14 18:43:34 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-05-14 18:43:34 +0000 |
commit | 2b7f092b857df8cde0cd4680e9de55f4cb98596b (patch) | |
tree | 221203a26c8e6a5b902f55ba87c40f36f886003f /libs/ardour/lv2_plugin.cc | |
parent | c78528dcea03a61685ad0586eaa6302847af6fe9 (diff) |
Generic scale points API.
Hide scale points implementation inside specific Plugin subclass.
Don't needlessley/slowly get scale points twice for each port while building UI.
Remove dependence on specific plugin types from GenericPluginUI.
git-svn-id: svn://localhost/ardour2/branches/3.0@9511 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/lv2_plugin.cc')
-rw-r--r-- | libs/ardour/lv2_plugin.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index e7c9dad4ec..6c1664bc01 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -1027,6 +1027,33 @@ LV2Plugin::print_parameter(uint32_t param, char* buf, uint32_t len) const } } +boost::shared_ptr<Plugin::ScalePoints> +LV2Plugin::get_scale_points(uint32_t port_index) const +{ + SLV2Port port = slv2_plugin_get_port_by_index(_plugin, port_index); + SLV2ScalePoints points = slv2_port_get_scale_points(_plugin, port); + + boost::shared_ptr<Plugin::ScalePoints> ret; + if (!points) { + return ret; + } + + ret = boost::shared_ptr<Plugin::ScalePoints>(new ScalePoints()); + + for (unsigned i = 0; i < slv2_scale_points_size(points); ++i) { + SLV2ScalePoint p = slv2_scale_points_get_at(points, i); + SLV2Value label = slv2_scale_point_get_label(p); + SLV2Value value = slv2_scale_point_get_value(p); + if (label && (slv2_value_is_float(value) || slv2_value_is_int(value))) { + ret->insert(make_pair(slv2_value_as_string(label), + slv2_value_as_float(value))); + } + } + + slv2_scale_points_free(points); + return ret; +} + void LV2Plugin::run(pframes_t nframes) { |