diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/engine/LADSPANode.cpp | 368 | ||||
-rw-r--r-- | src/engine/LADSPANode.hpp | 91 | ||||
-rw-r--r-- | src/engine/LADSPAPlugin.cpp | 115 | ||||
-rw-r--r-- | src/engine/LADSPAPlugin.hpp | 75 | ||||
-rw-r--r-- | src/engine/NodeFactory.cpp | 129 | ||||
-rw-r--r-- | src/engine/NodeFactory.hpp | 17 | ||||
-rw-r--r-- | src/engine/events/CreateNode.cpp | 31 | ||||
-rw-r--r-- | src/engine/events/CreateNode.hpp | 7 | ||||
-rw-r--r-- | src/engine/internals/Note.cpp | 2 | ||||
-rw-r--r-- | src/engine/wscript | 2 |
10 files changed, 7 insertions, 830 deletions
diff --git a/src/engine/LADSPANode.cpp b/src/engine/LADSPANode.cpp deleted file mode 100644 index 60bf2bdf..00000000 --- a/src/engine/LADSPANode.cpp +++ /dev/null @@ -1,368 +0,0 @@ -/* This file is part of Ingen. - * Copyright (C) 2007-2009 David Robillard <http://drobilla.net> - * - * Ingen is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <cassert> -#include <cmath> -#include <map> -#include <string> -#include <stdint.h> -#include <boost/optional.hpp> -#include "shared/LV2URIMap.hpp" -#include "raul/log.hpp" -#include "raul/Maid.hpp" -#include "LADSPANode.hpp" -#include "AudioBuffer.hpp" -#include "InputPort.hpp" -#include "OutputPort.hpp" -#include "PluginImpl.hpp" -#include "ProcessContext.hpp" - -using namespace std; -using namespace Raul; - -namespace Ingen { - -using namespace Shared; - - -/** Partially construct a LADSPANode. - * - * Object is not usable until instantiate() is called with success. - * (It _will_ crash!) - */ -LADSPANode::LADSPANode(PluginImpl* plugin, - const string& path, - bool polyphonic, - PatchImpl* parent, - const LADSPA_Descriptor* descriptor, - SampleRate srate) - : NodeImpl(plugin, path, polyphonic, parent, srate) - , _descriptor(descriptor) - , _instances(NULL) - , _prepared_instances(NULL) -{ - assert(_descriptor != NULL); -} - - -LADSPANode::~LADSPANode() -{ - delete _instances; -} - - -bool -LADSPANode::prepare_poly(BufferFactory& bufs, uint32_t poly) -{ - if (!_polyphonic) - poly = 1; - - NodeImpl::prepare_poly(bufs, poly); - - if (_polyphony == poly) - return true; - - _prepared_instances = new Instances(poly, *_instances, SharedPtr<Instance>()); - for (uint32_t i = _polyphony; i < _prepared_instances->size(); ++i) { - _prepared_instances->at(i) = SharedPtr<Instance>(new Instance(_descriptor, - _descriptor->instantiate(_descriptor, _srate))); - if (!_prepared_instances->at(i)->handle) { - error << "Failed to instantiate plugin" << endl; - return false; - } - - // Initialize the values of new ports - for (uint32_t j = 0; j < num_ports(); ++j) { - PortImpl* const port = _ports->at(j); - Buffer* const buffer = port->prepared_buffer(i).get(); - if (buffer) { - if (port->is_a(PortType::CONTROL)) { - ((AudioBuffer*)buffer)->set_value(port->value().get_float(), 0, 0); - } else { - buffer->clear(); - } - } - } - - if (_activated && _descriptor->activate) - _descriptor->activate(_prepared_instances->at(i)->handle); - } - - return true; -} - - -bool -LADSPANode::apply_poly(Raul::Maid& maid, uint32_t poly) -{ - if (!_polyphonic) - poly = 1; - - if (_prepared_instances) { - maid.push(_instances); - _instances = _prepared_instances; - _prepared_instances = NULL; - } - assert(poly <= _instances->size()); - - return NodeImpl::apply_poly(maid, poly); -} - - -/** Instantiate self from LADSPA plugin descriptor. - * - * Implemented as a seperate function (rather than in the constructor) to - * allow graceful error-catching of broken plugins. - * - * Returns whether or not plugin was successfully instantiated. If return - * value is false, this object may not be used. - */ -bool -LADSPANode::instantiate(BufferFactory& bufs) -{ - const LV2URIMap& uris = bufs.uris(); - if (!_ports) - _ports = new Raul::Array<PortImpl*>(_descriptor->PortCount); - - _instances = new Instances(_polyphony); - - for (uint32_t i = 0; i < _polyphony; ++i) { - (*_instances)[i] = SharedPtr<Instance>(new Instance( - _descriptor, _descriptor->instantiate(_descriptor, _srate))); - if (!instance(i)) { - error << "Failed to instantiate plugin" << endl; - return false; - } - } - - PortImpl* port = NULL; - std::map<Symbol, uint32_t> symbols; - - for (uint32_t j=0; j < _descriptor->PortCount; ++j) { - // Convert name into valid symbol - Symbol symbol = Symbol::symbolify(_descriptor->PortNames[j]); - - // Ensure symbol is unique - std::map<Symbol, uint32_t>::iterator existing = symbols.find(symbol); - uint32_t offset = 2; - bool type_clash = false; - while (existing != symbols.end()) { - const uint32_t e = existing->second; - if (!type_clash && LADSPA_IS_PORT_CONTROL(_descriptor->PortDescriptors[j]) - && LADSPA_IS_PORT_AUDIO(_descriptor->PortDescriptors[e])) { - symbol = string(symbol.c_str()) + "_CR"; - type_clash = true; - } else if (!type_clash && LADSPA_IS_PORT_AUDIO(_descriptor->PortDescriptors[j]) - && LADSPA_IS_PORT_CONTROL(_descriptor->PortDescriptors[e])) { - symbol = string(symbol.c_str()) + "_AR"; - type_clash = true; - } else { - std::ostringstream ss; - ss << symbol << "_" << offset; - symbol = ss.str(); - } - existing = symbols.find(symbol); - } - - symbols.insert(make_pair(symbol, j)); - - Path port_path(path().child(symbol)); - - PortType type = PortType::AUDIO; - - if (LADSPA_IS_PORT_CONTROL(_descriptor->PortDescriptors[j])) { - type = PortType::CONTROL; - } else { - assert(LADSPA_IS_PORT_AUDIO(_descriptor->PortDescriptors[j])); - } - assert (LADSPA_IS_PORT_INPUT(_descriptor->PortDescriptors[j]) - || LADSPA_IS_PORT_OUTPUT(_descriptor->PortDescriptors[j])); - - boost::optional<Sample> default_val, min, max; - get_port_limits(j, default_val, min, max); - - const float value = default_val ? default_val.get() : 0.0f; - - if (LADSPA_IS_PORT_INPUT(_descriptor->PortDescriptors[j])) { - port = new InputPort(bufs, this, symbol, j, _polyphony, type, value); - _ports->at(j) = port; - } else if (LADSPA_IS_PORT_OUTPUT(_descriptor->PortDescriptors[j])) { - port = new OutputPort(bufs, this, symbol, j, _polyphony, type, value); - _ports->at(j) = port; - } - - port->set_property(uris.lv2_name, _descriptor->PortNames[j]); - - assert(port); - assert(_ports->at(j) == port); - - // Work around broke-ass crackhead plugins - if (default_val && default_val.get() < min.get()) { - warn << "Broken LADSPA " << _descriptor->UniqueID - << ": Port default < minimum. Minimum adjusted." << endl; - min = default_val; - } - - if (default_val && default_val.get() > max.get()) { - warn << "Broken LADSPA " << _descriptor->UniqueID - << ": Maximum adjusted." << endl; - max = default_val; - } - - // Set initial/default value - if (type == PortType::CONTROL) - port->set_value(value); - - if (port->is_input() && type == PortType::CONTROL) { - if (min) - port->set_meta_property(uris.lv2_minimum, min.get()); - if (max) - port->set_meta_property(uris.lv2_maximum, max.get()); - if (default_val) - port->set_meta_property(uris.lv2_default, default_val.get()); - } - } - - return true; -} - - -void -LADSPANode::activate(BufferFactory& bufs) -{ - NodeImpl::activate(bufs); - - if (_descriptor->activate != NULL) - for (uint32_t i = 0; i < _polyphony; ++i) - _descriptor->activate(instance(i)); -} - - -void -LADSPANode::deactivate() -{ - NodeImpl::deactivate(); - - for (uint32_t i = 0; i < _polyphony; ++i) - if (_descriptor->deactivate != NULL) - _descriptor->deactivate(instance(i)); -} - - -void -LADSPANode::process(ProcessContext& context) -{ - NodeImpl::pre_process(context); - - for (uint32_t i = 0; i < _polyphony; ++i) - _descriptor->run(instance(i), context.nframes()); - - NodeImpl::post_process(context); -} - - -void -LADSPANode::set_port_buffer(uint32_t voice, uint32_t port_num, - IntrusivePtr<Buffer> buf, SampleCount offset) -{ - NodeImpl::set_port_buffer(voice, port_num, buf, offset); - - _descriptor->connect_port(instance(voice), port_num, - buf ? (LADSPA_Data*)buf->port_data(_ports->at(port_num)->buffer_type(), offset) : NULL); -} - - -void -LADSPANode::get_port_limits(unsigned long port_index, - boost::optional<Sample>& normal, - boost::optional<Sample>& lower, - boost::optional<Sample>& upper) -{ - LADSPA_PortRangeHintDescriptor hint_descriptor = _descriptor->PortRangeHints[port_index].HintDescriptor; - - /* set upper and lower, possibly adjusted to the sample rate */ - if (LADSPA_IS_HINT_SAMPLE_RATE(hint_descriptor)) { - upper = _descriptor->PortRangeHints[port_index].UpperBound * _srate; - lower = _descriptor->PortRangeHints[port_index].LowerBound * _srate; - } else { - upper = _descriptor->PortRangeHints[port_index].UpperBound; - lower = _descriptor->PortRangeHints[port_index].LowerBound; - } - - if (LADSPA_IS_HINT_LOGARITHMIC(hint_descriptor)) { - /* FLT_EPSILON is defined as the different between 1.0 and the minimum - * float greater than 1.0. So, if lower is < FLT_EPSILON, it will be 1.0 - * and the logarithmic control will have a base of 1 and thus not change - */ - if (lower.get() < FLT_EPSILON) lower = FLT_EPSILON; - } - - - if (LADSPA_IS_HINT_HAS_DEFAULT(hint_descriptor)) { - - if (LADSPA_IS_HINT_DEFAULT_MINIMUM(hint_descriptor)) { - normal = lower; - } else if (LADSPA_IS_HINT_DEFAULT_LOW(hint_descriptor)) { - assert(lower); - assert(upper); - if (LADSPA_IS_HINT_LOGARITHMIC(hint_descriptor)) { - normal = exp(log(lower.get()) * 0.75 + log(upper.get()) * 0.25); - } else { - normal = lower.get() * 0.75 + upper.get() * 0.25; - } - } else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(hint_descriptor)) { - assert(lower); - assert(upper); - if (LADSPA_IS_HINT_LOGARITHMIC(hint_descriptor)) { - normal = exp(log(lower.get()) * 0.5 + log(upper.get()) * 0.5); - } else { - normal = lower.get() * 0.5 + upper.get() * 0.5; - } - } else if (LADSPA_IS_HINT_DEFAULT_HIGH(hint_descriptor)) { - assert(lower); - assert(upper); - if (LADSPA_IS_HINT_LOGARITHMIC(hint_descriptor)) { - normal = exp(log(lower.get()) * 0.25 + log(upper.get()) * 0.75); - } else { - normal = lower.get() * 0.25 + upper.get() * 0.75; - } - } else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(hint_descriptor)) { - assert(upper); - normal = upper.get(); - } else if (LADSPA_IS_HINT_DEFAULT_0(hint_descriptor)) { - normal = 0.0; - } else if (LADSPA_IS_HINT_DEFAULT_1(hint_descriptor)) { - normal = 1.0; - } else if (LADSPA_IS_HINT_DEFAULT_100(hint_descriptor)) { - normal = 100.0; - } else if (LADSPA_IS_HINT_DEFAULT_440(hint_descriptor)) { - normal = 440.0; - } - } else { // No default hint - if (LADSPA_IS_HINT_BOUNDED_BELOW(hint_descriptor)) { - assert(lower); - normal = lower.get(); - } else if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint_descriptor)) { - assert(upper); - normal = upper.get(); - } - } -} - - -} // namespace Ingen - diff --git a/src/engine/LADSPANode.hpp b/src/engine/LADSPANode.hpp deleted file mode 100644 index ad1773d9..00000000 --- a/src/engine/LADSPANode.hpp +++ /dev/null @@ -1,91 +0,0 @@ -/* This file is part of Ingen. - * Copyright (C) 2007-2009 David Robillard <http://drobilla.net> - * - * Ingen is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef INGEN_ENGINE_LADSPANODE_HPP -#define INGEN_ENGINE_LADSPANODE_HPP - -#include <string> -#include <ladspa.h> -#include <boost/optional.hpp> -#include "raul/IntrusivePtr.hpp" -#include "types.hpp" -#include "NodeImpl.hpp" -#include "PluginImpl.hpp" - -namespace Ingen { - - -/** An instance of a LADSPA plugin. - * - * \ingroup engine - */ -class LADSPANode : public NodeImpl -{ -public: - LADSPANode(PluginImpl* plugin, - const std::string& name, - bool polyphonic, - PatchImpl* parent, - const LADSPA_Descriptor* descriptor, - SampleRate srate); - - ~LADSPANode(); - - bool instantiate(BufferFactory& bufs); - - bool prepare_poly(BufferFactory& bufs, uint32_t poly); - bool apply_poly(Raul::Maid& maid, uint32_t poly); - - void activate(BufferFactory& bufs); - void deactivate(); - - void process(ProcessContext& context); - - void set_port_buffer(uint32_t voice, uint32_t port_num, - IntrusivePtr<Buffer> buf, SampleCount offset); - -protected: - inline LADSPA_Handle instance(uint32_t voice) { return (*_instances)[voice]->handle; } - - void get_port_limits(unsigned long port_index, - boost::optional<Sample>& default_value, - boost::optional<Sample>& lower_bound, - boost::optional<Sample>& upper_bound); - - struct Instance { - Instance(const LADSPA_Descriptor* d=NULL, LADSPA_Handle h=NULL) - : descriptor(d), handle(h) - {} - ~Instance() { - if (descriptor && handle) - descriptor->cleanup(handle); - } - const LADSPA_Descriptor* descriptor; - LADSPA_Handle handle; - }; - - typedef Raul::Array< SharedPtr<Instance> > Instances; - - const LADSPA_Descriptor* _descriptor; - Instances* _instances; - Instances* _prepared_instances; -}; - - -} // namespace Ingen - -#endif // INGEN_ENGINE_LADSPANODE_HPP diff --git a/src/engine/LADSPAPlugin.cpp b/src/engine/LADSPAPlugin.cpp deleted file mode 100644 index 9b43b28c..00000000 --- a/src/engine/LADSPAPlugin.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/* This file is part of Ingen. - * Copyright (C) 2007-2009 David Robillard <http://drobilla.net> - * - * Ingen is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include <cassert> -#include <string> -#include <ladspa.h> -#include <raul/Symbol.hpp> -#include "shared/LV2URIMap.hpp" -#include "LADSPAPlugin.hpp" -#include "LADSPANode.hpp" -#include "Engine.hpp" -#include "Driver.hpp" - -using namespace std; -using namespace Raul; - -namespace Ingen { - - -LADSPAPlugin::LADSPAPlugin( - Shared::LV2URIMap& uris, - const std::string& library_path, - const std::string& uri, - unsigned long id, - const std::string& label, - const std::string& name) - : PluginImpl(uris, Plugin::LADSPA, uri, library_path) - , _id(id) - , _label(label) - , _name(name) -{ - set_property(uris.rdf_type, uris.ingen_LADSPAPlugin); - set_property(uris.lv2_symbol, Symbol::symbolify(label)); - set_property(uris.doap_name, name); -} - - -const Raul::Atom& -LADSPAPlugin::get_property(const Raul::URI& uri) const -{ - if (uri == _uris.doap_name) - return _name; - else - return ResourceImpl::get_property(uri); -} - - -NodeImpl* -LADSPAPlugin::instantiate(BufferFactory& bufs, - const string& name, - bool polyphonic, - Ingen::PatchImpl* parent, - Engine& engine) -{ - assert(_id != 0); - - const SampleCount srate = engine.driver()->sample_rate(); - - union { - void* dp; - LADSPA_Descriptor_Function fp; - } df; - df.dp = NULL; - df.fp = NULL; - - LADSPANode* n = NULL; - - load(); // FIXME: unload at some point - assert(_module); - assert(*_module); - - if (!_module->get_symbol("ladspa_descriptor", df.dp)) { - warn << _library_path << " is not a LADSPA plugin library" << endl; - return NULL; - } - - // Attempt to find the plugin in library - LADSPA_Descriptor* descriptor = NULL; - for (unsigned long i=0; (descriptor = (LADSPA_Descriptor*)df.fp(i)) != NULL; ++i) { - if (descriptor->UniqueID == _id) { - break; - } - } - - if (descriptor != NULL) { - n = new LADSPANode(this, name, polyphonic, parent, descriptor, srate); - - if ( ! n->instantiate(bufs) ) { - delete n; - n = NULL; - } - - } else { - error << "Could not find plugin `" << _id << "' in " << _library_path << endl; - } - - return n; -} - - -} // namespace Ingen diff --git a/src/engine/LADSPAPlugin.hpp b/src/engine/LADSPAPlugin.hpp deleted file mode 100644 index 88fd1f32..00000000 --- a/src/engine/LADSPAPlugin.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/* This file is part of Ingen. - * Copyright (C) 2007-2009 David Robillard <http://drobilla.net> - * - * Ingen is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef INGEN_ENGINE_LADSPAPLUGIN_HPP -#define INGEN_ENGINE_LADSPAPLUGIN_HPP - -#include <cstdlib> -#include <glibmm/module.h> -#include <boost/utility.hpp> -#include <dlfcn.h> -#include <string> -#include "raul/Path.hpp" -#include "raul/Atom.hpp" -#include "PluginImpl.hpp" - -namespace Ingen { - -class NodeImpl; - - -/** Implementation of a LADSPA plugin (loaded shared library). - */ -class LADSPAPlugin : public PluginImpl -{ -public: - LADSPAPlugin( - Shared::LV2URIMap& uris, - const std::string& library_path, - const std::string& uri, - unsigned long id, - const std::string& label, - const std::string& name); - - NodeImpl* instantiate(BufferFactory& bufs, - const std::string& name, - bool polyphonic, - Ingen::PatchImpl* parent, - Engine& engine); - - const std::string& label() const { return _label; } - unsigned long id() const { return _id; } - const std::string symbol() const { return Raul::Path::nameify(_label); } - const std::string name() const { return _name.get_string(); } - - const std::string library_name() const { - return _library_path.substr(_library_path.find_last_of("/")+1); - } - - const Raul::Atom& get_property(const Raul::URI& uri) const; - -private: - const unsigned long _id; - const std::string _label; - const Raul::Atom _name; -}; - - -} // namespace Ingen - -#endif // INGEN_ENGINE_LADSPAPLUGIN_HPP - diff --git a/src/engine/NodeFactory.cpp b/src/engine/NodeFactory.cpp index 9ee32c12..64b6e2b6 100644 --- a/src/engine/NodeFactory.cpp +++ b/src/engine/NodeFactory.cpp @@ -35,10 +35,6 @@ #include "NodeFactory.hpp" #include "PatchImpl.hpp" #include "ThreadManager.hpp" -#ifdef HAVE_LADSPA_H -#include "LADSPANode.hpp" -#include "LADSPAPlugin.hpp" -#endif #ifdef HAVE_SLV2 #include "slv2/slv2.h" #include "LV2Plugin.hpp" @@ -80,31 +76,6 @@ NodeFactory::plugin(const Raul::URI& uri) } -/** DEPRECATED: Find a plugin by type, lib, label. - * - * Slow. Evil. Do not use. - */ -PluginImpl* -NodeFactory::plugin(const string& type, const string& lib, const string& label) -{ - if (type != "LADSPA" || lib.empty() || label.empty()) - return NULL; - -#ifdef HAVE_LADSPA_H - for (Plugins::const_iterator i = _plugins.begin(); i != _plugins.end(); ++i) { - LADSPAPlugin* lp = dynamic_cast<LADSPAPlugin*>(i->second); - if (lp && lp->library_name() == lib - && lp->label() == label) - return lp; - } -#endif - - error << "Failed to find " << type << " plugin " << lib << " / " << label << endl; - - return NULL; -} - - void NodeFactory::load_plugins() { @@ -124,10 +95,6 @@ NodeFactory::load_plugins() load_lv2_plugins(); #endif -#ifdef HAVE_LADSPA_H - load_ladspa_plugins(); -#endif - _has_loaded = true; } @@ -181,100 +148,4 @@ NodeFactory::load_lv2_plugins() } #endif // HAVE_SLV2 - -#ifdef HAVE_LADSPA_H -/** Loads information about all LADSPA plugins into internal plugin database. - */ -void -NodeFactory::load_ladspa_plugins() -{ - char* env_ladspa_path = getenv("LADSPA_PATH"); - string ladspa_path; - if (!env_ladspa_path) { - info << "Using default LADSPA_PATH=/usr/lib/ladspa:/usr/local/lib/ladspa:~/.ladspa" << endl; - ladspa_path = string("/usr/lib/ladspa:/usr/local/lib/ladspa:").append( - getenv("HOME")).append("/.ladspa"); - } else { - ladspa_path = env_ladspa_path; - } - - // Yep, this should use an sstream alright.. - while (!ladspa_path.empty()) { - const string dir = ladspa_path.substr(0, ladspa_path.find(':')); - if (ladspa_path.find(':') != string::npos) - ladspa_path = ladspa_path.substr(ladspa_path.find(':')+1); - else - ladspa_path.clear(); - - DIR* pdir = opendir(dir.c_str()); - if (pdir == NULL) - continue; - - struct dirent* pfile; - while ((pfile = readdir(pdir))) { - union { - void* dp; - LADSPA_Descriptor_Function fp; - } df; - df.dp = NULL; - df.fp = NULL; - - LADSPA_Descriptor* descriptor = NULL; - - if (!strcmp(pfile->d_name, ".") || !strcmp(pfile->d_name, "..")) - continue; - - const string lib_path = Glib::build_filename(dir, pfile->d_name); - - // Ignore stupid libtool files. Kludge alert. - if (lib_path.substr(lib_path.length()-3) == ".la") - continue; - - Glib::Module* plugin_library = new Glib::Module(lib_path, Glib::MODULE_BIND_LOCAL); - if (!plugin_library) - continue; - - if (!(*plugin_library)) { - delete plugin_library; - continue; - } - - bool found = plugin_library->get_symbol("ladspa_descriptor", df.dp); - if (!found || !df.dp) { - warn << "Non-LADSPA library " << lib_path << " found in LADSPA path" << endl; - delete plugin_library; - continue; - } - - for (unsigned long i=0; (descriptor = (LADSPA_Descriptor*)df.fp(i)) != NULL; ++i) { - char id_str[11]; - snprintf(id_str, 11, "%lu", descriptor->UniqueID); - const string uri = string("urn:ladspa:").append(id_str); - - const Plugins::const_iterator i = _plugins.find(uri); - - if (i == _plugins.end()) { - LADSPAPlugin* plugin = new LADSPAPlugin(*_world->uris().get(), - lib_path, uri, - descriptor->UniqueID, - descriptor->Label, - descriptor->Name); - - _plugins.insert(make_pair(uri, plugin)); - - } else { - warn << "Duplicate " << uri - << " - Using " << i->second->library_path() - << " over " << lib_path << endl; - } - } - - delete plugin_library; - } - closedir(pdir); - } -} -#endif // HAVE_LADSPA_H - - } // namespace Ingen diff --git a/src/engine/NodeFactory.hpp b/src/engine/NodeFactory.hpp index 88a4b099..1f53f6af 100644 --- a/src/engine/NodeFactory.hpp +++ b/src/engine/NodeFactory.hpp @@ -38,13 +38,7 @@ class LV2Info; #endif -/** Loads plugins and creates Nodes from them. - * - * NodeFactory's responsibility is to get enough information to allow the - * loading of a plugin possible (ie finding/opening shared libraries etc) - * - * The constructor of various Node types (ie LADSPANode) are responsible - * for actually creating a Node instance of the plugin. +/** Discovers and loads plugin libraries. * * \ingroup engine */ @@ -61,16 +55,7 @@ public: PluginImpl* plugin(const Raul::URI& uri); - /** DEPRECATED */ - PluginImpl* plugin(const std::string& type, - const std::string& lib, - const std::string& label); - private: -#ifdef HAVE_LADSPA_H - void load_ladspa_plugins(); -#endif - #ifdef HAVE_SLV2 void load_lv2_plugins(); #endif diff --git a/src/engine/events/CreateNode.cpp b/src/engine/events/CreateNode.cpp index 421f819e..9fef8070 100644 --- a/src/engine/events/CreateNode.cpp +++ b/src/engine/events/CreateNode.cpp @@ -51,36 +51,14 @@ CreateNode::CreateNode( : QueuedEvent(engine, request, timestamp) , _path(path) , _plugin_uri(plugin_uri) - , _polyphonic(false) , _patch(NULL) , _plugin(NULL) , _node(NULL) , _compiled_patch(NULL) , _node_already_exists(false) + , _polyphonic(false) , _properties(properties) { - string uri = _plugin_uri.str(); - if (uri.substr(0, 3) == "om:") { - size_t colon = 2; - - uri = uri.substr(colon + 1); - if ((colon = uri.find(":")) == string::npos) { - Raul::error << "Invalid plugin URI `" << _plugin_uri << "'" << endl; - return; - } - _plugin_type = uri.substr(0, colon); - - uri = uri.substr(colon + 1); - if ((colon = uri.find(":")) == string::npos) { - Raul::error << "Invalid plugin URI `" << _plugin_uri << "'" << endl; - return; - } - _plugin_lib = uri.substr(0, colon); - - uri = uri.substr(colon + 1); - _plugin_label = uri; - } - const Resource::Properties::const_iterator p = properties.find( engine.world()->uris()->ingen_polyphonic); if (p != properties.end() && p->second.type() == Raul::Atom::BOOL @@ -98,11 +76,8 @@ CreateNode::pre_process() return; } - _patch = _engine.engine_store()->find_patch(_path.parent()); - - _plugin = (_plugin_label.empty()) - ? _engine.node_factory()->plugin(_plugin_uri.str()) - : _engine.node_factory()->plugin(_plugin_type, _plugin_lib, _plugin_label); + _patch = _engine.engine_store()->find_patch(_path.parent()); + _plugin = _engine.node_factory()->plugin(_plugin_uri.str()); if (_patch && _plugin) { diff --git a/src/engine/events/CreateNode.hpp b/src/engine/events/CreateNode.hpp index c302e02b..456bcc04 100644 --- a/src/engine/events/CreateNode.hpp +++ b/src/engine/events/CreateNode.hpp @@ -53,16 +53,13 @@ public: private: Raul::Path _path; - Raul::URI _plugin_uri; ///< If nonempty then type, library, label, are ignored - std::string _plugin_type; - std::string _plugin_lib; - std::string _plugin_label; - bool _polyphonic; + Raul::URI _plugin_uri; PatchImpl* _patch; PluginImpl* _plugin; NodeImpl* _node; CompiledPatch* _compiled_patch; ///< Patch's new process order bool _node_already_exists; + bool _polyphonic; Shared::Resource::Properties _properties; }; diff --git a/src/engine/internals/Note.cpp b/src/engine/internals/Note.cpp index c00c2a3c..a92e3069 100644 --- a/src/engine/internals/Note.cpp +++ b/src/engine/internals/Note.cpp @@ -399,7 +399,7 @@ NoteNode::note_to_freq(int num) static const float A4 = 440.0f; if (num >= 0 && num <= 119) return A4 * powf(2.0f, (float)(num - 57.0f) / 12.0f); - return 1.0f; // Some LADSPA plugins don't like freq=0 + return 1.0f; // Frequency of zero causes numerical problems... } diff --git a/src/engine/wscript b/src/engine/wscript index 70c1fe08..42e31d2c 100644 --- a/src/engine/wscript +++ b/src/engine/wscript @@ -59,8 +59,6 @@ def build(bld): internals/Trigger.cpp ''' - if bld.env['HAVE_LADSPA_H'] == 1: - core_source += ' LADSPAPlugin.cpp LADSPANode.cpp ' if bld.env['HAVE_SLV2'] == 1: core_source += ' LV2Info.cpp LV2Plugin.cpp LV2Node.cpp ' |