Browse Source

Implement LV2 MIDI out

tags/1.9.4
falkTX 12 years ago
parent
commit
d4b6f523d3
3 changed files with 78 additions and 1 deletions
  1. +9
    -0
      source/backend/CarlaEngine.hpp
  2. +68
    -0
      source/backend/plugin/Lv2Plugin.cpp
  3. +1
    -1
      source/carla_shared.py

+ 9
- 0
source/backend/CarlaEngine.hpp View File

@@ -19,6 +19,7 @@
#define __CARLA_ENGINE_HPP__

#include "CarlaBackend.hpp"
#include "CarlaMIDI.h"
#include "CarlaString.hpp"

#ifdef BUILD_BRIDGE
@@ -525,6 +526,14 @@ public:
*/
virtual void writeMidiEvent(const uint32_t time, const uint8_t channel, const uint8_t port, const uint8_t* const data, const uint8_t size);

/*!
* Write a MIDI event into the buffer, overloaded call.
*/
void writeMidiEvent(const uint32_t time, const uint8_t* const data, const uint8_t size)
{
writeMidiEvent(time, MIDI_GET_CHANNEL_FROM_DATA(data), 0, data, size);
}

/*!
* Write a MIDI event into the buffer, overloaded call.
*/


+ 68
- 0
source/backend/plugin/Lv2Plugin.cpp View File

@@ -2889,6 +2889,74 @@ public:

CARLA_PROCESS_CONTINUE_CHECK;

// --------------------------------------------------------------------------------------------------------
// MIDI Output

if (fEventsOut.ctrl != nullptr && fEventsOut.ctrl->port != nullptr)
{
if (fEventsOut.ctrl->type & CARLA_EVENT_DATA_ATOM)
{
const LV2_Atom_Event* ev;
LV2_Atom_Buffer_Iterator iter;

uint8_t* data;
lv2_atom_buffer_begin(&iter, fEventsOut.ctrl->atom);

while (true)
{
data = nullptr;
ev = lv2_atom_buffer_get(&iter, &data);

if (ev == nullptr || data == nullptr)
break;

if (ev->body.type == CARLA_URI_MAP_ID_MIDI_EVENT)
fEventsOut.ctrl->port->writeMidiEvent(ev->time.frames, data, ev->body.size);

lv2_atom_buffer_increment(&iter);
}
}
else if (fEventsOut.ctrl->type & CARLA_EVENT_DATA_EVENT)
{
const LV2_Event* ev;
LV2_Event_Iterator iter;

uint8_t* data;
lv2_event_begin(&iter, fEventsOut.ctrl->event);

while (true)
{
data = nullptr;
ev = lv2_event_get(&iter, &data);

if (ev == nullptr || data == nullptr)
break;

if (ev->type == CARLA_URI_MAP_ID_MIDI_EVENT)
fEventsOut.ctrl->port->writeMidiEvent(ev->frames, data, ev->size);

lv2_event_increment(&iter);
}
}
else if (fEventsOut.ctrl->type & CARLA_EVENT_DATA_MIDI_LL)
{
LV2_MIDIState state = { fEventsOut.ctrl->midi, frames, 0 };

uint32_t eventSize;
double eventTime;
unsigned char* eventData;

while (lv2midi_get_event(&state, &eventTime, &eventSize, &eventData) < frames)
{
if (eventData == nullptr || eventSize == 0)
break;

fEventsOut.ctrl->port->writeMidiEvent(eventTime, eventData, eventSize);
lv2midi_step(&state);
}
}
}

// --------------------------------------------------------------------------------------------------------
// Control Output



+ 1
- 1
source/carla_shared.py View File

@@ -911,7 +911,7 @@ class CarlaAboutW(QDialog):
#"<li>http://lv2plug.in/ns/ext/patch</li>"
#"<li>http://lv2plug.in/ns/ext/port-groups</li>"
#"<li>http://lv2plug.in/ns/ext/port-props</li>"
#"<li>http://lv2plug.in/ns/ext/presets</li>"
"<li>http://lv2plug.in/ns/ext/presets</li>"
"<li>http://lv2plug.in/ns/ext/state</li>"
"<li>http://lv2plug.in/ns/ext/time</li>"
"<li>http://lv2plug.in/ns/ext/uri-map</li>"


Loading…
Cancel
Save