diff options
author | David Robillard <d@drobilla.net> | 2008-08-17 01:34:53 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-08-17 01:34:53 +0000 |
commit | 694b31089c8060fc6b908b146b12c0e340d004c7 (patch) | |
tree | 48b0e0195de5e7b297e65be15eda35639585ef8a /src/libs/client | |
parent | 3dc90cc95df35e5c786857336f22856c6373b00f (diff) | |
download | ingen-694b31089c8060fc6b908b146b12c0e340d004c7.tar.gz ingen-694b31089c8060fc6b908b146b12c0e340d004c7.tar.bz2 ingen-694b31089c8060fc6b908b146b12c0e340d004c7.zip |
Cloooser...
Bundling of OSC communication both ways (previous was just engine->client).
Factor out common OSC*Sender functionality (bundling stuff).
Fully type-safe and polyphony-aware port value setting/getting, from RDF through OSC through engine and back again.
git-svn-id: http://svn.drobilla.net/lad/ingen@1409 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/client')
-rw-r--r-- | src/libs/client/ClientStore.cpp | 4 | ||||
-rw-r--r-- | src/libs/client/ClientStore.hpp | 2 | ||||
-rw-r--r-- | src/libs/client/DeprecatedLoader.cpp | 3 | ||||
-rw-r--r-- | src/libs/client/Makefile.am | 1 | ||||
-rw-r--r-- | src/libs/client/OSCClientReceiver.cpp | 23 | ||||
-rw-r--r-- | src/libs/client/OSCClientReceiver.hpp | 3 | ||||
-rw-r--r-- | src/libs/client/OSCEngineSender.cpp | 365 | ||||
-rw-r--r-- | src/libs/client/OSCEngineSender.hpp | 48 | ||||
-rw-r--r-- | src/libs/client/PluginUI.cpp | 6 | ||||
-rw-r--r-- | src/libs/client/SigClientInterface.hpp | 12 | ||||
-rw-r--r-- | src/libs/client/ThreadedSigClientInterface.hpp | 14 |
11 files changed, 188 insertions, 293 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; |