summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/client/DeprecatedSerializer.cpp12
-rw-r--r--src/libs/client/Loader.cpp54
-rw-r--r--src/libs/client/PortModel.h39
-rw-r--r--src/libs/client/RDFQuery.cpp2
-rw-r--r--src/libs/client/RDFQuery.h4
-rw-r--r--src/libs/client/Serializer.cpp2
-rw-r--r--src/libs/client/Store.cpp10
-rw-r--r--src/libs/engine/DataType.h1
-rw-r--r--src/libs/engine/OSCClientSender.cpp2
-rw-r--r--src/libs/engine/OSCEngineReceiver.cpp2
-rw-r--r--src/libs/engine/ObjectSender.cpp6
-rw-r--r--src/libs/engine/events/AddPortEvent.cpp18
12 files changed, 99 insertions, 53 deletions
diff --git a/src/libs/client/DeprecatedSerializer.cpp b/src/libs/client/DeprecatedSerializer.cpp
index d3d5a09f..b8156a95 100644
--- a/src/libs/client/DeprecatedSerializer.cpp
+++ b/src/libs/client/DeprecatedSerializer.cpp
@@ -425,22 +425,22 @@ DeprecatedSerializer::load_node(const Path& parent, xmlDocPtr doc, const xmlNode
if (plugin_type == "Internal") {
if (plugin_label == "audio_input") {
- _engine->create_port(path, "AUDIO", false);
+ _engine->create_port(path, "ingen:audio", false);
is_port = true;
} else if (plugin_label == "audio_output") {
- _engine->create_port(path, "AUDIO", true);
+ _engine->create_port(path, "ingen:audio", true);
is_port = true;
} else if (plugin_label == "control_input") {
- _engine->create_port(path, "CONTROL", false);
+ _engine->create_port(path, "ingen:control", false);
is_port = true;
} else if (plugin_label == "control_output" ) {
- _engine->create_port(path, "CONTROL", true);
+ _engine->create_port(path, "ingen:control", true);
is_port = true;
} else if (plugin_label == "midi_input") {
- _engine->create_port(path, "MIDI", false);
+ _engine->create_port(path, "ingen:midi", false);
is_port = true;
} else if (plugin_label == "midi_output" ) {
- _engine->create_port(path, "MIDI", true);
+ _engine->create_port(path, "ingen:midi", true);
is_port = true;
}
}
diff --git a/src/libs/client/Loader.cpp b/src/libs/client/Loader.cpp
index ac661e58..fe1af795 100644
--- a/src/libs/client/Loader.cpp
+++ b/src/libs/client/Loader.cpp
@@ -31,6 +31,7 @@ Loader::Loader(SharedPtr<ModelEngineInterface> engine, SharedPtr<Namespaces> nam
_namespaces = SharedPtr<Namespaces>(new Namespaces());
// FIXME: hack
+ _namespaces->add("ingen", "http://codeson.net/ns/ingen#");
_namespaces->add("ingenuity", "http://codeson.net/ns/ingenuity#");
}
@@ -47,14 +48,16 @@ Loader::load(const Glib::ustring& filename,
{
std::map<Glib::ustring, bool> created;
+
+ /* Load nodes */
+
RDFQuery query(Glib::ustring(
"SELECT DISTINCT ?name ?plugin ?floatkey ?floatval FROM <") + filename + "> WHERE {\n"
"?patch ingen:node ?node .\n"
"?node ingen:name ?name ;\n"
" ingen:plugin ?plugin ;\n"
- "OPTIONAL { ?node ?floatkey ?floatval . \n"
- " FILTER ( datatype(?floatval) = xsd:decimal )\n"
- " }\n"
+ "OPTIONAL { ?node ?floatkey ?floatval . \n"
+ " FILTER ( datatype(?floatval) = xsd:decimal ) }\n"
"}");
RDFQuery::Results nodes = query.run(filename);
@@ -64,7 +67,6 @@ Loader::load(const Glib::ustring& filename,
const Glib::ustring& plugin = (*i)["plugin"];
if (created.find(name) == created.end()) {
- cerr << "CREATING " << name << endl;
_engine->create_node(parent.base() + name, plugin, false);
created[name] = true;
}
@@ -72,13 +74,49 @@ Loader::load(const Glib::ustring& filename,
Glib::ustring floatkey = _namespaces->qualify((*i)["floatkey"]);
Glib::ustring floatval = (*i)["floatval"];
- float val = atof(floatval.c_str());
+ if (floatkey != "" && floatval != "") {
+ const float val = atof(floatval.c_str());
+ _engine->set_metadata(parent.base() + name, floatkey, Atom(val));
+ }
+ }
+
+ created.clear();
- cerr << floatkey << " = " << val << endl;
- _engine->set_metadata(parent.base() + name, floatkey, Atom(val));
- }
+ /* Load patch ports */
+ query = RDFQuery(Glib::ustring(
+ "SELECT DISTINCT ?port ?type ?name ?datatype ?floatkey ?floatval FROM <") + filename + "> WHERE {\n"
+ "?patch ingen:port ?port .\n"
+ "?port a ?type ;\n"
+ " ingen:name ?name ;\n"
+ " ingen:dataType ?datatype .\n"
+ "OPTIONAL { ?port ?floatkey ?floatval . \n"
+ " FILTER ( datatype(?floatval) = xsd:decimal ) }\n"
+ "}");
+
+ RDFQuery::Results ports = query.run(filename);
+
+ for (RDFQuery::Results::iterator i = ports.begin(); i != ports.end(); ++i) {
+ const Glib::ustring& name = (*i)["name"];
+ const Glib::ustring& type = _namespaces->qualify((*i)["type"]);
+ const Glib::ustring& datatype = (*i)["datatype"];
+
+ if (created.find(name) == created.end()) {
+ cerr << "TYPE: " << type << endl;
+ bool is_output = (type == "ingen:OutputPort"); // FIXME: check validity
+ _engine->create_port(parent.base() + name, datatype, is_output);
+ created[name] = true;
+ }
+
+ Glib::ustring floatkey = _namespaces->qualify((*i)["floatkey"]);
+ Glib::ustring floatval = (*i)["floatval"];
+
+ if (floatkey != "" && floatval != "") {
+ const float val = atof(floatval.c_str());
+ _engine->set_metadata(parent.base() + name, floatkey, Atom(val));
+ }
+ }
}
diff --git a/src/libs/client/PortModel.h b/src/libs/client/PortModel.h
index e5ce23fc..1dc68ccd 100644
--- a/src/libs/client/PortModel.h
+++ b/src/libs/client/PortModel.h
@@ -18,13 +18,14 @@
#define PORTMODEL_H
#include <cstdlib>
+#include <iostream>
#include <string>
#include <list>
#include <sigc++/sigc++.h>
#include "ObjectModel.h"
#include "raul/SharedPtr.h"
#include "raul/Path.h"
-using std::string; using std::list;
+using std::string; using std::list; using std::cerr; using std::endl;
namespace Ingen {
namespace Client {
@@ -37,22 +38,22 @@ namespace Client {
class PortModel : public ObjectModel
{
public:
- // FIXME: metadataify
- enum Type { CONTROL, AUDIO, MIDI };
enum Direction { INPUT, OUTPUT };
+
+ // FIXME: metadataify
enum Hint { NONE, INTEGER, TOGGLE, LOGARITHMIC };
- inline float value() const { return m_current_val; }
- inline bool connected() const { return (m_connections > 0); }
- inline Type type() const { return m_type; }
- inline bool is_input() const { return (m_direction == INPUT); }
- inline bool is_output() const { return (m_direction == OUTPUT); }
- inline bool is_audio() const { return (m_type == AUDIO); }
- inline bool is_control() const { return (m_type == CONTROL); }
- inline bool is_midi() const { return (m_type == MIDI); }
- inline bool is_logarithmic() const { return (m_hint == LOGARITHMIC); }
- inline bool is_integer() const { return (m_hint == INTEGER); }
- inline bool is_toggle() const { return (m_hint == TOGGLE); }
+ inline float value() const { return m_current_val; }
+ inline bool connected() const { return (m_connections > 0); }
+ inline string type() const { return m_type; }
+ inline bool is_input() const { return (m_direction == INPUT); }
+ inline bool is_output() const { return (m_direction == OUTPUT); }
+ inline bool is_audio() const { return (m_type == "ingen:audio"); }
+ inline bool is_control() const { return (m_type == "ingen:control"); }
+ inline bool is_midi() const { return (m_type == "ingen:midi"); }
+ inline bool is_logarithmic() const { return (m_hint == LOGARITHMIC); }
+ inline bool is_integer() const { return (m_hint == INTEGER); }
+ inline bool is_toggle() const { return (m_hint == TOGGLE); }
inline bool operator==(const PortModel& pm) const { return (_path == pm._path); }
@@ -64,7 +65,7 @@ public:
private:
friend class Store;
- PortModel(const Path& path, Type type, Direction dir, Hint hint)
+ PortModel(const Path& path, const string& type, Direction dir, Hint hint)
: ObjectModel(path),
m_type(type),
m_direction(dir),
@@ -72,9 +73,11 @@ private:
m_current_val(0.0f),
m_connections(0)
{
+ if (!is_audio() && !is_control() && !is_input())
+ cerr << "[PortModel] Warning: Unknown port type" << endl;
}
- PortModel(const Path& path, Type type, Direction dir)
+ PortModel(const Path& path, const string& type, Direction dir)
: ObjectModel(path),
m_type(type),
m_direction(dir),
@@ -82,6 +85,8 @@ private:
m_current_val(0.0f),
m_connections(0)
{
+ if (!is_audio() && !is_control() && !is_input())
+ cerr << "[PortModel] Warning: Unknown port type" << endl;
}
inline void value(float f) { m_current_val = f; control_change_sig.emit(f); }
@@ -92,7 +97,7 @@ private:
void connected_to(SharedPtr<PortModel> p) { ++m_connections; connection_sig.emit(p); }
void disconnected_from(SharedPtr<PortModel> p) { --m_connections; disconnection_sig.emit(p); }
- Type m_type;
+ string m_type;
Direction m_direction;
Hint m_hint;
float m_current_val;
diff --git a/src/libs/client/RDFQuery.cpp b/src/libs/client/RDFQuery.cpp
index 178e2eba..02a491bb 100644
--- a/src/libs/client/RDFQuery.cpp
+++ b/src/libs/client/RDFQuery.cpp
@@ -27,7 +27,7 @@ namespace Client {
RDFQuery::Results
-RDFQuery::run(const Glib::ustring filename)
+RDFQuery::run(const Glib::ustring filename) const
{
Results result;
diff --git a/src/libs/client/RDFQuery.h b/src/libs/client/RDFQuery.h
index e22f3ae7..990d9e4f 100644
--- a/src/libs/client/RDFQuery.h
+++ b/src/libs/client/RDFQuery.h
@@ -45,9 +45,9 @@ public:
_query = _prefix_header + query;
}
- Results run(const Glib::ustring filename);
+ Results run(const Glib::ustring filename) const;
- Glib::ustring string() { return _query; }
+ Glib::ustring string() const { return _query; };
private:
diff --git a/src/libs/client/Serializer.cpp b/src/libs/client/Serializer.cpp
index b8929546..d57f908f 100644
--- a/src/libs/client/Serializer.cpp
+++ b/src/libs/client/Serializer.cpp
@@ -305,6 +305,8 @@ Serializer::serialize_port(SharedPtr<PortModel> port, unsigned depth)
_writer.write(port_id, NS_RDF("type"), NS_INGEN("OutputPort"));
_writer.write(port_id, NS_INGEN("name"), Atom(port->path().name().c_str()));
+
+ _writer.write(port_id, NS_INGEN("dataType"), Atom(port->type()));
if (port->metadata().size() > 0) {
for (MetadataMap::const_iterator m = port->metadata().begin(); m != port->metadata().end(); ++m) {
diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp
index 75667ee6..69358d0c 100644
--- a/src/libs/client/Store.cpp
+++ b/src/libs/client/Store.cpp
@@ -378,17 +378,9 @@ Store::new_node_event(const string& plugin_uri, const Path& node_path, bool is_p
void
Store::new_port_event(const Path& path, const string& type, bool is_output)
{
- // FIXME: this sucks
-
- PortModel::Type ptype = PortModel::CONTROL;
- if (type == "AUDIO") ptype = PortModel::AUDIO;
- else if (type == "CONTROL") ptype = PortModel::CONTROL;
- else if (type== "MIDI") ptype = PortModel::MIDI;
- else cerr << "[Store] WARNING: Unknown port type received (" << type << ")" << endl;
-
PortModel::Direction pdir = is_output ? PortModel::OUTPUT : PortModel::INPUT;
- SharedPtr<PortModel> p(new PortModel(path, ptype, pdir));
+ SharedPtr<PortModel> p(new PortModel(path, type, pdir));
add_object(p);
if (p->parent())
resolve_connection_orphans(p);
diff --git a/src/libs/engine/DataType.h b/src/libs/engine/DataType.h
index c658eccc..fbfda7a6 100644
--- a/src/libs/engine/DataType.h
+++ b/src/libs/engine/DataType.h
@@ -56,6 +56,7 @@ public:
inline bool operator!=(const Symbol& symbol) const { return (_symbol != symbol); }
inline bool operator==(const DataType& type) const { return (_symbol == type._symbol); }
inline bool operator!=(const DataType& type) const { return (_symbol != type._symbol); }
+
private:
Symbol _symbol;
diff --git a/src/libs/engine/OSCClientSender.cpp b/src/libs/engine/OSCClientSender.cpp
index eaceb14c..e858e572 100644
--- a/src/libs/engine/OSCClientSender.cpp
+++ b/src/libs/engine/OSCClientSender.cpp
@@ -330,7 +330,7 @@ void OSCClientSender::new_node(string plugin_uri,
/** \page client_osc_namespace
* <p> \b /om/new_port - Notification of a new port's creation.
* \arg \b path (string) - Path of new port
- * \arg \b data-type (string) - Type of port (CONTROL or AUDIO)
+ * \arg \b data-type (string) - Type of port (ingen:audio, ingen:control, or ingen:midi)
* \arg \b direction ("is-output") (integer) - Direction of data flow (Input = 0, Output = 1)
*
* \li Note that in the event of loading a patch, this message could be
diff --git a/src/libs/engine/OSCEngineReceiver.cpp b/src/libs/engine/OSCEngineReceiver.cpp
index b7e8f3a1..26377a37 100644
--- a/src/libs/engine/OSCEngineReceiver.cpp
+++ b/src/libs/engine/OSCEngineReceiver.cpp
@@ -479,7 +479,7 @@ OSCEngineReceiver::m_clear_patch_cb(const char* path, const char* types, lo_arg*
* <p> \b /om/synth/create_port - Add a port into a given patch (load a plugin by URI)
* \arg \b response-id (integer)
* \arg \b path (string) - Full path of the new port (ie. /patch2/subpatch/newport)
- * \arg \b data-type (string) - Data type for port to contain ("AUDIO", "CONTROL", or "MIDI")
+ * \arg \b data-type (string) - Data type for port to contain ("ingen:audio", "ingen:control", or "ingen:midi")
* \arg \b direction ("is-output") (integer) - Direction of data flow (Input = 0, Output = 1) </p> \n \n
*/
int
diff --git a/src/libs/engine/ObjectSender.cpp b/src/libs/engine/ObjectSender.cpp
index 6e93f405..8b238c72 100644
--- a/src/libs/engine/ObjectSender.cpp
+++ b/src/libs/engine/ObjectSender.cpp
@@ -130,9 +130,11 @@ ObjectSender::send_port(ClientInterface* client, const Port* port)
string type = port->type().uri();
if (port->type() == DataType::FLOAT) {
if (port->buffer_size() == 1)
- type = "CONTROL";
+ type = "ingen:control";
else
- type = "AUDIO";
+ type = "ingen:audio";
+ } else if (port->type() == DataType::MIDI) {
+ type = "ingen:midi";
}
//cerr << ", type = " << type << endl;
diff --git a/src/libs/engine/events/AddPortEvent.cpp b/src/libs/engine/events/AddPortEvent.cpp
index 08126d3a..aa7c3ca5 100644
--- a/src/libs/engine/events/AddPortEvent.cpp
+++ b/src/libs/engine/events/AddPortEvent.cpp
@@ -38,7 +38,13 @@
namespace Ingen {
-AddPortEvent::AddPortEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& path, const string& type, bool is_output, QueuedEventSource* source)
+AddPortEvent::AddPortEvent(Engine& engine,
+ SharedPtr<Responder> responder,
+ SampleCount timestamp,
+ const string& path,
+ const string& type,
+ bool is_output,
+ QueuedEventSource* source)
: QueuedEvent(engine, responder, timestamp, true, source),
_path(path),
_type(type),
@@ -57,9 +63,9 @@ AddPortEvent::AddPortEvent(Engine& engine, SharedPtr<Responder> responder, Sampl
*/
string type_str;
- if (type == "CONTROL" || type == "AUDIO")
+ if (type == "ingen:control" || type == "ingen:audio")
_data_type = DataType::FLOAT;
- else if (type == "MIDI")
+ else if (type == "ingen:midi")
_data_type = DataType::MIDI;
}
@@ -80,7 +86,7 @@ AddPortEvent::pre_process()
assert(_patch->path() == _path.parent());
size_t buffer_size = 1;
- if (_type == "AUDIO" || _type == "MIDI")
+ if (_type == "ingen:audio" || _type == "ingen:midi")
buffer_size = _engine.audio_driver()->buffer_size();
const size_t old_num_ports = _patch->num_ports();
@@ -104,10 +110,10 @@ AddPortEvent::pre_process()
_engine.object_store()->add(_patch_port);
if (!_patch->parent()) {
- if (_type == "AUDIO")
+ if (_type == "ingen:audio")
_driver_port = _engine.audio_driver()->create_port(
dynamic_cast<DuplexPort<Sample>*>(_patch_port));
- else if (_type == "MIDI")
+ else if (_type == "ingen:midi")
_driver_port = _engine.midi_driver()->create_port(
dynamic_cast<DuplexPort<MidiMessage>*>(_patch_port));
}