summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libs/client/NodeModel.cpp32
-rw-r--r--src/libs/client/NodeModel.hpp2
-rw-r--r--src/libs/engine/ObjectSender.cpp10
-rw-r--r--src/libs/gui/ControlGroups.cpp4
-rw-r--r--src/libs/gui/Port.cpp47
-rw-r--r--src/libs/gui/Port.hpp5
-rw-r--r--src/libs/gui/PortPropertiesWindow.cpp2
7 files changed, 59 insertions, 43 deletions
diff --git a/src/libs/client/NodeModel.cpp b/src/libs/client/NodeModel.cpp
index 76faa158..a910d67e 100644
--- a/src/libs/client/NodeModel.cpp
+++ b/src/libs/client/NodeModel.cpp
@@ -135,7 +135,7 @@ NodeModel::get_port(const string& port_name) const
void
NodeModel::add_program(int bank, int program, const string& name)
{
- _banks[bank][program] = name;
+ _banks[bank][program] = name;
}
@@ -149,28 +149,38 @@ NodeModel::remove_program(int bank, int program)
void
-NodeModel::port_value_range(const string& name, float& min, float& max)
+NodeModel::port_value_range(SharedPtr<PortModel> port, float& min, float& max)
{
- // FIXME: cache these values
- const Atom& min_atom = get_metadata("ingen:minimum");
- const Atom& max_atom = get_metadata("ingen:maximum");
- if (min_atom.type() == Atom::FLOAT)
- min = min_atom.get_float();
- if (max_atom.type() == Atom::FLOAT)
- max = max_atom.get_float();
+ assert(port->parent().get() == this);
+ // FIXME: cache these values
+
+ // Plugin value first
#ifdef HAVE_SLV2
if (plugin() && plugin()->type() == PluginModel::LV2) {
min = slv2_port_get_minimum_value(
plugin()->slv2_plugin(),
slv2_plugin_get_port_by_symbol(plugin()->slv2_plugin(),
- name.c_str()));
+ port->path().name().c_str()));
max = slv2_port_get_maximum_value(
plugin()->slv2_plugin(),
slv2_plugin_get_port_by_symbol(plugin()->slv2_plugin(),
- name.c_str()));
+ port->path().name().c_str()));
+
+ //cerr << "SLV2: " << min << " .. " << max << endl;
}
#endif
+
+ // Possibly overriden
+ const Atom& min_atom = port->get_metadata("ingen:minimum");
+ const Atom& max_atom = port->get_metadata("ingen:maximum");
+ if (min_atom.type() == Atom::FLOAT)
+ min = min_atom.get_float();
+ if (max_atom.type() == Atom::FLOAT)
+ max = max_atom.get_float();
+
+ //cerr << (unsigned)plugin()->type() << "::" << _path << ".port_value_range(" << port->path().name()
+ // << ") == " << min << " .. " << max << endl;
}
diff --git a/src/libs/client/NodeModel.hpp b/src/libs/client/NodeModel.hpp
index 05a92d7c..fe7faa0a 100644
--- a/src/libs/client/NodeModel.hpp
+++ b/src/libs/client/NodeModel.hpp
@@ -58,7 +58,7 @@ public:
const PortModelList& ports() const { return _ports; }
virtual bool polyphonic() const { return _polyphonic; }
- void port_value_range(const string& name, float& min, float& max);
+ void port_value_range(SharedPtr<PortModel> port, float& min, float& max);
// Signals
sigc::signal<void, SharedPtr<PortModel> > new_port_sig;
diff --git a/src/libs/engine/ObjectSender.cpp b/src/libs/engine/ObjectSender.cpp
index c40ba972..d585ab71 100644
--- a/src/libs/engine/ObjectSender.cpp
+++ b/src/libs/engine/ObjectSender.cpp
@@ -141,6 +141,11 @@ ObjectSender::send_port(ClientInterface* client, const Port* port)
client->new_port(port->path(), type, port->is_output());
+ // Send metadata
+ const GraphObject::MetadataMap& data = port->metadata();
+ for (GraphObject::MetadataMap::const_iterator j = data.begin(); j != data.end(); ++j)
+ client->metadata_update(port->path(), (*j).first, (*j).second);
+
// Send control value
if (port->type() == DataType::FLOAT && port->buffer_size() == 1) {
const Sample value = dynamic_cast<const AudioBuffer*>(port->buffer(0))->value_at(0);
@@ -148,11 +153,6 @@ ObjectSender::send_port(ClientInterface* client, const Port* port)
client->control_change(port->path(), value);
}
- // Send metadata
- const GraphObject::MetadataMap& data = port->metadata();
- for (GraphObject::MetadataMap::const_iterator j = data.begin(); j != data.end(); ++j)
- client->metadata_update(port->path(), (*j).first, (*j).second);
-
client->bundle_end();
}
diff --git a/src/libs/gui/ControlGroups.cpp b/src/libs/gui/ControlGroups.cpp
index b6c62435..d82fca13 100644
--- a/src/libs/gui/ControlGroups.cpp
+++ b/src/libs/gui/ControlGroups.cpp
@@ -119,7 +119,7 @@ SliderControlGroup::init(ControlPanel* panel, SharedPtr<PortModel> pm)
boost::shared_ptr<NodeModel> parent = PtrCast<NodeModel>(_port_model->parent());
if (parent)
- parent->port_value_range(_port_model->path().name(), min, max);
+ parent->port_value_range(_port_model, min, max);
if (pm->is_integer() || pm->is_toggle()) {
_slider->set_increments(1, 10);
@@ -128,7 +128,7 @@ SliderControlGroup::init(ControlPanel* panel, SharedPtr<PortModel> pm)
_slider->set_increments(0, 0);
}
- _slider->set_range(min, max);
+ _slider->set_range(std::min(min, pm->value()), std::max(max, pm->value()));
//_value_spinner->set_range(min, max);
set_value(pm->value());
diff --git a/src/libs/gui/Port.cpp b/src/libs/gui/Port.cpp
index 49a1a7c6..455f9e8c 100644
--- a/src/libs/gui/Port.cpp
+++ b/src/libs/gui/Port.cpp
@@ -48,14 +48,24 @@ Port::Port(boost::shared_ptr<FlowCanvas::Module> module, SharedPtr<PortModel> pm
_menu.items().push_back(Gtk::Menu_Helpers::MenuElem("Destroy",
sigc::mem_fun(this, &Port::on_menu_destroy)));
- control_changed(_port_model->value());
-
_port_model->renamed_sig.connect(sigc::mem_fun(this, &Port::renamed));
if (pm->is_control()) {
show_control();
+
+ float min = 0.0f, max = 1.0f;
+ boost::shared_ptr<NodeModel> parent = PtrCast<NodeModel>(_port_model->parent());
+ if (parent)
+ parent->port_value_range(_port_model, min, max);
+
+ set_control_min(min);
+ set_control_max(max);
+
+ pm->metadata_update_sig.connect(sigc::mem_fun(this, &Port::metadata_update));
_port_model->control_change_sig.connect(sigc::mem_fun(this, &Port::control_changed));
}
+
+ control_changed(_port_model->value());
}
@@ -76,33 +86,26 @@ Port::renamed()
void
Port::control_changed(float value)
{
- float min = 0.0f, max = 1.0f;
- boost::shared_ptr<NodeModel> parent = PtrCast<NodeModel>(_port_model->parent());
- if (parent)
- parent->port_value_range(_port_model->path().name(), min, max);
-
- /*cerr << "Control changed: " << value << endl;
- cerr << "Min: " << min << endl;
- cerr << "Max: " << max << endl;*/
-
- FlowCanvas::Port::set_control((value - min) / (max - min));
+ FlowCanvas::Port::set_control(value);
}
void
-Port::set_control(float value)
+Port::set_control(float value, bool signal)
{
- if (_port_model->is_control()) {
- //cerr << "Set control: " << value << endl;
- float min = 0.0f, max = 1.0f;
- boost::shared_ptr<NodeModel> parent = PtrCast<NodeModel>(_port_model->parent());
- if (parent)
- parent->port_value_range(_port_model->path().name(), min, max);
+ if (signal)
+ App::instance().engine()->set_port_value(_port_model->path(), value);
+ FlowCanvas::Port::set_control(value);
+}
- App::instance().engine()->set_port_value(_port_model->path(),
- min + (value * (max-min)));
- FlowCanvas::Port::set_control(value);
+void
+Port::metadata_update(const string& key, const Atom& value)
+{
+ if ( (key == "ingen:minimum") && value.type() == Atom::FLOAT) {
+ set_control_min(value.get_float());
+ } else if ( (key == "ingen:maximum") && value.type() == Atom::FLOAT) {
+ set_control_max(value.get_float());
}
}
diff --git a/src/libs/gui/Port.hpp b/src/libs/gui/Port.hpp
index f7eed2f7..5925860d 100644
--- a/src/libs/gui/Port.hpp
+++ b/src/libs/gui/Port.hpp
@@ -22,6 +22,7 @@
#include <string>
#include <flowcanvas/Port.hpp>
#include <raul/SharedPtr.hpp>
+#include <raul/Atom.hpp>
namespace Ingen { namespace Client { class PortModel; } }
using Ingen::Client::PortModel;
@@ -43,10 +44,12 @@ public:
SharedPtr<PortModel> model() const { return _port_model; }
- virtual void set_control(float value);
+ virtual void set_control(float value, bool signal);
void control_changed(float value);
private:
+
+ void metadata_update(const string& key, const Raul::Atom& value);
void on_menu_destroy();
void renamed();
diff --git a/src/libs/gui/PortPropertiesWindow.cpp b/src/libs/gui/PortPropertiesWindow.cpp
index c975d289..3d69e648 100644
--- a/src/libs/gui/PortPropertiesWindow.cpp
+++ b/src/libs/gui/PortPropertiesWindow.cpp
@@ -65,7 +65,7 @@ PortPropertiesWindow::init(ControlGroup* control, SharedPtr<PortModel> pm)
float min = 0.0f, max = 1.0f;
boost::shared_ptr<NodeModel> parent = PtrCast<NodeModel>(_port_model->parent());
if (parent)
- parent->port_value_range(_port_model->path().name(), min, max);
+ parent->port_value_range(_port_model, min, max);
_initial_min = min;
_initial_max = max;