lv2 messaging: fix proper ports order
This commit is contained in:
parent
f7b8b434c8
commit
7d9f2a0c3a
@ -89,7 +89,10 @@ static uint32_t index_to_param[DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONT
|
|||||||
|
|
||||||
{{?it.product.messaging}}
|
{{?it.product.messaging}}
|
||||||
#define DATA_MESSAGING 1
|
#define DATA_MESSAGING 1
|
||||||
|
#define DATA_MESSAGING_PORTS_N 2
|
||||||
#define DATA_MESSAGING_MAX {{=it.product.messaging.maxSize}}
|
#define DATA_MESSAGING_MAX {{=it.product.messaging.maxSize}}
|
||||||
#define DATA_MESSAGING_PORT_IN {{=it.tibia.lv2.ports.indexOf(it.tibia.lv2.ports.find(p => p.id == 'message_in'))}}
|
#define DATA_MESSAGING_PORT_IN {{=it.tibia.lv2.ports.indexOf(it.tibia.lv2.ports.find(p => p.id == 'message_in'))}}
|
||||||
#define DATA_MESSAGING_PORT_OUT {{=it.tibia.lv2.ports.indexOf(it.tibia.lv2.ports.find(p => p.id == 'message_out'))}}
|
#define DATA_MESSAGING_PORT_OUT {{=it.tibia.lv2.ports.indexOf(it.tibia.lv2.ports.find(p => p.id == 'message_out'))}}
|
||||||
|
{{??}}
|
||||||
|
#define DATA_MESSAGING_PORTS_N 0
|
||||||
{{?}}
|
{{?}}
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#define TEMPLATE_SUPPORTS_MESSAGING 1
|
||||||
|
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "plugin_api.h"
|
#include "plugin_api.h"
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
@ -74,7 +76,8 @@
|
|||||||
DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N \
|
DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N \
|
||||||
+ DATA_PRODUCT_AUDIO_OUTPUT_CHANNELS_N \
|
+ DATA_PRODUCT_AUDIO_OUTPUT_CHANNELS_N \
|
||||||
+ DATA_PRODUCT_MIDI_INPUTS_N \
|
+ DATA_PRODUCT_MIDI_INPUTS_N \
|
||||||
+ DATA_PRODUCT_MIDI_OUTPUTS_N )
|
+ DATA_PRODUCT_MIDI_OUTPUTS_N \
|
||||||
|
+ DATA_MESSAGING_PORTS_N )
|
||||||
#define CONTROL_OUTPUT_INDEX_OFFSET (CONTROL_INPUT_INDEX_OFFSET + DATA_PRODUCT_CONTROL_INPUTS_N)
|
#define CONTROL_OUTPUT_INDEX_OFFSET (CONTROL_INPUT_INDEX_OFFSET + DATA_PRODUCT_CONTROL_INPUTS_N)
|
||||||
|
|
||||||
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
@ -330,18 +333,7 @@ err_instance:
|
|||||||
|
|
||||||
static void connect_port(LV2_Handle instance, uint32_t port, void * data_location) {
|
static void connect_port(LV2_Handle instance, uint32_t port, void * data_location) {
|
||||||
plugin_instance * i = (plugin_instance *)instance;
|
plugin_instance * i = (plugin_instance *)instance;
|
||||||
printf("connect_port %u \n", port);
|
|
||||||
#ifdef DATA_MESSAGING
|
|
||||||
// Well, these should stay last...
|
|
||||||
if (port == DATA_MESSAGING_PORT_IN) {
|
|
||||||
i->control = (const LV2_Atom_Sequence*)data_location;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (port == DATA_MESSAGING_PORT_OUT) {
|
|
||||||
i->notify = (LV2_Atom_Sequence*)data_location;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N > 0
|
#if DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N > 0
|
||||||
if (port < DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N) {
|
if (port < DATA_PRODUCT_AUDIO_INPUT_CHANNELS_N) {
|
||||||
i->x[port] = data_location;
|
i->x[port] = data_location;
|
||||||
@ -370,6 +362,19 @@ static void connect_port(LV2_Handle instance, uint32_t port, void * data_locatio
|
|||||||
}
|
}
|
||||||
port -= DATA_PRODUCT_MIDI_OUTPUTS_N;
|
port -= DATA_PRODUCT_MIDI_OUTPUTS_N;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef DATA_MESSAGING
|
||||||
|
if (port < DATA_MESSAGING_PORTS_N) {
|
||||||
|
if (port == 0) {
|
||||||
|
i->control = (const LV2_Atom_Sequence*)data_location;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (port == 1) {
|
||||||
|
i->notify = (LV2_Atom_Sequence*)data_location;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
port -= DATA_MESSAGING_PORTS_N;
|
||||||
|
#endif
|
||||||
#if (DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N) > 0
|
#if (DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N) > 0
|
||||||
i->c[port] = data_location;
|
i->c[port] = data_location;
|
||||||
#endif
|
#endif
|
||||||
@ -398,8 +403,6 @@ static void activate(LV2_Handle instance) {
|
|||||||
static void run(LV2_Handle instance, uint32_t sample_count) {
|
static void run(LV2_Handle instance, uint32_t sample_count) {
|
||||||
plugin_instance * i = (plugin_instance *)instance;
|
plugin_instance * i = (plugin_instance *)instance;
|
||||||
|
|
||||||
printf("run A \n"); fflush(stdout);
|
|
||||||
|
|
||||||
if (0 && i->control) {
|
if (0 && i->control) {
|
||||||
const LV2_Atom_Event* ev = lv2_atom_sequence_begin(&(i->control)->body);
|
const LV2_Atom_Event* ev = lv2_atom_sequence_begin(&(i->control)->body);
|
||||||
while (!lv2_atom_sequence_is_end(&i->control->body, i->control->atom.size, ev)) {
|
while (!lv2_atom_sequence_is_end(&i->control->body, i->control->atom.size, ev)) {
|
||||||
@ -413,7 +416,7 @@ static void run(LV2_Handle instance, uint32_t sample_count) {
|
|||||||
lv2_atom_object_get(obj, i->c_uris.prop_customMessage, &msg_atom, 0);
|
lv2_atom_object_get(obj, i->c_uris.prop_customMessage, &msg_atom, 0);
|
||||||
|
|
||||||
printf("audio - custom msg %d \n", i->c_uris.prop_customMessage);
|
printf("audio - custom msg %d \n", i->c_uris.prop_customMessage);
|
||||||
printf("audio - %p \n", msg_atom);
|
printf("audio - %p \n", (void*) msg_atom);
|
||||||
printf("audio - %d %d \n", msg_atom->type, i->c_uris.atom_String);
|
printf("audio - %d %d \n", msg_atom->type, i->c_uris.atom_String);
|
||||||
|
|
||||||
if (msg_atom && msg_atom->type == i->c_uris.atom_String) {
|
if (msg_atom && msg_atom->type == i->c_uris.atom_String) {
|
||||||
@ -808,6 +811,7 @@ static void ui_port_event(LV2UI_Handle handle, uint32_t port_index, uint32_t buf
|
|||||||
* - format == 0: Control port event (float)
|
* - format == 0: Control port event (float)
|
||||||
* - format > 0: Message (atom)
|
* - format > 0: Message (atom)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (format == instance->c_uris.atom_eventTransfer && lv2_atom_forge_is_object_type(&instance->forge, atom->type)) {
|
if (format == instance->c_uris.atom_eventTransfer && lv2_atom_forge_is_object_type(&instance->forge, atom->type)) {
|
||||||
const LV2_Atom_Object* obj = (const LV2_Atom_Object*)atom;
|
const LV2_Atom_Object* obj = (const LV2_Atom_Object*)atom;
|
||||||
if (obj->body.otype == instance->c_uris.prop_customMessage) {
|
if (obj->body.otype == instance->c_uris.prop_customMessage) {
|
||||||
|
@ -114,17 +114,6 @@ module.exports = function (data, api, outputCommon, outputData) {
|
|||||||
data.tibia.lv2.ports.push.apply(data.tibia.lv2.ports, audioPorts);
|
data.tibia.lv2.ports.push.apply(data.tibia.lv2.ports, audioPorts);
|
||||||
data.tibia.lv2.ports.push.apply(data.tibia.lv2.ports, midiPorts);
|
data.tibia.lv2.ports.push.apply(data.tibia.lv2.ports, midiPorts);
|
||||||
|
|
||||||
var ports = [];
|
|
||||||
for (var i = 0; i < data.product.parameters.length; i++) {
|
|
||||||
var p = data.product.parameters[i];
|
|
||||||
var e = Object.create(p);
|
|
||||||
e.type = "control";
|
|
||||||
e.paramIndex = i;
|
|
||||||
ports.push(e);
|
|
||||||
}
|
|
||||||
ports.sort((a, b) => a.direction != b.direction ? (a.direction == "input" ? -1 : 1) : 0);
|
|
||||||
data.tibia.lv2.ports.push.apply(data.tibia.lv2.ports, ports);
|
|
||||||
|
|
||||||
if (data.product.messaging) {
|
if (data.product.messaging) {
|
||||||
const ps = [
|
const ps = [
|
||||||
{
|
{
|
||||||
@ -145,6 +134,17 @@ module.exports = function (data, api, outputCommon, outputData) {
|
|||||||
];
|
];
|
||||||
data.tibia.lv2.ports.push.apply(data.tibia.lv2.ports, ps);
|
data.tibia.lv2.ports.push.apply(data.tibia.lv2.ports, ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ports = [];
|
||||||
|
for (var i = 0; i < data.product.parameters.length; i++) {
|
||||||
|
var p = data.product.parameters[i];
|
||||||
|
var e = Object.create(p);
|
||||||
|
e.type = "control";
|
||||||
|
e.paramIndex = i;
|
||||||
|
ports.push(e);
|
||||||
|
}
|
||||||
|
ports.sort((a, b) => a.direction != b.direction ? (a.direction == "input" ? -1 : 1) : 0);
|
||||||
|
data.tibia.lv2.ports.push.apply(data.tibia.lv2.ports, ports);
|
||||||
}
|
}
|
||||||
|
|
||||||
api.generateFileFromTemplateFile(`data${sep}manifest.ttl.in`, `data${sep}manifest.ttl.in`, data);
|
api.generateFileFromTemplateFile(`data${sep}manifest.ttl.in`, `data${sep}manifest.ttl.in`, data);
|
||||||
|
Loading…
Reference in New Issue
Block a user