From d5a514148bec58cd7e97d032259362b2e19c0e95 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 29 Jan 2010 01:43:54 +0000 Subject: Magic MIDI binding via special ingen_control port. Always set lv2:minimum and lv2:maximum properties for control ports so they show up in properties dialog (and can be used for MIDI binding). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2391 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/events/CreatePort.cpp | 3 ++ src/engine/events/CreatePort.hpp | 1 - src/engine/events/Learn.cpp | 99 +++++++++++++++++++++++++++++++++++++ src/engine/events/Learn.hpp | 61 +++++++++++++++++++++++ src/engine/events/MidiLearn.cpp | 85 ------------------------------- src/engine/events/MidiLearn.hpp | 60 ---------------------- src/engine/events/SendPortValue.cpp | 4 +- src/engine/events/SetMetadata.cpp | 2 +- 8 files changed, 165 insertions(+), 150 deletions(-) create mode 100644 src/engine/events/Learn.cpp create mode 100644 src/engine/events/Learn.hpp delete mode 100644 src/engine/events/MidiLearn.cpp delete mode 100644 src/engine/events/MidiLearn.hpp (limited to 'src/engine/events') diff --git a/src/engine/events/CreatePort.cpp b/src/engine/events/CreatePort.cpp index 7845994a..73ba4b83 100644 --- a/src/engine/events/CreatePort.cpp +++ b/src/engine/events/CreatePort.cpp @@ -143,6 +143,9 @@ CreatePort::execute(ProcessContext& context) if (_driver_port) { _engine.driver()->add_port(_driver_port); } + + if (_source) + _source->unblock(); } diff --git a/src/engine/events/CreatePort.hpp b/src/engine/events/CreatePort.hpp index c7ddb56a..adda30bb 100644 --- a/src/engine/events/CreatePort.hpp +++ b/src/engine/events/CreatePort.hpp @@ -55,7 +55,6 @@ public: void post_process(); private: - enum ErrorType { NO_ERROR, UNKNOWN_TYPE, diff --git a/src/engine/events/Learn.cpp b/src/engine/events/Learn.cpp new file mode 100644 index 00000000..e700ab79 --- /dev/null +++ b/src/engine/events/Learn.cpp @@ -0,0 +1,99 @@ +/* This file is part of Ingen. + * Copyright (C) 2007-2009 Dave Robillard + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "events/Learn.hpp" +#include "ClientBroadcaster.hpp" +#include "ControlBindings.hpp" +#include "Engine.hpp" +#include "EngineStore.hpp" +#include "NodeImpl.hpp" +#include "PluginImpl.hpp" +#include "PortImpl.hpp" +#include "Responder.hpp" +#include "internals/Controller.hpp" + +using namespace std; + +namespace Ingen { +namespace Events { + + +Learn::Learn(Engine& engine, SharedPtr responder, SampleCount timestamp, const Raul::Path& path) + : QueuedEvent(engine, responder, timestamp) + , _error(NO_ERROR) + , _path(path) + , _object(NULL) + , _done(false) +{ +} + + +void +Learn::pre_process() +{ + _object = _engine.engine_store()->find_object(_path); + + PortImpl* port = dynamic_cast(_object); + if (port) { + _done = true; + if (port->type() == Shared::PortType::CONTROL) + _engine.control_bindings()->learn(port); + } + + QueuedEvent::pre_process(); +} + + +void +Learn::execute(ProcessContext& context) +{ + QueuedEvent::execute(context); + + if (_done || !_object) + return; + + NodeImpl* node = dynamic_cast(_object); + if (node) { + if (node->plugin_impl()->type() == Shared::Plugin::Internal) { + ((NodeBase*)_object)->learn(); + } else { + _error = INVALID_NODE_TYPE; + } + } +} + + +void +Learn::post_process() +{ + if (_error == NO_ERROR) { + _responder->respond_ok(); + } else if (_object == NULL) { + string msg = "Did not find node '"; + msg.append(_path.str()).append("' for learn."); + _responder->respond_error(msg); + } else { + const string msg = string("Object '") + _path.str() + "' is not capable of learning."; + _responder->respond_error(msg); + } +} + + +} // namespace Ingen +} // namespace Events + + diff --git a/src/engine/events/Learn.hpp b/src/engine/events/Learn.hpp new file mode 100644 index 00000000..8eb61c5f --- /dev/null +++ b/src/engine/events/Learn.hpp @@ -0,0 +1,61 @@ +/* This file is part of Ingen. + * Copyright (C) 2007-2009 Dave Robillard + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef MIDILEARNEVENT_H +#define MIDILEARNEVENT_H + +#include "QueuedEvent.hpp" +#include "internals/Controller.hpp" +#include "types.hpp" + +namespace Ingen { + +class NodeImpl; + +namespace Events { + + +/** A MIDI learn event (used by control node to learn controller number). + * + * \ingroup engine + */ +class Learn : public QueuedEvent +{ +public: + Learn(Engine& engine, SharedPtr responder, SampleCount timestamp, const Raul::Path& path); + + void pre_process(); + void execute(ProcessContext& context); + void post_process(); + +private: + enum ErrorType { + NO_ERROR, + INVALID_NODE_TYPE + }; + + ErrorType _error; + const Raul::Path _path; + GraphObjectImpl* _object; + bool _done; +}; + + +} // namespace Ingen +} // namespace Events + +#endif // MIDILEARNEVENT_H diff --git a/src/engine/events/MidiLearn.cpp b/src/engine/events/MidiLearn.cpp deleted file mode 100644 index b5c25102..00000000 --- a/src/engine/events/MidiLearn.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* This file is part of Ingen. - * Copyright (C) 2007-2009 Dave Robillard - * - * Ingen is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "events/MidiLearn.hpp" -#include "Responder.hpp" -#include "Engine.hpp" -#include "EngineStore.hpp" -#include "NodeImpl.hpp" -#include "internals/Controller.hpp" -#include "ClientBroadcaster.hpp" -#include "PluginImpl.hpp" - -using namespace std; - -namespace Ingen { -namespace Events { - - -MidiLearn::MidiLearn(Engine& engine, SharedPtr responder, SampleCount timestamp, const Raul::Path& node_path) - : QueuedEvent(engine, responder, timestamp) - , _error(NO_ERROR) - , _node_path(node_path) - , _node(NULL) -{ -} - - -void -MidiLearn::pre_process() -{ - _node = _engine.engine_store()->find_node(_node_path); - - QueuedEvent::pre_process(); -} - - -void -MidiLearn::execute(ProcessContext& context) -{ - QueuedEvent::execute(context); - - if (_node != NULL) { - if (_node->plugin_impl()->type() == Shared::Plugin::Internal) { - ((NodeBase*)_node)->learn(); - } else { - _error = INVALID_NODE_TYPE; - } - } -} - - -void -MidiLearn::post_process() -{ - if (_error == NO_ERROR) { - _responder->respond_ok(); - } else if (_node == NULL) { - string msg = "Did not find node '"; - msg.append(_node_path.str()).append("' for MIDI learn."); - _responder->respond_error(msg); - } else { - const string msg = string("Node '") + _node_path.str() + "' is not capable of MIDI learn."; - _responder->respond_error(msg); - } -} - - -} // namespace Ingen -} // namespace Events - - diff --git a/src/engine/events/MidiLearn.hpp b/src/engine/events/MidiLearn.hpp deleted file mode 100644 index 5835cf6a..00000000 --- a/src/engine/events/MidiLearn.hpp +++ /dev/null @@ -1,60 +0,0 @@ -/* This file is part of Ingen. - * Copyright (C) 2007-2009 Dave Robillard - * - * Ingen is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef MIDILEARNEVENT_H -#define MIDILEARNEVENT_H - -#include "QueuedEvent.hpp" -#include "internals/Controller.hpp" -#include "types.hpp" - -namespace Ingen { - -class NodeImpl; - -namespace Events { - - -/** A MIDI learn event (used by control node to learn controller number). - * - * \ingroup engine - */ -class MidiLearn : public QueuedEvent -{ -public: - MidiLearn(Engine& engine, SharedPtr responder, SampleCount timestamp, const Raul::Path& node_path); - - void pre_process(); - void execute(ProcessContext& context); - void post_process(); - -private: - enum ErrorType { - NO_ERROR, - INVALID_NODE_TYPE - }; - - ErrorType _error; - const Raul::Path _node_path; - NodeImpl* _node; -}; - - -} // namespace Ingen -} // namespace Events - -#endif // MIDILEARNEVENT_H diff --git a/src/engine/events/SendPortValue.cpp b/src/engine/events/SendPortValue.cpp index 4088568f..1052033b 100644 --- a/src/engine/events/SendPortValue.cpp +++ b/src/engine/events/SendPortValue.cpp @@ -30,12 +30,10 @@ namespace Events { void SendPortValue::post_process() { - // FIXME... - if (_omni) { _engine.broadcaster()->set_port_value(_port->path(), _value); } else { - _engine.broadcaster()->set_port_value(_port->path(), _value); + _engine.broadcaster()->set_voice_value(_port->path(), _voice_num, _value); } } diff --git a/src/engine/events/SetMetadata.cpp b/src/engine/events/SetMetadata.cpp index 5669b63d..ae69aecf 100644 --- a/src/engine/events/SetMetadata.cpp +++ b/src/engine/events/SetMetadata.cpp @@ -203,7 +203,7 @@ SetMetadata::execute(ProcessContext& context) if (_create_event) { QueuedEvent::execute(context); _create_event->execute(context); - if (_blocking) + if (_blocking && _source) _source->unblock(); return; } -- cgit v1.2.1