diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/client/DeprecatedLoader.cpp | 18 | ||||
-rw-r--r-- | src/libs/client/DeprecatedLoader.hpp | 1 | ||||
-rw-r--r-- | src/libs/gui/LoadPatchWindow.cpp | 7 | ||||
-rw-r--r-- | src/libs/gui/LoadRemotePatchWindow.cpp | 3 | ||||
-rw-r--r-- | src/libs/gui/LoadSubpatchWindow.cpp | 13 | ||||
-rw-r--r-- | src/libs/gui/ThreadedLoader.cpp | 6 | ||||
-rw-r--r-- | src/libs/gui/ThreadedLoader.hpp | 3 | ||||
-rw-r--r-- | src/libs/serialisation/Loader.cpp | 49 |
8 files changed, 54 insertions, 46 deletions
diff --git a/src/libs/client/DeprecatedLoader.cpp b/src/libs/client/DeprecatedLoader.cpp index 19ce6b7e..621420c4 100644 --- a/src/libs/client/DeprecatedLoader.cpp +++ b/src/libs/client/DeprecatedLoader.cpp @@ -39,8 +39,7 @@ #include "PluginModel.hpp" #include "DeprecatedLoader.hpp" -using std::string; using std::vector; using std::pair; -using std::cerr; using std::cout; using std::endl; +using namespace std; namespace Ingen { namespace Client { @@ -188,7 +187,6 @@ string DeprecatedLoader::load_patch(const Glib::ustring& filename, boost::optional<Path> parent_path, string name, - uint32_t poly, MetadataMap initial_data, bool existing) { @@ -197,7 +195,13 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename, Path path = "/"; // path of the new patch const bool load_name = (name == ""); - const bool load_poly = (poly == 0); + + size_t poly = 0; + + /* Use parameter overridden polyphony, if given */ + Raul::Table<string, Atom>::iterator poly_param = initial_data.find("ingen:polyphony"); + if (poly_param != initial_data.end() && poly_param->second.type() == Atom::INT) + poly = poly_param->second; if (initial_data.find("filename") == initial_data.end()) initial_data["filename"] = Atom(filename.c_str()); // FIXME: URL? @@ -239,7 +243,7 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename, path = Path("/"); } } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"polyphony"))) { - if (load_poly) { + if (poly == 0) { poly = atoi((char*)key); } } else if (xmlStrcmp(cur->name, (const xmlChar*)"connection") @@ -569,7 +573,7 @@ DeprecatedLoader::load_subpatch(const Path& parent, xmlDocPtr doc, const xmlNode if ((!xmlStrcmp(cur->name, (const xmlChar*)"name"))) { name = (const char*)key; } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"polyphony"))) { - poly = atoi((const char*)key); + initial_data.insert(make_pair("ingen::polyphony", (int)poly)); } else if ((!xmlStrcmp(cur->name, (const xmlChar*)"filename"))) { filename = (const char*)key; } else { // Don't know what this tag is, add it as metadata @@ -584,7 +588,7 @@ DeprecatedLoader::load_subpatch(const Path& parent, xmlDocPtr doc, const xmlNode // load_patch sets the passed metadata last, so values stored in the parent // will override values stored in the child patch file - string path = load_patch(filename, parent, name, poly, initial_data, false); + /*string path = */load_patch(filename, parent, name, initial_data, false); return false; } diff --git a/src/libs/client/DeprecatedLoader.hpp b/src/libs/client/DeprecatedLoader.hpp index fd1be335..413c46b5 100644 --- a/src/libs/client/DeprecatedLoader.hpp +++ b/src/libs/client/DeprecatedLoader.hpp @@ -63,7 +63,6 @@ public: string load_patch(const Glib::ustring& filename, boost::optional<Path> parent_path, string name, - uint32_t poly, MetadataMap initial_data, bool existing = false); diff --git a/src/libs/gui/LoadPatchWindow.cpp b/src/libs/gui/LoadPatchWindow.cpp index da557b40..593f2b6d 100644 --- a/src/libs/gui/LoadPatchWindow.cpp +++ b/src/libs/gui/LoadPatchWindow.cpp @@ -116,14 +116,13 @@ LoadPatchWindow::poly_from_user_selected() void LoadPatchWindow::ok_clicked() { - // If unset load_patch will load values + // If unset load_patch will load value optional<const string&> name; - optional<uint32_t> poly; optional<Path> parent; if (_poly_from_user_radio->get_active()) - poly = _poly_spinbutton->get_value_as_int(); + _initial_data.insert(make_pair("ingen:polyphony", _poly_spinbutton->get_value_as_int())); if (_replace) App::instance().engine()->clear_patch(_patch->path()); @@ -132,7 +131,7 @@ LoadPatchWindow::ok_clicked() parent = _patch->path().parent(); App::instance().loader()->load_patch(true, get_uri(), "/", - _initial_data, parent, name, poly); + _initial_data, parent, name); hide(); } diff --git a/src/libs/gui/LoadRemotePatchWindow.cpp b/src/libs/gui/LoadRemotePatchWindow.cpp index b5caf351..c2d40c5e 100644 --- a/src/libs/gui/LoadRemotePatchWindow.cpp +++ b/src/libs/gui/LoadRemotePatchWindow.cpp @@ -136,7 +136,6 @@ LoadRemotePatchWindow::open_clicked() // If unset load_patch will load values optional<const string&> name; - optional<uint32_t> poly; optional<Path> parent; @@ -147,7 +146,7 @@ LoadRemotePatchWindow::open_clicked() parent = _patch->path().parent(); App::instance().loader()->load_patch(true, uri, "/", - _initial_data, parent, name, poly); + _initial_data, parent, name); hide(); } diff --git a/src/libs/gui/LoadSubpatchWindow.cpp b/src/libs/gui/LoadSubpatchWindow.cpp index d3628e64..42058578 100644 --- a/src/libs/gui/LoadSubpatchWindow.cpp +++ b/src/libs/gui/LoadSubpatchWindow.cpp @@ -144,7 +144,6 @@ LoadSubpatchWindow::ok_clicked() // If unset load_patch will load values optional<const string&> name; - optional<uint32_t> poly; string name_str = ""; if (_name_from_user_radio->get_active()) { @@ -152,13 +151,15 @@ LoadSubpatchWindow::ok_clicked() name = name_str; } - if (_poly_from_user_radio->get_active()) - poly = _poly_spinbutton->get_value_as_int(); - else if (_poly_from_parent_radio->get_active()) - poly = _patch->poly(); + if (_poly_from_user_radio->get_active()) { + cerr << "Overriding poly: " << _poly_spinbutton->get_value_as_int() << endl; + _initial_data.insert(make_pair("ingen:polyphony", (int)_poly_spinbutton->get_value_as_int())); + } else if (_poly_from_parent_radio->get_active()) { + _initial_data.insert(make_pair("ingen:polyphony", (int)_patch->poly())); + } App::instance().loader()->load_patch(false, get_uri(), "/", - _initial_data, _patch->path(), name, poly); + _initial_data, _patch->path(), name); hide(); } diff --git a/src/libs/gui/ThreadedLoader.cpp b/src/libs/gui/ThreadedLoader.cpp index 22b0a8d9..568806a8 100644 --- a/src/libs/gui/ThreadedLoader.cpp +++ b/src/libs/gui/ThreadedLoader.cpp @@ -71,15 +71,13 @@ ThreadedLoader::_whipped() _mutex.unlock(); } -/** FIXME: use poly parameter */ void ThreadedLoader::load_patch(bool merge, const string& data_base_uri, const Path& data_path, MetadataMap engine_data, optional<Path> engine_parent, - optional<const string&> engine_name, - optional<uint32_t> engine_poly) + optional<const string&> engine_name) { _mutex.lock(); @@ -90,7 +88,6 @@ ThreadedLoader::load_patch(bool merge, data_base_uri, engine_parent, (engine_name) ? engine_name.get() : "", - (engine_poly) ? engine_poly.get() : 1, engine_data, false))); } else { @@ -101,7 +98,6 @@ ThreadedLoader::load_patch(bool merge, data_base_uri, engine_parent, (engine_name) ? engine_name.get() : "", - // FIXME: poly here "", engine_data ))); } diff --git a/src/libs/gui/ThreadedLoader.hpp b/src/libs/gui/ThreadedLoader.hpp index e65470f7..68045598 100644 --- a/src/libs/gui/ThreadedLoader.hpp +++ b/src/libs/gui/ThreadedLoader.hpp @@ -66,8 +66,7 @@ public: const Path& data_path, MetadataMap engine_data, optional<Path> engine_parent, - optional<const string&> engine_name = optional<const string&>(), - optional<uint32_t> engine_poly = optional<uint32_t>()); + optional<const string&> engine_name = optional<const string&>()); void save_patch(SharedPtr<PatchModel> model, const string& filename); diff --git a/src/libs/serialisation/Loader.cpp b/src/libs/serialisation/Loader.cpp index 1a33dac9..e34b5503 100644 --- a/src/libs/serialisation/Loader.cpp +++ b/src/libs/serialisation/Loader.cpp @@ -64,24 +64,35 @@ Loader::load(SharedPtr<EngineInterface> engine, cerr << "[Loader] Loading " << patch_uri << " from " << document_uri << " under " << (string)(parent ? (string)parent.get() : "no parent") << endl; - /* Get polyphony (mandatory) */ - - // FIXME: polyphony datatype - RDF::Query query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?poly WHERE {\n") + - patch_uri + " ingen:polyphony ?poly\n }"); - - RDF::Query::Results results = query.run(*rdf_world, model); + size_t patch_poly = 1; + + /* Use parameter overridden polyphony, if given */ + Raul::Table<string, Atom>::iterator poly_param = data.find("ingen:polyphony"); + if (poly_param != data.end() && poly_param->second.type() == Atom::INT) { + cerr << "Using overridden poly: " << poly_param->second.get_int32(); + patch_poly = poly_param->second.get_int32(); + + /* Get polyphony from file (mandatory if not specified in parameters) */ + } else { + cerr << "No overridden poly." << endl; + + // FIXME: polyphony datatype? + RDF::Query query(*rdf_world, Glib::ustring( + "SELECT DISTINCT ?poly WHERE {\n") + + patch_uri + " ingen:polyphony ?poly\n }"); + + RDF::Query::Results results = query.run(*rdf_world, model); + + if (results.size() == 0) { + cerr << "[Loader] ERROR: No polyphony found!" << endl; + return false; + } - if (results.size() == 0) { - cerr << "[Loader] ERROR: No polyphony found!" << endl; - return false; + const RDF::Node& poly_node = (*results.begin())["poly"]; + assert(poly_node.is_int()); + patch_poly = static_cast<size_t>(poly_node.to_int()); } - RDF::Node poly_node = (*results.begin())["poly"]; - assert(poly_node.is_int()); - const size_t patch_poly = static_cast<size_t>(poly_node.to_int()); - /* Get name (if available/necessary) */ if (patch_name == "") { @@ -89,11 +100,11 @@ Loader::load(SharedPtr<EngineInterface> engine, if (patch_name.substr(patch_name.length()-10) == ".ingen.ttl") patch_name = patch_name.substr(0, patch_name.length()-10); - query = RDF::Query(*rdf_world, Glib::ustring( + RDF::Query query(*rdf_world, Glib::ustring( "SELECT DISTINCT ?name WHERE {\n") + patch_uri + " ingen:name ?name\n}"); - results = query.run(*rdf_world, model); + RDF::Query::Results results = query.run(*rdf_world, model); if (results.size() > 0) patch_name = (*results.begin())["name"].to_string(); @@ -107,7 +118,7 @@ Loader::load(SharedPtr<EngineInterface> engine, /* Load (plugin) nodes */ - query = RDF::Query(*rdf_world, Glib::ustring( + RDF::Query query(*rdf_world, Glib::ustring( "SELECT DISTINCT ?name ?plugin ?floatkey ?floatval WHERE {\n") + patch_uri + " ingen:node ?node .\n" "?node ingen:name ?name ;\n" @@ -116,7 +127,7 @@ Loader::load(SharedPtr<EngineInterface> engine, " FILTER ( datatype(?floatval) = xsd:decimal ) }\n" "}"); - results = query.run(*rdf_world, model); + RDF::Query::Results results = query.run(*rdf_world, model); for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { |