summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-02-03 06:08:08 +0000
committerDavid Robillard <d@drobilla.net>2010-02-03 06:08:08 +0000
commit44859a84f0bad75cb358dc1d91e5cfcdeda10ba7 (patch)
treebf16298b7448f7b696bbe0649940838e7504861b /src/engine
parent87597f85c5a69a9accd3ce2ed88f2a006173e885 (diff)
downloadingen-44859a84f0bad75cb358dc1d91e5cfcdeda10ba7.tar.gz
ingen-44859a84f0bad75cb358dc1d91e5cfcdeda10ba7.tar.bz2
ingen-44859a84f0bad75cb358dc1d91e5cfcdeda10ba7.zip
Bind ports with lv2:portProperty lv2:toggled specially (on iff value >= half).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2410 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/ControlBindings.cpp12
-rw-r--r--src/engine/LV2Node.cpp13
-rw-r--r--src/engine/internals/Controller.cpp2
-rw-r--r--src/engine/internals/Note.cpp4
-rw-r--r--src/engine/internals/Trigger.cpp4
5 files changed, 27 insertions, 8 deletions
diff --git a/src/engine/ControlBindings.cpp b/src/engine/ControlBindings.cpp
index 2144aba7..ee41bd51 100644
--- a/src/engine/ControlBindings.cpp
+++ b/src/engine/ControlBindings.cpp
@@ -69,8 +69,10 @@ void
ControlBindings::set_port_value(ProcessContext& context, PortImpl* port, Type type, int16_t value)
{
// TODO: cache these to avoid the lookup
- float min = port->get_property(Shared::LV2URIMap::instance().lv2_minimum).get_float();
- float max = port->get_property(Shared::LV2URIMap::instance().lv2_maximum).get_float();
+ const Shared::LV2URIMap& uris = Shared::LV2URIMap::instance();
+ float min = port->get_property(uris.lv2_minimum).get_float();
+ float max = port->get_property(uris.lv2_maximum).get_float();
+ bool toggled = port->has_property(uris.lv2_portProperty, uris.lv2_toggled);
float normal;
switch (type) {
@@ -84,7 +86,11 @@ ControlBindings::set_port_value(ProcessContext& context, PortImpl* port, Type ty
break;
}
- Raul::Atom atom(static_cast<float>(normal * (max - min) + min));
+ float scaled_value = normal * (max - min) + min;
+ if (toggled)
+ scaled_value = (scaled_value < 0.5) ? 0.0 : 1.0;
+
+ Raul::Atom atom(scaled_value);
port->set_value(atom);
const Events::SendPortValue ev(context.engine(), context.start(), port, true, 0,
diff --git a/src/engine/LV2Node.cpp b/src/engine/LV2Node.cpp
index a0c7dd07..2e176abe 100644
--- a/src/engine/LV2Node.cpp
+++ b/src/engine/LV2Node.cpp
@@ -198,6 +198,9 @@ LV2Node::instantiate(BufferFactory& bufs)
SLV2Value min_size_pred = slv2_value_new_uri(info->lv2_world(),
"http://lv2plug.in/ns/dev/resize-port#minimumSize");
+ SLV2Value port_property_pred = slv2_value_new_uri(info->lv2_world(),
+ "http://lv2plug.in/ns/lv2core#portProperty");
+
//SLV2Value as_large_as_pred = slv2_value_new_uri(info->lv2_world(),
// "http://lv2plug.in/ns/dev/resize-port#asLargeAs");
@@ -291,6 +294,16 @@ LV2Node::instantiate(BufferFactory& bufs)
}
}
+ // Set lv2:portProperty properties
+ SLV2Values properties = slv2_port_get_value(plug, id, port_property_pred);
+ for (uint32_t i = 0; i < slv2_values_size(properties); ++i) {
+ SLV2Value p = slv2_values_get_at(properties, i);
+ if (slv2_value_is_uri(p)) {
+ Raul::info << "SET PORT PROPERTY " << slv2_value_as_uri(p) << endl;
+ port->set_property(uris.lv2_portProperty, Raul::URI(slv2_value_as_uri(p)));
+ }
+ }
+
SLV2Values contexts = slv2_port_get_value(plug, id, context_pred);
for (uint32_t i = 0; i < slv2_values_size(contexts); ++i) {
SLV2Value c = slv2_values_get_at(contexts, i);
diff --git a/src/engine/internals/Controller.cpp b/src/engine/internals/Controller.cpp
index 4d102bef..56bc433d 100644
--- a/src/engine/internals/Controller.cpp
+++ b/src/engine/internals/Controller.cpp
@@ -61,7 +61,7 @@ ControllerNode::ControllerNode(BufferFactory& bufs,
_ports->at(1) = _param_port;
_log_port = new InputPort(bufs, this, "logarithmic", 2, 1, PortType::CONTROL, 0.0f, sizeof(Sample));
- _log_port->set_property(uris.lv2_toggled, true);
+ _log_port->set_property(uris.lv2_portProperty, uris.lv2_toggled);
_ports->at(2) = _log_port;
_min_port = new InputPort(bufs, this, "minimum", 3, 1, PortType::CONTROL, 0.0f, sizeof(Sample));
diff --git a/src/engine/internals/Note.cpp b/src/engine/internals/Note.cpp
index ecee587f..10d7eeaf 100644
--- a/src/engine/internals/Note.cpp
+++ b/src/engine/internals/Note.cpp
@@ -66,11 +66,11 @@ NoteNode::NoteNode(BufferFactory& bufs, const string& path, bool polyphonic, Pat
_ports->at(2) = _vel_port;
_gate_port = new OutputPort(bufs, this, "gate", 3, _polyphony, PortType::AUDIO, 0.0f, _buffer_size);
- _gate_port->set_property(uris.lv2_toggled, true);
+ _gate_port->set_property(uris.lv2_portProperty, uris.lv2_toggled);
_ports->at(3) = _gate_port;
_trig_port = new OutputPort(bufs, this, "trigger", 4, _polyphony, PortType::AUDIO, 0.0f, _buffer_size);
- _trig_port->set_property(uris.lv2_toggled, true);
+ _trig_port->set_property(uris.lv2_portProperty, uris.lv2_toggled);
_ports->at(4) = _trig_port;
}
diff --git a/src/engine/internals/Trigger.cpp b/src/engine/internals/Trigger.cpp
index 68d938c0..a92ab605 100644
--- a/src/engine/internals/Trigger.cpp
+++ b/src/engine/internals/Trigger.cpp
@@ -58,11 +58,11 @@ TriggerNode::TriggerNode(BufferFactory& bufs, const string& path, bool polyphoni
_ports->at(1) = _note_port;
_gate_port = new OutputPort(bufs, this, "gate", 2, 1, PortType::AUDIO, 0.0f, _buffer_size);
- _gate_port->set_property(uris.lv2_toggled, true);
+ _gate_port->set_property(uris.lv2_portProperty, uris.lv2_toggled);
_ports->at(2) = _gate_port;
_trig_port = new OutputPort(bufs, this, "trigger", 3, 1, PortType::AUDIO, 0.0f, _buffer_size);
- _trig_port->set_property(uris.lv2_toggled, true);
+ _trig_port->set_property(uris.lv2_portProperty, uris.lv2_toggled);
_ports->at(3) = _trig_port;
_vel_port = new OutputPort(bufs, this, "velocity", 4, 1, PortType::AUDIO, 0.0f, _buffer_size);