diff --git a/plugin/hydrumkit.ttl b/plugin/hydrumkit.ttl index 4327aab7e6a614a11d1ee7af5e2b45cb48e60bf8..8248bfbdf62ee3f75a0c852cd973e4cbe5f982c1 100644 --- a/plugin/hydrumkit.ttl +++ b/plugin/hydrumkit.ttl @@ -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> diff --git a/plugin/plugin.c b/plugin/plugin.c index 89ab72de0a972cfacdcbc20512213d935467a543..941c0bccb194e2637041e41c187b0e1de9fb8ccb 100644 --- a/plugin/plugin.c +++ b/plugin/plugin.c @@ -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,