aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2019-04-06 21:34:34 +0200
committerHanspeter Portner <dev@open-music-kontrollers.ch>2019-04-06 21:34:34 +0200
commit4258e0f80a6ece809ecdbee6d3ca47be1ed6b9a7 (patch)
treeb17bee473b3dd839797dff69a82197bd51786262
parentefb8123e89614c6c3739027306cac2fdc473681b (diff)
downloadmonitors.lv2-4258e0f80a6ece809ecdbee6d3ca47be1ed6b9a7.tar.xz
add optional support for inline display.
-rw-r--r--VERSION2
-rw-r--r--meson.build20
-rw-r--r--meson_options.txt1
-rw-r--r--monitors.ttl.in (renamed from monitors.ttl)15
-rw-r--r--monitors_audio_wave.c95
-rw-r--r--monitors_midi_pianoroll.c77
-rw-r--r--monitors_time_metronom.c95
7 files changed, 281 insertions, 24 deletions
diff --git a/VERSION b/VERSION
index 5c5c55e..f9a70ce 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.233
+0.1.235
diff --git a/meson.build b/meson.build
index 27b3d90..2db0b4a 100644
--- a/meson.build
+++ b/meson.build
@@ -10,6 +10,15 @@ add_project_arguments('-D_GNU_SOURCE', language : 'c')
conf_data = configuration_data()
cc = meson.get_compiler('c')
+build_idisp= get_option('build-inline-display')
+
+if build_idisp
+ add_project_arguments('-DBUILD_IDISP', language: 'c')
+ conf_data.set('BUILD_IDISP', '')
+else
+ conf_data.set('BUILD_IDISP', '#')
+endif
+
cp = find_program('cp')
lv2_validate = find_program('lv2_validate', native : true, required : false)
lv2lint = find_program('lv2lint', required : false)
@@ -17,6 +26,9 @@ clone = [cp, '@INPUT@', '@OUTPUT@']
m_dep = cc.find_library('m')
lv2_dep = dependency('lv2', version : '>=1.14.0')
+cairo_dep = dependency('cairo', version : '>=1.0.0',
+ static : meson.is_cross_build() and false, #FIXME
+ required: build_idisp)
canvas_inc = include_directories('canvas.lv2')
timely_inc = include_directories('timely.lv2')
@@ -43,7 +55,7 @@ mod = shared_module('monitors', srcs,
c_args : c_args,
name_prefix : '',
include_directories : [canvas_inc, timely_inc],
- dependencies : [m_dep, lv2_dep],
+ dependencies : [m_dep, lv2_dep, cairo_dep],
install : true,
install_dir : inst_dir)
@@ -60,10 +72,8 @@ manifest_ttl = configure_file(input : 'manifest.ttl.in', output : 'manifest.ttl'
install : true,
install_dir : inst_dir)
-dsp_ttl = custom_target('monitors_ttl',
- input : 'monitors.ttl',
- output : 'monitors.ttl',
- command : clone,
+dsp_ttl = configure_file(input : 'monitors.ttl.in', output : 'monitors.ttl',
+ configuration : conf_data,
install : true,
install_dir : inst_dir)
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..dca36c1
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1 @@
+option('build-inline-display', type : 'boolean', value : false)
diff --git a/monitors.ttl b/monitors.ttl.in
index 8c7a5d7..6f617d5 100644
--- a/monitors.ttl
+++ b/monitors.ttl.in
@@ -31,6 +31,7 @@
@prefix midi: <http://lv2plug.in/ns/ext/midi#> .
@prefix ui: <http://lv2plug.in/ns/extentions/ui#> .
@prefix units: <http://lv2plug.in/ns/extensions/units#> .
+@prefix idisp: <http://harrisonconsoles.com/lv2/inlinedisplay#> .
@prefix lic: <http://opensource.org/licenses/> .
@prefix omk: <http://open-music-kontrollers.ch/ventosus#> .
@@ -38,6 +39,12 @@
@prefix monitors: <http://open-music-kontrollers.ch/lv2/monitors#> .
@prefix canvas: <http://open-music-kontrollers.ch/lv2/canvas#> .
+# to please sord_validate
+idisp:queue_draw
+ a lv2:Feature .
+idisp:interface
+ a lv2:ExtensionData .
+
# Maintainer
omk:me
a foaf:Person ;
@@ -108,6 +115,8 @@ monitors:audio_wave_mono
lv2:requiredFeature urid:map, state:loadDefaultState, opts:options ;
lv2:optionalFeature lv2:isLive, lv2:hardRTCapable, state:threadSafeRestore, log:log ;
lv2:extensionData state:interface ;
+ @BUILD_IDISP@lv2:optionalFeature idisp:queue_draw ;
+ @BUILD_IDISP@lv2:extensionData idisp:interface ;
opts:requiredOption ui:updateRate ;
lv2:port [
@@ -171,6 +180,8 @@ monitors:audio_wave_stereo
lv2:requiredFeature urid:map, state:loadDefaultState, opts:options ;
lv2:optionalFeature lv2:isLive, lv2:hardRTCapable, state:threadSafeRestore, log:log ;
lv2:extensionData state:interface ;
+ @BUILD_IDISP@lv2:optionalFeature idisp:queue_draw ;
+ @BUILD_IDISP@lv2:extensionData idisp:interface ;
opts:requiredOption ui:updateRate ;
lv2:port [
@@ -246,6 +257,8 @@ monitors:midi_pianoroll
lv2:requiredFeature urid:map, state:loadDefaultState, opts:options ;
lv2:optionalFeature lv2:isLive, lv2:hardRTCapable, state:threadSafeRestore, log:log ;
lv2:extensionData state:interface ;
+ @BUILD_IDISP@lv2:optionalFeature idisp:queue_draw ;
+ @BUILD_IDISP@lv2:extensionData idisp:interface ;
opts:requiredOption ui:updateRate ;
lv2:port [
@@ -301,6 +314,8 @@ monitors:time_metronom
lv2:requiredFeature urid:map, state:loadDefaultState, opts:options ;
lv2:optionalFeature lv2:isLive, lv2:hardRTCapable, state:threadSafeRestore, log:log ;
lv2:extensionData state:interface ;
+ @BUILD_IDISP@lv2:optionalFeature idisp:queue_draw ;
+ @BUILD_IDISP@lv2:extensionData idisp:interface ;
opts:requiredOption ui:updateRate ;
lv2:port [
diff --git a/monitors_audio_wave.c b/monitors_audio_wave.c
index ae456cd..bb263c9 100644
--- a/monitors_audio_wave.c
+++ b/monitors_audio_wave.c
@@ -25,6 +25,10 @@
#include <canvas.lv2/canvas.h>
#include <canvas.lv2/forge.h>
+#ifdef BUILD_IDISP
+# include <canvas.lv2/idisp.h>
+#endif
+
#define MAX_CHANNELS 2
#define MAX_SAMPLES 512
#define MAX_GRAPH 0x20000 //FIXME actually measure this
@@ -73,6 +77,9 @@ struct _plughandle_t {
const LV2_Atom_Sequence *control;
craft_t notify;
+#ifdef BUILD_IDISP
+ LV2_Canvas_Idisp idisp;
+#endif
LV2_Canvas_URID urid;
double sample_rate;
float update_rate;
@@ -246,6 +253,10 @@ _render(plughandle_t *handle)
_props_impl_set(&handle->props, impl, value->type, value->size,
LV2_ATOM_BODY_CONST(value));
}
+
+#ifdef BUILD_IDISP
+ lv2_canvas_idisp_queue_draw(&handle->idisp);
+#endif
}
static void
@@ -313,6 +324,9 @@ instantiate(const LV2_Descriptor* descriptor, double rate,
handle->nchannels = 2;
LV2_Options_Option *opts = NULL;
+#ifdef BUILD_IDISP
+ LV2_Inline_Display *queue_draw = NULL;
+#endif
for(unsigned i=0; features[i]; i++)
{
if(!strcmp(features[i]->URI, LV2_URID__map))
@@ -321,6 +335,10 @@ instantiate(const LV2_Descriptor* descriptor, double rate,
opts = features[i]->data;
else if(!strcmp(features[i]->URI, LV2_LOG__log))
handle->log = features[i]->data;
+#ifdef BUILD_IDISP
+ else if(!strcmp(features[i]->URI, LV2_INLINEDISPLAY__queue_draw))
+ queue_draw = features[i]->data;
+#endif
}
if(!handle->map)
@@ -346,6 +364,9 @@ instantiate(const LV2_Descriptor* descriptor, double rate,
_craft_init(&handle->notify, handle->map);
lv2_canvas_urid_init(&handle->urid, handle->map);
+#ifdef BUILD_IDISP
+ lv2_canvas_idisp_init(&handle->idisp, queue_draw, handle->map);
+#endif
const LV2_URID ui_update_rate= handle->map->map(handle->map->handle,
LV2_UI__updateRate);
@@ -528,15 +549,6 @@ run(LV2_Handle instance, uint32_t nsamples)
_craft_out(&handle->notify);
}
-static void
-cleanup(LV2_Handle instance)
-{
- plughandle_t *handle = instance;
-
- munlock(handle, sizeof(plughandle_t));
- free(handle);
-}
-
static LV2_State_Status
_state_save(LV2_Handle instance, LV2_State_Store_Function store,
LV2_State_Handle state, uint32_t flags,
@@ -562,11 +574,76 @@ static const LV2_State_Interface state_iface = {
.restore = _state_restore
};
+#ifdef BUILD_IDISP
+static LV2_Inline_Display_Image_Surface *
+_idisp_render(LV2_Handle instance, uint32_t w, uint32_t h)
+{
+ plughandle_t *handle = instance;
+
+ float aspect_ratio = 1.f;
+
+ {
+ props_impl_t *impl = _props_impl_get(&handle->props,
+ handle->urid.Canvas_aspectRatio);
+
+ if(impl)
+ {
+ _props_impl_spin_lock(impl, PROP_STATE_NONE, PROP_STATE_LOCK);
+
+ memcpy(&aspect_ratio, impl->stash.body, impl->stash.size);
+
+ _props_impl_unlock(impl, PROP_STATE_NONE);
+ }
+ }
+
+ LV2_Inline_Display_Image_Surface *surf =
+ lv2_canvas_idisp_surf_configure(&handle->idisp, w, h, aspect_ratio);
+
+ if(surf)
+ {
+ props_impl_t *impl = _props_impl_get(&handle->props,
+ handle->urid.Canvas_graph);
+
+ if(impl)
+ {
+ _props_impl_spin_lock(impl, PROP_STATE_NONE, PROP_STATE_LOCK);
+
+ lv2_canvas_idisp_render_body(&handle->idisp, impl->type, impl->stash.size,
+ impl->stash.body);
+
+ _props_impl_unlock(impl, PROP_STATE_NONE);
+ }
+ }
+
+ return surf;
+}
+
+static const LV2_Inline_Display_Interface idisp_iface = {
+ .render = _idisp_render
+};
+#endif
+
+static void
+cleanup(LV2_Handle instance)
+{
+ plughandle_t *handle = instance;
+
+ munlock(handle, sizeof(plughandle_t));
+#ifdef BUILD_IDISP
+ lv2_canvas_idisp_deinit(&handle->idisp);
+#endif
+ free(handle);
+}
+
static const void*
extension_data(const char* uri)
{
if(!strcmp(uri, LV2_STATE__interface))
return &state_iface;
+#ifdef BUILD_IDISP
+ else if(!strcmp(uri, LV2_INLINEDISPLAY__interface))
+ return &idisp_iface;
+#endif
return NULL;
}
diff --git a/monitors_midi_pianoroll.c b/monitors_midi_pianoroll.c
index f1b225d..0df1f85 100644
--- a/monitors_midi_pianoroll.c
+++ b/monitors_midi_pianoroll.c
@@ -25,6 +25,10 @@
#include <canvas.lv2/canvas.h>
#include <canvas.lv2/forge.h>
+#ifdef BUILD_IDISP
+# include <canvas.lv2/idisp.h>
+#endif
+
#define MAX_GRAPH 0x20000 //FIXME actually measure this
#define MAX_NPROPS 7
#define MAX_KEYS 0x80
@@ -70,6 +74,9 @@ struct _plughandle_t {
LV2_URID midi_MidiEvent;
+#ifdef BUILD_IDISP
+ LV2_Canvas_Idisp idisp;
+#endif
LV2_Canvas_URID urid;
double sample_rate;
float update_rate;
@@ -261,6 +268,10 @@ _render(plughandle_t *handle, int64_t frames)
_props_impl_set(&handle->props, impl, value->type, value->size,
LV2_ATOM_BODY_CONST(value));
}
+
+#ifdef BUILD_IDISP
+ lv2_canvas_idisp_queue_draw(&handle->idisp);
+#endif
}
static void
@@ -379,6 +390,9 @@ instantiate(const LV2_Descriptor* descriptor, double rate,
mlock(handle, sizeof(plughandle_t));
LV2_Options_Option *opts = NULL;
+#ifdef BUILD_IDISP
+ LV2_Inline_Display *queue_draw = NULL;
+#endif
for(unsigned i=0; features[i]; i++)
{
if(!strcmp(features[i]->URI, LV2_URID__map))
@@ -387,6 +401,10 @@ instantiate(const LV2_Descriptor* descriptor, double rate,
opts = features[i]->data;
else if(!strcmp(features[i]->URI, LV2_LOG__log))
handle->log = features[i]->data;
+#ifdef BUILD_IDISP
+ else if(!strcmp(features[i]->URI, LV2_INLINEDISPLAY__queue_draw))
+ queue_draw = features[i]->data;
+#endif
}
if(!handle->map)
@@ -412,6 +430,9 @@ instantiate(const LV2_Descriptor* descriptor, double rate,
_craft_init(&handle->notify, handle->map);
lv2_canvas_urid_init(&handle->urid, handle->map);
+#ifdef BUILD_IDISP
+ lv2_canvas_idisp_init(&handle->idisp, queue_draw, handle->map);
+#endif
handle->midi_MidiEvent = handle->map->map(handle->map->handle, LV2_MIDI__MidiEvent);
@@ -592,12 +613,64 @@ run(LV2_Handle instance, uint32_t nsamples)
_craft_out(&handle->notify);
}
+#ifdef BUILD_IDISP
+static LV2_Inline_Display_Image_Surface *
+_idisp_render(LV2_Handle instance, uint32_t w, uint32_t h)
+{
+ plughandle_t *handle = instance;
+
+ float aspect_ratio = 1.f;
+
+ {
+ props_impl_t *impl = _props_impl_get(&handle->props,
+ handle->urid.Canvas_aspectRatio);
+
+ if(impl)
+ {
+ _props_impl_spin_lock(impl, PROP_STATE_NONE, PROP_STATE_LOCK);
+
+ memcpy(&aspect_ratio, impl->stash.body, impl->stash.size);
+
+ _props_impl_unlock(impl, PROP_STATE_NONE);
+ }
+ }
+
+ LV2_Inline_Display_Image_Surface *surf =
+ lv2_canvas_idisp_surf_configure(&handle->idisp, w, h, aspect_ratio);
+
+ if(surf)
+ {
+ props_impl_t *impl = _props_impl_get(&handle->props,
+ handle->urid.Canvas_graph);
+
+ if(impl)
+ {
+ _props_impl_spin_lock(impl, PROP_STATE_NONE, PROP_STATE_LOCK);
+
+ lv2_canvas_idisp_render_body(&handle->idisp, impl->type, impl->stash.size,
+ impl->stash.body);
+
+ _props_impl_unlock(impl, PROP_STATE_NONE);
+ }
+ }
+
+ return surf;
+}
+
+static const LV2_Inline_Display_Interface idisp_iface = {
+ .render = _idisp_render
+};
+#endif
+
static void
cleanup(LV2_Handle instance)
{
plughandle_t *handle = instance;
munlock(handle, sizeof(plughandle_t));
+#ifdef BUILD_IDISP
+ lv2_canvas_idisp_deinit(&handle->idisp);
+#endif
free(handle);
}
@@ -631,6 +704,10 @@ extension_data(const char* uri)
{
if(!strcmp(uri, LV2_STATE__interface))
return &state_iface;
+#ifdef BUILD_IDISP
+ else if(!strcmp(uri, LV2_INLINEDISPLAY__interface))
+ return &idisp_iface;
+#endif
return NULL;
}
diff --git a/monitors_time_metronom.c b/monitors_time_metronom.c
index cb79d55..1c2aec2 100644
--- a/monitors_time_metronom.c
+++ b/monitors_time_metronom.c
@@ -27,6 +27,10 @@
#include <canvas.lv2/canvas.h>
#include <canvas.lv2/forge.h>
+#ifdef BUILD_IDISP
+# include <canvas.lv2/idisp.h>
+#endif
+
#define MAX_GRAPH 0x20000 //FIXME actually measure this
#define MAX_NPROPS 5
@@ -52,6 +56,9 @@ struct _plughandle_t {
timely_t timely;
+#ifdef BUILD_IDISP
+ LV2_Canvas_Idisp idisp;
+#endif
LV2_Canvas_URID urid;
float update_rate;
uint32_t graph_size;
@@ -153,6 +160,10 @@ _render(plughandle_t *handle, int64_t frames __attribute__((unused)))
_props_impl_set(&handle->props, impl, value->type, value->size,
LV2_ATOM_BODY_CONST(value));
}
+
+#ifdef BUILD_IDISP
+ lv2_canvas_idisp_queue_draw(&handle->idisp);
+#endif
}
static const props_def_t defs [MAX_NPROPS] = {
@@ -205,6 +216,9 @@ instantiate(const LV2_Descriptor* descriptor, double rate,
mlock(handle, sizeof(plughandle_t));
LV2_Options_Option *opts = NULL;
+#ifdef BUILD_IDISP
+ LV2_Inline_Display *queue_draw = NULL;
+#endif
for(unsigned i=0; features[i]; i++)
{
if(!strcmp(features[i]->URI, LV2_URID__map))
@@ -213,6 +227,10 @@ instantiate(const LV2_Descriptor* descriptor, double rate,
opts = features[i]->data;
else if(!strcmp(features[i]->URI, LV2_LOG__log))
handle->log = features[i]->data;
+#ifdef BUILD_IDISP
+ else if(!strcmp(features[i]->URI, LV2_INLINEDISPLAY__queue_draw))
+ queue_draw = features[i]->data;
+#endif
}
if(!handle->map)
@@ -238,6 +256,9 @@ instantiate(const LV2_Descriptor* descriptor, double rate,
_craft_init(&handle->notify, handle->map);
lv2_canvas_urid_init(&handle->urid, handle->map);
+#ifdef BUILD_IDISP
+ lv2_canvas_idisp_init(&handle->idisp, queue_draw, handle->map);
+#endif
timely_init(&handle->timely, handle->map, rate, 0, _cb, handle);
const LV2_URID ui_update_rate= handle->map->map(handle->map->handle,
@@ -343,15 +364,6 @@ run(LV2_Handle instance, uint32_t nsamples)
_craft_out(&handle->notify);
}
-static void
-cleanup(LV2_Handle instance)
-{
- plughandle_t *handle = instance;
-
- munlock(handle, sizeof(plughandle_t));
- free(handle);
-}
-
static LV2_State_Status
_state_save(LV2_Handle instance, LV2_State_Store_Function store,
LV2_State_Handle state, uint32_t flags,
@@ -377,11 +389,76 @@ static const LV2_State_Interface state_iface = {
.restore = _state_restore
};
+#ifdef BUILD_IDISP
+static LV2_Inline_Display_Image_Surface *
+_idisp_render(LV2_Handle instance, uint32_t w, uint32_t h)
+{
+ plughandle_t *handle = instance;
+
+ float aspect_ratio = 1.f;
+
+ {
+ props_impl_t *impl = _props_impl_get(&handle->props,
+ handle->urid.Canvas_aspectRatio);
+
+ if(impl)
+ {
+ _props_impl_spin_lock(impl, PROP_STATE_NONE, PROP_STATE_LOCK);
+
+ memcpy(&aspect_ratio, impl->stash.body, impl->stash.size);
+
+ _props_impl_unlock(impl, PROP_STATE_NONE);
+ }
+ }
+
+ LV2_Inline_Display_Image_Surface *surf =
+ lv2_canvas_idisp_surf_configure(&handle->idisp, w, h, aspect_ratio);
+
+ if(surf)
+ {
+ props_impl_t *impl = _props_impl_get(&handle->props,
+ handle->urid.Canvas_graph);
+
+ if(impl)
+ {
+ _props_impl_spin_lock(impl, PROP_STATE_NONE, PROP_STATE_LOCK);
+
+ lv2_canvas_idisp_render_body(&handle->idisp, impl->type, impl->stash.size,
+ impl->stash.body);
+
+ _props_impl_unlock(impl, PROP_STATE_NONE);
+ }
+ }
+
+ return surf;
+}
+
+static const LV2_Inline_Display_Interface idisp_iface = {
+ .render = _idisp_render
+};
+#endif
+
+static void
+cleanup(LV2_Handle instance)
+{
+ plughandle_t *handle = instance;
+
+ munlock(handle, sizeof(plughandle_t));
+#ifdef BUILD_IDISP
+ lv2_canvas_idisp_deinit(&handle->idisp);
+#endif
+ free(handle);
+}
+
static const void*
extension_data(const char* uri)
{
if(!strcmp(uri, LV2_STATE__interface))
return &state_iface;
+#ifdef BUILD_IDISP
+ else if(!strcmp(uri, LV2_INLINEDISPLAY__interface))
+ return &idisp_iface;
+#endif
return NULL;
}