From d1ba04724f0bfbed18690316dbe5eb977a131733 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 23 Sep 2007 02:03:41 +0000 Subject: Working LV2 UI control setting (including MIDI). Klaviatur (ll-plugins virtual keyboard) is now fully functional inside Ingen. git-svn-id: http://svn.drobilla.net/lad/ingen@766 a436a847-0d15-0410-975c-d299462d15a1 --- src/common/interface/EngineInterface.hpp | 4 + src/libs/client/ConnectionModel.hpp | 8 +- src/libs/client/DeprecatedLoader.cpp | 2 +- src/libs/client/NodeModel.cpp | 9 +- src/libs/client/OSCEngineSender.cpp | 86 +++++++++++----- src/libs/client/OSCEngineSender.hpp | 4 + src/libs/client/PluginModel.cpp | 42 +++++--- src/libs/client/PluginModel.hpp | 4 +- src/libs/client/PortModel.hpp | 6 +- src/libs/engine/MidiBuffer.cpp | 5 + src/libs/engine/MidiNoteNode.cpp | 6 +- src/libs/engine/OSCEngineReceiver.cpp | 110 ++++++++++++++------- src/libs/engine/OSCEngineReceiver.hpp | 2 - src/libs/engine/QueuedEngineInterface.cpp | 4 + src/libs/engine/QueuedEngineInterface.hpp | 4 + src/libs/engine/events/SetPortValueEvent.cpp | 4 +- src/libs/engine/events/SetPortValueQueuedEvent.cpp | 29 ++++-- src/libs/gui/ControlPanel.cpp | 6 +- src/libs/gui/NodeMenu.cpp | 2 +- src/libs/gui/NodeModule.cpp | 4 +- src/libs/gui/Port.cpp | 3 +- src/libs/serialisation/Loader.cpp | 5 +- 22 files changed, 241 insertions(+), 108 deletions(-) (limited to 'src') diff --git a/src/common/interface/EngineInterface.hpp b/src/common/interface/EngineInterface.hpp index ac4d3395..8bbd6f18 100644 --- a/src/common/interface/EngineInterface.hpp +++ b/src/common/interface/EngineInterface.hpp @@ -98,19 +98,23 @@ public: virtual void disconnect_all(const string& path) = 0; virtual void set_port_value(const string& port_path, + const string& type_uri, uint32_t data_size, const void* data) = 0; virtual void set_port_value(const string& port_path, + const string& type_uri, uint32_t voice, uint32_t data_size, const void* data) = 0; virtual void set_port_value_immediate(const string& port_path, + const string& type_uri, uint32_t data_size, const void* data) = 0; virtual void set_port_value_immediate(const string& port_path, + const string& type_uri, uint32_t voice, uint32_t data_size, const void* data) = 0; diff --git a/src/libs/client/ConnectionModel.hpp b/src/libs/client/ConnectionModel.hpp index 59dacae7..304db2b7 100644 --- a/src/libs/client/ConnectionModel.hpp +++ b/src/libs/client/ConnectionModel.hpp @@ -19,11 +19,11 @@ #define CONNECTIONMODEL_H #include +#include #include #include #include "PortModel.hpp" #include -using std::string; namespace Ingen { namespace Client { @@ -59,8 +59,8 @@ private: void set_src_port(SharedPtr port) { _src_port = port; _src_port_path = port->path(); } void set_dst_port(SharedPtr port) { _dst_port = port; _dst_port_path = port->path(); } - void src_port_path(const string& s) { _src_port_path = s; } - void dst_port_path(const string& s) { _dst_port_path = s; } + void src_port_path(const std::string& s) { _src_port_path = s; } + void dst_port_path(const std::string& s) { _dst_port_path = s; } Path _src_port_path; ///< Only used if _src_port == NULL Path _dst_port_path; ///< Only used if _dst_port == NULL @@ -68,7 +68,7 @@ private: SharedPtr _dst_port; }; -typedef list > ConnectionList; +typedef std::list > ConnectionList; } // namespace Client diff --git a/src/libs/client/DeprecatedLoader.cpp b/src/libs/client/DeprecatedLoader.cpp index 9cff9422..ce536b4f 100644 --- a/src/libs/client/DeprecatedLoader.cpp +++ b/src/libs/client/DeprecatedLoader.cpp @@ -259,7 +259,7 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename, list::const_iterator i = pm->controls().begin(); for ( ; i != pm->controls().end(); ++i) { const float value = i->value(); - _engine->set_port_value(i->port_path(), sizeof(float), &value); + _engine->set_port_value(i->port_path(), "ingen:control", sizeof(float), &value); } } else { cerr << "WARNING: Unknown preset: \"" << pm->name() << endl; diff --git a/src/libs/client/NodeModel.cpp b/src/libs/client/NodeModel.cpp index 8c5892e7..2816c7fa 100644 --- a/src/libs/client/NodeModel.cpp +++ b/src/libs/client/NodeModel.cpp @@ -48,7 +48,13 @@ NodeModel::~NodeModel() void NodeModel::remove_port(SharedPtr port) { - _ports.remove(port); + // FIXME: slow + for (PortModelList::iterator i = _ports.begin(); i != _ports.end(); ++i) { + if ((*i) == port) { + _ports.erase(i); + break; + } + } signal_removed_port.emit(port); } @@ -56,6 +62,7 @@ NodeModel::remove_port(SharedPtr port) void NodeModel::remove_port(const Path& port_path) { + // FIXME: slow for (PortModelList::iterator i = _ports.begin(); i != _ports.end(); ++i) { if ((*i)->path() == port_path) { _ports.erase(i); diff --git a/src/libs/client/OSCEngineSender.cpp b/src/libs/client/OSCEngineSender.cpp index 90f27676..cadb962c 100644 --- a/src/libs/client/OSCEngineSender.cpp +++ b/src/libs/client/OSCEngineSender.cpp @@ -351,61 +351,103 @@ OSCEngineSender::disconnect_all(const string& node_path) void OSCEngineSender::set_port_value(const string& port_path, + const string& type_uri, uint32_t data_size, const void* data) { assert(_engine_addr); - assert(data_size == 4); - lo_send(_engine_addr, "/ingen/set_port_value", "isf", - next_id(), - port_path.c_str(), - *(float*)data); + if (type_uri == "ingen:control") { + assert(data_size == 4); + lo_send(_engine_addr, "/ingen/set_port_value", "isf", + next_id(), + port_path.c_str(), + *(float*)data); + } else { + lo_blob b = lo_blob_new(data_size, data); + lo_send(_engine_addr, "/ingen/set_port_value", "isb", + next_id(), + port_path.c_str(), + b); + lo_blob_free(b); + } } void OSCEngineSender::set_port_value(const string& port_path, + const string& type_uri, uint32_t voice, uint32_t data_size, const void* data) { assert(_engine_addr); - assert(data_size == 4); - lo_send(_engine_addr, "/ingen/set_port_value", "isif", - next_id(), - port_path.c_str(), - voice, - *(float*)data); + if (type_uri == "ingen:control") { + assert(data_size == 4); + lo_send(_engine_addr, "/ingen/set_port_value", "isf", + next_id(), + port_path.c_str(), + *(float*)data); + } else { + lo_blob b = lo_blob_new(data_size, data); + lo_send(_engine_addr, "/ingen/set_port_value", "isb", + next_id(), + port_path.c_str(), + b); + lo_blob_free(b); + } } void OSCEngineSender::set_port_value_immediate(const string& port_path, + const string& type_uri, uint32_t data_size, const void* data) { assert(_engine_addr); - assert(data_size == 4); - lo_send(_engine_addr, "/ingen/set_port_value_immediate", "isf", - next_id(), - port_path.c_str(), - *(float*)data); + + if (type_uri == "ingen:control") { + assert(data_size == 4); + lo_send(_engine_addr, "/ingen/set_port_value_immediate", "isf", + next_id(), + port_path.c_str(), + *(float*)data); + } else { + lo_blob b = lo_blob_new(data_size, data); + lo_send(_engine_addr, "/ingen/set_port_value_immediate", "isb", + next_id(), + port_path.c_str(), + b); + lo_blob_free(b); + } } void OSCEngineSender::set_port_value_immediate(const string& port_path, + const string& type_uri, uint32_t voice, uint32_t data_size, const void* data) { assert(_engine_addr); - assert(data_size == 4); - lo_send(_engine_addr, "/ingen/set_port_value_immediate", "isif", - next_id(), - port_path.c_str(), - voice, - *(float*)data); + + if (type_uri == "ingen:control") { + assert(data_size == 4); + lo_send(_engine_addr, "/ingen/set_port_value_immediate", "isif", + next_id(), + port_path.c_str(), + voice, + *(float*)data); + } else { + lo_blob b = lo_blob_new(data_size, data); + lo_send(_engine_addr, "/ingen/set_port_value_immediate", "isib", + next_id(), + port_path.c_str(), + voice, + b); + lo_blob_free(b); + } } diff --git a/src/libs/client/OSCEngineSender.hpp b/src/libs/client/OSCEngineSender.hpp index bdaf8337..c91dfbbd 100644 --- a/src/libs/client/OSCEngineSender.hpp +++ b/src/libs/client/OSCEngineSender.hpp @@ -112,19 +112,23 @@ public: void disconnect_all(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 string& type_uri, uint32_t voice, uint32_t data_size, const void* data); 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 string& type_uri, uint32_t voice, uint32_t data_size, const void* data); diff --git a/src/libs/client/PluginModel.cpp b/src/libs/client/PluginModel.cpp index 6fb7e95a..cfe6d547 100644 --- a/src/libs/client/PluginModel.cpp +++ b/src/libs/client/PluginModel.cpp @@ -20,6 +20,7 @@ #include "PluginModel.hpp" #include "PatchModel.hpp" +using Ingen::Shared::EngineInterface; namespace Ingen { namespace Client { @@ -53,25 +54,29 @@ PluginModel::default_node_name(SharedPtr parent) } +struct NodeController { + EngineInterface* engine; + NodeModel* node; +}; + + void lv2_ui_write(LV2UI_Controller controller, - uint32_t port, - uint32_t buffer_size, - const void* buffer) + uint32_t port, + uint32_t buffer_size, + const void* buffer) { - cerr << "********* LV2 UI WRITE port " << port << ", size " - << buffer_size << endl; - for (uint32_t i=0; i < buffer_size; ++i) { - fprintf(stderr, "( %X )", *((uint8_t*)buffer + i)); - } - fprintf(stderr, "\n"); + NodeController* nc = (NodeController*)controller; + + nc->engine->set_port_value_immediate(nc->node->ports()[port]->path(), + "ingen:midi", buffer_size, buffer); } void lv2_ui_command(LV2UI_Controller controller, - uint32_t argc, - const char* const* argv) + uint32_t argc, + const char* const* argv) { cerr << "********* LV2 UI COMMAND" << endl; } @@ -79,7 +84,7 @@ lv2_ui_command(LV2UI_Controller controller, void lv2_ui_program_change(LV2UI_Controller controller, - unsigned char program) + unsigned char program) { cerr << "********* LV2 UI PROGRAM CHANGE" << endl; } @@ -87,8 +92,8 @@ lv2_ui_program_change(LV2UI_Controller controller, void lv2_ui_program_save(LV2UI_Controller controller, - unsigned char program, - const char* name) + unsigned char program, + const char* name) { cerr << "********* LV2 UI PROGRAM SAVE" << endl; } @@ -96,12 +101,17 @@ lv2_ui_program_save(LV2UI_Controller controller, #ifdef HAVE_SLV2 SLV2UIInstance -PluginModel::ui() +PluginModel::ui(EngineInterface* engine, NodeModel* node) { if (_type != LV2) return NULL; Glib::Mutex::Lock(_rdf_world->mutex()); + + // FIXME: leak + NodeController* controller = new NodeController(); + controller->engine = engine; + controller->node = node; SLV2UIInstance ret = NULL; @@ -129,7 +139,7 @@ PluginModel::ui() slv2_values_get_at(ui, 0), lv2_ui_write, lv2_ui_command, lv2_ui_program_change, lv2_ui_program_save, - NULL, NULL); + controller, NULL); } slv2_values_free(ui); diff --git a/src/libs/client/PluginModel.hpp b/src/libs/client/PluginModel.hpp index bcf2645c..444ed666 100644 --- a/src/libs/client/PluginModel.hpp +++ b/src/libs/client/PluginModel.hpp @@ -27,12 +27,14 @@ #ifdef HAVE_SLV2 #include #endif +#include "interface/EngineInterface.hpp" using std::string; using std::cerr; using std::endl; namespace Ingen { namespace Client { class PatchModel; +class NodeModel; /** Model for a plugin available for loading. @@ -107,7 +109,7 @@ public: _slv2_plugins = slv2_world_get_all_plugins(_slv2_world); } - SLV2UIInstance ui(); + SLV2UIInstance ui(Ingen::Shared::EngineInterface* engine, NodeModel* node); #endif static void set_rdf_world(Raul::RDF::World& world) { diff --git a/src/libs/client/PortModel.hpp b/src/libs/client/PortModel.hpp index 6b49310b..80d5e524 100644 --- a/src/libs/client/PortModel.hpp +++ b/src/libs/client/PortModel.hpp @@ -21,12 +21,12 @@ #include #include #include -#include +#include #include #include "ObjectModel.hpp" #include #include -using std::string; using std::list; using std::cerr; using std::endl; +using std::string; using std::vector; using std::cerr; using std::endl; namespace Ingen { namespace Client { @@ -96,7 +96,7 @@ private: size_t _connections; }; -typedef list > PortModelList; +typedef vector > PortModelList; } // namespace Client diff --git a/src/libs/engine/MidiBuffer.cpp b/src/libs/engine/MidiBuffer.cpp index 0e10a44e..59da7646 100644 --- a/src/libs/engine/MidiBuffer.cpp +++ b/src/libs/engine/MidiBuffer.cpp @@ -178,6 +178,11 @@ MidiBuffer::append(double timestamp, uint32_t size, const unsigned char* data) { + /*cerr << "Append midi " << size << " bytes @ " << timestamp << ":" << endl; + for (uint32_t i=0; i < size; ++i) { + fprintf(stderr, "( %X )", *((uint8_t*)data + i)); + }*/ + if (_buf->capacity - _buf->size < sizeof(double) + sizeof(uint32_t) + size) return false; diff --git a/src/libs/engine/MidiNoteNode.cpp b/src/libs/engine/MidiNoteNode.cpp index a5b29f85..42d96dfa 100644 --- a/src/libs/engine/MidiNoteNode.cpp +++ b/src/libs/engine/MidiNoteNode.cpp @@ -218,8 +218,8 @@ MidiNoteNode::note_on(uchar note_num, uchar velocity, FrameTime time, SampleCoun assert(voice != NULL); assert(voice == &(*_voices)[voice_num]); - //cerr << "[MidiNoteNode] Note " << (int)note_num << " on @ " << time - // << ". Voice " << voice_num << " / " << _polyphony << endl; + cerr << "[MidiNoteNode] Note " << (int)note_num << " on @ " << time + << ". Voice " << voice_num << " / " << _polyphony << endl; // Update stolen key, if applicable if (voice->state == Voice::Voice::ACTIVE) { @@ -273,7 +273,7 @@ MidiNoteNode::note_off(uchar note_num, FrameTime time, SampleCount nframes, Fram Key* key = &_keys[note_num]; - //cerr << "[MidiNoteNode] Note off @ " << time << ". Key " << (int)note_num << endl; + cerr << "[MidiNoteNode] Note off @ " << time << ". Key " << (int)note_num << endl; if (key->state == Key::ON_ASSIGNED) { // Assigned key, turn off voice and key diff --git a/src/libs/engine/OSCEngineReceiver.cpp b/src/libs/engine/OSCEngineReceiver.cpp index caaf0d73..d2d7a4a0 100644 --- a/src/libs/engine/OSCEngineReceiver.cpp +++ b/src/libs/engine/OSCEngineReceiver.cpp @@ -96,10 +96,8 @@ OSCEngineReceiver::OSCEngineReceiver(Engine& engine, size_t queue_size, uint16_t lo_server_add_method(_server, "/ingen/connect", "iss", connect_cb, this); lo_server_add_method(_server, "/ingen/disconnect", "iss", disconnect_cb, this); lo_server_add_method(_server, "/ingen/disconnect_all", "is", disconnect_all_cb, this); - lo_server_add_method(_server, "/ingen/set_port_value", "isf", set_port_value_cb, this); - lo_server_add_method(_server, "/ingen/set_port_value", "isif", set_port_value_voice_cb, this); - lo_server_add_method(_server, "/ingen/set_port_value_immediate", "isf", set_port_value_immediate_cb, this); - lo_server_add_method(_server, "/ingen/set_port_value_immediate", "isif", set_port_value_immediate_voice_cb, this); + lo_server_add_method(_server, "/ingen/set_port_value", NULL, set_port_value_cb, this); + lo_server_add_method(_server, "/ingen/set_port_value_immediate", NULL, set_port_value_immediate_cb, this); lo_server_add_method(_server, "/ingen/note_on", "isii", note_on_cb, this); lo_server_add_method(_server, "/ingen/note_off", "isi", note_off_cb, this); lo_server_add_method(_server, "/ingen/all_notes_off", "isi", all_notes_off_cb, this); @@ -598,7 +596,7 @@ OSCEngineReceiver::_disconnect_cb(const char* path, const char* types, lo_arg** int OSCEngineReceiver::_disconnect_all_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg) { - const char* node_path = &argv[1]->s; + const char* node_path = &argv[1]->s; disconnect_all(node_path); return 0; @@ -611,17 +609,6 @@ OSCEngineReceiver::_disconnect_all_cb(const char* path, const char* types, lo_ar * \arg \b port-path (string) - Name of port * \arg \b value (float) - Value to set port to

