summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/client/NodeModel.cpp14
-rw-r--r--src/libs/engine/LADSPANode.cpp72
-rw-r--r--src/libs/engine/LADSPANode.hpp11
-rw-r--r--src/libs/engine/LV2Node.cpp35
-rw-r--r--src/libs/engine/LV2Node.hpp6
-rw-r--r--src/libs/engine/NodeBase.cpp2
-rw-r--r--src/libs/serialisation/Loader.cpp6
7 files changed, 95 insertions, 51 deletions
diff --git a/src/libs/client/NodeModel.cpp b/src/libs/client/NodeModel.cpp
index 1ee67dcf..b429d356 100644
--- a/src/libs/client/NodeModel.cpp
+++ b/src/libs/client/NodeModel.cpp
@@ -151,24 +151,21 @@ void
NodeModel::port_value_range(SharedPtr<PortModel> port, float& min, float& max)
{
assert(port->parent().get() == this);
-
- Glib::Mutex::Lock(PluginModel::rdf_world()->mutex());
-
- // FIXME: cache these values
- // Plugin value first
#ifdef HAVE_SLV2
+ // Plugin value first
if (_plugin && _plugin->type() == PluginModel::LV2) {
+ Glib::Mutex::Lock(PluginModel::rdf_world()->mutex());
+
min = slv2_port_get_minimum_value(
_plugin->slv2_plugin(),
slv2_plugin_get_port_by_symbol(_plugin->slv2_plugin(),
port->path().name().c_str()));
+
max = slv2_port_get_maximum_value(
_plugin->slv2_plugin(),
slv2_plugin_get_port_by_symbol(_plugin->slv2_plugin(),
port->path().name().c_str()));
-
- //cerr << "SLV2: " << min << " .. " << max << endl;
}
#endif
@@ -179,9 +176,6 @@ NodeModel::port_value_range(SharedPtr<PortModel> port, float& min, float& max)
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/engine/LADSPANode.cpp b/src/libs/engine/LADSPANode.cpp
index 033f3d50..f8ecb1f5 100644
--- a/src/libs/engine/LADSPANode.cpp
+++ b/src/libs/engine/LADSPANode.cpp
@@ -19,6 +19,7 @@
#include <cassert>
#include <cmath>
#include <stdint.h>
+#include <raul/Maid.hpp>
#include "LADSPANode.hpp"
#include "AudioBuffer.hpp"
#include "InputPort.hpp"
@@ -37,14 +38,63 @@ namespace Ingen {
* (It _will_ crash!)
*/
LADSPANode::LADSPANode(PluginImpl* plugin, const string& path, bool polyphonic, PatchImpl* parent, const LADSPA_Descriptor* descriptor, SampleRate srate, size_t buffer_size)
-: NodeBase(plugin, path, polyphonic, parent, srate, buffer_size),
- _descriptor(descriptor),
- _instances(NULL)
+ : NodeBase(plugin, path, polyphonic, parent, srate, buffer_size)
+ , _descriptor(descriptor)
+ , _instances(NULL)
+ , _prepared_instances(NULL)
{
assert(_descriptor != NULL);
}
+bool
+LADSPANode::prepare_poly(uint32_t poly)
+{
+ NodeBase::prepare_poly(poly);
+
+ if ( (!_polyphonic)
+ || (_prepared_instances && poly <= _prepared_instances->size()) ) {
+ return true;
+ }
+
+ _prepared_instances = new Raul::Array<LADSPA_Handle>(poly, *_instances);
+ for (uint32_t i = _polyphony; i < _prepared_instances->size(); ++i) {
+ _prepared_instances->at(i) = _descriptor->instantiate(_descriptor, _srate);
+ if ((*_prepared_instances)[i] == NULL) {
+ cerr << "Failed to instantiate plugin!" << endl;
+ return false;
+ }
+
+ if (_activated)
+ _descriptor->activate((*_prepared_instances)[i]);
+ }
+
+ return true;
+}
+
+
+bool
+LADSPANode::apply_poly(Raul::Maid& maid, uint32_t poly)
+{
+ if (!_polyphonic)
+ return true;
+
+ if (_prepared_instances) {
+ assert(poly <= _prepared_instances->size());
+ maid.push(_instances);
+ _instances = _prepared_instances;
+ _prepared_instances = NULL;
+ }
+
+ assert(poly <= _instances->size());
+ _polyphony = poly;
+
+ NodeBase::apply_poly(maid, poly);
+
+ return true;
+}
+
+
/** Instantiate self from LADSPA plugin descriptor.
*
* Implemented as a seperate function (rather than in the constructor) to
@@ -59,13 +109,13 @@ LADSPANode::instantiate()
if (!_ports)
_ports = new Raul::Array<PortImpl*>(_descriptor->PortCount);
- _instances = new LADSPA_Handle[_polyphony];
+ _instances = new Raul::Array<LADSPA_Handle>(_polyphony, NULL);
size_t port_buffer_size = 0;
for (uint32_t i=0; i < _polyphony; ++i) {
- _instances[i] = _descriptor->instantiate(_descriptor, _srate);
- if (_instances[i] == NULL) {
+ (*_instances)[i] = _descriptor->instantiate(_descriptor, _srate);
+ if ((*_instances)[i] == NULL) {
cerr << "Failed to instantiate plugin!" << endl;
return false;
}
@@ -157,7 +207,7 @@ LADSPANode::instantiate()
LADSPANode::~LADSPANode()
{
for (uint32_t i=0; i < _polyphony; ++i)
- _descriptor->cleanup(_instances[i]);
+ _descriptor->cleanup((*_instances)[i]);
delete[] _instances;
}
@@ -177,7 +227,7 @@ LADSPANode::activate()
port->set_value(0.0f, 0);*/
}
if (_descriptor->activate != NULL)
- _descriptor->activate(_instances[i]);
+ _descriptor->activate((*_instances)[i]);
}
}
@@ -189,7 +239,7 @@ LADSPANode::deactivate()
for (uint32_t i=0; i < _polyphony; ++i)
if (_descriptor->deactivate != NULL)
- _descriptor->deactivate(_instances[i]);
+ _descriptor->deactivate((*_instances)[i]);
}
@@ -199,7 +249,7 @@ LADSPANode::process(ProcessContext& context)
NodeBase::pre_process(context);
for (uint32_t i=0; i < _polyphony; ++i)
- _descriptor->run(_instances[i], context.nframes());
+ _descriptor->run((*_instances)[i], context.nframes());
NodeBase::post_process(context);
}
@@ -214,7 +264,7 @@ LADSPANode::set_port_buffer(uint32_t voice, uint32_t port_num, Buffer* buf)
assert(audio_buffer);
if (port_num < _descriptor->PortCount)
- _descriptor->connect_port(_instances[voice], port_num,
+ _descriptor->connect_port((*_instances)[voice], port_num,
audio_buffer->data());
}
diff --git a/src/libs/engine/LADSPANode.hpp b/src/libs/engine/LADSPANode.hpp
index 6d6cd442..abadcf9f 100644
--- a/src/libs/engine/LADSPANode.hpp
+++ b/src/libs/engine/LADSPANode.hpp
@@ -42,9 +42,12 @@ public:
SampleRate srate,
size_t buffer_size);
- virtual ~LADSPANode();
+ ~LADSPANode();
- virtual bool instantiate();
+ bool instantiate();
+
+ bool prepare_poly(uint32_t poly);
+ bool apply_poly(Raul::Maid& maid, uint32_t poly);
void activate();
void deactivate();
@@ -54,11 +57,11 @@ public:
void set_port_buffer(uint32_t voice, uint32_t port_num, Buffer* buf);
protected:
- //void get_port_vals(ulong port_index, PortInfo* info);
void get_port_limits(unsigned long port_index, Sample& default_value, Sample& lower_bound, Sample& upper_bound);
const LADSPA_Descriptor* _descriptor;
- LADSPA_Handle* _instances;
+ Raul::Array<LADSPA_Handle>* _instances;
+ Raul::Array<LADSPA_Handle>* _prepared_instances;
};
diff --git a/src/libs/engine/LV2Node.cpp b/src/libs/engine/LV2Node.cpp
index bfcc619a..eb8f86b7 100644
--- a/src/libs/engine/LV2Node.cpp
+++ b/src/libs/engine/LV2Node.cpp
@@ -58,14 +58,13 @@ LV2Node::LV2Node(PluginImpl* plugin,
bool
LV2Node::prepare_poly(uint32_t poly)
{
- if (!_polyphonic)
- return true;
-
NodeBase::prepare_poly(poly);
-
- if (_prepared_instances && poly <= _prepared_instances->size())
- return true;
+ if ( (!_polyphonic)
+ || (_prepared_instances && poly <= _prepared_instances->size()) ) {
+ return true;
+ }
+
_prepared_instances = new Raul::Array<SLV2Instance>(poly, *_instances);
for (uint32_t i = _polyphony; i < _prepared_instances->size(); ++i) {
_prepared_instances->at(i) = slv2_plugin_instantiate(_lv2_plugin, _srate, NULL);
@@ -88,22 +87,14 @@ LV2Node::apply_poly(Raul::Maid& maid, uint32_t poly)
if (!_polyphonic)
return true;
- assert(poly <= _prepared_instances->size());
-
if (_prepared_instances) {
+ assert(poly <= _prepared_instances->size());
maid.push(_instances);
_instances = _prepared_instances;
-
-#if 0
- for (uint32_t port=0; port < num_ports(); ++port)
- for (uint32_t voice = /*_polyphony*/0; voice < _prepared_instances->size(); ++voice)
- slv2_instance_connect_port((*_instances)[voice], port,
- _ports->at(port)->buffer(voice)->raw_data());
-#endif
-
_prepared_instances = NULL;
}
+ assert(poly <= _instances->size());
_polyphony = poly;
NodeBase::apply_poly(maid, poly);
@@ -219,12 +210,16 @@ LV2Node::activate()
for (uint32_t i=0; i < _polyphony; ++i) {
for (unsigned long j=0; j < num_ports(); ++j) {
PortImpl* const port = _ports->at(j);
+
set_port_buffer(i, j, port->buffer(i));
+
if (port->type() == DataType::CONTROL) {
- ((AudioBuffer*)port->buffer(i))->set(
- slv2_port_get_default_value(_lv2_plugin,
- slv2_plugin_get_port_by_index(_lv2_plugin, j)),
- 0);
+
+ const float val = slv2_port_get_default_value(_lv2_plugin,
+ slv2_plugin_get_port_by_index(_lv2_plugin, j));
+
+ ((AudioBuffer*)port->buffer(i))->set(val, 0);
+
} else if (port->type() == DataType::AUDIO) {
((AudioBuffer*)port->buffer(i))->set(0.0f, 0);
}
diff --git a/src/libs/engine/LV2Node.hpp b/src/libs/engine/LV2Node.hpp
index dbd79671..b0257bb8 100644
--- a/src/libs/engine/LV2Node.hpp
+++ b/src/libs/engine/LV2Node.hpp
@@ -41,9 +41,9 @@ public:
SampleRate srate,
size_t buffer_size);
- virtual ~LV2Node();
+ ~LV2Node();
- virtual bool instantiate();
+ bool instantiate();
bool prepare_poly(uint32_t poly);
bool apply_poly(Raul::Maid& maid, uint32_t poly);
@@ -56,8 +56,6 @@ public:
void set_port_buffer(uint32_t voice, uint32_t port_num, Buffer* buf);
protected:
- //void get_port_vals(ulong port_index, PortInfo* info);
-
SLV2Plugin _lv2_plugin;
Raul::Array<SLV2Instance>* _instances;
Raul::Array<SLV2Instance>* _prepared_instances;
diff --git a/src/libs/engine/NodeBase.cpp b/src/libs/engine/NodeBase.cpp
index 78825e7a..6fe320e8 100644
--- a/src/libs/engine/NodeBase.cpp
+++ b/src/libs/engine/NodeBase.cpp
@@ -116,7 +116,7 @@ NodeBase::apply_poly(Raul::Maid& maid, uint32_t poly)
if (_ports)
for (size_t i=0; i < _ports->size(); ++i)
_ports->at(i)->apply_poly(maid, poly);
-
+
return true;
}
diff --git a/src/libs/serialisation/Loader.cpp b/src/libs/serialisation/Loader.cpp
index e1eb3aa6..1e2497fb 100644
--- a/src/libs/serialisation/Loader.cpp
+++ b/src/libs/serialisation/Loader.cpp
@@ -131,6 +131,8 @@ Loader::load(SharedPtr<EngineInterface> engine,
map<const string, const Atom> variable;
+ rdf_world->mutex().lock();
+
for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) {
const string node_name = (*i)["name"].to_string();
@@ -154,6 +156,8 @@ Loader::load(SharedPtr<EngineInterface> engine,
if (key != "")
engine->set_variable(node_path, key, AtomRedland::rdf_node_to_atom(val_node));
}
+
+ rdf_world->mutex().unlock();
/* Load subpatches */
@@ -166,7 +170,7 @@ Loader::load(SharedPtr<EngineInterface> engine,
"}");
results = query.run(*rdf_world, model);
-
+
for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) {
const string name = (*i)["name"].to_string();