summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2013-05-19 17:19:01 +0200
committerRobin Gareus <robin@gareus.org>2013-05-19 17:19:01 +0200
commitdb3961323894d93d7159f6bc254aefe7a7ac1f99 (patch)
tree81070e82c50690a9e4bf2a2c4d5b278b3fb46475 /libs/ardour
parent1acf8bdc674ac0ebfd5fc39885c7fe9e70840960 (diff)
Forward midi feedback from LV2 plugins and allow to chain LV2 midi plugins.
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/ardour/buffer_set.h3
-rw-r--r--libs/ardour/buffer_set.cc19
-rw-r--r--libs/ardour/lv2_plugin.cc24
3 files changed, 44 insertions, 2 deletions
diff --git a/libs/ardour/ardour/buffer_set.h b/libs/ardour/ardour/buffer_set.h
index 3cb6cbdbd9..1a1d564288 100644
--- a/libs/ardour/ardour/buffer_set.h
+++ b/libs/ardour/ardour/buffer_set.h
@@ -122,6 +122,9 @@ public:
/** Flush modified LV2 event output buffers back to Ardour buffers */
void flush_lv2_midi(bool input, size_t i);
+
+ /** Forward plugin MIDI output to to Ardour buffers */
+ void forward_lv2_midi(LV2_Evbuf*, size_t, bool purge_ardour_buffer = true);
#endif
#if defined VST_SUPPORT || defined LXVST_SUPPORT
diff --git a/libs/ardour/buffer_set.cc b/libs/ardour/buffer_set.cc
index 1f8317ffe2..c231a8f402 100644
--- a/libs/ardour/buffer_set.cc
+++ b/libs/ardour/buffer_set.cc
@@ -266,6 +266,25 @@ BufferSet::get_lv2_midi(bool input, size_t i, bool old_api)
}
void
+BufferSet::forward_lv2_midi(LV2_Evbuf* buf, size_t i, bool purge_ardour_buffer)
+{
+ MidiBuffer& mbuf = get_midi(i);
+ if (purge_ardour_buffer) {
+ mbuf.silence(0, 0);
+ }
+ for (LV2_Evbuf_Iterator i = lv2_evbuf_begin(buf);
+ lv2_evbuf_is_valid(i);
+ i = lv2_evbuf_next(i)) {
+ uint32_t frames, subframes, type, size;
+ uint8_t* data;
+ lv2_evbuf_get(i, &frames, &subframes, &type, &size, &data);
+ if (type == LV2Plugin::urids.midi_MidiEvent) {
+ mbuf.push_back(frames, size, data);
+ }
+ }
+}
+
+void
BufferSet::flush_lv2_midi(bool input, size_t i)
{
MidiBuffer& mbuf = get_midi(i);
diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc
index c900a21176..0389a33c69 100644
--- a/libs/ardour/lv2_plugin.cc
+++ b/libs/ardour/lv2_plugin.cc
@@ -1640,8 +1640,28 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
PortFlags flags = _port_flags[port_index];
bool valid = false;
- // Flush MIDI (write back to Ardour MIDI buffers)
- if ((flags & PORT_OUTPUT) && (flags & (PORT_EVENT|PORT_SEQUENCE))) {
+ /* TODO ask drobilla about comment
+ * "Make Ardour event buffers generic so plugins can communicate"
+ * in libs/ardour/buffer_set.cc:310
+ *
+ * ideally the user could choose which of the following two modes
+ * to use (e.g. instrument/effect chains MIDI OUT vs MIDI TRHU).
+ *
+ * This implementation follows the discussion on IRC Mar 16 2013 16:47 UTC
+ * 16:51 < drobilla> rgareus: [..] i.e always replace with MIDI output [of LV2 plugin] if it's there
+ * 16:52 < drobilla> rgareus: That would probably be good enough [..] to make users not complain
+ * for quite a while at least ;)
+ */
+ // copy output of LV2 plugin's MIDI port to Ardour MIDI buffers -- MIDI OUT
+ if ((flags & PORT_OUTPUT) && (flags & (PORT_EVENT|PORT_SEQUENCE|PORT_MIDI))) {
+ const uint32_t buf_index = out_map.get(
+ DataType::MIDI, midi_out_index++, &valid);
+ if (valid) {
+ bufs.forward_lv2_midi(_ev_buffers[port_index], buf_index);
+ }
+ }
+ // Flush MIDI (write back to Ardour MIDI buffers) -- MIDI THRU
+ else if ((flags & PORT_OUTPUT) && (flags & (PORT_EVENT|PORT_SEQUENCE))) {
const uint32_t buf_index = out_map.get(
DataType::MIDI, midi_out_index++, &valid);
if (valid) {