Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8ddf42ea33 | ||
![]() |
2d66e616cd |
@ -62,7 +62,7 @@ else
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS := -O3 -Wall -Wpedantic -Wextra
|
CFLAGS := -O0 -g -Wall -Wpedantic -Wextra
|
||||||
CFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) $(shell pkg-config --cflags lv2) -fPIC $(CFLAGS_EXTRA) $(CFLAGS)
|
CFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -I$(API_DIR) $(shell pkg-config --cflags lv2) -fPIC $(CFLAGS_EXTRA) $(CFLAGS)
|
||||||
|
|
||||||
LDFLAGS :=
|
LDFLAGS :=
|
||||||
|
@ -36,6 +36,15 @@
|
|||||||
{{?(it.product.state && it.product.state.dspCustom)}}
|
{{?(it.product.state && it.product.state.dspCustom)}}
|
||||||
lv2:extensionData state:interface ;
|
lv2:extensionData state:interface ;
|
||||||
{{?}}
|
{{?}}
|
||||||
|
|
||||||
|
{{~it.tibia.lv2.parameters:p:i}}
|
||||||
|
{{?p.direction == "input"}}
|
||||||
|
patch:writable plugin:{{=p.id}};
|
||||||
|
{{??}}
|
||||||
|
patch:readable plugin:{{=p.id}};
|
||||||
|
{{?}}
|
||||||
|
{{~}}
|
||||||
|
|
||||||
lv2:port [
|
lv2:port [
|
||||||
{{~it.tibia.lv2.ports :p:i}}
|
{{~it.tibia.lv2.ports :p:i}}
|
||||||
{{?p.isBypass}}
|
{{?p.isBypass}}
|
||||||
@ -68,6 +77,22 @@
|
|||||||
lv2:portProperty lv2:connectionOptional ;
|
lv2:portProperty lv2:connectionOptional ;
|
||||||
lv2:portProperty lv2:integer ;
|
lv2:portProperty lv2:integer ;
|
||||||
lv2:portProperty lv2:reportsLatency ;
|
lv2:portProperty lv2:reportsLatency ;
|
||||||
|
{{??p.isInputParameterMessage}}
|
||||||
|
a lv2:InputPort ,
|
||||||
|
atom:AtomPort ;
|
||||||
|
atom:bufferType atom:Sequence ;
|
||||||
|
atom:supports patch:Message ;
|
||||||
|
lv2:designation lv2:control ;
|
||||||
|
lv2:symbol "InputParameterMessage" ;
|
||||||
|
lv2:name "InputParameterMessage" ;
|
||||||
|
{{??p.isOutputParameterMessage}}
|
||||||
|
a lv2:OutputPort ,
|
||||||
|
atom:AtomPort ;
|
||||||
|
atom:bufferType atom:Sequence ;
|
||||||
|
atom:supports patch:Message ;
|
||||||
|
lv2:designation lv2:control ;
|
||||||
|
lv2:symbol "OutputParameterMessage" ;
|
||||||
|
lv2:name "OutputParameterMessage" ;
|
||||||
{{??}}
|
{{??}}
|
||||||
a {{?p.type == "control"}}lv2:ControlPort{{??p.type == "midi"}}atom:AtomPort{{??}}{{?p.cv}}lv2:CVPort{{??}}lv2:AudioPort{{?}}{{?}} ,
|
a {{?p.type == "control"}}lv2:ControlPort{{??p.type == "midi"}}atom:AtomPort{{??}}{{?p.cv}}lv2:CVPort{{??}}lv2:AudioPort{{?}}{{?}} ,
|
||||||
{{?p.direction == "input"}}lv2:InputPort{{??}}lv2:OutputPort{{?}} ;
|
{{?p.direction == "input"}}lv2:InputPort{{??}}lv2:OutputPort{{?}} ;
|
||||||
@ -129,6 +154,20 @@
|
|||||||
{{?}}
|
{{?}}
|
||||||
{{~}}
|
{{~}}
|
||||||
|
|
||||||
|
{{~it.tibia.lv2.parameters:p:i}}
|
||||||
|
|
||||||
|
plugin:{{=p.id}}
|
||||||
|
a lv2:Parameter ;
|
||||||
|
rdfs:label "{{=p.name}}" ;
|
||||||
|
rdfs:range {{?p.toggled}}atom:Bool{{??p.integer}}atom:Int{{??}}atom:Float{{?}} ;
|
||||||
|
{{?p.unit && p.unit in it.tibia.lv2.units}}
|
||||||
|
units:unit {{=it.tibia.lv2.ttlURI(it.tibia.lv2.units[p.unit])}} ;
|
||||||
|
{{?}}
|
||||||
|
lv2:minimum {{=p.minimum.toExponential()}} ;
|
||||||
|
lv2:maximum {{=p.maximum.toExponential()}} ;
|
||||||
|
lv2:default {{=p.defaultValue.toExponential()}} .
|
||||||
|
{{~}}
|
||||||
|
|
||||||
{{?it.product.ui}}
|
{{?it.product.ui}}
|
||||||
plugin:ui
|
plugin:ui
|
||||||
a ui:@UI_TYPE@ ;
|
a ui:@UI_TYPE@ ;
|
||||||
|
@ -37,12 +37,56 @@ static uint32_t midi_in_index[DATA_PRODUCT_MIDI_INPUTS_N] = {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
|
||||||
|
|
||||||
# define DATA_PARAM_BYPASS 1
|
# define DATA_PARAM_BYPASS 1
|
||||||
# define DATA_PARAM_TOGGLED (1<<1)
|
# define DATA_PARAM_TOGGLED (1<<1)
|
||||||
# define DATA_PARAM_INTEGER (1<<2)
|
# define DATA_PARAM_INTEGER (1<<2)
|
||||||
|
|
||||||
|
{{?it.lv2.use_parameters}}
|
||||||
|
#define DATA_PRODUCT_USE_PARAMETERS 1
|
||||||
|
|
||||||
|
{{?it.tibia.lv2.ports.find(p => p.isInputParameterMessage)}}
|
||||||
|
#define DATA_PRODUCT_IPM {{=it.tibia.lv2.ports.indexOf(it.tibia.lv2.ports.find(p => p.isInputParameterMessage))}}
|
||||||
|
{{?}}
|
||||||
|
{{?it.tibia.lv2.ports.find(p => p.isOutputParameterMessage)}}
|
||||||
|
#define DATA_PRODUCT_OPM {{=it.tibia.lv2.ports.indexOf(it.tibia.lv2.ports.find(p => p.isOutputParameterMessage))}}
|
||||||
|
{{?}}
|
||||||
|
|
||||||
|
|
||||||
|
#if DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N > 0
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
uint32_t index;
|
||||||
|
float min;
|
||||||
|
float max;
|
||||||
|
float def;
|
||||||
|
uint32_t flags;
|
||||||
|
const char *id;
|
||||||
|
} param_data[DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N] = {
|
||||||
|
{{~it.tibia.lv2.parameters :p}}
|
||||||
|
{
|
||||||
|
/* .index = */ {{=p.paramIndex}},
|
||||||
|
/* .min = */ {{=p.minimum.toExponential()}}f,
|
||||||
|
/* .max = */ {{=p.maximum.toExponential()}}f,
|
||||||
|
/* .def = */ {{=p.defaultValue.toExponential()}}f,
|
||||||
|
/* .flags = */ {{?p.isBypass}}DATA_PARAM_BYPASS{{??p.isLatency}}DATA_PARAM_INTEGER{{??}}0{{?p.toggled}} | DATA_PARAM_TOGGLED{{?}}{{?p.integer}} | DATA_PARAM_INTEGER{{?}}{{?}},
|
||||||
|
/* .id = */ DATA_LV2_URI"#{{=p.id}}"
|
||||||
|
},
|
||||||
|
{{~}}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if DATA_PRODUCT_CONTROL_OUTPUTS_N > 0
|
||||||
|
static uint32_t param_out_index[DATA_PRODUCT_CONTROL_OUTPUTS_N] = {
|
||||||
|
{{~it.tibia.lv2.parameters.filter(x => x.direction == "output") :p}}{{=p.paramIndex}}, {{~}}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
{{??}}
|
||||||
|
|
||||||
|
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
uint32_t index;
|
uint32_t index;
|
||||||
float min;
|
float min;
|
||||||
@ -69,6 +113,8 @@ static uint32_t param_out_index[DATA_PRODUCT_CONTROL_OUTPUTS_N] = {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
{{?}}
|
||||||
|
|
||||||
{{?it.product.ui}}
|
{{?it.product.ui}}
|
||||||
#define DATA_UI
|
#define DATA_UI
|
||||||
#define DATA_LV2_UI_URI "{{=it.tibia.CGetUTF8StringLiteral(it.tibia.lv2.expandURI(it.lv2.uri + '#ui'))}}"
|
#define DATA_LV2_UI_URI "{{=it.tibia.CGetUTF8StringLiteral(it.tibia.lv2.expandURI(it.lv2.uri + '#ui'))}}"
|
||||||
|
@ -49,6 +49,10 @@
|
|||||||
#ifdef DATA_STATE_DSP_CUSTOM
|
#ifdef DATA_STATE_DSP_CUSTOM
|
||||||
# include <lv2/state/state.h>
|
# include <lv2/state/state.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if DATA_PRODUCT_USE_PARAMETERS
|
||||||
|
# include "lv2/lv2plug.in/ns/ext/patch/patch.h"
|
||||||
|
# include <lv2/lv2plug.in/ns/ext/atom/forge.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -105,9 +109,6 @@ typedef struct {
|
|||||||
#if DATA_PRODUCT_MIDI_OUTPUTS_N > 0
|
#if DATA_PRODUCT_MIDI_OUTPUTS_N > 0
|
||||||
LV2_Atom_Sequence * y_midi[DATA_PRODUCT_MIDI_OUTPUTS_N];
|
LV2_Atom_Sequence * y_midi[DATA_PRODUCT_MIDI_OUTPUTS_N];
|
||||||
#endif
|
#endif
|
||||||
#if (DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N) > 0
|
|
||||||
float * c[DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N];
|
|
||||||
#endif
|
|
||||||
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
float params[DATA_PRODUCT_CONTROL_INPUTS_N];
|
float params[DATA_PRODUCT_CONTROL_INPUTS_N];
|
||||||
# ifdef DATA_STATE_DSP_CUSTOM
|
# ifdef DATA_STATE_DSP_CUSTOM
|
||||||
@ -131,6 +132,30 @@ typedef struct {
|
|||||||
LV2_State_Store_Function state_store;
|
LV2_State_Store_Function state_store;
|
||||||
LV2_State_Handle state_handle;
|
LV2_State_Handle state_handle;
|
||||||
#endif
|
#endif
|
||||||
|
#if (DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N) > 0
|
||||||
|
# if DATA_PRODUCT_USE_PARAMETERS
|
||||||
|
LV2_URID uri_atom_Blank;
|
||||||
|
LV2_URID uri_atom_Object;
|
||||||
|
LV2_URID uri_atom_URID;
|
||||||
|
LV2_URID uri_atom_Float;
|
||||||
|
LV2_URID uri_atom_Bool;
|
||||||
|
LV2_URID uri_patch_Set;
|
||||||
|
LV2_URID uri_patch_Get;
|
||||||
|
LV2_URID uri_patch_property;
|
||||||
|
LV2_URID uri_patch_value;
|
||||||
|
LV2_URID uri_parameters[DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N]; // TODO: Fix 0 params case
|
||||||
|
# if DATA_PRODUCT_IPM
|
||||||
|
const LV2_Atom_Sequence *controlIn;
|
||||||
|
# endif
|
||||||
|
# if DATA_PRODUCT_OPM
|
||||||
|
const LV2_Atom_Sequence *controlOut;
|
||||||
|
LV2_Atom_Forge forge;
|
||||||
|
LV2_Atom_Float output_parameter_atoms[DATA_PRODUCT_CONTROL_OUTPUTS_N];
|
||||||
|
# endif
|
||||||
|
# else
|
||||||
|
float *c[DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N];
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
} plugin_instance;
|
} plugin_instance;
|
||||||
|
|
||||||
static const char * get_bundle_path_cb(void *handle) {
|
static const char * get_bundle_path_cb(void *handle) {
|
||||||
@ -241,8 +266,29 @@ static LV2_Handle instantiate(const struct LV2_Descriptor * descriptor, double s
|
|||||||
instance->y_midi[i] = NULL;
|
instance->y_midi[i] = NULL;
|
||||||
#endif
|
#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
|
||||||
|
# if DATA_PRODUCT_USE_PARAMETERS
|
||||||
|
instance->uri_atom_Blank = instance->map->map (instance->map->handle, LV2_ATOM__Blank);
|
||||||
|
instance->uri_atom_Object = instance->map->map (instance->map->handle, LV2_ATOM__Object);
|
||||||
|
instance->uri_atom_URID = instance->map->map (instance->map->handle, LV2_ATOM__URID);
|
||||||
|
instance->uri_atom_Float = instance->map->map (instance->map->handle, LV2_ATOM__Float);
|
||||||
|
instance->uri_atom_Bool = instance->map->map (instance->map->handle, LV2_ATOM__Bool);
|
||||||
|
instance->uri_patch_Set = instance->map->map (instance->map->handle, LV2_PATCH__Set);
|
||||||
|
instance->uri_patch_Get = instance->map->map (instance->map->handle, LV2_PATCH__Get);
|
||||||
|
instance->uri_patch_property = instance->map->map (instance->map->handle, LV2_PATCH__property);
|
||||||
|
instance->uri_patch_value = instance->map->map (instance->map->handle, LV2_PATCH__value);
|
||||||
|
for (int i = 0; i < DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N; i++) {
|
||||||
|
instance->uri_parameters[i] = instance->map->map (instance->map->handle, param_data[i].id);
|
||||||
|
}
|
||||||
|
lv2_atom_forge_init(&instance->forge, instance->map);
|
||||||
|
for (int aa = 0; aa < DATA_PRODUCT_CONTROL_OUTPUTS_N; aa++) {
|
||||||
|
instance->output_parameter_atoms[aa].atom.size = sizeof(float);
|
||||||
|
instance->output_parameter_atoms[aa].atom.type = instance->uri_atom_Float;
|
||||||
|
instance->output_parameter_atoms[aa].body = param_data[param_out_index[aa]].def;
|
||||||
|
}
|
||||||
|
# else
|
||||||
for (uint32_t i = 0; i < DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N; i++)
|
for (uint32_t i = 0; i < DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N; i++)
|
||||||
instance->c[i] = NULL;
|
instance->c[i] = NULL;
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
@ -260,6 +306,9 @@ 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) {
|
||||||
|
#if DATA_PRODUCT_USE_PARAMETERS
|
||||||
|
const uint32_t port0 = port;
|
||||||
|
#endif
|
||||||
plugin_instance * i = (plugin_instance *)instance;
|
plugin_instance * i = (plugin_instance *)instance;
|
||||||
#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) {
|
||||||
@ -289,8 +338,24 @@ 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
|
||||||
#if (DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N) > 0
|
|
||||||
|
#if DATA_PRODUCT_USE_PARAMETERS
|
||||||
|
# if DATA_PRODUCT_IPM
|
||||||
|
if (port0 == DATA_PRODUCT_IPM) {
|
||||||
|
i->controlIn = (const LV2_Atom_Sequence*) data_location;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
# if DATA_PRODUCT_OPM
|
||||||
|
if (port0 == DATA_PRODUCT_OPM) {
|
||||||
|
i->controlOut = (const LV2_Atom_Sequence*) data_location;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# if (DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N) > 0
|
||||||
i->c[port] = data_location;
|
i->c[port] = data_location;
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,7 +363,11 @@ static void activate(LV2_Handle instance) {
|
|||||||
plugin_instance * i = (plugin_instance *)instance;
|
plugin_instance * i = (plugin_instance *)instance;
|
||||||
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
#if DATA_PRODUCT_CONTROL_INPUTS_N > 0
|
||||||
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_INPUTS_N; j++) {
|
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_INPUTS_N; j++) {
|
||||||
|
# if DATA_PRODUCT_USE_PARAMETERS
|
||||||
|
i->params[j] = param_data[j].def;
|
||||||
|
# else
|
||||||
i->params[j] = i->c[j] != NULL ? *i->c[j] : param_data[j].def;
|
i->params[j] = i->c[j] != NULL ? *i->c[j] : param_data[j].def;
|
||||||
|
# endif
|
||||||
plugin_set_parameter(&i->p, param_data[j].index, i->params[j]);
|
plugin_set_parameter(&i->p, param_data[j].index, i->params[j]);
|
||||||
}
|
}
|
||||||
# ifdef DATA_STATE_DSP_CUSTOM
|
# ifdef DATA_STATE_DSP_CUSTOM
|
||||||
@ -314,9 +383,32 @@ static void activate(LV2_Handle instance) {
|
|||||||
plugin_reset(&i->p);
|
plugin_reset(&i->p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if DATA_PRODUCT_USE_PARAMETERS
|
||||||
|
static inline int getParamIndexByURI(plugin_instance *instance, LV2_URID uri) {
|
||||||
|
for (int i = 0; i < DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N; i++)
|
||||||
|
if (instance->uri_parameters[i] == uri)
|
||||||
|
return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static LV2_State_Status write_param_to_forge(LV2_State_Handle handle, uint32_t key, const void *value, size_t size, uint32_t type) {
|
||||||
|
LV2_Atom_Forge* forge = (LV2_Atom_Forge*)handle;
|
||||||
|
if (!lv2_atom_forge_key(forge, key) || !lv2_atom_forge_atom(forge, size, type) || !lv2_atom_forge_write(forge, value, size))
|
||||||
|
return LV2_STATE_ERR_UNKNOWN;
|
||||||
|
return LV2_STATE_SUCCESS;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
#if DATA_PRODUCT_USE_PARAMETERS
|
||||||
|
const uint32_t out_capacity = i->controlOut->atom.size;
|
||||||
|
lv2_atom_forge_set_buffer(&i->forge, (uint8_t*)i->controlOut, out_capacity);
|
||||||
|
LV2_Atom_Forge_Frame out_frame;
|
||||||
|
lv2_atom_forge_sequence_head(&i->forge, &out_frame, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__aarch64__)
|
#if defined(__aarch64__)
|
||||||
uint64_t fpcr;
|
uint64_t fpcr;
|
||||||
__asm__ __volatile__ ("mrs %0, fpcr" : "=r"(fpcr));
|
__asm__ __volatile__ ("mrs %0, fpcr" : "=r"(fpcr));
|
||||||
@ -352,23 +444,93 @@ static void run(LV2_Handle instance, uint32_t sample_count) {
|
|||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# if DATA_PRODUCT_USE_PARAMETERS
|
||||||
|
if (i->controlIn && i->map) {
|
||||||
|
LV2_ATOM_SEQUENCE_FOREACH (i->controlIn, ev) {
|
||||||
|
if (ev->body.type != i->uri_atom_Object) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const LV2_Atom_Object *obj = (LV2_Atom_Object*)&ev->body;
|
||||||
|
if (obj->body.otype == i->uri_patch_Set) {
|
||||||
|
const LV2_Atom* property = NULL;
|
||||||
|
lv2_atom_object_get (obj, i->uri_patch_property, &property, 0);
|
||||||
|
if (!property || property->type != i->uri_atom_URID)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const LV2_Atom* val = NULL;
|
||||||
|
lv2_atom_object_get (obj, i->uri_patch_value, &val, 0);
|
||||||
|
if (!val)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
int index = getParamIndexByURI(i, ((LV2_Atom_URID*)property)->body);
|
||||||
|
if (index < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
float v = adjust_param(index, *((float*)(val + 1)));
|
||||||
|
if (v != i->params[index]) {
|
||||||
|
i->params[index] = v;
|
||||||
|
# ifdef DATA_STATE_DSP_CUSTOM
|
||||||
|
if (locked) {
|
||||||
|
i->params_sync[index] = i->params[index];
|
||||||
|
# endif
|
||||||
|
plugin_set_parameter(&i->p, param_data[index].index, v);
|
||||||
|
# ifdef DATA_STATE_DSP_CUSTOM
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (obj->body.otype == i->uri_patch_Get) {
|
||||||
|
const LV2_Atom_URID *property = NULL;
|
||||||
|
lv2_atom_object_get(obj, i->uri_patch_property, (const LV2_Atom**)&property, 0);
|
||||||
|
|
||||||
|
if (!property || property->atom.type != i->uri_atom_URID)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const LV2_URID key = property->body;
|
||||||
|
const int index = getParamIndexByURI(i, key);
|
||||||
|
if (index < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
int outIndex = -1;
|
||||||
|
for (int p = 0; p < DATA_PRODUCT_CONTROL_OUTPUTS_N; p++) {
|
||||||
|
if (param_out_index[p] == (uint32_t) index)
|
||||||
|
outIndex = p;
|
||||||
|
}
|
||||||
|
if (outIndex == -1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const LV2_Atom* value = &i->output_parameter_atoms[outIndex].atom;
|
||||||
|
LV2_Atom_Forge_Frame frame;
|
||||||
|
lv2_atom_forge_frame_time(&i->forge, ev->time.frames);
|
||||||
|
lv2_atom_forge_object( &i->forge, &frame, 0, i->uri_patch_Set);
|
||||||
|
lv2_atom_forge_key( &i->forge, i->uri_patch_property);
|
||||||
|
lv2_atom_forge_urid( &i->forge, property->body);
|
||||||
|
write_param_to_forge( &i->forge, i->uri_patch_value, value + 1, value->size, value->type);
|
||||||
|
lv2_atom_forge_pop( &i->forge, &frame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# else
|
||||||
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_INPUTS_N; j++) {
|
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_INPUTS_N; j++) {
|
||||||
if (i->c[j] == NULL)
|
if (i->c[j] == NULL)
|
||||||
continue;
|
continue;
|
||||||
float v = adjust_param(j, *i->c[j]);
|
float v = adjust_param(j, *i->c[j]);
|
||||||
if (v != i->params[j]) {
|
if (v != i->params[j]) {
|
||||||
i->params[j] = v;
|
i->params[j] = v;
|
||||||
# ifdef DATA_STATE_DSP_CUSTOM
|
# ifdef DATA_STATE_DSP_CUSTOM
|
||||||
if (locked) {
|
if (locked) {
|
||||||
i->params_sync[j] = i->params[j];
|
i->params_sync[j] = i->params[j];
|
||||||
# endif
|
# endif
|
||||||
plugin_set_parameter(&i->p, param_data[j].index, v);
|
plugin_set_parameter(&i->p, param_data[j].index, v);
|
||||||
# ifdef DATA_STATE_DSP_CUSTOM
|
# ifdef DATA_STATE_DSP_CUSTOM
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# endif
|
||||||
|
|
||||||
# ifdef DATA_STATE_DSP_CUSTOM
|
# ifdef DATA_STATE_DSP_CUSTOM
|
||||||
if (locked)
|
if (locked)
|
||||||
atomic_flag_clear(&i->sync_lock_flag);
|
atomic_flag_clear(&i->sync_lock_flag);
|
||||||
@ -404,11 +566,31 @@ static void run(LV2_Handle instance, uint32_t sample_count) {
|
|||||||
plugin_process(&i->p, x, y, sample_count);
|
plugin_process(&i->p, x, y, sample_count);
|
||||||
|
|
||||||
#if DATA_PRODUCT_CONTROL_OUTPUTS_N > 0
|
#if DATA_PRODUCT_CONTROL_OUTPUTS_N > 0
|
||||||
|
# if DATA_PRODUCT_USE_PARAMETERS
|
||||||
|
|
||||||
|
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_OUTPUTS_N; j++) {
|
||||||
|
|
||||||
|
float v = plugin_get_parameter(&i->p, param_out_index[j]);
|
||||||
|
i->output_parameter_atoms[j].body = v;
|
||||||
|
lv2_atom_forge_frame_time(&i->forge, 0);
|
||||||
|
LV2_Atom_Forge_Frame frame;
|
||||||
|
lv2_atom_forge_object(&i->forge, &frame, 0, i->uri_patch_Set);
|
||||||
|
lv2_atom_forge_key( &i->forge, i->uri_patch_property);
|
||||||
|
lv2_atom_forge_urid( &i->forge, i->uri_parameters[param_out_index[j]]);
|
||||||
|
lv2_atom_forge_key( &i->forge, i->uri_patch_value);
|
||||||
|
lv2_atom_forge_float( &i->forge, i->output_parameter_atoms[j].body);
|
||||||
|
lv2_atom_forge_pop( &i->forge, &frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
lv2_atom_forge_pop(&i->forge, &out_frame);
|
||||||
|
|
||||||
|
# else
|
||||||
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_OUTPUTS_N; j++) {
|
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_OUTPUTS_N; j++) {
|
||||||
uint32_t k = param_out_index[j];
|
uint32_t k = param_out_index[j];
|
||||||
if (i->c[k] != NULL)
|
if (i->c[k] != NULL)
|
||||||
*i->c[k] = plugin_get_parameter(&i->p, k);
|
*i->c[k] = plugin_get_parameter(&i->p, k);
|
||||||
}
|
}
|
||||||
|
# endif
|
||||||
#else
|
#else
|
||||||
(void)plugin_get_parameter;
|
(void)plugin_get_parameter;
|
||||||
#endif
|
#endif
|
||||||
@ -419,6 +601,7 @@ static void run(LV2_Handle instance, uint32_t sample_count) {
|
|||||||
_MM_SET_FLUSH_ZERO_MODE(flush_zero_mode);
|
_MM_SET_FLUSH_ZERO_MODE(flush_zero_mode);
|
||||||
_MM_SET_DENORMALS_ZERO_MODE(denormals_zero_mode);
|
_MM_SET_DENORMALS_ZERO_MODE(denormals_zero_mode);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cleanup(LV2_Handle instance) {
|
static void cleanup(LV2_Handle instance) {
|
||||||
|
@ -37,7 +37,8 @@ module.exports = function (data, api, outputCommon, outputData) {
|
|||||||
{ id: "state", uri: "http://lv2plug.in/ns/extensions/state#" },
|
{ id: "state", uri: "http://lv2plug.in/ns/extensions/state#" },
|
||||||
{ id: "ui", uri: "http://lv2plug.in/ns/extensions/ui#" },
|
{ id: "ui", uri: "http://lv2plug.in/ns/extensions/ui#" },
|
||||||
{ id: "units", uri: "http://lv2plug.in/ns/extensions/units#" },
|
{ id: "units", uri: "http://lv2plug.in/ns/extensions/units#" },
|
||||||
{ id: "urid", uri: "http://lv2plug.in/ns/ext/urid#" }
|
{ id: "urid", uri: "http://lv2plug.in/ns/ext/urid#" },
|
||||||
|
{ id: "patch", uri: "http://lv2plug.in/ns/ext/patch#"}
|
||||||
],
|
],
|
||||||
units: {
|
units: {
|
||||||
"bar": "@units:bar",
|
"bar": "@units:bar",
|
||||||
@ -115,16 +116,38 @@ 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 = [];
|
if (data.lv2.use_parameters) {
|
||||||
for (var i = 0; i < data.product.parameters.length; i++) {
|
let parameters = [];
|
||||||
var p = data.product.parameters[i];
|
for (var i = 0; i < data.product.parameters.length; i++) {
|
||||||
var e = Object.create(p);
|
let e = Object.create(data.product.parameters[i]);
|
||||||
e.type = "control";
|
e.paramIndex = i;
|
||||||
e.paramIndex = i;
|
parameters.push(e);
|
||||||
ports.push(e);
|
}
|
||||||
|
data.tibia.lv2.parameters = parameters;
|
||||||
|
|
||||||
|
if (data.product.parameters.find(p => p.direction == "input")) {
|
||||||
|
data.tibia.lv2.ports.push({
|
||||||
|
isInputParameterMessage: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (data.product.parameters.find(p => p.direction == "output")) {
|
||||||
|
data.tibia.lv2.ports.push({
|
||||||
|
isOutputParameterMessage: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
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);
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
"uri": "@example:tibia_test",
|
"uri": "@example:tibia_test",
|
||||||
"project": "@example:project",
|
"project": "@example:project",
|
||||||
"types": [ "@lv2:AmplifierPlugin" ],
|
"types": [ "@lv2:AmplifierPlugin" ],
|
||||||
"version": "1.0"
|
"version": "1.0",
|
||||||
|
|
||||||
|
"use_parameters": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user