summaryrefslogtreecommitdiffstats
path: root/src/engine/ControlBindings.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-03-06 10:23:19 +0000
committerDavid Robillard <d@drobilla.net>2010-03-06 10:23:19 +0000
commit059f20c9666234f2be01498ee04f1e7ee795ba8f (patch)
treeef0d53073d53012aeaa7d084fccf477b166c0684 /src/engine/ControlBindings.cpp
parent085a451dfec54126be1b9346899c81d82e6eb58e (diff)
downloadingen-059f20c9666234f2be01498ee04f1e7ee795ba8f.tar.gz
ingen-059f20c9666234f2be01498ee04f1e7ee795ba8f.tar.bz2
ingen-059f20c9666234f2be01498ee04f1e7ee795ba8f.zip
Save Ingen patches as working standard LV2 plugin bundles.
This allows you to create an Ingen patch in Ingen running as a Jack client, save it, then load that patch as an LV2 plugin in any LV2 compliant host. Eliminate (hopefully) all static data in the engine (for multiple instantiations in a single process). More API/ABI stable interface for Ingen::Shared::World. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2533 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine/ControlBindings.cpp')
-rw-r--r--src/engine/ControlBindings.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/engine/ControlBindings.cpp b/src/engine/ControlBindings.cpp
index ead1e6ea..e861d2ed 100644
--- a/src/engine/ControlBindings.cpp
+++ b/src/engine/ControlBindings.cpp
@@ -18,6 +18,8 @@
#include <math.h>
#include "raul/log.hpp"
#include "raul/midi_events.h"
+#include "shared/LV2URIMap.hpp"
+#include "module/World.hpp"
#include "events/SendPortValue.hpp"
#include "events/SendBinding.hpp"
#include "AudioBuffer.hpp"
@@ -36,9 +38,8 @@ using namespace Raul;
namespace Ingen {
-ControlBindings::ControlBindings(Engine& engine, SharedPtr<Shared::LV2URIMap> map)
+ControlBindings::ControlBindings(Engine& engine)
: _engine(engine)
- , _map(map)
, _learn_port(NULL)
, _bindings(new Bindings())
, _feedback(new EventBuffer(*_engine.buffer_factory(), 1024)) // FIXME: size
@@ -55,8 +56,8 @@ ControlBindings::~ControlBindings()
ControlBindings::Key
ControlBindings::port_binding(PortImpl* port)
{
- const Shared::LV2URIMap& uris = Shared::LV2URIMap::instance();
- const Raul::Atom& binding = port->get_property(uris.ingen_controlBinding);
+ const Shared::LV2URIMap& uris = *_engine.world()->uris().get();
+ const Raul::Atom& binding = port->get_property(uris.ingen_controlBinding);
Key key;
if (binding.type() == Atom::DICT) {
const Atom::DictValue& dict = binding.get_dict();
@@ -114,6 +115,7 @@ ControlBindings::port_binding_changed(ProcessContext& context, PortImpl* port)
void
ControlBindings::port_value_changed(ProcessContext& context, PortImpl* port)
{
+ const Shared::LV2URIMap& uris = *_engine.world()->uris().get();
Key key = port_binding(port);
if (key) {
int16_t value = port_value_to_control(port, key.type);
@@ -150,7 +152,7 @@ ControlBindings::port_value_changed(ProcessContext& context, PortImpl* port)
break;
}
if (size > 0)
- _feedback->append(0, 0, _map->midi_event.id, size, buf);
+ _feedback->append(0, 0, uris.midi_event.id, size, buf);
}
}
@@ -166,7 +168,7 @@ ControlBindings::learn(PortImpl* port)
Raul::Atom
ControlBindings::control_to_port_value(PortImpl* port, Type type, int16_t value)
{
- const Shared::LV2URIMap& uris = Shared::LV2URIMap::instance();
+ const Shared::LV2URIMap& uris = *_engine.world()->uris().get();
// TODO: cache these to avoid the lookup
float min = port->get_property(uris.lv2_minimum).get_float();
@@ -203,7 +205,7 @@ ControlBindings::port_value_to_control(PortImpl* port, Type type)
if (port->value().type() != Atom::FLOAT)
return 0;
- const Shared::LV2URIMap& uris = Shared::LV2URIMap::instance();
+ const Shared::LV2URIMap& uris = *_engine.world()->uris().get();
// TODO: cache these to avoid the lookup
float min = port->get_property(uris.lv2_minimum).get_float();
@@ -259,7 +261,7 @@ ControlBindings::set_port_value(ProcessContext& context, PortImpl* port, Type ty
bool
ControlBindings::bind(ProcessContext& context, Key key)
{
- const Shared::LV2URIMap& uris = Shared::LV2URIMap::instance();
+ const Shared::LV2URIMap& uris = *context.engine().world()->uris().get();
assert(_learn_port);
if (key.type == MIDI_NOTE) {
bool toggled = _learn_port->has_property(uris.lv2_portProperty, uris.lv2_toggled);
@@ -336,12 +338,14 @@ ControlBindings::pre_process(ProcessContext& context, EventBuffer* buffer)
SharedPtr<Bindings> bindings = _bindings;
_feedback->clear();
+ const Shared::LV2URIMap& uris = *context.engine().world()->uris().get();
+
// Learn from input if necessary
if (_learn_port) {
for (buffer->rewind();
buffer->get_event(&frames, &subframes, &type, &size, &buf);
buffer->increment()) {
- if (type != _map->midi_event.id)
+ if (type != uris.midi_event.id)
continue;
const Key key = midi_event_key(size, buf, value);
@@ -358,7 +362,7 @@ ControlBindings::pre_process(ProcessContext& context, EventBuffer* buffer)
for (buffer->rewind();
buffer->get_event(&frames, &subframes, &type, &size, &buf);
buffer->increment()) {
- if (type != _map->midi_event.id)
+ if (type != uris.midi_event.id)
continue;
const Key key = midi_event_key(size, buf, value);