summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/client/ClientStore.cpp4
-rw-r--r--src/libs/client/ClientStore.hpp2
-rw-r--r--src/libs/client/DeprecatedLoader.cpp3
-rw-r--r--src/libs/client/Makefile.am1
-rw-r--r--src/libs/client/OSCClientReceiver.cpp23
-rw-r--r--src/libs/client/OSCClientReceiver.hpp3
-rw-r--r--src/libs/client/OSCEngineSender.cpp365
-rw-r--r--src/libs/client/OSCEngineSender.hpp48
-rw-r--r--src/libs/client/PluginUI.cpp6
-rw-r--r--src/libs/client/SigClientInterface.hpp12
-rw-r--r--src/libs/client/ThreadedSigClientInterface.hpp14
-rw-r--r--src/libs/engine/ClientBroadcaster.cpp4
-rw-r--r--src/libs/engine/ClientBroadcaster.hpp2
-rw-r--r--src/libs/engine/OSCClientSender.cpp111
-rw-r--r--src/libs/engine/OSCClientSender.hpp57
-rw-r--r--src/libs/engine/OSCEngineReceiver.cpp23
-rw-r--r--src/libs/engine/ObjectSender.cpp2
-rw-r--r--src/libs/engine/QueuedEngineInterface.cpp36
-rw-r--r--src/libs/engine/QueuedEngineInterface.hpp26
-rw-r--r--src/libs/engine/events/MidiLearnEvent.cpp2
-rw-r--r--src/libs/engine/events/RequestPortValueEvent.cpp2
-rw-r--r--src/libs/engine/events/SendPortValueEvent.cpp4
-rw-r--r--src/libs/engine/events/SetPortValueEvent.cpp44
-rw-r--r--src/libs/engine/events/SetPortValueEvent.hpp27
-rw-r--r--src/libs/gui/ControlPanel.cpp6
-rw-r--r--src/libs/gui/Port.cpp3
-rw-r--r--src/libs/serialisation/Loader.cpp8
-rw-r--r--src/libs/shared/Makefile.am2
28 files changed, 320 insertions, 520 deletions
diff --git a/src/libs/client/ClientStore.cpp b/src/libs/client/ClientStore.cpp
index d0cb5906..39908eb5 100644
--- a/src/libs/client/ClientStore.cpp
+++ b/src/libs/client/ClientStore.cpp
@@ -50,7 +50,7 @@ ClientStore::ClientStore(SharedPtr<EngineInterface> engine, SharedPtr<SigClientI
emitter->signal_connection.connect(sigc::mem_fun(this, &ClientStore::connection_event));
emitter->signal_disconnection.connect(sigc::mem_fun(this, &ClientStore::disconnection_event));
emitter->signal_variable_change.connect(sigc::mem_fun(this, &ClientStore::variable_change_event));
- emitter->signal_control_change.connect(sigc::mem_fun(this, &ClientStore::control_change_event));
+ emitter->signal_port_value.connect(sigc::mem_fun(this, &ClientStore::port_value_event));
emitter->signal_port_activity.connect(sigc::mem_fun(this, &ClientStore::port_activity_event));
}
@@ -524,7 +524,7 @@ ClientStore::variable_change_event(const Path& subject_path, const string& predi
void
-ClientStore::control_change_event(const Path& port_path, float value)
+ClientStore::port_value_event(const Path& port_path, const Raul::Atom& value)
{
SharedPtr<PortModel> port = PtrCast<PortModel>(object(port_path));
if (port)
diff --git a/src/libs/client/ClientStore.hpp b/src/libs/client/ClientStore.hpp
index 187070b0..d71067d6 100644
--- a/src/libs/client/ClientStore.hpp
+++ b/src/libs/client/ClientStore.hpp
@@ -106,7 +106,7 @@ private:
void patch_polyphony_event(const Path& path, uint32_t poly);
void patch_cleared_event(const Path& path);
void variable_change_event(const Path& subject_path, const string& predicate, const Atom& value);
- void control_change_event(const Path& port_path, float value);
+ void port_value_event(const Path& port_path, const Raul::Atom& value);
void port_activity_event(const Path& port_path);
void connection_event(const Path& src_port_path, const Path& dst_port_path);
void disconnection_event(const Path& src_port_path, const Path& dst_port_path);
diff --git a/src/libs/client/DeprecatedLoader.cpp b/src/libs/client/DeprecatedLoader.cpp
index ea853b23..42f2f5fc 100644
--- a/src/libs/client/DeprecatedLoader.cpp
+++ b/src/libs/client/DeprecatedLoader.cpp
@@ -342,8 +342,7 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename,
list<ControlModel>::const_iterator i = pm->controls().begin();
for ( ; i != pm->controls().end(); ++i) {
const float value = i->value();
- _engine->set_port_value(translate_load_path(i->port_path()),
- "ingen:Float", sizeof(float), &value);
+ _engine->set_port_value(translate_load_path(i->port_path()), Atom(value));
}
} else {
cerr << "WARNING: Unknown preset: \"" << pm->name() << endl;
diff --git a/src/libs/client/Makefile.am b/src/libs/client/Makefile.am
index 7047ce62..88e2b393 100644
--- a/src/libs/client/Makefile.am
+++ b/src/libs/client/Makefile.am
@@ -18,6 +18,7 @@ libingen_client_la_CXXFLAGS = \
@SLV2_CFLAGS@
libingen_client_la_LIBADD = \
+ ../shared/libingen_shared.la \
@GLIBMM_LIBS@ \
@LIBLO_LIBS@ \
@LSIGCPP_LIBS@ \
diff --git a/src/libs/client/OSCClientReceiver.cpp b/src/libs/client/OSCClientReceiver.cpp
index 856e66cc..091b921b 100644
--- a/src/libs/client/OSCClientReceiver.cpp
+++ b/src/libs/client/OSCClientReceiver.cpp
@@ -31,8 +31,7 @@ namespace Client {
OSCClientReceiver::OSCClientReceiver(int listen_port)
- : ClientInterface("localhost")
- , _listen_port(listen_port)
+ : _listen_port(listen_port)
, _st(NULL)
{
start(false); // true = dump, false = shutup
@@ -159,7 +158,8 @@ OSCClientReceiver::setup_callbacks()
lo_server_thread_add_method(_st, "/ingen/polyphonic", "sT", polyphonic_cb, this);
lo_server_thread_add_method(_st, "/ingen/polyphonic", "sF", polyphonic_cb, this);
lo_server_thread_add_method(_st, "/ingen/set_variable", NULL, set_variable_cb, this);
- lo_server_thread_add_method(_st, "/ingen/control_change", "sf", control_change_cb, this);
+ lo_server_thread_add_method(_st, "/ingen/set_port_value", "sf", set_port_value_cb, this);
+ lo_server_thread_add_method(_st, "/ingen/set_voice_value", "sif", set_voice_value_cb, this);
lo_server_thread_add_method(_st, "/ingen/port_activity", "s", port_activity_cb, this);
lo_server_thread_add_method(_st, "/ingen/program_add", "siis", program_add_cb, this);
lo_server_thread_add_method(_st, "/ingen/program_remove", "sii", program_remove_cb, this);
@@ -321,12 +321,25 @@ OSCClientReceiver::_set_variable_cb(const char* path, const char* types, lo_arg*
int
-OSCClientReceiver::_control_change_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+OSCClientReceiver::_set_port_value_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
const char* const port_path = &argv[0]->s;
const float value = argv[1]->f;
- control_change(port_path, value);
+ set_port_value(port_path, value);
+
+ return 0;
+}
+
+
+int
+OSCClientReceiver::_set_voice_value_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+{
+ const char* const port_path = &argv[0]->s;
+ const int voice = argv[1]->i;
+ const float value = argv[2]->f;
+
+ set_voice_value(port_path, voice, value);
return 0;
}
diff --git a/src/libs/client/OSCClientReceiver.hpp b/src/libs/client/OSCClientReceiver.hpp
index 76689ff2..564e39a9 100644
--- a/src/libs/client/OSCClientReceiver.hpp
+++ b/src/libs/client/OSCClientReceiver.hpp
@@ -97,7 +97,8 @@ private:
LO_HANDLER(new_port);
LO_HANDLER(polyphonic);
LO_HANDLER(set_variable);
- LO_HANDLER(control_change);
+ LO_HANDLER(set_port_value);
+ LO_HANDLER(set_voice_value);
LO_HANDLER(port_activity);
LO_HANDLER(program_add);
LO_HANDLER(program_remove);
diff --git a/src/libs/client/OSCEngineSender.cpp b/src/libs/client/OSCEngineSender.cpp
index e622b37d..5f2db7ad 100644
--- a/src/libs/client/OSCEngineSender.cpp
+++ b/src/libs/client/OSCEngineSender.cpp
@@ -24,21 +24,22 @@ using namespace std;
namespace Ingen {
namespace Client {
+
/** Note the sending port is implicitly set by liblo, lo_send by default sends
* from the most recently created server, so create the OSC listener before
* this to have it all happen on the same port. Yeah, this is a big magic :/
*/
OSCEngineSender::OSCEngineSender(const string& engine_url)
-: _engine_url(engine_url)
-, _engine_addr(lo_address_new_from_url(engine_url.c_str()))
-, _id(0)
+ : _engine_url(engine_url)
+ , _id(0)
{
+ _address = lo_address_new_from_url(engine_url.c_str());
}
OSCEngineSender::~OSCEngineSender()
{
- lo_address_free(_engine_addr);
+ lo_address_free(_address);
}
@@ -55,20 +56,10 @@ OSCEngineSender::~OSCEngineSender()
void
OSCEngineSender::attach(int32_t ping_id, bool block)
{
- //start_listen_thread(_client_port);
-
- /*if (engine_url == "") {
- string local_url = _osc_listener->listen_url().substr(
- 0, _osc_listener->listen_url().find_last_of(":"));
- local_url.append(":16180");
- _engine_addr = lo_address_new_from_url(local_url.c_str());
- } else {
- _engine_addr = lo_address_new_from_url(engine_url.c_str());
- }
- */
- _engine_addr = lo_address_new_from_url(_engine_url.c_str());
+ if (!_address)
+ _address = lo_address_new_from_url(_engine_url.c_str());
- if (_engine_addr == NULL) {
+ if (_address == NULL) {
cerr << "Aborting: Unable to connect to " << _engine_url << endl;
exit(EXIT_FAILURE);
}
@@ -77,24 +68,6 @@ OSCEngineSender::attach(int32_t ping_id, bool block)
_id = ping_id;
this->ping();
-
- /*if (block) {
- set_wait_response_id(request_id);
-
- while (1) {
- if (_response_semaphore.try_wait() != 0) {
- cout << ".";
- cout.flush();
- ping(request_id);
- usleep(100000);
- } else {
- cout << " connected." << endl;
- _waiting_for_response = false;
- break;
- }
- }
- }
- */
}
/* *** EngineInterface implementation below here *** */
@@ -110,72 +83,43 @@ void
OSCEngineSender::register_client(ClientInterface* client)
{
// FIXME: use parameters.. er, somehow.
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/register_client", "i", next_id());
+ send("/ingen/register_client", "i", next_id(), LO_ARGS_END, LO_ARGS_END);
}
void
OSCEngineSender::unregister_client(const string& uri)
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/unregister_client", "i", next_id());
+ send("/ingen/unregister_client", "i", next_id(), LO_ARGS_END);
}
-// Bundles
-
-void
-OSCEngineSender::bundle_begin()
-{
- //cerr << "BUNDLE {" << endl;
- /*assert(!_bundle);
- _bundle = lo_bundle_new(LO_TT_IMMEDIATE);*/
-}
-
-
-void
-OSCEngineSender::bundle_end()
-{
- //cerr << "} BUNDLE" << endl;
- /*assert(_bundle);
- lo_send_bundle(_address, _bundle);
- lo_bundle_free(_bundle);
- _bundle = NULL;*/
-}
-
-
-
// Engine commands
void
OSCEngineSender::load_plugins()
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/load_plugins", "i", next_id());
+ send("/ingen/load_plugins", "i", next_id(), LO_ARGS_END);
}
void
OSCEngineSender::activate()
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/activate", "i", next_id());
+ send("/ingen/activate", "i", next_id(), LO_ARGS_END);
}
void
OSCEngineSender::deactivate()
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/deactivate", "i", next_id());
+ send("/ingen/deactivate", "i", next_id(), LO_ARGS_END);
}
void
OSCEngineSender::quit()
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/quit", "i", next_id());
+ send("/ingen/quit", "i", next_id(), LO_ARGS_END);
}
@@ -186,11 +130,11 @@ void
OSCEngineSender::new_patch(const string& path,
uint32_t poly)
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/new_patch", "isi",
+ send("/ingen/new_patch", "isi",
next_id(),
path.c_str(),
- poly);
+ poly,
+ LO_ARGS_END);
}
@@ -199,12 +143,12 @@ OSCEngineSender::new_port(const string& path,
const string& data_type,
bool is_output)
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/new_port", "issi",
+ send("/ingen/new_port", "issi",
next_id(),
path.c_str(),
data_type.c_str(),
- (is_output ? 1 : 0));
+ (is_output ? 1 : 0),
+ LO_ARGS_END);
}
@@ -213,18 +157,19 @@ OSCEngineSender::new_node(const string& path,
const string& plugin_uri,
bool polyphonic)
{
- assert(_engine_addr);
if (polyphonic)
- lo_send(_engine_addr, "/ingen/new_node", "issT",
+ send("/ingen/new_node", "issT",
next_id(),
path.c_str(),
- plugin_uri.c_str());
+ plugin_uri.c_str(),
+ LO_ARGS_END);
else
- lo_send(_engine_addr, "/ingen/new_node", "issF",
+ send("/ingen/new_node", "issF",
next_id(),
path.c_str(),
- plugin_uri.c_str());
+ plugin_uri.c_str(),
+ LO_ARGS_END);
}
@@ -239,21 +184,22 @@ OSCEngineSender::new_node_deprecated(const string& path,
const string& plugin_label,
bool polyphonic)
{
- assert(_engine_addr);
if (polyphonic)
- lo_send(_engine_addr, "/ingen/new_node", "issssT",
+ send("/ingen/new_node", "issssT",
next_id(),
path.c_str(),
plugin_type.c_str(),
library_name.c_str(),
- plugin_label.c_str());
+ plugin_label.c_str(),
+ LO_ARGS_END);
else
- lo_send(_engine_addr, "/ingen/new_node", "issssF",
+ send("/ingen/new_node", "issssF",
next_id(),
path.c_str(),
plugin_type.c_str(),
library_name.c_str(),
- plugin_label.c_str());
+ plugin_label.c_str(),
+ LO_ARGS_END);
}
@@ -261,57 +207,58 @@ void
OSCEngineSender::rename(const string& old_path,
const string& new_name)
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/rename", "iss",
+ send("/ingen/rename", "iss",
next_id(),
old_path.c_str(),
- new_name.c_str());
+ new_name.c_str(),
+ LO_ARGS_END);
}
void
OSCEngineSender::destroy(const string& path)
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/destroy", "is",
+ send("/ingen/destroy", "is",
next_id(),
- path.c_str());
+ path.c_str(),
+ LO_ARGS_END);
}
void
OSCEngineSender::clear_patch(const string& patch_path)
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/clear_patch", "is",
+ send("/ingen/clear_patch", "is",
next_id(),
- patch_path.c_str());
+ patch_path.c_str(),
+ LO_ARGS_END);
}
void
OSCEngineSender::set_polyphony(const string& patch_path, uint32_t poly)
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/set_polyphony", "isi",
+ send("/ingen/set_polyphony", "isi",
next_id(),
patch_path.c_str(),
- poly);
+ poly,
+ LO_ARGS_END);
}
void
OSCEngineSender::set_polyphonic(const string& path, bool poly)
{
- assert(_engine_addr);
if (poly) {
- lo_send(_engine_addr, "/ingen/set_polyphonic", "isT",
+ send("/ingen/set_polyphonic", "isT",
next_id(),
- path.c_str());
+ path.c_str(),
+ LO_ARGS_END);
} else {
- lo_send(_engine_addr, "/ingen/set_polyphonic", "isF",
+ send("/ingen/set_polyphonic", "isF",
next_id(),
- path.c_str());
+ path.c_str(),
+ LO_ARGS_END);
}
}
@@ -319,20 +266,20 @@ OSCEngineSender::set_polyphonic(const string& path, bool poly)
void
OSCEngineSender::enable_patch(const string& patch_path)
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/enable_patch", "is",
+ send("/ingen/enable_patch", "is",
next_id(),
- patch_path.c_str());
+ patch_path.c_str(),
+ LO_ARGS_END);
}
void
OSCEngineSender::disable_patch(const string& patch_path)
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/disable_patch", "is",
+ send("/ingen/disable_patch", "is",
next_id(),
- patch_path.c_str());
+ patch_path.c_str(),
+ LO_ARGS_END);
}
@@ -340,11 +287,11 @@ void
OSCEngineSender::connect(const string& src_port_path,
const string& dst_port_path)
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/connect", "iss",
+ send("/ingen/connect", "iss",
next_id(),
src_port_path.c_str(),
- dst_port_path.c_str());
+ dst_port_path.c_str(),
+ LO_ARGS_END);
}
@@ -352,11 +299,11 @@ void
OSCEngineSender::disconnect(const string& src_port_path,
const string& dst_port_path)
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/disconnect", "iss",
+ send("/ingen/disconnect", "iss",
next_id(),
src_port_path.c_str(),
- dst_port_path.c_str());
+ dst_port_path.c_str(),
+ LO_ARGS_END);
}
@@ -364,144 +311,79 @@ void
OSCEngineSender::disconnect_all(const string& parent_patch_path,
const string& node_path)
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/disconnect_all", "iss",
+ send("/ingen/disconnect_all", "iss",
next_id(),
parent_patch_path.c_str(),
- node_path.c_str());
+ node_path.c_str(),
+ LO_ARGS_END);
}
void
-OSCEngineSender::set_port_value(const string& port_path,
- const string& type_uri,
- uint32_t data_size,
- const void* data)
+OSCEngineSender::set_port_value(const string& port_path,
+ const Raul::Atom& value)
{
- assert(_engine_addr);
- if (type_uri == "ingen:Float") {
- assert(data_size == 4);
- lo_send(_engine_addr, "/ingen/set_port_value", "isf",
- next_id(),
- port_path.c_str(),
- *(float*)data);
- } else if (type_uri == "lv2_midi:MidiEvent") {
- lo_blob b = lo_blob_new(data_size, (void*)data);
- lo_send(_engine_addr, "/ingen/set_port_value", "issb",
- next_id(),
- port_path.c_str(),
- type_uri.c_str(),
- b);
- lo_blob_free(b);
- // FIXME: support atomic bundles of events here
- } else {
- cerr << "ERROR: Unknown value type '" << type_uri << "', ignoring" << endl;
- }
+ lo_message m = lo_message_new();
+ lo_message_add_string(m, port_path.c_str());
+ Raul::AtomLiblo::lo_message_add_atom(m, value);
+ send_message("/ingen/set_port_value", m);
}
void
-OSCEngineSender::set_port_value(const string& port_path,
- const string& type_uri,
- uint32_t voice,
- uint32_t data_size,
- const void* data)
+OSCEngineSender::set_voice_value(const string& port_path,
+ uint32_t voice,
+ const Raul::Atom& value)
{
- assert(_engine_addr);
- if (type_uri == "ingen:Float") {
- assert(data_size == 4);
- lo_send(_engine_addr, "/ingen/set_port_value", "isf",
- next_id(),
- port_path.c_str(),
- *(float*)data);
- } else if (type_uri == "lv2_midi:MidiEvent") {
- lo_blob b = lo_blob_new(data_size, (void*)data);
- lo_send(_engine_addr, "/ingen/set_port_value", "issb",
- next_id(),
- port_path.c_str(),
- type_uri.c_str(),
- b);
- lo_blob_free(b);
- } else {
- cerr << "ERROR: Unknown value type '" << type_uri << "', ignoring" << endl;
- }
+ lo_message m = lo_message_new();
+ lo_message_add_string(m, port_path.c_str());
+ lo_message_add_int32(m, voice);
+ Raul::AtomLiblo::lo_message_add_atom(m, value);
+ send_message("/ingen/set_port_value", m);
}
void
-OSCEngineSender::set_port_value_immediate(const string& port_path,
- const string& type_uri,
- uint32_t data_size,
- const void* data)
+OSCEngineSender::set_port_value_immediate(const string& port_path,
+ const Raul::Atom& value)
{
- assert(_engine_addr);
-
- if (type_uri == "ingen:Float") {
- assert(data_size == 4);
- lo_send(_engine_addr, "/ingen/set_port_value_immediate", "isf",
- next_id(),
- port_path.c_str(),
- *(float*)data);
- } else if (type_uri == "lv2_midi:MidiEvent") {
- lo_blob b = lo_blob_new(data_size, (void*)data);
- lo_send(_engine_addr, "/ingen/set_port_value_immediate", "issb",
- next_id(),
- port_path.c_str(),
- type_uri.c_str(),
- b);
- lo_blob_free(b);
- } else {
- cerr << "ERROR: Unknown value type '" << type_uri << "', ignoring" << endl;
- }
+ lo_message m = lo_message_new();
+ lo_message_add_string(m, port_path.c_str());
+ Raul::AtomLiblo::lo_message_add_atom(m, value);
+ send_message("/ingen/set_port_value_immediate", m);
}
void
-OSCEngineSender::set_port_value_immediate(const string& port_path,
- const string& type_uri,
- uint32_t voice,
- uint32_t data_size,
- const void* data)
+OSCEngineSender::set_voice_value_immediate(const string& port_path,
+ uint32_t voice,
+ const Raul::Atom& value)
{
- assert(_engine_addr);
-
- if (type_uri == "ingen:Float") {
- assert(data_size == 4);
- lo_send(_engine_addr, "/ingen/set_port_value_immediate", "isif",
- next_id(),
- port_path.c_str(),
- voice,
- *(float*)data);
- } else if (type_uri == "lv2_midi:MidiEvent") {
- lo_blob b = lo_blob_new(data_size, (void*)data);
- lo_send(_engine_addr, "/ingen/set_port_value_immediate", "isisb",
- next_id(),
- port_path.c_str(),
- voice,
- type_uri.c_str(),
- b);
- lo_blob_free(b);
- } else {
- cerr << "ERROR: Unknown value type '" << type_uri << "', ignoring" << endl;
- }
+ lo_message m = lo_message_new();
+ lo_message_add_string(m, port_path.c_str());
+ lo_message_add_int32(m, voice);
+ Raul::AtomLiblo::lo_message_add_atom(m, value);
+ send_message("/ingen/set_port_value_immediate", m);
}
void
OSCEngineSender::enable_port_broadcasting(const string& port_path)
{
- lo_send(_engine_addr, "/ingen/enable_port_broadcasting", "is",
+ send("/ingen/enable_port_broadcasting", "is",
next_id(),
- port_path.c_str());
+ port_path.c_str(),
+ LO_ARGS_END);
}
void
OSCEngineSender::disable_port_broadcasting(const string& port_path)
{
- lo_send(_engine_addr, "/ingen/disable_port_broadcasting", "is",
+ send("/ingen/disable_port_broadcasting", "is",
next_id(),
- port_path.c_str());
+ port_path.c_str(),
+ LO_ARGS_END);
}
@@ -510,22 +392,21 @@ OSCEngineSender::set_program(const string& node_path,
uint32_t bank,
uint32_t program)
{
- assert(_engine_addr);
- lo_send(_engine_addr,
- (string("/dssi") + node_path + "/program").c_str(),
+ send((string("/dssi") + node_path + "/program").c_str(),
"ii",
bank,
- program);
+ program,
+ LO_ARGS_END);
}
void
OSCEngineSender::midi_learn(const string& node_path)
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/midi_learn", "is",
+ send("/ingen/midi_learn", "is",
next_id(),
- node_path.c_str());
+ node_path.c_str(),
+ LO_ARGS_END);
}
@@ -535,13 +416,12 @@ OSCEngineSender::set_variable(const string& obj_path,
const Raul::Atom& value)
{
- assert(_engine_addr);
lo_message m = lo_message_new();
lo_message_add_int32(m, next_id());
lo_message_add_string(m, obj_path.c_str());
lo_message_add_string(m, predicate.c_str());
Raul::AtomLiblo::lo_message_add_atom(m, value);
- lo_send_message(_engine_addr, "/ingen/set_variable", m);
+ send_message("/ingen/set_variable", m);
}
@@ -550,64 +430,61 @@ OSCEngineSender::set_variable(const string& obj_path,
void
OSCEngineSender::ping()
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/ping", "i", next_id());
+ send("/ingen/ping", "i", next_id(), LO_ARGS_END);
}
void
OSCEngineSender::request_plugin(const string& uri)
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/request_plugin", "is",
+ send("/ingen/request_plugin", "is",
next_id(),
- uri.c_str());
+ uri.c_str(),
+ LO_ARGS_END);
}
void
OSCEngineSender::request_object(const string& path)
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/request_object", "is",
+ send("/ingen/request_object", "is",
next_id(),
- path.c_str());
+ path.c_str(),
+ LO_ARGS_END);
}
void
OSCEngineSender::request_port_value(const string& port_path)
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/request_port_value", "is",
+ send("/ingen/request_port_value", "is",
next_id(),
- port_path.c_str());
+ port_path.c_str(),
+ LO_ARGS_END);
}
void
OSCEngineSender::request_variable(const string& object_path, const string& key)
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/request_variable", "iss",
+ send("/ingen/request_variable", "iss",
next_id(),
object_path.c_str(),
- key.c_str());
+ key.c_str(),
+ LO_ARGS_END);
}
void
OSCEngineSender::request_plugins()
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/request_plugins", "i", next_id());
+ send("/ingen/request_plugins", "i", next_id(), LO_ARGS_END);
}
void
OSCEngineSender::request_all_objects()
{
- assert(_engine_addr);
- lo_send(_engine_addr, "/ingen/request_all_objects", "i", next_id());
+ send("/ingen/request_all_objects", "i", next_id(), LO_ARGS_END);
}
diff --git a/src/libs/client/OSCEngineSender.hpp b/src/libs/client/OSCEngineSender.hpp
index 0c317608..d32a4849 100644
--- a/src/libs/client/OSCEngineSender.hpp
+++ b/src/libs/client/OSCEngineSender.hpp
@@ -22,6 +22,7 @@
#include <string>
#include <lo/lo.h>
#include "interface/EngineInterface.hpp"
+#include "shared/OSCSender.hpp"
using std::string;
using Ingen::Shared::EngineInterface;
using Ingen::Shared::ClientInterface;
@@ -37,8 +38,7 @@ namespace Client {
*
* \ingroup IngenClient
*/
-class OSCEngineSender : public EngineInterface
-{
+class OSCEngineSender : public EngineInterface, public Shared::OSCSender {
public:
OSCEngineSender(const string& engine_url);
@@ -46,7 +46,7 @@ public:
string engine_url() { return _engine_url; }
- inline size_t next_id()
+ inline int32_t next_id()
{ int32_t ret = (_id == -1) ? -1 : _id++; return ret; }
void set_next_response_id(int32_t id) { _id = id; }
@@ -56,6 +56,14 @@ public:
/* *** EngineInterface implementation below here *** */
+
+ void enable() { _enabled = true; }
+ void disable() { _enabled = false; }
+
+ void bundle_begin() { OSCSender::bundle_begin(); }
+ void bundle_end() { OSCSender::bundle_end(); }
+ void transfer_begin() { OSCSender::transfer_begin(); }
+ void transfer_end() { OSCSender::transfer_end(); }
// Client registration
void register_client(ClientInterface* client);
@@ -67,10 +75,6 @@ public:
void deactivate();
void quit();
- // Bundles
- void bundle_begin();
- void bundle_end();
-
// Object commands
void new_patch(const string& path,
@@ -114,27 +118,19 @@ public:
void disconnect_all(const string& parent_patch_path,
const string& node_path);
- void set_port_value(const string& port_path,
- const string& type_uri,
- uint32_t data_size,
- const void* data);
+ void set_port_value(const string& port_path,
+ const Raul::Atom& value);
- void set_port_value(const string& port_path,
- const string& type_uri,
- uint32_t voice,
- uint32_t data_size,
- const void* data);
+ void set_voice_value(const string& port_path,
+ uint32_t voice,
+ const Raul::Atom& value);
- void set_port_value_immediate(const string& port_path,
- const string& type_uri,
- uint32_t data_size,
- const void* data);
+ void set_port_value_immediate(const string& port_path,
+ const Raul::Atom& value);
- void set_port_value_immediate(const string& port_path,
- const string& type_uri,
- uint32_t voice,
- uint32_t data_size,
- const void* data);
+ void set_voice_value_immediate(const string& port_path,
+ uint32_t voice,
+ const Raul::Atom& value);
void enable_port_broadcasting(const string& port_path);
@@ -167,9 +163,7 @@ public:
void request_all_objects();
protected:
- lo_bundle _bundle;
string _engine_url;
- lo_address _engine_addr;
int _client_port;
int32_t _id;
};
diff --git a/src/libs/client/PluginUI.cpp b/src/libs/client/PluginUI.cpp
index f2f591bd..df958f06 100644
--- a/src/libs/client/PluginUI.cpp
+++ b/src/libs/client/PluginUI.cpp
@@ -64,9 +64,7 @@ lv2_ui_write(LV2UI_Controller controller,
if (*(float*)buffer == port->value().get_float())
return; // do nothing (handle stupid plugin UIs that feed back)
- ui->world()->engine->set_port_value_immediate(port->path(),
- port->type().uri(),
- buffer_size, buffer);
+ ui->world()->engine->set_port_value_immediate(port->path(), Atom(*(float*)buffer));
// FIXME: slow, need to cache ID
} else if (format == map->uri_to_id(NULL, "http://lv2plug.in/ns/extensions/ui#Events")) {
@@ -80,7 +78,7 @@ lv2_ui_write(LV2UI_Controller controller,
if (ev->type == midi_event_type) {
// FIXME: bundle multiple events by writing an entire buffer here
ui->world()->engine->set_port_value_immediate(port->path(),
- "lv2_midi:MidiEvent", ev->size, data);
+ Atom("lv2_midi:MidiEvent", ev->size, data));
} else {
cerr << "WARNING: Unable to send event type " << ev->type <<
" over OSC, ignoring event" << endl;
diff --git a/src/libs/client/SigClientInterface.hpp b/src/libs/client/SigClientInterface.hpp
index d1ea30f2..6463bf3a 100644
--- a/src/libs/client/SigClientInterface.hpp
+++ b/src/libs/client/SigClientInterface.hpp
@@ -42,6 +42,8 @@ class SigClientInterface : virtual public Ingen::Shared::ClientInterface, public
public:
SigClientInterface() : _enabled(true) {}
+ std::string uri() const { return "(internal)"; }
+
// Signal parameters match up directly with ClientInterface calls
sigc::signal<void, int32_t> signal_response_ok;
@@ -64,7 +66,8 @@ public:
sigc::signal<void, string, string> signal_connection;
sigc::signal<void, string, string> signal_disconnection;
sigc::signal<void, string, string, Raul::Atom> signal_variable_change;
- sigc::signal<void, string, float> signal_control_change;
+ sigc::signal<void, string, Raul::Atom> signal_port_value;
+ sigc::signal<void, string, uint32_t, Raul::Atom> signal_voice_value;
sigc::signal<void, string> signal_port_activity;
sigc::signal<void, string, uint32_t, uint32_t, string> signal_program_add;
sigc::signal<void, string, uint32_t, uint32_t> signal_program_remove;
@@ -143,8 +146,11 @@ protected:
void set_variable(const string& path, const string& key, const Raul::Atom& value)
{ if (_enabled) signal_variable_change.emit(path, key, value); }
- void control_change(const string& port_path, float value)
- { if (_enabled) signal_control_change.emit(port_path, value); }
+ void set_port_value(const string& port_path, const Raul::Atom& value)
+ { if (_enabled) signal_port_value.emit(port_path, value); }
+
+ void set_voice_value(const string& port_path, uint32_t voice, const Raul::Atom& value)
+ { if (_enabled) signal_voice_value.emit(port_path, voice, value); }
void port_activity(const string& port_path)
{ if (_enabled) signal_port_activity.emit(port_path); }
diff --git a/src/libs/client/ThreadedSigClientInterface.hpp b/src/libs/client/ThreadedSigClientInterface.hpp
index 03c638bb..ccdbf318 100644
--- a/src/libs/client/ThreadedSigClientInterface.hpp
+++ b/src/libs/client/ThreadedSigClientInterface.hpp
@@ -64,12 +64,14 @@ public:
, object_renamed_slot(signal_object_renamed.make_slot())
, disconnection_slot(signal_disconnection.make_slot())
, variable_change_slot(signal_variable_change.make_slot())
- , control_change_slot(signal_control_change.make_slot())
+ , port_value_slot(signal_port_value.make_slot())
, port_activity_slot(signal_port_activity.make_slot())
, program_add_slot(signal_program_add.make_slot())
, program_remove_slot(signal_program_remove.make_slot())
{}
+ virtual std::string uri() const { return "(internal)"; }
+
virtual void subscribe(Shared::EngineInterface* engine) { throw; }
void bundle_begin()
@@ -134,8 +136,11 @@ public:
void set_variable(const string& path, const string& key, const Raul::Atom& value)
{ push_sig(sigc::bind(variable_change_slot, path, key, value)); }
- void control_change(const string& port_path, float value)
- { push_sig(sigc::bind(control_change_slot, port_path, value)); }
+ void set_port_value(const string& port_path, const Raul::Atom& value)
+ { push_sig(sigc::bind(port_value_slot, port_path, value)); }
+
+ void set_voice_value(const string& port_path, uint32_t voice, const Raul::Atom& value)
+ { push_sig(sigc::bind(voice_value_slot, port_path, voice, value)); }
void port_activity(const string& port_path)
{ push_sig(sigc::bind(port_activity_slot, port_path)); }
@@ -175,7 +180,8 @@ private:
sigc::slot<void, string, string> object_renamed_slot;
sigc::slot<void, string, string> disconnection_slot;
sigc::slot<void, string, string, Raul::Atom> variable_change_slot;
- sigc::slot<void, string, float> control_change_slot;
+ sigc::slot<void, string, Raul::Atom> port_value_slot;
+ sigc::slot<void, string, uint32_t, Raul::Atom> voice_value_slot;
sigc::slot<void, string> port_activity_slot;
sigc::slot<void, string, uint32_t, uint32_t, string> program_add_slot;
sigc::slot<void, string, uint32_t, uint32_t> program_remove_slot;
diff --git a/src/libs/engine/ClientBroadcaster.cpp b/src/libs/engine/ClientBroadcaster.cpp
index 7e54f994..949784c3 100644
--- a/src/libs/engine/ClientBroadcaster.cpp
+++ b/src/libs/engine/ClientBroadcaster.cpp
@@ -235,10 +235,10 @@ ClientBroadcaster::send_variable_change(const string& node_path, const string& k
* forcing clients to ignore things to avoid feedback loops etc).
*/
void
-ClientBroadcaster::send_control_change(const string& port_path, float value)
+ClientBroadcaster::send_port_value(const string& port_path, const Raul::Atom& value)
{
for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
- (*i).second->control_change(port_path, value);
+ (*i).second->set_port_value(port_path, value);
}
diff --git a/src/libs/engine/ClientBroadcaster.hpp b/src/libs/engine/ClientBroadcaster.hpp
index 800f6950..323a1912 100644
--- a/src/libs/engine/ClientBroadcaster.hpp
+++ b/src/libs/engine/ClientBroadcaster.hpp
@@ -80,7 +80,7 @@ public:
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_control_change(const string& port_path, float 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);
void send_program_remove(const string& node_path, int bank, int program);
diff --git a/src/libs/engine/OSCClientSender.cpp b/src/libs/engine/OSCClientSender.cpp
index c9b156db..60edbe07 100644
--- a/src/libs/engine/OSCClientSender.cpp
+++ b/src/libs/engine/OSCClientSender.cpp
@@ -35,90 +35,6 @@ using namespace std;
namespace Ingen {
-void
-OSCClientSender::bundle_begin()
-{
- assert(!_transfer);
- _transfer = lo_bundle_new(LO_TT_IMMEDIATE);
- _send_state = SendingBundle;
-
-}
-
-void
-OSCClientSender::bundle_end()
-{
- transfer_end();
-}
-
-
-void
-OSCClientSender::transfer_begin()
-{
- //cerr << "TRANSFER {" << endl;
- assert(!_transfer);
- _transfer = lo_bundle_new(LO_TT_IMMEDIATE);
- _send_state = SendingTransfer;
-}
-
-
-void
-OSCClientSender::transfer_end()
-{
- //cerr << "} TRANSFER" << endl;
- assert(_transfer);
- lo_send_bundle(_address, _transfer);
- lo_bundle_free(_transfer);
- _transfer = NULL;
- _send_state = Immediate;
-}
-
-
-int
-OSCClientSender::send(const char *path, const char *types, ...)
-{
- if (!_enabled)
- return 0;
-
- va_list args;
- va_start(args, types);
-
- lo_message msg = lo_message_new();
- int ret = lo_message_add_varargs(msg, types, args);
-
- if (!ret)
- send_message(path, msg);
-
- va_end(args);
-
- return ret;
-}
-
-
-void
-OSCClientSender::send_message(const char* path, lo_message msg)
-{
- // FIXME: size? liblo doesn't export this.
- // Don't want to exceed max UDP packet size (1500 bytes?)
- static const size_t MAX_BUNDLE_SIZE = 1500 - 32*5;
-
- if (!_enabled)
- return;
-
- if (_transfer) {
- if (lo_bundle_length(_transfer) + lo_message_length(msg, path) > MAX_BUNDLE_SIZE) {
- if (_send_state == SendingBundle)
- cerr << "WARNING: Maximum bundle size reached, bundle split" << endl;
- lo_send_bundle(_address, _transfer);
- _transfer = lo_bundle_new(LO_TT_IMMEDIATE);
- }
- lo_bundle_add_message(_transfer, path, msg);
-
- } else {
- lo_send_message(_address, path, msg);
- }
-}
-
-
/*! \page client_osc_namespace Client OSC Namespace Documentation
*
@@ -460,14 +376,33 @@ OSCClientSender::set_variable(const std::string& path, const std::string& key, c
/** \page client_osc_namespace
- * <p> \b /ingen/control_change - Notification the value of a port has changed
+ * <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
+ */
+void
+OSCClientSender::set_port_value(const std::string& port_path, const Raul::Atom& value)
+{
+ lo_message m = lo_message_new();
+ lo_message_add_string(m, port_path.c_str());
+ Raul::AtomLiblo::lo_message_add_atom(m, value);
+ send_message("/ingen/set_port_value", 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 (float) - New value of port </p> \n \n
+ * \arg \b voice (int) - Voice which is set to this value
+ * \arg \b value (any) - New value of port </p> \n \n
*/
void
-OSCClientSender::control_change(const std::string& port_path, float value)
+OSCClientSender::set_voice_value(const std::string& port_path, uint32_t voice, const Raul::Atom& value)
{
- send("/ingen/control_change", "sf", port_path.c_str(), value, LO_ARGS_END);
+ lo_message m = lo_message_new();
+ lo_message_add_string(m, port_path.c_str());
+ Raul::AtomLiblo::lo_message_add_atom(m, value);
+ send_message("/ingen/set_port_value", m);
}
diff --git a/src/libs/engine/OSCClientSender.hpp b/src/libs/engine/OSCClientSender.hpp
index cc700e38..662ba75b 100644
--- a/src/libs/engine/OSCClientSender.hpp
+++ b/src/libs/engine/OSCClientSender.hpp
@@ -21,15 +21,11 @@
#include <cassert>
#include <string>
#include <iostream>
-#include <list>
#include <lo/lo.h>
#include <pthread.h>
#include "types.hpp"
#include "interface/ClientInterface.hpp"
-
-using std::list;
-using std::string;
-using std::cerr;
+#include "shared/OSCSender.hpp"
namespace Ingen {
@@ -40,35 +36,33 @@ namespace Shared { class EngineInterface; }
*
* \ingroup engine
*/
-class OSCClientSender : public Shared::ClientInterface
+class OSCClientSender : public Shared::ClientInterface, public Shared::OSCSender
{
public:
OSCClientSender(const std::string& url)
- : Shared::ClientInterface(url)
- , _address(lo_address_new_from_url(url.c_str()))
- , _transfer(NULL)
- , _enabled(true)
- {}
+ : _url(url)
+ {
+ _address = lo_address_new_from_url(url.c_str());
+ }
virtual ~OSCClientSender()
{ lo_address_free(_address); }
-
- lo_address address() const { return _address; }
+
+ void enable() { _enabled = true; }
+ void disable() { _enabled = false; }
+
+ void bundle_begin() { OSCSender::bundle_begin(); }
+ void bundle_end() { OSCSender::bundle_end(); }
+ void transfer_begin() { OSCSender::transfer_begin(); }
+ void transfer_end() { OSCSender::transfer_end(); }
+
+ std::string uri() const { return lo_address_get_url(_address); }
void subscribe(Shared::EngineInterface* engine) { }
/* *** ClientInterface Implementation Below *** */
//void client_registration(const std::string& url, int client_id);
-
- void enable() { _enabled = true; }
- void disable() { _enabled = false; }
-
- void bundle_begin();
- void bundle_end();
-
- void transfer_begin();
- void transfer_end();
void response_ok(int32_t id);
void response_error(int32_t id, const std::string& msg);
@@ -120,8 +114,12 @@ public:
const std::string& predicate,
const Raul::Atom& value);
- virtual void control_change(const std::string& port_path,
- float value);
+ virtual void set_port_value(const std::string& port_path,
+ const Raul::Atom& value);
+
+ virtual void set_voice_value(const std::string& port_path,
+ uint32_t voice,
+ const Raul::Atom& value);
virtual void port_activity(const std::string& port_path);
@@ -135,16 +133,7 @@ public:
uint32_t program);
private:
- int send(const char *path, const char *types, ...);
- void send_message(const char* path, lo_message m);
-
- enum SendState { Immediate, SendingBundle, SendingTransfer };
-
- string _url;
- lo_address _address;
- SendState _send_state;
- lo_bundle _transfer;
- bool _enabled;
+ std::string _url;
};
diff --git a/src/libs/engine/OSCEngineReceiver.cpp b/src/libs/engine/OSCEngineReceiver.cpp
index 4cc27367..74947917 100644
--- a/src/libs/engine/OSCEngineReceiver.cpp
+++ b/src/libs/engine/OSCEngineReceiver.cpp
@@ -639,23 +639,26 @@ OSCEngineReceiver::_set_port_value_immediate_cb(const char* path, const char* ty
return 1;
const char* port_path = &argv[1]->s;
+ using Raul::Atom;
if (!strcmp(types, "isf")) { // float, all voices
const float value = argv[2]->f;
- set_port_value_immediate(port_path, "ingen:Float", sizeof(float), &value);
+ set_port_value_immediate(port_path, Atom(value));
} else if (!strcmp(types, "isif")) { // float, specific voice
const float value = argv[3]->f;
- set_port_value_immediate(port_path, "ingen:Float", argv[2]->i, sizeof(float), &value);
+ set_voice_value_immediate(port_path, argv[2]->i, Atom(value));
} else if (!strcmp(types, "issb")) { // blob (event), all voices
+ const char* type = &argv[2]->s;
lo_blob b = argv[3];
size_t data_size = lo_blob_datasize(b);
void* data = lo_blob_dataptr(b);
- set_port_value_immediate(port_path, &argv[2]->s, data_size, data);
+ set_port_value_immediate(port_path, Atom(type, data_size, data));
} else if (!strcmp(types, "isisb")) { // blob (event), specific voice
+ const char* type = &argv[3]->s;
lo_blob b = argv[4];
size_t data_size = lo_blob_datasize(b);
void* data = lo_blob_dataptr(b);
- set_port_value_immediate(port_path, &argv[3]->s, argv[2]->i, data_size, data);
+ set_voice_value_immediate(port_path, argv[2]->i, Atom(type, data_size, data));
} else {
return 1;
}
@@ -700,22 +703,26 @@ OSCEngineReceiver::_set_port_value_cb(const char* path, const char* types, lo_ar
const char* port_path = &argv[1]->s;
+ using Raul::Atom;
+
if (!strcmp(types, "isf")) { // float, all voices
const float value = argv[2]->f;
- set_port_value_immediate(port_path, "ingen:Float", sizeof(float), &value);
+ set_port_value_immediate(port_path, Atom(value));
} else if (!strcmp(types, "isif")) { // float, specific voice
const float value = argv[3]->f;
- set_port_value_immediate(port_path, "ingen:Float", argv[2]->i, sizeof(float), &value);
+ set_voice_value_immediate(port_path, argv[2]->i, Atom(value));
} else if (!strcmp(types, "issb")) { // blob (event), all voices
+ const char* type = &argv[2]->s;
lo_blob b = argv[3];
size_t data_size = lo_blob_datasize(b);
void* data = lo_blob_dataptr(b);
- set_port_value_immediate(port_path, &argv[2]->s, data_size, data);
+ set_port_value_immediate(port_path, Atom(type, data_size, data));
} else if (!strcmp(types, "isisb")) { // blob (event), specific voice
+ const char* type = &argv[3]->s;
lo_blob b = argv[4];
size_t data_size = lo_blob_datasize(b);
void* data = lo_blob_dataptr(b);
- set_port_value_immediate(port_path, &argv[3]->s, argv[2]->i, data_size, data);
+ set_voice_value_immediate(port_path, argv[2]->i, Atom(type, data_size, data));
} else {
return 1;
}
diff --git a/src/libs/engine/ObjectSender.cpp b/src/libs/engine/ObjectSender.cpp
index 5e456dbc..0bbe6533 100644
--- a/src/libs/engine/ObjectSender.cpp
+++ b/src/libs/engine/ObjectSender.cpp
@@ -132,7 +132,7 @@ ObjectSender::send_port(ClientInterface* client, const PortImpl* port)
if (port->type() == DataType::CONTROL) {
const Sample value = dynamic_cast<const AudioBuffer*>(port->buffer(0))->value_at(0);
//cerr << port->path() << " sending default value " << default_value << endl;
- client->control_change(port->path(), value);
+ client->set_port_value(port->path(), value);
}
client->bundle_end();
diff --git a/src/libs/engine/QueuedEngineInterface.cpp b/src/libs/engine/QueuedEngineInterface.cpp
index 65f2c14b..6593ec81 100644
--- a/src/libs/engine/QueuedEngineInterface.cpp
+++ b/src/libs/engine/QueuedEngineInterface.cpp
@@ -250,44 +250,36 @@ QueuedEngineInterface::disconnect_all(const string& patch_path,
void
-QueuedEngineInterface::set_port_value(const string& port_path,
- const string& type_uri,
- uint32_t data_size,
- const void* data)
+QueuedEngineInterface::set_port_value(const string& port_path,
+ const Raul::Atom& value)
{
- push_queued(new SetPortValueEvent(_engine, _responder, true, now(), port_path, type_uri, data_size, data));
+ push_queued(new SetPortValueEvent(_engine, _responder, true, now(), port_path, value));
}
void
-QueuedEngineInterface::set_port_value(const string& port_path,
- const string& type_uri,
- uint32_t voice,
- uint32_t data_size,
- const void* data)
+QueuedEngineInterface::set_voice_value(const string& port_path,
+ uint32_t voice,
+ const Raul::Atom& value)
{
- push_queued(new SetPortValueEvent(_engine, _responder, true, now(), voice, port_path, type_uri, data_size, data));
+ push_queued(new SetPortValueEvent(_engine, _responder, true, now(), voice, port_path, value));
}
void
-QueuedEngineInterface::set_port_value_immediate(const string& port_path,
- const string& type_uri,
- uint32_t data_size,
- const void* data)
+QueuedEngineInterface::set_port_value_immediate(const string& port_path,
+ const Raul::Atom& value)
{
- push_stamped(new SetPortValueEvent(_engine, _responder, false, now(), port_path, type_uri, data_size, data));
+ push_stamped(new SetPortValueEvent(_engine, _responder, false, now(), port_path, value));
}
void
-QueuedEngineInterface::set_port_value_immediate(const string& port_path,
- const string& type_uri,
- uint32_t voice,
- uint32_t data_size,
- const void* data)
+QueuedEngineInterface::set_voice_value_immediate(const string& port_path,
+ uint32_t voice,
+ const Raul::Atom& value)
{
- push_stamped(new SetPortValueEvent(_engine, _responder, false, now(), voice, port_path, type_uri, data_size, data));
+ push_stamped(new SetPortValueEvent(_engine, _responder, false, now(), voice, port_path, value));
}
diff --git a/src/libs/engine/QueuedEngineInterface.hpp b/src/libs/engine/QueuedEngineInterface.hpp
index 280e9b4e..3d8b8d12 100644
--- a/src/libs/engine/QueuedEngineInterface.hpp
+++ b/src/libs/engine/QueuedEngineInterface.hpp
@@ -123,27 +123,19 @@ public:
virtual void disconnect_all(const string& patch_path,
const string& node_path);
- virtual void set_port_value(const string& port_path,
- const string& type_uri,
- uint32_t data_size,
- const void* data);
+ virtual void set_port_value(const string& port_path,
+ const Raul::Atom& value);
- virtual void set_port_value(const string& port_path,
- const string& type_uri,
- uint32_t voice,
- uint32_t data_size,
- const void* data);
+ virtual void set_voice_value(const string& port_path,
+ uint32_t voice,
+ const Raul::Atom& value);
virtual void set_port_value_immediate(const string& port_path,
- const string& type_uri,
- uint32_t data_size,
- const void* data);
+ const Raul::Atom& value);
- virtual void set_port_value_immediate(const string& port_path,
- const string& type_uri,
- uint32_t voice,
- uint32_t data_size,
- const void* data);
+ virtual void set_voice_value_immediate(const string& port_path,
+ uint32_t voice,
+ const Raul::Atom& value);
virtual void enable_port_broadcasting(const string& port_path);
diff --git a/src/libs/engine/events/MidiLearnEvent.cpp b/src/libs/engine/events/MidiLearnEvent.cpp
index 45216e70..2f37f30d 100644
--- a/src/libs/engine/events/MidiLearnEvent.cpp
+++ b/src/libs/engine/events/MidiLearnEvent.cpp
@@ -32,7 +32,7 @@ namespace Ingen {
void
MidiLearnResponseEvent::post_process()
{
- _engine.broadcaster()->send_control_change(_port_path, _value);
+ _engine.broadcaster()->send_port_value(_port_path, _value);
}
diff --git a/src/libs/engine/events/RequestPortValueEvent.cpp b/src/libs/engine/events/RequestPortValueEvent.cpp
index 20203f88..025d3700 100644
--- a/src/libs/engine/events/RequestPortValueEvent.cpp
+++ b/src/libs/engine/events/RequestPortValueEvent.cpp
@@ -70,7 +70,7 @@ RequestPortValueEvent::post_process()
_responder->respond_error("Unable to find port for get_value responder.");
} else if (_responder->client()) {
_responder->respond_ok();
- _responder->client()->control_change(_port_path, _value);
+ _responder->client()->set_port_value(_port_path, _value);
} else {
_responder->respond_error("Unable to find client to send port value");
}
diff --git a/src/libs/engine/events/SendPortValueEvent.cpp b/src/libs/engine/events/SendPortValueEvent.cpp
index 89e8c9e0..d3fb0d36 100644
--- a/src/libs/engine/events/SendPortValueEvent.cpp
+++ b/src/libs/engine/events/SendPortValueEvent.cpp
@@ -32,9 +32,9 @@ SendPortValueEvent::post_process()
// FIXME...
if (_omni) {
- _engine.broadcaster()->send_control_change(_port->path(), _value);
+ _engine.broadcaster()->send_port_value(_port->path(), _value);
} else {
- _engine.broadcaster()->send_control_change(_port->path(), _value);
+ _engine.broadcaster()->send_port_value(_port->path(), _value);
}
}
diff --git a/src/libs/engine/events/SetPortValueEvent.cpp b/src/libs/engine/events/SetPortValueEvent.cpp
index 01263d2c..f69ba9a3 100644
--- a/src/libs/engine/events/SetPortValueEvent.cpp
+++ b/src/libs/engine/events/SetPortValueEvent.cpp
@@ -39,21 +39,16 @@ SetPortValueEvent::SetPortValueEvent(Engine& engine,
bool queued,
SampleCount timestamp,
const string& port_path,
- const string& data_type,
- uint32_t data_size,
- const void* data)
+ const Raul::Atom& value)
: QueuedEvent(engine, responder, timestamp)
, _queued(queued)
, _omni(true)
, _voice_num(0)
, _port_path(port_path)
- , _data_type(data_type)
- , _data_size(data_size)
- , _data(malloc(data_size))
+ , _value(value)
, _port(NULL)
, _error(NO_ERROR)
{
- memcpy(_data, data, data_size);
}
@@ -64,27 +59,21 @@ SetPortValueEvent::SetPortValueEvent(Engine& engine,
SampleCount timestamp,
uint32_t voice_num,
const string& port_path,
- const string& data_type,
- uint32_t data_size,
- const void* data)
+ const Raul::Atom& value)
: QueuedEvent(engine, responder, timestamp)
, _queued(queued)
, _omni(false)
, _voice_num(voice_num)
, _port_path(port_path)
- , _data_type(data_type)
- , _data_size(data_size)
- , _data(malloc(data_size))
+ , _value(value)
, _port(NULL)
, _error(NO_ERROR)
{
- memcpy(_data, data, data_size);
}
SetPortValueEvent::~SetPortValueEvent()
{
- free(_data);
}
@@ -129,13 +118,19 @@ SetPortValueEvent::execute(ProcessContext& context)
Buffer* const buf = _port->buffer(0);
AudioBuffer* const abuf = dynamic_cast<AudioBuffer*>(buf);
if (abuf) {
+ if (_value.type() != Atom::FLOAT) {
+ _error = TYPE_MISMATCH;
+ return;
+ }
+
if (_omni) {
for (uint32_t i=0; i < _port->poly(); ++i)
- ((AudioBuffer*)_port->buffer(i))->set_value(*(float*)_data, context.start(), _time);
+ ((AudioBuffer*)_port->buffer(i))->set_value(
+ _value.get_float(), context.start(), _time);
} else {
if (_voice_num < _port->poly())
((AudioBuffer*)_port->buffer(_voice_num))->set_value(
- *(float*)_data, context.start(), _time);
+ _value.get_float(), context.start(), _time);
else
_error = ILLEGAL_VOICE;
}
@@ -144,7 +139,8 @@ SetPortValueEvent::execute(ProcessContext& context)
EventBuffer* const ebuf = dynamic_cast<EventBuffer*>(buf);
// FIXME: eliminate string comparisons
- if (ebuf && _data_type == "lv2_midi:MidiEvent") {
+ if (ebuf && _value.type() == Atom::BLOB
+ && !strcmp(_value.get_blob_type(), "lv2_midi:MidiEvent")) {
const LV2Features::Feature* f = _engine.world()->lv2_features->feature(LV2_URI_MAP_URI);
LV2URIMap* map = (LV2URIMap*)f->controller;
const uint32_t type_id = map->uri_to_id(NULL, "http://lv2plug.in/ns/ext/midi#MidiEvent");
@@ -152,14 +148,18 @@ SetPortValueEvent::execute(ProcessContext& context)
ebuf->prepare_write(context.start(), context.nframes());
// FIXME: how should this work? binary over OSC, ick
// Message is an event:
- ebuf->append(frames, 0, type_id, _data_size, (const unsigned char*)_data);
+ ebuf->append(frames, 0, type_id, _value.data_size(), (const uint8_t*)_value.get_blob());
// Message is an event buffer:
//ebuf->append((LV2_Event_Buffer*)_data);
_port->raise_set_by_user_flag();
return;
}
- cerr << "WARNING: Unknown value type " << _data_type << ", ignoring" << endl;
+
+ if (_value.type() == Atom::BLOB)
+ cerr << "WARNING: Unknown value blob type " << _value.get_blob_type() << endl;
+ else
+ cerr << "WARNING: Unknown value type " << (int)_value.type() << endl;
}
}
@@ -170,7 +170,7 @@ SetPortValueEvent::post_process()
if (_error == NO_ERROR) {
assert(_port != NULL);
_responder->respond_ok();
- _engine.broadcaster()->send_control_change(_port_path, *(float*)_data);
+ _engine.broadcaster()->send_port_value(_port_path, _value);
} else if (_error == ILLEGAL_PATH) {
string msg = "Illegal port path \"";
@@ -189,7 +189,7 @@ SetPortValueEvent::post_process()
} else if (_error == NO_SPACE) {
std::ostringstream msg("Attempt to write ");
- msg << _data_size << " bytes to " << _port_path << ", with capacity "
+ msg << _value.data_size() << " bytes to " << _port_path << ", with capacity "
<< _port->buffer_size() << endl;
_responder->respond_error(msg.str());
}
diff --git a/src/libs/engine/events/SetPortValueEvent.hpp b/src/libs/engine/events/SetPortValueEvent.hpp
index a509af33..2fc68d9b 100644
--- a/src/libs/engine/events/SetPortValueEvent.hpp
+++ b/src/libs/engine/events/SetPortValueEvent.hpp
@@ -45,9 +45,7 @@ public:
bool queued,
SampleCount timestamp,
const string& port_path,
- const string& data_type,
- uint32_t data_size,
- const void* data);
+ const Raul::Atom& value);
SetPortValueEvent(Engine& engine,
SharedPtr<Responder> responder,
@@ -55,9 +53,7 @@ public:
SampleCount timestamp,
uint32_t voice_num,
const string& port_path,
- const string& data_type,
- uint32_t data_size,
- const void* data);
+ const Raul::Atom& value);
~SetPortValueEvent();
@@ -66,17 +62,16 @@ public:
void post_process();
private:
- enum ErrorType { NO_ERROR, PORT_NOT_FOUND, NO_SPACE, ILLEGAL_PATH, ILLEGAL_VOICE };
+ enum ErrorType { NO_ERROR, PORT_NOT_FOUND, NO_SPACE,
+ ILLEGAL_PATH, ILLEGAL_VOICE, TYPE_MISMATCH };
- bool _queued;
- bool _omni;
- uint32_t _voice_num;
- const string _port_path;
- const string _data_type;
- uint32_t _data_size;
- void* _data;
- PortImpl* _port;
- ErrorType _error;
+ bool _queued;
+ bool _omni;
+ uint32_t _voice_num;
+ const string _port_path;
+ const Raul::Atom _value;
+ PortImpl* _port;
+ ErrorType _error;
};
diff --git a/src/libs/gui/ControlPanel.cpp b/src/libs/gui/ControlPanel.cpp
index 9be36b65..0f38d5dd 100644
--- a/src/libs/gui/ControlPanel.cpp
+++ b/src/libs/gui/ControlPanel.cpp
@@ -226,13 +226,11 @@ ControlPanel::value_changed(SharedPtr<PortModel> port, float val)
if (_callback_enabled) {
if (_all_voices_radio->get_active()) {
- App::instance().engine()->set_port_value_immediate(port->path(), "ingen:Float",
- sizeof(float), &val);
+ App::instance().engine()->set_port_value_immediate(port->path(), Atom(val));
port->value(val);
} else {
int voice = _voice_spinbutton->get_value_as_int() - 1;
- App::instance().engine()->set_port_value_immediate(port->path(), "ingen:Float",
- voice, sizeof(float), &val);
+ App::instance().engine()->set_voice_value_immediate(port->path(), voice, Atom(val));
port->value(val);
}
diff --git a/src/libs/gui/Port.cpp b/src/libs/gui/Port.cpp
index 71050a3e..f675497b 100644
--- a/src/libs/gui/Port.cpp
+++ b/src/libs/gui/Port.cpp
@@ -116,8 +116,7 @@ Port::set_control(float value, bool signal)
return;
if (signal)
- App::instance().engine()->set_port_value_immediate(_port_model->path(), "ingen:Float",
- sizeof(float), &value);
+ App::instance().engine()->set_port_value_immediate(_port_model->path(), Atom(value));
FlowCanvas::Port::set_control(value);
}
diff --git a/src/libs/serialisation/Loader.cpp b/src/libs/serialisation/Loader.cpp
index ec06d0bc..bb085d57 100644
--- a/src/libs/serialisation/Loader.cpp
+++ b/src/libs/serialisation/Loader.cpp
@@ -210,13 +210,12 @@ Loader::load(Ingen::Shared::World* world,
const string node_name = (*i)["nodename"].to_string();
const string port_name = (*i)["portname"].to_string();
- const float val = (*i)["portval"].to_float();
assert(Path::is_valid_name(node_name));
assert(Path::is_valid_name(port_name));
const Path port_path = patch_path.base() + node_name + "/" + port_name;
- world->engine->set_port_value(port_path, "ingen:Float", sizeof(float), &val);
+ world->engine->set_port_value(port_path, AtomRDF::node_to_atom((*i)["portval"]));
}
@@ -254,10 +253,7 @@ Loader::load(Ingen::Shared::World* world,
}
const Redland::Node val_node = (*i)["portval"];
- if (val_node.is_float()) {
- const float val = val_node.to_float();
- world->engine->set_port_value(patch_path.base() + name, "ingen:Float", sizeof(float), &val);
- }
+ world->engine->set_port_value(patch_path.base() + name, AtomRDF::node_to_atom(val_node));
const string key = world->rdf_world->prefixes().qualify((*i)["varkey"].to_string());
const Redland::Node var_val_node = (*i)["varval"];
diff --git a/src/libs/shared/Makefile.am b/src/libs/shared/Makefile.am
index b7868bd1..9e52923a 100644
--- a/src/libs/shared/Makefile.am
+++ b/src/libs/shared/Makefile.am
@@ -12,5 +12,7 @@ libingen_shared_la_SOURCES = \
LV2Features.hpp \
LV2URIMap.cpp \
LV2URIMap.hpp \
+ OSCSender.cpp \
+ OSCSender.hpp \
Store.cpp \
Store.hpp