summaryrefslogtreecommitdiffstats
path: root/src/libs/engine
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-08-17 03:10:58 +0000
committerDavid Robillard <d@drobilla.net>2008-08-17 03:10:58 +0000
commitd6823fa9b29bcff74ca180e6d389d8a21cf88d1f (patch)
treeb79dcfd907f83f035d657964d26b578c85ef0de2 /src/libs/engine
parent694b31089c8060fc6b908b146b12c0e340d004c7 (diff)
downloadingen-d6823fa9b29bcff74ca180e6d389d8a21cf88d1f.tar.gz
ingen-d6823fa9b29bcff74ca180e6d389d8a21cf88d1f.tar.bz2
ingen-d6823fa9b29bcff74ca180e6d389d8a21cf88d1f.zip
There!
Loader uses only CommonInterface and is now able to parse into a client or engine. Proper OSC serialisation of boolean atoms. Remove patch_enabled and patch_disabled calls/signals/etc in favour of new generic "property" mechanism (courtesy of which much more killed API is to come). git-svn-id: http://svn.drobilla.net/lad/ingen@1410 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine')
-rw-r--r--src/libs/engine/ClientBroadcaster.cpp28
-rw-r--r--src/libs/engine/ClientBroadcaster.hpp3
-rw-r--r--src/libs/engine/OSCClientSender.cpp54
-rw-r--r--src/libs/engine/OSCClientSender.hpp8
-rw-r--r--src/libs/engine/OSCEngineReceiver.cpp65
-rw-r--r--src/libs/engine/OSCEngineReceiver.hpp3
-rw-r--r--src/libs/engine/ObjectSender.cpp3
-rw-r--r--src/libs/engine/QueuedEngineInterface.cpp32
-rw-r--r--src/libs/engine/QueuedEngineInterface.hpp9
-rw-r--r--src/libs/engine/events/EnablePatchEvent.cpp5
10 files changed, 91 insertions, 119 deletions
diff --git a/src/libs/engine/ClientBroadcaster.cpp b/src/libs/engine/ClientBroadcaster.cpp
index 949784c3..dce6691e 100644
--- a/src/libs/engine/ClientBroadcaster.cpp
+++ b/src/libs/engine/ClientBroadcaster.cpp
@@ -193,22 +193,6 @@ ClientBroadcaster::send_disconnection(const string& src_port_path, const string&
void
-ClientBroadcaster::send_patch_enable(const string& patch_path)
-{
- for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
- (*i).second->patch_enabled(patch_path);
-}
-
-
-void
-ClientBroadcaster::send_patch_disable(const string& patch_path)
-{
- for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
- (*i).second->patch_disabled(patch_path);
-}
-
-
-void
ClientBroadcaster::send_patch_polyphony(const string& patch_path, uint32_t poly)
{
for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
@@ -228,6 +212,18 @@ ClientBroadcaster::send_variable_change(const string& node_path, const string& k
}
+/** Send notification of a property update.
+ *
+ * Like control changes, does not send update to client that set the property, if applicable.
+ */
+void
+ClientBroadcaster::send_property_change(const string& node_path, const string& key, const Atom& value)
+{
+ for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
+ (*i).second->set_property(node_path, key, value);
+}
+
+
/** Send notification of a control change.
*
* If responder is specified, the notification will not be send to the address of
diff --git a/src/libs/engine/ClientBroadcaster.hpp b/src/libs/engine/ClientBroadcaster.hpp
index 323a1912..07da01f5 100644
--- a/src/libs/engine/ClientBroadcaster.hpp
+++ b/src/libs/engine/ClientBroadcaster.hpp
@@ -76,10 +76,9 @@ public:
void send_connection(const SharedPtr<const ConnectionImpl> connection);
void send_disconnection(const string& src_port_path, const string& dst_port_path);
void send_rename(const string& old_path, const string& new_path);
- void send_patch_enable(const string& patch_path);
- void send_patch_disable(const string& patch_path);
void send_patch_polyphony(const string& patch_path, uint32_t poly);
void send_variable_change(const string& node_path, const string& key, const Raul::Atom& value);
+ void send_property_change(const string& node_path, const string& key, const Raul::Atom& value);
void send_port_value(const string& port_path, const Raul::Atom& value);
void send_port_activity(const string& port_path);
void send_program_add(const string& node_path, int bank, int program, const string& name);
diff --git a/src/libs/engine/OSCClientSender.cpp b/src/libs/engine/OSCClientSender.cpp
index 60edbe07..1429d616 100644
--- a/src/libs/engine/OSCClientSender.cpp
+++ b/src/libs/engine/OSCClientSender.cpp
@@ -298,28 +298,6 @@ OSCClientSender::patch_cleared(const std::string& patch_path)
/** \page client_osc_namespace
- * <p> \b /ingen/patch_enabled - Notification a patch's DSP processing has been enabled.
- * \arg \b path (string) - Path of enabled patch</p> \n \n
- */
-void
-OSCClientSender::patch_enabled(const std::string& patch_path)
-{
- send("/ingen/patch_enabled", "s", patch_path.c_str(), LO_ARGS_END);
-}
-
-
-/** \page client_osc_namespace
- * <p> \b /ingen/patch_disabled - Notification a patch's DSP processing has been disabled.
- * \arg \b path (string) - Path of disabled patch</p> \n \n
- */
-void
-OSCClientSender::patch_disabled(const std::string& patch_path)
-{
- send("/ingen/patch_disabled", "s", patch_path.c_str(), LO_ARGS_END);
-}
-
-
-/** \page client_osc_namespace
* <p> \b /ingen/patch_polyphony - Notification a patch's DSP processing has been polyphony.
* \arg \b path (string) - Path of polyphony patch</p> \n \n
*/
@@ -359,8 +337,8 @@ OSCClientSender::disconnect(const std::string& src_port_path, const std::string&
/** \page client_osc_namespace
- * <p> \b /ingen/set_variable - Notification of a piece of variable.
- * \arg \b path (string) - Path of the object associated with variable (can be a node, patch, or port)
+ * <p> \b /ingen/set_variable - Notification of a variable.
+ * \arg \b path (string) - Path of the object associated with variable (node, patch, or port)
* \arg \b key (string)
* \arg \b value (string)</p> \n \n
*/
@@ -376,6 +354,23 @@ OSCClientSender::set_variable(const std::string& path, const std::string& key, c
/** \page client_osc_namespace
+ * <p> \b /ingen/set_property - Notification of a property.
+ * \arg \b path (string) - Path of the object associated with property (node, patch, or port)
+ * \arg \b key (string)
+ * \arg \b value (string)</p> \n \n
+ */
+void
+OSCClientSender::set_property(const std::string& path, const std::string& key, const Atom& value)
+{
+ lo_message m = lo_message_new();
+ lo_message_add_string(m, path.c_str());
+ lo_message_add_string(m, key.c_str());
+ Raul::AtomLiblo::lo_message_add_atom(m, value);
+ send_message("/ingen/set_property", m);
+}
+
+
+/** \page client_osc_namespace
* <p> \b /ingen/set_port_value - Notification the value of a port has changed
* \arg \b path (string) - Path of port
* \arg \b value (any) - New value of port </p> \n \n
@@ -467,17 +462,6 @@ void
OSCClientSender::new_patch(const std::string& path, uint32_t poly)
{
send("/ingen/new_patch", "si", path.c_str(), poly, LO_ARGS_END);
-
- /*
- if (p->process())
- patch_enabled(p->path());
-
- // Send variables
- const map<const std::string&, const std::string&>& data = p->variable();
- for (map<const std::string&, const std::string&>::const_iterator i = data.begin(); i != data.end(); ++i) {
- set_variable(p->path(), (*i).first, (*i).second);
- }
- */
}
diff --git a/src/libs/engine/OSCClientSender.hpp b/src/libs/engine/OSCClientSender.hpp
index 662ba75b..714e17b2 100644
--- a/src/libs/engine/OSCClientSender.hpp
+++ b/src/libs/engine/OSCClientSender.hpp
@@ -90,10 +90,6 @@ public:
virtual void polyphonic(const std::string& path,
bool polyphonic);
- virtual void patch_enabled(const std::string& path);
-
- virtual void patch_disabled(const std::string& path);
-
virtual void patch_polyphony(const std::string& path,
uint32_t poly);
@@ -114,6 +110,10 @@ public:
const std::string& predicate,
const Raul::Atom& value);
+ virtual void set_property(const std::string& subject_path,
+ const std::string& predicate,
+ const Raul::Atom& value);
+
virtual void set_port_value(const std::string& port_path,
const Raul::Atom& value);
diff --git a/src/libs/engine/OSCEngineReceiver.cpp b/src/libs/engine/OSCEngineReceiver.cpp
index 74947917..afac70b0 100644
--- a/src/libs/engine/OSCEngineReceiver.cpp
+++ b/src/libs/engine/OSCEngineReceiver.cpp
@@ -87,8 +87,6 @@ OSCEngineReceiver::OSCEngineReceiver(Engine& engine, size_t queue_size, uint16_t
lo_server_add_method(_server, "/ingen/activate", "i", engine_activate_cb, this);
lo_server_add_method(_server, "/ingen/deactivate", "i", engine_deactivate_cb, this);
lo_server_add_method(_server, "/ingen/new_patch", "isi", new_patch_cb, this);
- lo_server_add_method(_server, "/ingen/enable_patch", "is", enable_patch_cb, this);
- lo_server_add_method(_server, "/ingen/disable_patch", "is", disable_patch_cb, this);
lo_server_add_method(_server, "/ingen/clear_patch", "is", clear_patch_cb, this);
lo_server_add_method(_server, "/ingen/set_polyphony", "isi", set_polyphony_cb, this);
lo_server_add_method(_server, "/ingen/set_polyphonic", "isT", set_polyphonic_cb, this);
@@ -112,6 +110,7 @@ OSCEngineReceiver::OSCEngineReceiver(Engine& engine, size_t queue_size, uint16_t
lo_server_add_method(_server, "/ingen/all_notes_off", "isi", all_notes_off_cb, this);
lo_server_add_method(_server, "/ingen/midi_learn", "is", midi_learn_cb, this);
lo_server_add_method(_server, "/ingen/set_variable", NULL, variable_set_cb, this);
+ lo_server_add_method(_server, "/ingen/set_property", NULL, property_set_cb, this);
// Queries
lo_server_add_method(_server, "/ingen/request_variable", "iss", variable_get_cb, this);
@@ -407,36 +406,6 @@ OSCEngineReceiver::_rename_cb(const char* path, const char* types, lo_arg** argv
/** \page engine_osc_namespace
- * <p> \b /ingen/enable_patch - Enable DSP processing of a patch
- * \arg \b response-id (integer)
- * \arg \b patch-path - Patch's path </p> \n \n
- */
-int
-OSCEngineReceiver::_enable_patch_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* patch_path = &argv[1]->s;
-
- enable_patch(patch_path);
- return 0;
-}
-
-
-/** \page engine_osc_namespace
- * <p> \b /ingen/disable_patch - Disable DSP processing of a patch
- * \arg \b response-id (integer)
- * \arg \b patch-path - Patch's path </p> \n \n
- */
-int
-OSCEngineReceiver::_disable_patch_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* patch_path = &argv[1]->s;
-
- disable_patch(patch_path);
- return 0;
-}
-
-
-/** \page engine_osc_namespace
* <p> \b /ingen/clear_patch - Remove all nodes from a patch
* \arg \b response-id (integer)
* \arg \b patch-path - Patch's path </p> \n \n
@@ -485,6 +454,7 @@ OSCEngineReceiver::_set_polyphonic_cb(const char* path, const char* types, lo_ar
}
+// FIXME: add index
/** \page engine_osc_namespace
* <p> \b /ingen/new_port - Add a port into a given patch (load a plugin by URI)
* \arg \b response-id (integer)
@@ -499,7 +469,7 @@ OSCEngineReceiver::_new_port_cb(const char* path, const char* types, lo_arg** ar
const char* data_type = &argv[2]->s;
const int32_t direction = argv[3]->i;
- new_port(port_path, data_type, (direction == 1));
+ new_port(port_path, 0, data_type, (direction == 1));
return 0;
}
@@ -840,11 +810,11 @@ OSCEngineReceiver::_midi_learn_cb(const char* path, const char* types, lo_arg**
/** \page engine_osc_namespace
- * <p> \b /ingen/set_variable - Sets a piece of variable, associated with a synth-space object (node, etc)
+ * <p> \b /ingen/set_variable - Set a variable, associated with a synth-space object (node, etc)
* \arg \b response-id (integer)
* \arg \b object-path (string) - Full path of object to associate variable with
- * \arg \b key (string) - Key (index) for new piece of variable
- * \arg \b value (string) - Value of new piece of variable </p> \n \n
+ * \arg \b key (string) - Key (index/predicate/ID) for new variable
+ * \arg \b value (string) - Value of new variable </p> \n \n
*/
int
OSCEngineReceiver::_variable_set_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
@@ -863,6 +833,29 @@ OSCEngineReceiver::_variable_set_cb(const char* path, const char* types, lo_arg*
/** \page engine_osc_namespace
+ * <p> \b /ingen/set_property - Set an (RDF) property, associated with a synth-space object (node, etc)
+ * \arg \b response-id (integer)
+ * \arg \b object-path (string) - Full path of object to associate variable with
+ * \arg \b key (string) - URI/QName for predicate of this property (e.g. "ingen:enabled")
+ * \arg \b value (string) - Value of property </p> \n \n
+ */
+int
+OSCEngineReceiver::_property_set_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+{
+ if (argc != 4 || types[0] != 'i' || types[1] != 's' || types[2] != 's')
+ return 1;
+
+ const char* object_path = &argv[1]->s;
+ const char* key = &argv[2]->s;
+
+ Raul::Atom value = Raul::AtomLiblo::lo_arg_to_atom(types[3], argv[3]);
+
+ set_property(object_path, key, value);
+ return 0;
+}
+
+
+/** \page engine_osc_namespace
* <p> \b /ingen/request_variable - Requests the engine send a piece of variable, associated with a synth-space object (node, etc)
* \arg \b response-id (integer)
* \arg \b object-path (string) - Full path of object variable is associated with
diff --git a/src/libs/engine/OSCEngineReceiver.hpp b/src/libs/engine/OSCEngineReceiver.hpp
index 35d7d531..980e2f78 100644
--- a/src/libs/engine/OSCEngineReceiver.hpp
+++ b/src/libs/engine/OSCEngineReceiver.hpp
@@ -98,8 +98,6 @@ private:
LO_HANDLER(new_port);
LO_HANDLER(new_node);
LO_HANDLER(new_node_by_uri);
- LO_HANDLER(enable_patch);
- LO_HANDLER(disable_patch);
LO_HANDLER(clear_patch);
LO_HANDLER(set_polyphony);
LO_HANDLER(set_polyphonic);
@@ -117,6 +115,7 @@ private:
LO_HANDLER(midi_learn);
LO_HANDLER(variable_get);
LO_HANDLER(variable_set);
+ LO_HANDLER(property_set);
LO_HANDLER(request_plugin);
LO_HANDLER(request_object);
LO_HANDLER(request_port_value);
diff --git a/src/libs/engine/ObjectSender.cpp b/src/libs/engine/ObjectSender.cpp
index 0bbe6533..82500446 100644
--- a/src/libs/engine/ObjectSender.cpp
+++ b/src/libs/engine/ObjectSender.cpp
@@ -43,8 +43,7 @@ ObjectSender::send_patch(ClientInterface* client, const PatchImpl* patch, bool r
for (GraphObjectImpl::Variables::const_iterator j = data.begin(); j != data.end(); ++j)
client->set_variable(patch->path(), (*j).first, (*j).second);
- if (patch->enabled())
- client->patch_enabled(patch->path());
+ client->set_property(patch->path(), "ingen:enabled", (bool)patch->enabled());
client->bundle_end();
diff --git a/src/libs/engine/QueuedEngineInterface.cpp b/src/libs/engine/QueuedEngineInterface.cpp
index 6593ec81..6deeb727 100644
--- a/src/libs/engine/QueuedEngineInterface.cpp
+++ b/src/libs/engine/QueuedEngineInterface.cpp
@@ -145,7 +145,9 @@ QueuedEngineInterface::new_patch(const string& path,
}
+// FIXME: use index
void QueuedEngineInterface::new_port(const string& path,
+ uint32_t index,
const string& data_type,
bool direction)
{
@@ -211,20 +213,6 @@ QueuedEngineInterface::set_polyphonic(const string& path, bool poly)
void
-QueuedEngineInterface::enable_patch(const string& patch_path)
-{
- push_queued(new EnablePatchEvent(_engine, _responder, now(), patch_path, true));
-}
-
-
-void
-QueuedEngineInterface::disable_patch(const string& patch_path)
-{
- push_queued(new EnablePatchEvent(_engine, _responder, now(), patch_path, false));
-}
-
-
-void
QueuedEngineInterface::connect(const string& src_port_path,
const string& dst_port_path)
{
@@ -321,6 +309,22 @@ QueuedEngineInterface::set_variable(const string& path,
push_queued(new SetMetadataEvent(_engine, _responder, now(), path, predicate, value));
}
+
+void
+QueuedEngineInterface::set_property(const string& path,
+ const string& predicate,
+ const Atom& value)
+{
+ // FIXME: implement generically
+ if (predicate == "ingen:enabled") {
+ if (value.type() == Atom::BOOL) {
+ push_queued(new EnablePatchEvent(_engine, _responder, now(), path, value.get_bool()));
+ return;
+ }
+ }
+ cerr << "WARNING: Unknown property \"" << predicate << "\" ignored" << endl;
+}
+
// Requests //
diff --git a/src/libs/engine/QueuedEngineInterface.hpp b/src/libs/engine/QueuedEngineInterface.hpp
index 3d8b8d12..585f1104 100644
--- a/src/libs/engine/QueuedEngineInterface.hpp
+++ b/src/libs/engine/QueuedEngineInterface.hpp
@@ -85,6 +85,7 @@ public:
uint32_t poly);
virtual void new_port(const string& path,
+ uint32_t index,
const string& data_type,
bool direction);
@@ -110,10 +111,6 @@ public:
virtual void set_polyphonic(const string& path, bool poly);
- virtual void enable_patch(const string& patch_path);
-
- virtual void disable_patch(const string& patch_path);
-
virtual void connect(const string& src_port_path,
const string& dst_port_path);
@@ -151,6 +148,10 @@ public:
const string& predicate,
const Raul::Atom& value);
+ virtual void set_property(const string& path,
+ const string& predicate,
+ const Raul::Atom& value);
+
// Requests //
virtual void ping();
diff --git a/src/libs/engine/events/EnablePatchEvent.cpp b/src/libs/engine/events/EnablePatchEvent.cpp
index 48657146..04759cea 100644
--- a/src/libs/engine/events/EnablePatchEvent.cpp
+++ b/src/libs/engine/events/EnablePatchEvent.cpp
@@ -75,10 +75,7 @@ EnablePatchEvent::post_process()
{
if (_patch != NULL) {
_responder->respond_ok();
- if (_enable)
- _engine.broadcaster()->send_patch_enable(_patch_path);
- else
- _engine.broadcaster()->send_patch_disable(_patch_path);
+ _engine.broadcaster()->send_property_change(_patch_path, "ingen:enabled", (bool)_enable);
} else {
_responder->respond_error(string("Patch ") + _patch_path + " not found");
}