summaryrefslogtreecommitdiffstats
path: root/src/libs/engine/LV2Node.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-01-25 06:55:57 +0000
committerDavid Robillard <d@drobilla.net>2008-01-25 06:55:57 +0000
commitdf8ee18c0139f889bf7c697713a2205364845464 (patch)
tree2d3d2389504676b194fcb47a9ed3e7b1da8f94c4 /src/libs/engine/LV2Node.cpp
parentf3f08e248a96f2a6d75d4fc6ee3dc34985805e58 (diff)
downloadingen-df8ee18c0139f889bf7c697713a2205364845464.tar.gz
ingen-df8ee18c0139f889bf7c697713a2205364845464.tar.bz2
ingen-df8ee18c0139f889bf7c697713a2205364845464.zip
Overhaul SLV2 API to return/take SLV2Value (instead of strings or primitives) wherever possible.
Make 'index' a fundemental property of ingen ports. git-svn-id: http://svn.drobilla.net/lad/ingen@1113 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine/LV2Node.cpp')
-rw-r--r--src/libs/engine/LV2Node.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/libs/engine/LV2Node.cpp b/src/libs/engine/LV2Node.cpp
index 2fbd390f..a0fdebc0 100644
--- a/src/libs/engine/LV2Node.cpp
+++ b/src/libs/engine/LV2Node.cpp
@@ -153,7 +153,7 @@ LV2Node::instantiate()
SLV2Port id = slv2_plugin_get_port_by_index(plug, j);
// LV2 shortnames are guaranteed to be unique, valid C identifiers
- port_name = (char*)slv2_port_get_symbol(plug, id);
+ port_name = slv2_value_as_string(slv2_port_get_symbol(plug, id));
assert(port_name.find("/") == string::npos);
@@ -185,15 +185,24 @@ LV2Node::instantiate()
_instances = NULL;
return false;
}
+
+ SLV2Value def, min, max;
+ slv2_port_get_range(plug, id, &def, &min, &max);
+
+ // FIXME: need nice type preserving SLV2Value -> Raul::Atom conversion
+ Atom defatm = (float)((def && slv2_value_is_float(def)) ? slv2_value_as_float(def) : 0.0f);
if (direction == INPUT)
- port = new InputPort(this, port_name, j, _polyphony, data_type, port_buffer_size);
+ port = new InputPort(this, port_name, j, _polyphony, data_type, defatm, port_buffer_size);
else
- port = new OutputPort(this, port_name, j, _polyphony, data_type, port_buffer_size);
+ port = new OutputPort(this, port_name, j, _polyphony, data_type, defatm, port_buffer_size);
if (direction == INPUT && data_type == DataType::CONTROL)
- ((AudioBuffer*)port->buffer(0))->set(
- slv2_port_get_default_value(_lv2_plugin->slv2_plugin(), id), 0);
+ ((AudioBuffer*)port->buffer(0))->set(slv2_value_as_float(def), 0);
+
+ slv2_value_free(def);
+ slv2_value_free(min);
+ slv2_value_free(max);
_ports->at(j) = port;
}
@@ -213,12 +222,7 @@ LV2Node::activate()
set_port_buffer(i, j, port->buffer(i));
if (port->type() == DataType::CONTROL) {
-
- const float val = slv2_port_get_default_value(_lv2_plugin->slv2_plugin(),
- slv2_plugin_get_port_by_index(_lv2_plugin->slv2_plugin(), j));
-
- ((AudioBuffer*)port->buffer(i))->set(val, 0);
-
+ ((AudioBuffer*)port->buffer(i))->set(port->value().get_float(), 0);
} else if (port->type() == DataType::AUDIO) {
((AudioBuffer*)port->buffer(i))->set(0.0f, 0);
}