From d1ba04724f0bfbed18690316dbe5eb977a131733 Mon Sep 17 00:00:00 2001
From: David Robillard
\b /ingen/set_port_value_immediate - Sets the value of a port for a specific voice (both AR and CR) * \arg \b response-id (integer) @@ -632,13 +619,43 @@ OSCEngineReceiver::_set_port_value_immediate_cb(const char* path, const char* ty * See documentation for set_port_value for the distinction between these two messages. */ int -OSCEngineReceiver::_set_port_value_immediate_voice_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) +OSCEngineReceiver::_set_port_value_immediate_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { - const char* port_path = &argv[1]->s; - const int32_t voice = argv[2]->i; - const float value = argv[3]->f; + if (argc < 3 || argc > 4 || strncmp(types, "is", 2)) + return 1; + + const char* port_path = &argv[1]->s; + + if (argc == 3) { + if (types[2] == 'f') { + const float value = argv[2]->f; + set_port_value_immediate(port_path, "who cares", sizeof(float), &value); + return 0; + } else if (types[2] == 'b') { + lo_blob b = argv[2]; + size_t data_size = lo_blob_datasize(b); + void* data = lo_blob_dataptr(b); + set_port_value_immediate(port_path, "who cares", data_size, data); + return 0; + } else { + return 1; + } + } else { + if (types[3] == 'f') { + const float value = argv[3]->f; + set_port_value_immediate(port_path, "who cares", argv[2]->i, sizeof(float), &value); + return 0; + } else if (types[3] == 'b') { + 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, "who cares", argv[2]->i, data_size, data); + return 0; + } else { + return 1; + } + } - set_port_value_immediate(port_path, voice, sizeof(float), &value); return 0; } @@ -657,17 +674,6 @@ OSCEngineReceiver::_set_port_value_immediate_voice_cb(const char* path, const ch * There is also a fast "immediate" version of this message, set_port_value_immediate, which * does not have this ordering guarantee.
\n \n */ -int -OSCEngineReceiver::_set_port_value_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) -{ - const char* port_path = &argv[1]->s; - const float value = argv[2]->f; - - set_port_value(port_path, sizeof(float), &value); - return 0; -} - - /** \page engine_osc_namespace *\b /ingen/set_port_value - Sets the value of a port for all voices (as a QueuedEvent) * \arg \b response-id (integer) @@ -683,13 +689,43 @@ OSCEngineReceiver::_set_port_value_cb(const char* path, const char* types, lo_ar * does not have this ordering guarantee.
\n \n */ int -OSCEngineReceiver::_set_port_value_voice_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) +OSCEngineReceiver::_set_port_value_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { - const char* port_path = &argv[1]->s; - const int32_t voice = argv[2]->i; - const float value = argv[3]->f; + if (argc < 3 || argc > 4 || strncmp(types, "is", 2)) + return 1; + + const char* port_path = &argv[1]->s; + + if (argc == 3) { + if (types[2] == 'f') { + const float value = argv[2]->f; + set_port_value(port_path, "who cares", sizeof(float), &value); + return 0; + } else if (types[2] == 'b') { + lo_blob b = argv[2]; + size_t data_size = lo_blob_datasize(b); + void* data = lo_blob_dataptr(b); + set_port_value(port_path, "who cares", data_size, data); + return 0; + } else { + return 1; + } + } else { + if (types[3] == 'f') { + const float value = argv[3]->f; + set_port_value(port_path, "who cares", argv[2]->i, sizeof(float), &value); + return 0; + } else if (types[3] == 'b') { + lo_blob b = argv[3]; + size_t data_size = lo_blob_datasize(b); + void* data = lo_blob_dataptr(b); + set_port_value(port_path, "who cares", argv[2]->i, data_size, data); + return 0; + } else { + return 1; + } + } - set_port_value(port_path, voice, sizeof(float), &value); return 0; } diff --git a/src/libs/engine/OSCEngineReceiver.hpp b/src/libs/engine/OSCEngineReceiver.hpp index e6ecebac..75cbda7c 100644 --- a/src/libs/engine/OSCEngineReceiver.hpp +++ b/src/libs/engine/OSCEngineReceiver.hpp @@ -99,9 +99,7 @@ private: LO_HANDLER(disconnect); LO_HANDLER(disconnect_all); LO_HANDLER(set_port_value); - LO_HANDLER(set_port_value_voice); LO_HANDLER(set_port_value_immediate); - LO_HANDLER(set_port_value_immediate_voice); LO_HANDLER(note_on); LO_HANDLER(note_off); LO_HANDLER(all_notes_off); diff --git a/src/libs/engine/QueuedEngineInterface.cpp b/src/libs/engine/QueuedEngineInterface.cpp index 41780e92..72be00aa 100644 --- a/src/libs/engine/QueuedEngineInterface.cpp +++ b/src/libs/engine/QueuedEngineInterface.cpp @@ -233,6 +233,7 @@ QueuedEngineInterface::disconnect_all(const string& node_path) void QueuedEngineInterface::set_port_value(const string& port_path, + const string& type_uri, uint32_t data_size, const void* data) { @@ -242,6 +243,7 @@ QueuedEngineInterface::set_port_value(const string& port_path, void QueuedEngineInterface::set_port_value(const string& port_path, + const string& type_uri, uint32_t voice, uint32_t data_size, const void* data) @@ -252,6 +254,7 @@ QueuedEngineInterface::set_port_value(const string& port_path, void QueuedEngineInterface::set_port_value_immediate(const string& port_path, + const string& type_uri, uint32_t data_size, const void* data) { @@ -261,6 +264,7 @@ QueuedEngineInterface::set_port_value_immediate(const string& port_path, void QueuedEngineInterface::set_port_value_immediate(const string& port_path, + const string& type_uri, uint32_t voice, uint32_t data_size, const void* data) diff --git a/src/libs/engine/QueuedEngineInterface.hpp b/src/libs/engine/QueuedEngineInterface.hpp index 06583186..3a0ad016 100644 --- a/src/libs/engine/QueuedEngineInterface.hpp +++ b/src/libs/engine/QueuedEngineInterface.hpp @@ -119,19 +119,23 @@ public: virtual void disconnect_all(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 string& type_uri, uint32_t voice, uint32_t data_size, const void* data); virtual void set_port_value_immediate(const string& port_path, + const string& type_uri, uint32_t data_size, const void* data); virtual void set_port_value_immediate(const string& port_path, + const string& type_uri, uint32_t voice, uint32_t data_size, const void* data); diff --git a/src/libs/engine/events/SetPortValueEvent.cpp b/src/libs/engine/events/SetPortValueEvent.cpp index fa2238e2..9d1ad0db 100644 --- a/src/libs/engine/events/SetPortValueEvent.cpp +++ b/src/libs/engine/events/SetPortValueEvent.cpp @@ -95,7 +95,7 @@ SetPortValueEvent::execute(SampleCount nframes, FrameTime start, FrameTime end) Buffer* const buf = _port->buffer(0); AudioBuffer* const abuf = dynamic_cast