aboutsummaryrefslogtreecommitdiff
path: root/monitors_midi_pianoroll.c
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2018-05-06 11:04:24 +0200
committerHanspeter Portner <dev@open-music-kontrollers.ch>2018-05-06 11:04:24 +0200
commit79e2d15d9122d995e0a7184430dba8c01a9a946c (patch)
tree4da9413d8d0b34197b23e1935a8cfb628d18ca64 /monitors_midi_pianoroll.c
parent362336a569e5baa8ff3c98ac04d6cc3a5bb48f8d (diff)
downloadmonitors.lv2-79e2d15d9122d995e0a7184430dba8c01a9a946c.tar.xz
add monitors:rotation parameter.
Diffstat (limited to 'monitors_midi_pianoroll.c')
-rw-r--r--monitors_midi_pianoroll.c43
1 files changed, 32 insertions, 11 deletions
diff --git a/monitors_midi_pianoroll.c b/monitors_midi_pianoroll.c
index 5bad223..f73b398 100644
--- a/monitors_midi_pianoroll.c
+++ b/monitors_midi_pianoroll.c
@@ -26,7 +26,7 @@
#include <canvas.lv2/forge.h>
#define MAX_GRAPH 0x20000 //FIXME actually measure this
-#define MAX_NPROPS 3
+#define MAX_NPROPS 4
#define MAX_KEYS 0x80
#define MAX_NOTES 0x80
#define MAX_VELOCITY 0x80
@@ -51,6 +51,7 @@ struct _passive_note_t {
struct _plugstate_t {
int32_t window;
+ float rotation;
float aspect_ratio;
uint8_t graph [MAX_GRAPH];
};
@@ -101,18 +102,30 @@ _render(plughandle_t *handle, int64_t frames)
LV2_Atom_Forge_Frame frame;
const float dy = 1.f / MASK_KEYS;
-
lv2_atom_forge_set_buffer(forge, handle->state.graph, MAX_GRAPH);
if( !lv2_atom_forge_tuple(forge, &frame)
|| !lv2_canvas_forge_rectangle(forge, urid, 0.f, 0.f, 1.f, 1.f)
|| !lv2_canvas_forge_style(forge, urid, 0x0000003f)
|| !lv2_canvas_forge_fill(forge, urid)
- || !lv2_canvas_forge_lineWidth(forge, urid, dy) )
+ || !lv2_canvas_forge_lineWidth(forge, urid, dy)
+ || !lv2_canvas_forge_save(forge, urid) )
{
fprintf(stderr, "out-of-memory\n"); //FIXME
}
+ if( (fmod(handle->state.rotation, 360.f) != 0.f) )
+ {
+ const float rot = handle->state.rotation / 180.f * M_PI;
+
+ if( !lv2_canvas_forge_translate(forge, urid, 0.5f, 0.5f)
+ || !lv2_canvas_forge_rotate(forge, urid, rot)
+ || !lv2_canvas_forge_translate(forge, urid, -0.5f, -0.5f) )
+ {
+ fprintf(stderr, "out-of-memory\n"); //FIXME
+ }
+ }
+
const unsigned range = handle->range;
const float range_1 = handle->range_1;
const int64_t head = handle->cnt + frames;
@@ -184,17 +197,20 @@ _render(plughandle_t *handle, int64_t frames)
}
}
+ if( !lv2_canvas_forge_restore(forge, urid) )
{
- lv2_atom_forge_pop(forge, &frame);
+ fprintf(stderr, "out-of-memory\n"); //FIXME
+ }
- props_impl_t *impl = _props_bsearch(&handle->props, handle->urid.Canvas_graph);
- if(impl)
- {
- const LV2_Atom *value= (const LV2_Atom *)handle->state.graph;
+ lv2_atom_forge_pop(forge, &frame);
- _props_impl_set(&handle->props, impl, value->type, value->size,
- LV2_ATOM_BODY_CONST(value));
- }
+ props_impl_t *impl = _props_bsearch(&handle->props, handle->urid.Canvas_graph);
+ if(impl)
+ {
+ const LV2_Atom *value= (const LV2_Atom *)handle->state.graph;
+
+ _props_impl_set(&handle->props, impl, value->type, value->size,
+ LV2_ATOM_BODY_CONST(value));
}
}
@@ -221,6 +237,11 @@ static const props_def_t defs [MAX_NPROPS] = {
.event_cb = _intercept_window
},
{
+ .property = MONITORS__rotation,
+ .offset = offsetof(plugstate_t, rotation),
+ .type = LV2_ATOM__Float
+ },
+ {
.access = LV2_PATCH__readable,
.property = CANVAS__graph,
.offset = offsetof(plugstate_t, graph),