\n \n */ -int -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 float value = argv[2]->f; - - set_port_value_immediate(port_path, sizeof(float), &value); - return 0; -} - - /** \page engine_osc_namespace *

\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(buf); if (abuf) { - const size_t offset = (buf->size() == 1) ? 0 : _time - start; + const uint32_t offset = (buf->size() == 1) ? 0 : _time - start; if (_omni) for (uint32_t i=0; i < _port->poly(); ++i) @@ -108,7 +108,7 @@ SetPortValueEvent::execute(SampleCount nframes, FrameTime start, FrameTime end) MidiBuffer* const mbuf = dynamic_cast(buf); if (mbuf) { - const double stamp = std::max((double)_time, mbuf->latest_stamp()); + const double stamp = std::max((double)(_time - start), mbuf->latest_stamp()); mbuf->append(stamp, _data_size, (const unsigned char*)_data); } } diff --git a/src/libs/engine/events/SetPortValueQueuedEvent.cpp b/src/libs/engine/events/SetPortValueQueuedEvent.cpp index 8940d4c5..d0bfff4a 100644 --- a/src/libs/engine/events/SetPortValueQueuedEvent.cpp +++ b/src/libs/engine/events/SetPortValueQueuedEvent.cpp @@ -25,6 +25,7 @@ #include "Node.hpp" #include "ObjectStore.hpp" #include "AudioBuffer.hpp" +#include "MidiBuffer.hpp" namespace Ingen { @@ -94,14 +95,26 @@ SetPortValueQueuedEvent::execute(SampleCount nframes, FrameTime start, FrameTime if (_error == NO_ERROR) { assert(_port); - AudioBuffer* const buf = (AudioBuffer*)_port->buffer(0); - const size_t offset = (buf->size() == 1) ? 0 : _time - start; - - if (_omni) - for (uint32_t i=0; i < _port->poly(); ++i) - ((AudioBuffer*)_port->buffer(i))->set(*(float*)_data, offset); - else - ((AudioBuffer*)_port->buffer(_voice_num))->set(*(float*)_data, offset); + + Buffer* const buf = _port->buffer(0); + AudioBuffer* const abuf = dynamic_cast(buf); + if (abuf) { + const uint32_t offset = (buf->size() == 1) ? 0 : _time - start; + + if (_omni) + for (uint32_t i=0; i < _port->poly(); ++i) + ((AudioBuffer*)_port->buffer(i))->set(*(float*)_data, offset); + else + ((AudioBuffer*)_port->buffer(_voice_num))->set(*(float*)_data, offset); + + return; + } + + MidiBuffer* const mbuf = dynamic_cast(buf); + if (mbuf) { + const double stamp = std::max((double)(_time - start), mbuf->latest_stamp()); + mbuf->append(stamp, _data_size, (const unsigned char*)_data); + } } } diff --git a/src/libs/gui/ControlPanel.cpp b/src/libs/gui/ControlPanel.cpp index b12a21f5..bef5e18b 100644 --- a/src/libs/gui/ControlPanel.cpp +++ b/src/libs/gui/ControlPanel.cpp @@ -237,11 +237,13 @@ ControlPanel::value_changed(SharedPtr port, float val) * setting right away (so the value doesn't need to be echoed back) */ if (_all_voices_radio->get_active()) { - App::instance().engine()->set_port_value_immediate(port->path(), sizeof(float), &val); + App::instance().engine()->set_port_value_immediate(port->path(), "ingen:control", + sizeof(float), &val); port->value(val); } else { int voice = _voice_spinbutton->get_value_as_int(); - App::instance().engine()->set_port_value_immediate(port->path(), voice, sizeof(float), &val); + App::instance().engine()->set_port_value_immediate(port->path(), "ingen:control", + voice, sizeof(float), &val); port->value(val); } diff --git a/src/libs/gui/NodeMenu.cpp b/src/libs/gui/NodeMenu.cpp index 9c2d978e..6e4cb1d2 100644 --- a/src/libs/gui/NodeMenu.cpp +++ b/src/libs/gui/NodeMenu.cpp @@ -56,7 +56,7 @@ NodeMenu::init(SharedPtr node) sigc::mem_fun(App::instance().window_factory(), &WindowFactory::present_controls), node)); - if (node->plugin()->ui()) + if (node->plugin()->ui(App::instance().engine().get(), node.get())) _gui_menuitem->signal_activate().connect(sigc::mem_fun(this, &NodeMenu::show_gui)); //else // _gui_menuitem->hide(); diff --git a/src/libs/gui/NodeModule.cpp b/src/libs/gui/NodeModule.cpp index 25cc4aa1..d271dd2f 100644 --- a/src/libs/gui/NodeModule.cpp +++ b/src/libs/gui/NodeModule.cpp @@ -123,11 +123,11 @@ NodeModule::show_control_window() if (_node->plugin()->type() == PluginModel::LV2) { // FIXME: check type - SLV2UIInstance ui = _node->plugin()->ui(); + SLV2UIInstance ui = _node->plugin()->ui(App::instance().engine().get(), _node.get()); if (ui) { cerr << "Showing LV2 GUI" << endl; // FIXME: leak - GtkWidget* c_widget = (GtkWidget*)slv2_ui_instance_get_widget(_node->plugin()->ui()); + GtkWidget* c_widget = (GtkWidget*)slv2_ui_instance_get_widget(ui); Gtk::Window* win = new Gtk::Window(); Gtk::Widget* widget = Glib::wrap(c_widget); win->add(*widget); diff --git a/src/libs/gui/Port.cpp b/src/libs/gui/Port.cpp index 8ba43d56..b6c64cf0 100644 --- a/src/libs/gui/Port.cpp +++ b/src/libs/gui/Port.cpp @@ -90,7 +90,8 @@ void Port::set_control(float value, bool signal) { if (signal) - App::instance().engine()->set_port_value_immediate(_port_model->path(), sizeof(float), &value); + App::instance().engine()->set_port_value_immediate(_port_model->path(), "ingen:control", + sizeof(float), &value); FlowCanvas::Port::set_control(value); } diff --git a/src/libs/serialisation/Loader.cpp b/src/libs/serialisation/Loader.cpp index ec60225d..a911eb72 100644 --- a/src/libs/serialisation/Loader.cpp +++ b/src/libs/serialisation/Loader.cpp @@ -205,7 +205,7 @@ Loader::load(SharedPtr engine, const Path port_path = patch_path.base() + node_name +"/"+ port_name; - engine->set_port_value(port_path, sizeof(float), &val); + engine->set_port_value(port_path, "ingen:control", sizeof(float), &val); } @@ -242,9 +242,10 @@ Loader::load(SharedPtr engine, RDF::Node val_node = (*i)["portval"]; if (val_node.is_float()) { const float val = val_node.to_float(); - engine->set_port_value(patch_path.base() + name, sizeof(float), &val); + engine->set_port_value(patch_path.base() + name, "ingen:control", sizeof(float), &val); } + string floatkey = rdf_world->qualify((*i)["floatkey"].to_string()); val_node = (*i)["floatval"]; -- cgit v1.2.1