diff options
author | David Robillard <d@drobilla.net> | 2008-07-28 23:38:03 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-07-28 23:38:03 +0000 |
commit | 2811066546dfe0bd9349502572ee3b35c2532bad (patch) | |
tree | d6ec436efe0d51185fc5e46103f8f8575319d46c | |
parent | ed9e1aa15e5a9363653b46e12313878f82652393 (diff) | |
download | ingen-2811066546dfe0bd9349502572ee3b35c2532bad.tar.gz ingen-2811066546dfe0bd9349502572ee3b35c2532bad.tar.bz2 ingen-2811066546dfe0bd9349502572ee3b35c2532bad.zip |
Compatibility hacks for old Om patchages (many Smack patches now load successfully).
git-svn-id: http://svn.drobilla.net/lad/ingen@1299 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | src/libs/client/ControlModel.hpp | 4 | ||||
-rw-r--r-- | src/libs/client/DeprecatedLoader.cpp | 25 | ||||
-rw-r--r-- | src/libs/client/PresetModel.hpp | 7 | ||||
-rw-r--r-- | src/libs/engine/LADSPANode.cpp | 18 |
4 files changed, 44 insertions, 10 deletions
diff --git a/src/libs/client/ControlModel.hpp b/src/libs/client/ControlModel.hpp index db0e156b..b2a192e4 100644 --- a/src/libs/client/ControlModel.hpp +++ b/src/libs/client/ControlModel.hpp @@ -33,8 +33,8 @@ class ControlModel { public: ControlModel(const Path& port_path, float value) - : _port_path(port_path), - _value(value) + : _port_path(port_path) + , _value(value) { assert(_port_path.find("//") == string::npos); } diff --git a/src/libs/client/DeprecatedLoader.cpp b/src/libs/client/DeprecatedLoader.cpp index 889ef6ed..cb869827 100644 --- a/src/libs/client/DeprecatedLoader.cpp +++ b/src/libs/client/DeprecatedLoader.cpp @@ -68,13 +68,24 @@ DeprecatedLoader::translate_load_path(const string& path) if (t != _load_path_translations.end()) { assert(Path::is_valid((*t).second)); return (*t).second; - } else { + // Filthy, filthy kludges + // (FIXME: apply these less heavy handedly, only when it's an internal module) + } else if (path.find("midi") != string::npos) { assert(Path::is_valid(path)); - // Filthy kludge to fix the change from note node "midi_in" port to "input" if (path.substr(path.find_last_of("/")) == "/midi_in") return path.substr(0, path.find_last_of("/")) + "/input"; + else if (path.substr(path.find_last_of("/")) == "/note_number") + return path.substr(0, path.find_last_of("/")) + "/note"; + else if (path.substr(path.find_last_of("/")) == "/Gate") + return path.substr(0, path.find_last_of("/")) + "/gate"; + else if (path.substr(path.find_last_of("/")) == "/Trigger") + return path.substr(0, path.find_last_of("/")) + "/trigger"; + else if (path.substr(path.find_last_of("/")) == "/Velocity") + return path.substr(0, path.find_last_of("/")) + "/velocity"; else return path; + } else { + return path; } } @@ -410,6 +421,10 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr if (is_port) { const string old_path = path; const string new_path = (Path::is_valid(old_path) ? old_path : Path::pathify(old_path)); + + if (!Path::is_valid(old_path)) + cerr << "WARNING: Translating invalid port path \"" << old_path << "\" => \"" + << new_path << "\"" << endl; // Set up translations (for connections etc) to alias both the old // module path and the old module/port path to the new port path @@ -537,9 +552,9 @@ DeprecatedLoader::load_connection(const Path& parent, xmlDocPtr doc, const xmlNo // Compatibility fixes for old (fundamentally broken) patches source_node = nameify_if_invalid(source_node); - source_port = Path::nameify(source_port); + source_port = nameify_if_invalid(source_port); dest_node = nameify_if_invalid(dest_node); - dest_port = Path::nameify(dest_port); + dest_port = nameify_if_invalid(dest_port); _engine->connect( translate_load_path(parent.base() + source_node +"/"+ source_port), @@ -591,7 +606,7 @@ DeprecatedLoader::load_preset(const Path& parent, xmlDocPtr doc, const xmlNodePt // Compatibility fixes for old patch files if (node_name != "") node_name = nameify_if_invalid(node_name); - port_name = Path::nameify(port_name); + port_name = nameify_if_invalid(port_name); if (port_name == "") { string msg = "Unable to parse control in patch file ( node = "; diff --git a/src/libs/client/PresetModel.hpp b/src/libs/client/PresetModel.hpp index 6cc557a5..9bf0467b 100644 --- a/src/libs/client/PresetModel.hpp +++ b/src/libs/client/PresetModel.hpp @@ -42,9 +42,12 @@ public: /** Add a control value to this preset. An empty string for a node_name * means the port is on the patch itself (not a node in the patch). */ - void add_control(const string& node_name, - const string& port_name, float value) + void add_control(const string& node_name, string port_name, float value) { + // FIXME: filthy, filthy kludge for old Om patches + if (port_name == "note_number") + port_name = "note"; + if (node_name != "") _controls.push_back(ControlModel(_base_path + node_name +"/"+ port_name, value)); else diff --git a/src/libs/engine/LADSPANode.cpp b/src/libs/engine/LADSPANode.cpp index dd3ce0c2..ef4b0ece 100644 --- a/src/libs/engine/LADSPANode.cpp +++ b/src/libs/engine/LADSPANode.cpp @@ -104,6 +104,22 @@ LADSPANode::apply_poly(Raul::Maid& maid, uint32_t poly) return true; } + +static string +nameify_if_invalid(const string& name) +{ + if (Path::is_valid_name(name)) { + return name; + } else { + const string new_name = Path::nameify(name); + assert(Path::is_valid_name(new_name)); + if (new_name != name) + cerr << "WARNING: Illegal LADSPA port name '" + << name << "' converted to '" << new_name << "'" << endl; + return new_name; + } +} + /** Instantiate self from LADSPA plugin descriptor. * @@ -137,7 +153,7 @@ LADSPANode::instantiate() PortImpl* port = NULL; for (size_t j=0; j < _descriptor->PortCount; ++j) { - port_name = Path::nameify(_descriptor->PortNames[j]); + port_name = nameify_if_invalid(_descriptor->PortNames[j]); string::size_type slash_index; |