diff options
author | David Robillard <d@drobilla.net> | 2012-03-19 20:16:46 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-03-19 20:16:46 +0000 |
commit | 254b434f0a79fea54bd963e8ff2e845a5b0cd3a6 (patch) | |
tree | ddf849fc5b64d1096846c28c1f1a742f54c3adff /src/server/internals/Controller.cpp | |
parent | bc3afd8380d59c750c8f8e9bf1ed1b8d4a6826e9 (diff) | |
download | ingen-254b434f0a79fea54bd963e8ff2e845a5b0cd3a6.tar.gz ingen-254b434f0a79fea54bd963e8ff2e845a5b0cd3a6.tar.bz2 ingen-254b434f0a79fea54bd963e8ff2e845a5b0cd3a6.zip |
Partially functioning communication between Ingen LV2 plugin and UI.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4078 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/server/internals/Controller.cpp')
-rw-r--r-- | src/server/internals/Controller.cpp | 52 |
1 files changed, 23 insertions, 29 deletions
diff --git a/src/server/internals/Controller.cpp b/src/server/internals/Controller.cpp index e93d5f27..3c29edd3 100644 --- a/src/server/internals/Controller.cpp +++ b/src/server/internals/Controller.cpp @@ -20,10 +20,10 @@ #include "ingen/shared/LV2URIMap.hpp" #include "ingen/shared/URIs.hpp" #include "internals/Controller.hpp" +#include "lv2/lv2plug.in/ns/ext/atom/util.h" #include "raul/midi_events.h" #include "AudioBuffer.hpp" -#include "EventBuffer.hpp" #include "InputPort.hpp" #include "InternalPlugin.hpp" #include "Notification.hpp" @@ -54,37 +54,38 @@ ControllerNode::ControllerNode(InternalPlugin* plugin, const Ingen::Shared::URIs& uris = bufs.uris(); _ports = new Raul::Array<PortImpl*>(6); - _midi_in_port = new InputPort(bufs, this, "input", 0, 1, PortType::EVENTS, Raul::Atom()); - _midi_in_port->set_property(uris.lv2_name, bufs.forge().make("Input")); + _midi_in_port = new InputPort(bufs, this, "input", 0, 1, + PortType::MESSAGE, uris.atom_Sequence, Raul::Atom()); + _midi_in_port->set_property(uris.lv2_name, bufs.forge().alloc("Input")); _ports->at(0) = _midi_in_port; _param_port = new InputPort(bufs, this, "controller", 1, 1, - PortType::CONTROL, bufs.forge().make(0.0f)); + PortType::CONTROL, 0, bufs.forge().make(0.0f)); _param_port->set_property(uris.lv2_minimum, bufs.forge().make(0.0f)); _param_port->set_property(uris.lv2_maximum, bufs.forge().make(127.0f)); _param_port->set_property(uris.lv2_integer, bufs.forge().make(true)); - _param_port->set_property(uris.lv2_name, bufs.forge().make("Controller")); + _param_port->set_property(uris.lv2_name, bufs.forge().alloc("Controller")); _ports->at(1) = _param_port; _log_port = new InputPort(bufs, this, "logarithmic", 2, 1, - PortType::CONTROL, bufs.forge().make(0.0f)); + PortType::CONTROL, 0, bufs.forge().make(0.0f)); _log_port->set_property(uris.lv2_portProperty, uris.lv2_toggled); - _log_port->set_property(uris.lv2_name, bufs.forge().make("Logarithmic")); + _log_port->set_property(uris.lv2_name, bufs.forge().alloc("Logarithmic")); _ports->at(2) = _log_port; _min_port = new InputPort(bufs, this, "minimum", 3, 1, - PortType::CONTROL, bufs.forge().make(0.0f)); - _min_port->set_property(uris.lv2_name, bufs.forge().make("Minimum")); + PortType::CONTROL, 0, bufs.forge().make(0.0f)); + _min_port->set_property(uris.lv2_name, bufs.forge().alloc("Minimum")); _ports->at(3) = _min_port; _max_port = new InputPort(bufs, this, "maximum", 4, 1, - PortType::CONTROL, bufs.forge().make(1.0f)); - _max_port->set_property(uris.lv2_name, bufs.forge().make("Maximum")); + PortType::CONTROL, 0, bufs.forge().make(1.0f)); + _max_port->set_property(uris.lv2_name, bufs.forge().alloc("Maximum")); _ports->at(4) = _max_port; _audio_port = new OutputPort(bufs, this, "ar_output", 5, 1, - PortType::AUDIO, bufs.forge().make(0.0f)); - _audio_port->set_property(uris.lv2_name, bufs.forge().make("Output")); + PortType::AUDIO, 0, bufs.forge().make(0.0f)); + _audio_port->set_property(uris.lv2_name, bufs.forge().alloc("Output")); _ports->at(5) = _audio_port; } @@ -93,22 +94,15 @@ ControllerNode::process(ProcessContext& context) { NodeImpl::pre_process(context); - uint32_t frames = 0; - uint32_t subframes = 0; - uint16_t type = 0; - uint16_t size = 0; - uint8_t* buf = NULL; - - EventBuffer* const midi_in = (EventBuffer*)_midi_in_port->buffer(0).get(); - - midi_in->rewind(); - - while (midi_in->get_event(&frames, &subframes, &type, &size, &buf)) { - // FIXME: type - if (size >= 3 && (buf[0] & 0xF0) == MIDI_CMD_CONTROL) - control(context, buf[1], buf[2], frames + context.start()); - - midi_in->increment(); + Buffer* const midi_in = _midi_in_port->buffer(0).get(); + LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)midi_in->atom(); + LV2_SEQUENCE_FOREACH(seq, i) { + LV2_Atom_Event* const ev = lv2_sequence_iter_get(i); + const uint8_t* buf = (const uint8_t*)LV2_ATOM_BODY(&ev->body); + if (ev->body.type == _midi_in_port->bufs().uris().midi_MidiEvent && + ev->body.size >= 3 && (buf[0] & 0xF0) == MIDI_CMD_CONTROL) { + control(context, buf[1], buf[2], ev->time.frames + context.start()); + } } NodeImpl::post_process(context); |