Commit 1cfee8c1 authored by ale's avatar ale

Export LV2 plugin latency over a control port

parent fca90104
......@@ -5,6 +5,7 @@
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix state: <http://lv2plug.in/ns/ext/state#> .
@prefix ui: <http://lv2plug.in/ns/extensions/ui#> .
@prefix units: <http://lv2plug.in/ns/extensions/units#> .
@prefix urid: <http://lv2plug.in/ns/ext/urid#> .
@prefix work: <http://lv2plug.in/ns/ext/worker#> .
@prefix param: <http://lv2plug.in/ns/ext/parameters#> .
......@@ -70,6 +71,16 @@
pg:group <http://lv2.incal.net/plugins/hydrumkit/out> ;
pg:role pg:rightChannel
]
] , [
a lv2:OutputPort ,
lv2:ControlPort ;
lv2:index 4 ;
lv2:symbol "latency" ;
lv2:name "latency" ;
lv2:minimum 0 ;
lv2:maximum 192000 ;
lv2:portProperty lv2:reportsLatency, lv2:integer ;
units:unit units:frame ;
];
state:state [
<http://lv2.incal.net/plugins/hydrumkit#drumkit> <none>
......
......@@ -28,6 +28,7 @@
#define SAMPLER_NOTIFY 1
#define SAMPLER_OUT_L 2
#define SAMPLER_OUT_R 3
#define SAMPLER_LATENCY 4
#define NUM_VOICES 64
......@@ -40,6 +41,7 @@ struct sampler_plugin {
LV2_Atom_Sequence *notify_port;
float *output_port_l;
float *output_port_r;
float *output_latency;
LV2_Atom_Forge_Frame notify_frame;
LV2_Atom_Forge forge;
......@@ -138,6 +140,9 @@ static void connect_port(LV2_Handle instance, uint32_t port, void *data) {
case SAMPLER_OUT_R:
plugin->output_port_r = (float *)data;
break;
case SAMPLER_LATENCY:
plugin->output_latency = (float *)data;
break;
default:
break;
}
......@@ -266,6 +271,10 @@ static void run(LV2_Handle instance, uint32_t sample_count) {
}
render(plugin, plugin->frame_offset, sample_count);
if (plugin->output_latency) {
*(plugin->output_latency) = (float)sampler_get_latency(plugin->sampler);
}
}
static LV2_State_Status save(LV2_Handle instance,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment