diff options
author | David Robillard <d@drobilla.net> | 2008-11-27 22:50:32 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-11-27 22:50:32 +0000 |
commit | c58f17efff27f959147dfd231a8b059950d06e69 (patch) | |
tree | f10dd950a9b1b15461a6200f9396a989b3e1ad9d /src/engine/events | |
parent | cb1d3b65670febd0bd5c3ac7d128f45ef0a744a4 (diff) | |
download | ingen-c58f17efff27f959147dfd231a8b059950d06e69.tar.gz ingen-c58f17efff27f959147dfd231a8b059950d06e69.tar.bz2 ingen-c58f17efff27f959147dfd231a8b059950d06e69.zip |
MIDI learn for control node.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1806 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/events')
-rw-r--r-- | src/engine/events/MidiLearnEvent.cpp | 26 | ||||
-rw-r--r-- | src/engine/events/MidiLearnEvent.hpp | 6 |
2 files changed, 23 insertions, 9 deletions
diff --git a/src/engine/events/MidiLearnEvent.cpp b/src/engine/events/MidiLearnEvent.cpp index 2f37f30d..68293cb7 100644 --- a/src/engine/events/MidiLearnEvent.cpp +++ b/src/engine/events/MidiLearnEvent.cpp @@ -40,10 +40,11 @@ MidiLearnResponseEvent::post_process() // MidiLearnEvent MidiLearnEvent::MidiLearnEvent(Engine& engine, SharedPtr<Responder> responder, SampleCount timestamp, const string& node_path) -: QueuedEvent(engine, responder, timestamp), - _node_path(node_path), - _node(NULL), - _response_event(NULL) + : QueuedEvent(engine, responder, timestamp) + , _error(NO_ERROR) + , _node_path(node_path) + , _node(NULL) + , _response_event(NULL) { } @@ -63,10 +64,14 @@ MidiLearnEvent::execute(ProcessContext& context) { QueuedEvent::execute(context); - // FIXME: this isn't very good at all. - if (_node != NULL && _node->plugin_impl()->type() == Plugin::Internal - && _node->plugin_impl()->uri() == "ingen:control_node") { + if (_node != NULL) { + if (_node->plugin_impl()->type() == Plugin::Internal + && _node->plugin_impl()->uri() == "http://drobilla.net/ns/ingen#control_node") { ((MidiControlNode*)_node)->learn(_response_event); + } else { + std::cout << "NOT CAPABLE: " << _node->plugin_impl()->uri() << std::endl; + _error = INVALID_NODE_TYPE; + } } } @@ -74,12 +79,15 @@ MidiLearnEvent::execute(ProcessContext& context) void MidiLearnEvent::post_process() { - if (_node != NULL) { + if (_error == NO_ERROR) { _responder->respond_ok(); - } else { + } else if (_node == NULL) { string msg = "Did not find node '"; msg.append(_node_path).append("' for MIDI learn."); _responder->respond_error(msg); + } else { + const string msg = string("Node '") + _node_path + "' is not capable of MIDI learn."; + _responder->respond_error(msg); } } diff --git a/src/engine/events/MidiLearnEvent.hpp b/src/engine/events/MidiLearnEvent.hpp index c0fc4a17..1dceb041 100644 --- a/src/engine/events/MidiLearnEvent.hpp +++ b/src/engine/events/MidiLearnEvent.hpp @@ -72,6 +72,12 @@ public: void post_process(); private: + enum ErrorType { + NO_ERROR, + INVALID_NODE_TYPE + }; + + ErrorType _error; const string _node_path; NodeImpl* _node; |