diff options
author | David Robillard <d@drobilla.net> | 2008-05-03 22:16:36 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-05-03 22:16:36 +0000 |
commit | 77b6f2a6a7b37e22323c4a0d80713f6cc8a231d7 (patch) | |
tree | 717506bbb1da0c108d7fcb7c1fd219ae6a41bfd4 /src/libs/client | |
parent | 511114a36510db5d1e55261fd07c8a4bc0f705b8 (diff) | |
download | ingen-77b6f2a6a7b37e22323c4a0d80713f6cc8a231d7.tar.gz ingen-77b6f2a6a7b37e22323c4a0d80713f6cc8a231d7.tar.bz2 ingen-77b6f2a6a7b37e22323c4a0d80713f6cc8a231d7.zip |
Apply slv2_plugin_get_port_ranges usage Ingen patch from larsl.
git-svn-id: http://svn.drobilla.net/lad/ingen@1194 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/client')
-rw-r--r-- | src/libs/client/NodeModel.cpp | 32 | ||||
-rw-r--r-- | src/libs/client/NodeModel.hpp | 3 |
2 files changed, 26 insertions, 9 deletions
diff --git a/src/libs/client/NodeModel.cpp b/src/libs/client/NodeModel.cpp index 2f8af584..d47e0b8c 100644 --- a/src/libs/client/NodeModel.cpp +++ b/src/libs/client/NodeModel.cpp @@ -18,6 +18,7 @@ #include CONFIG_H_PATH #include <cassert> +#include <cmath> #include "interface/Port.hpp" #include "NodeModel.hpp" #include "PatchModel.hpp" @@ -30,12 +31,16 @@ NodeModel::NodeModel(Store& store, SharedPtr<PluginModel> plugin, const Path& pa : ObjectModel(store, path, polyphonic) , _plugin_uri(plugin->uri()) , _plugin(plugin) + , _min_values(0) + , _max_values(0) { } NodeModel::NodeModel(Store& store, const string& plugin_uri, const Path& path, bool polyphonic) : ObjectModel(store, path, polyphonic) , _plugin_uri(plugin_uri) + , _min_values(0) + , _max_values(0) { } @@ -78,6 +83,10 @@ NodeModel::clear() { _ports.clear(); assert(_ports.empty()); + delete [] _min_values; + delete [] _max_values; + _min_values = 0; + _max_values = 0; } @@ -155,17 +164,22 @@ NodeModel::port_value_range(SharedPtr<PortModel> port, float& min, float& max) #ifdef HAVE_SLV2 // Plugin value first if (_plugin && _plugin->type() == PluginModel::LV2) { - Glib::Mutex::Lock(PluginModel::rdf_world()->mutex()); - SLV2Value min_val, max_val; - slv2_port_get_range(_plugin->slv2_plugin(), - _plugin->slv2_port(port->index()), - NULL, &min_val, &max_val); + if (!_min_values) { + + Glib::Mutex::Lock(PluginModel::rdf_world()->mutex()); + + uint32_t num_lv2_ports = slv2_plugin_get_num_ports(_plugin->slv2_plugin()); + _min_values = new float[num_lv2_ports]; + _max_values = new float[num_lv2_ports]; + slv2_plugin_get_port_ranges(_plugin->slv2_plugin(), + _min_values, _max_values, 0); + } - if (min_val) - min = slv2_value_as_float(min_val); - if (max_val) - max = slv2_value_as_float(max_val); + if (!std::isnan(_min_values[port->index()])) + min = _min_values[port->index()]; + if (!std::isnan(_max_values[port->index()])) + max = _max_values[port->index()]; } #endif diff --git a/src/libs/client/NodeModel.hpp b/src/libs/client/NodeModel.hpp index 9e26daaa..d50926ae 100644 --- a/src/libs/client/NodeModel.hpp +++ b/src/libs/client/NodeModel.hpp @@ -85,6 +85,9 @@ protected: PortModelList _ports; ///< List of ports (not a Table to preserve order) string _plugin_uri; ///< Plugin URI (if PluginModel is unknown) SharedPtr<PluginModel> _plugin; ///< The plugin this node is an instance of + + float* _min_values; ///< The min values for the node ports (only used for LV2 so far) + float* _max_values; ///< The max values for the node ports (only used for LV2 so far) }; |