diff options
author | David Robillard <d@drobilla.net> | 2010-01-29 04:01:29 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-01-29 04:01:29 +0000 |
commit | 1b964e850bbe3207fe9a65849520634955d141f0 (patch) | |
tree | 8af6d825e666bbe0c97ca8fd3b7c89558e2c32c0 /src/engine | |
parent | d5a514148bec58cd7e97d032259362b2e19c0e95 (diff) | |
download | ingen-1b964e850bbe3207fe9a65849520634955d141f0.tar.gz ingen-1b964e850bbe3207fe9a65849520634955d141f0.tar.bz2 ingen-1b964e850bbe3207fe9a65849520634955d141f0.zip |
Send binding information to client.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2392 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/ClientBroadcaster.hpp | 4 | ||||
-rw-r--r-- | src/engine/ControlBindings.cpp | 26 | ||||
-rw-r--r-- | src/engine/ControlBindings.hpp | 3 | ||||
-rw-r--r-- | src/engine/HTTPClientSender.cpp | 7 | ||||
-rw-r--r-- | src/engine/HTTPClientSender.hpp | 2 | ||||
-rw-r--r-- | src/engine/OSCClientSender.cpp | 20 | ||||
-rw-r--r-- | src/engine/OSCClientSender.hpp | 2 | ||||
-rw-r--r-- | src/engine/events/SendBinding.cpp | 39 | ||||
-rw-r--r-- | src/engine/events/SendBinding.hpp | 68 | ||||
-rw-r--r-- | src/engine/wscript | 1 |
10 files changed, 165 insertions, 7 deletions
diff --git a/src/engine/ClientBroadcaster.hpp b/src/engine/ClientBroadcaster.hpp index 9de7aeff..fa44bc43 100644 --- a/src/engine/ClientBroadcaster.hpp +++ b/src/engine/ClientBroadcaster.hpp @@ -123,6 +123,10 @@ public: void error(const std::string& msg) { BROADCAST(error, msg); } void activity(const Raul::Path& path) { BROADCAST(activity, path); } + void binding(const Raul::Path& path, const Shared::MessageType& type) { + BROADCAST(binding, path, type); + } + private: typedef std::map<Raul::URI, Shared::ClientInterface*> Clients; Clients _clients; diff --git a/src/engine/ControlBindings.cpp b/src/engine/ControlBindings.cpp index 00241b54..b74a3124 100644 --- a/src/engine/ControlBindings.cpp +++ b/src/engine/ControlBindings.cpp @@ -18,6 +18,7 @@ #include "raul/log.hpp" #include "raul/midi_events.h" #include "events/SendPortValue.hpp" +#include "events/SendBinding.hpp" #include "ControlBindings.hpp" #include "EventBuffer.hpp" #include "PortImpl.hpp" @@ -41,21 +42,35 @@ ControlBindings::learn(PortImpl* port) void -ControlBindings::set_port_value(ProcessContext& context, PortImpl* port, int8_t value) +ControlBindings::set_port_value(ProcessContext& context, PortImpl* port, int8_t cc_value) { + // TODO: cache these to avoid the lookup float min = port->get_property("lv2:minimum").get_float(); float max = port->get_property("lv2:maximum").get_float(); - Raul::Atom scaled_value(static_cast<float>(((float)value / 127.0) * (max - min) + min)); - port->set_value(scaled_value); + Raul::Atom value(static_cast<float>(((float)cc_value / 127.0) * (max - min) + min)); + port->set_value(value); const Events::SendPortValue ev(context.engine(), context.start(), port, true, 0, - scaled_value.get_float()); + value.get_float()); context.event_sink().write(sizeof(ev), &ev); } void +ControlBindings::bind(ProcessContext& context, int8_t cc_num) +{ + _bindings.insert(make_pair(cc_num, _learn_port)); + + const Events::SendBinding ev(context.engine(), context.start(), _learn_port, + MessageType(MessageType::MIDI_CC, cc_num)); + context.event_sink().write(sizeof(ev), &ev); + + _learn_port = NULL; +} + + +void ControlBindings::process(ProcessContext& context, EventBuffer* buffer) { uint32_t frames = 0; @@ -69,8 +84,7 @@ ControlBindings::process(ProcessContext& context, EventBuffer* buffer) while (buffer->get_event(&frames, &subframes, &type, &size, &buf)) { if (type == _map->midi_event && (buf[0] & 0xF0) == MIDI_CMD_CONTROL) { const int8_t controller = static_cast<const int8_t>(buf[1]); - _bindings.insert(make_pair(controller, _learn_port)); - _learn_port = NULL; + bind(context, controller); break; } buffer->increment(); diff --git a/src/engine/ControlBindings.hpp b/src/engine/ControlBindings.hpp index 5e1e123d..8477a0fa 100644 --- a/src/engine/ControlBindings.hpp +++ b/src/engine/ControlBindings.hpp @@ -46,7 +46,8 @@ private: SharedPtr<Shared::LV2URIMap> _map; PortImpl* _learn_port; - void set_port_value(ProcessContext& context, PortImpl* port, int8_t value); + void set_port_value(ProcessContext& context, PortImpl* port, int8_t cc_value); + void bind(ProcessContext& context, int8_t cc_num); typedef std::map<int8_t, PortImpl*> Bindings; Bindings _bindings; diff --git a/src/engine/HTTPClientSender.cpp b/src/engine/HTTPClientSender.cpp index 8804c65c..0c14b06f 100644 --- a/src/engine/HTTPClientSender.cpp +++ b/src/engine/HTTPClientSender.cpp @@ -143,6 +143,13 @@ HTTPClientSender::activity(const Path& path) void +HTTPClientSender::binding(const Path& path, const MessageType& type) +{ + warn << "TODO: HTTP binding" << endl; +} + + +void HTTPClientSender::move(const Path& old_path, const Path& new_path) { string msg = string( diff --git a/src/engine/HTTPClientSender.hpp b/src/engine/HTTPClientSender.hpp index d3bc9505..e7120e81 100644 --- a/src/engine/HTTPClientSender.hpp +++ b/src/engine/HTTPClientSender.hpp @@ -93,6 +93,8 @@ public: virtual void activity(const Raul::Path& path); + virtual void binding(const Raul::Path& path, const Shared::MessageType& type); + private: Engine& _engine; std::string _url; diff --git a/src/engine/OSCClientSender.cpp b/src/engine/OSCClientSender.cpp index 13147a42..f07668ca 100644 --- a/src/engine/OSCClientSender.cpp +++ b/src/engine/OSCClientSender.cpp @@ -20,6 +20,7 @@ #include "raul/log.hpp" #include "raul/AtomLiblo.hpp" #include "interface/ClientInterface.hpp" +#include "interface/MessageType.hpp" #include "EngineStore.hpp" #include "NodeImpl.hpp" #include "OSCClientSender.hpp" @@ -246,4 +247,23 @@ OSCClientSender::activity(const Path& path) } +/** \page client_osc_namespace + * <h2>/ingen/binding</h2> + * \arg \b path (string) - Path of object + * \arg \b type (string) - Type of message (URI) + * \arg \b id (int) - Controller number (if applicable) + * + * Notification of "activity" (e.g. port message blinkenlights). + */ +void +OSCClientSender::binding(const Path& path, const MessageType& type) +{ + if (!_enabled) + return; + + lo_send(_address, "/ingen/binding", "ssi", + path.c_str(), type.type_uri(), type.num(), LO_ARGS_END); +} + + } // namespace Ingen diff --git a/src/engine/OSCClientSender.hpp b/src/engine/OSCClientSender.hpp index c5317a14..1ce58d45 100644 --- a/src/engine/OSCClientSender.hpp +++ b/src/engine/OSCClientSender.hpp @@ -93,6 +93,8 @@ public: virtual void activity(const Raul::Path& path); + virtual void binding(const Raul::Path& path, const Shared::MessageType& type); + private: Raul::URI _url; }; diff --git a/src/engine/events/SendBinding.cpp b/src/engine/events/SendBinding.cpp new file mode 100644 index 00000000..7168b142 --- /dev/null +++ b/src/engine/events/SendBinding.cpp @@ -0,0 +1,39 @@ +/* This file is part of Ingen. + * Copyright (C) 2007-2009 Dave Robillard <http://drobilla.net> + * + * 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 <sstream> +#include "events/SendBinding.hpp" +#include "Engine.hpp" +#include "PortImpl.hpp" +#include "ClientBroadcaster.hpp" + +using namespace std; + +namespace Ingen { +namespace Events { + + +void +SendBinding::post_process() +{ + _engine.broadcaster()->binding(_port->path(), _type); +} + + +} // namespace Ingen +} // namespace Events + diff --git a/src/engine/events/SendBinding.hpp b/src/engine/events/SendBinding.hpp new file mode 100644 index 00000000..303e29fa --- /dev/null +++ b/src/engine/events/SendBinding.hpp @@ -0,0 +1,68 @@ +/* This file is part of Ingen. + * Copyright (C) 2007-2009 Dave Robillard <http://drobilla.net> + * + * 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 SENDBINDINGEVENT_H +#define SENDBINDINGEVENT_H + +#include "raul/Atom.hpp" +#include "interface/MessageType.hpp" +#include "engine/Event.hpp" +#include "engine/types.hpp" + +namespace Ingen { + +class PortImpl; + +namespace Events { + + +/** A special event used internally to send control bindings from the audio thread. + * + * See SendPortValue documentation for details. + * + * \ingroup engine + */ +class SendBinding : public Event +{ +public: + inline SendBinding( + Engine& engine, + SampleCount timestamp, + PortImpl* port, + const Shared::MessageType& type) + : Event(engine, SharedPtr<Responder>(), timestamp) + , _port(port) + , _type(type) + {} + + inline void operator=(const SendBinding& ev) { + _port = ev._port; + _type = ev._type; + } + + void post_process(); + +private: + PortImpl* _port; + Shared::MessageType _type; +}; + + +} // namespace Ingen +} // namespace Events + +#endif // SENDBINDINGEVENT_H diff --git a/src/engine/wscript b/src/engine/wscript index e0ac6d69..7e630387 100644 --- a/src/engine/wscript +++ b/src/engine/wscript @@ -51,6 +51,7 @@ def build(bld): events/RequestAllObjects.cpp events/RequestMetadata.cpp events/RequestPlugins.cpp + events/SendBinding.cpp events/SendPortActivity.cpp events/SendPortValue.cpp events/SetMetadata.cpp |