aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2016-03-02 21:36:35 +0100
committerHanspeter Portner <dev@open-music-kontrollers.ch>2016-03-02 21:36:35 +0100
commit35cef1000931430bd386565afcd7be1443956c6e (patch)
tree7c7e72f0df5f7a0795ca96311d58cddb6d5713c1
parent5ee440092342550add72a62f01d8f5e9e8bd9633 (diff)
downloadsherlock.lv2-35cef1000931430bd386565afcd7be1443956c6e.tar.xz
overhaul midi/osc inspector plugin/ui.
* show frame offset and period size.
-rw-r--r--atom_inspector_ui.c17
-rw-r--r--midi_inspector.c22
-rw-r--r--midi_inspector_ui.c80
-rw-r--r--osc_inspector.c22
-rw-r--r--osc_inspector_ui.c80
-rw-r--r--sherlock.h7
6 files changed, 204 insertions, 24 deletions
diff --git a/atom_inspector_ui.c b/atom_inspector_ui.c
index 96dd24d..800b5c8 100644
--- a/atom_inspector_ui.c
+++ b/atom_inspector_ui.c
@@ -37,14 +37,8 @@
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
-typedef struct _position_t position_t;
typedef struct _UI UI;
-struct _position_t {
- uint64_t offset;
- uint32_t nsamples;
-};
-
struct _UI {
eo_ui_t eoui;
@@ -672,7 +666,7 @@ _seq_item_content_get(void *data, Evas_Object *obj, const char *part)
}
static void
-_item_del(void *data, Evas_Object *obj)
+_del(void *data, Evas_Object *obj)
{
free(data);
}
@@ -1090,7 +1084,7 @@ instantiate(const LV2UI_Descriptor *descriptor, const char *plugin_uri,
ui->itc_list->func.text_get = _list_item_label_get;
ui->itc_list->func.content_get = _seq_item_content_get;
ui->itc_list->func.state_get = NULL;
- ui->itc_list->func.del = _item_del;
+ ui->itc_list->func.del = _del;
}
ui->itc_group = elm_genlist_item_class_new();
@@ -1100,7 +1094,7 @@ instantiate(const LV2UI_Descriptor *descriptor, const char *plugin_uri,
ui->itc_group->func.text_get = NULL;
ui->itc_group->func.content_get = _group_item_content_get;
ui->itc_group->func.state_get = NULL;
- ui->itc_group->func.del = _item_del;
+ ui->itc_group->func.del = _del;
}
ui->itc_sherlock = elm_genlist_item_class_new();
@@ -1110,7 +1104,7 @@ instantiate(const LV2UI_Descriptor *descriptor, const char *plugin_uri,
ui->itc_sherlock->func.text_get = _seq_item_label_get;
ui->itc_sherlock->func.content_get = _seq_item_content_get;
ui->itc_sherlock->func.state_get = NULL;
- ui->itc_sherlock->func.del = _item_del;
+ ui->itc_sherlock->func.del = _del;
}
ui->itc_seq = elm_genlist_item_class_new();
@@ -1140,7 +1134,7 @@ instantiate(const LV2UI_Descriptor *descriptor, const char *plugin_uri,
ui->itc_vec->func.text_get = _atom_item_label_get;
ui->itc_vec->func.content_get = _atom_item_content_get;
ui->itc_vec->func.state_get = NULL;
- ui->itc_vec->func.del = _item_del;
+ ui->itc_vec->func.del = _del;
}
ui->itc_atom = elm_genlist_item_class_new();
@@ -1261,7 +1255,6 @@ port_event(LV2UI_Handle handle, uint32_t i, uint32_t size, uint32_t urid,
int n = elm_genlist_items_count(ui->list);
Elm_Object_Item *itm = NULL;
-
if(seq->atom.size > sizeof(LV2_Atom_Sequence_Body)) // there are events
{
position_t *pos = malloc(sizeof(position_t));
diff --git a/midi_inspector.c b/midi_inspector.c
index 754420c..48d4794 100644
--- a/midi_inspector.c
+++ b/midi_inspector.c
@@ -32,6 +32,7 @@ struct _handle_t {
LV2_Atom_Forge forge;
LV2_URID midi_event;
+ uint64_t offset;
};
static LV2_Handle
@@ -88,7 +89,7 @@ run(LV2_Handle instance, uint32_t nsamples)
handle_t *handle = (handle_t *)instance;
uint32_t capacity;
LV2_Atom_Forge *forge = &handle->forge;
- LV2_Atom_Forge_Frame frame [2];
+ LV2_Atom_Forge_Frame frame [3];
LV2_Atom_Forge_Ref ref;
// size of input sequence
@@ -104,17 +105,27 @@ run(LV2_Handle instance, uint32_t nsamples)
// forge whole sequence as single event
capacity = handle->notify->atom.size;
lv2_atom_forge_set_buffer(forge, (uint8_t *)handle->notify, capacity);
+
+ bool has_midi = false;
+
ref = lv2_atom_forge_sequence_head(forge, &frame[0], 0);
if(ref)
ref = lv2_atom_forge_frame_time(forge, 0);
if(ref)
- ref = lv2_atom_forge_sequence_head(forge, &frame[1], 0);
+ ref = lv2_atom_forge_tuple(forge, &frame[1]);
+ if(ref)
+ ref = lv2_atom_forge_long(forge, handle->offset);
+ if(ref)
+ ref = lv2_atom_forge_int(forge, nsamples);
+ if(ref)
+ ref = lv2_atom_forge_sequence_head(forge, &frame[2], 0);
// only serialize MIDI events to UI
LV2_ATOM_SEQUENCE_FOREACH(handle->control_in, ev)
{
if(ev->body.type == handle->midi_event)
{
+ has_midi = true;
if(ref)
ref = lv2_atom_forge_frame_time(forge, ev->time.frames);
if(ref)
@@ -125,11 +136,18 @@ run(LV2_Handle instance, uint32_t nsamples)
}
if(ref)
+ lv2_atom_forge_pop(forge, &frame[2]);
+ if(ref)
lv2_atom_forge_pop(forge, &frame[1]);
if(ref)
lv2_atom_forge_pop(forge, &frame[0]);
else
lv2_atom_sequence_clear(handle->notify);
+
+ if(!has_midi) // don't send anything
+ lv2_atom_sequence_clear(handle->notify);
+
+ handle->offset += nsamples;
}
static void
diff --git a/midi_inspector_ui.c b/midi_inspector_ui.c
index 4de746a..d5649ad 100644
--- a/midi_inspector_ui.c
+++ b/midi_inspector_ui.c
@@ -46,6 +46,7 @@ struct _UI {
Evas_Object *popup;
Elm_Genlist_Item_Class *itc_midi;
+ Elm_Genlist_Item_Class *itc_group;
char string_buf [STRING_BUF_SIZE];
char *logo_path;
@@ -466,8 +467,51 @@ _midi_content_get(void *data, Evas_Object *obj, const char *part)
return NULL;
}
+static Evas_Object *
+_group_item_content_get(void *data, Evas_Object *obj, const char *part)
+{
+ UI *ui = evas_object_data_get(obj, "ui");
+ const position_t *pos = data;
+
+ if(!ui)
+ return NULL;
+
+ if(!strcmp(part, "elm.swallow.icon"))
+ {
+ char *buf = ui->string_buf;
+
+ sprintf(buf, "<color=#000 font=Mono>0x%"PRIx64"</color>", pos->offset);
+
+ Evas_Object *label = elm_label_add(obj);
+ if(label)
+ {
+ elm_object_part_text_set(label, "default", buf);
+ evas_object_show(label);
+ }
+
+ return label;
+ }
+ else if(!strcmp(part, "elm.swallow.end"))
+ {
+ char *buf = ui->string_buf;
+
+ sprintf(buf, "<color=#0bb font=Mono>%"PRIu32"</color>", pos->nsamples);
+
+ Evas_Object *label = elm_label_add(obj);
+ if(label)
+ {
+ elm_object_part_text_set(label, "default", buf);
+ evas_object_show(label);
+ }
+
+ return label;
+ }
+
+ return NULL;
+}
+
static void
-_midi_del(void *data, Evas_Object *obj)
+_del(void *data, Evas_Object *obj)
{
free(data);
}
@@ -694,7 +738,17 @@ instantiate(const LV2UI_Descriptor *descriptor, const char *plugin_uri,
ui->itc_midi->func.text_get = _midi_label_get;
ui->itc_midi->func.content_get = _midi_content_get;
ui->itc_midi->func.state_get = NULL;
- ui->itc_midi->func.del = _midi_del;
+ ui->itc_midi->func.del = _del;
+ }
+
+ ui->itc_group = elm_genlist_item_class_new();
+ if(ui->itc_group)
+ {
+ ui->itc_group->item_style = "default_style";
+ ui->itc_group->func.text_get = NULL;
+ ui->itc_group->func.content_get = _group_item_content_get;
+ ui->itc_group->func.state_get = NULL;
+ ui->itc_group->func.del = _del;
}
sprintf(ui->string_buf, "%s/omk_logo_256x256.png", bundle_path);
@@ -734,9 +788,27 @@ port_event(LV2UI_Handle handle, uint32_t i, uint32_t size, uint32_t urid,
if( (i == 2) && (urid == ui->event_transfer) && ui->list)
{
- const LV2_Atom_Sequence *seq = buf;
+ const LV2_Atom_Tuple *tup = buf;
+ const LV2_Atom_Long *offset = (const LV2_Atom_Long *)lv2_atom_tuple_begin(tup);
+ const LV2_Atom_Int *nsamples = (const LV2_Atom_Int *)lv2_atom_tuple_next(&offset->atom);
+ const LV2_Atom_Sequence *seq = (const LV2_Atom_Sequence *)lv2_atom_tuple_next(&nsamples->atom);
int n = elm_genlist_items_count(ui->list);
+ Elm_Object_Item *itm = NULL;
+ if(seq->atom.size > sizeof(LV2_Atom_Sequence_Body)) // there are events
+ {
+ position_t *pos = malloc(sizeof(position_t));
+ if(pos)
+ {
+ pos->offset = offset->body;
+ pos->nsamples = nsamples->body;
+
+ itm = elm_genlist_item_append(ui->list, ui->itc_group,
+ pos, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
+ elm_genlist_item_select_mode_set(itm, ELM_OBJECT_SELECT_MODE_NONE);
+ }
+ }
+
LV2_ATOM_SEQUENCE_FOREACH(seq, elmnt)
{
size_t len = sizeof(LV2_Atom_Event) + elmnt->body.size;
@@ -765,7 +837,7 @@ port_event(LV2UI_Handle handle, uint32_t i, uint32_t size, uint32_t urid,
}
Elm_Object_Item *itm2 = elm_genlist_item_append(ui->list, ui->itc_midi,
- ev, NULL, ELM_GENLIST_ITEM_TREE, NULL, NULL);
+ ev, itm, ELM_GENLIST_ITEM_NONE, NULL, NULL);
elm_genlist_item_select_mode_set(itm2, ELM_OBJECT_SELECT_MODE_DEFAULT);
elm_genlist_item_expanded_set(itm2, EINA_FALSE);
n++;
diff --git a/osc_inspector.c b/osc_inspector.c
index 0ead8f6..1655bc5 100644
--- a/osc_inspector.c
+++ b/osc_inspector.c
@@ -32,6 +32,7 @@ struct _handle_t {
LV2_Atom_Forge forge;
osc_forge_t oforge;
+ uint64_t offset;
};
static LV2_Handle
@@ -87,7 +88,7 @@ run(LV2_Handle instance, uint32_t nsamples)
handle_t *handle = (handle_t *)instance;
uint32_t capacity;
LV2_Atom_Forge *forge = &handle->forge;
- LV2_Atom_Forge_Frame frame [2];
+ LV2_Atom_Forge_Frame frame [3];
LV2_Atom_Forge_Ref ref;
// size of input sequence
@@ -103,11 +104,20 @@ run(LV2_Handle instance, uint32_t nsamples)
// forge whole sequence as single event
capacity = handle->notify->atom.size;
lv2_atom_forge_set_buffer(forge, (uint8_t *)handle->notify, capacity);
+
+ bool has_osc = false;
+
ref = lv2_atom_forge_sequence_head(forge, &frame[0], 0);
if(ref)
ref = lv2_atom_forge_frame_time(forge, 0);
if(ref)
- ref = lv2_atom_forge_sequence_head(forge, &frame[1], 0);
+ ref = lv2_atom_forge_tuple(forge, &frame[1]);
+ if(ref)
+ ref = lv2_atom_forge_long(forge, handle->offset);
+ if(ref)
+ ref = lv2_atom_forge_int(forge, nsamples);
+ if(ref)
+ ref = lv2_atom_forge_sequence_head(forge, &frame[2], 0);
// only serialize OSC events to UI
LV2_ATOM_SEQUENCE_FOREACH(handle->control_in, ev)
@@ -117,6 +127,7 @@ run(LV2_Handle instance, uint32_t nsamples)
if( osc_atom_is_bundle(&handle->oforge, obj)
|| osc_atom_is_message(&handle->oforge, obj) )
{
+ has_osc = true;
if(ref)
ref = lv2_atom_forge_frame_time(forge, ev->time.frames);
if(ref)
@@ -127,11 +138,18 @@ run(LV2_Handle instance, uint32_t nsamples)
}
if(ref)
+ lv2_atom_forge_pop(forge, &frame[2]);
+ if(ref)
lv2_atom_forge_pop(forge, &frame[1]);
if(ref)
lv2_atom_forge_pop(forge, &frame[0]);
else
lv2_atom_sequence_clear(handle->notify);
+
+ if(!has_osc)
+ lv2_atom_sequence_clear(handle->notify);
+
+ handle->offset += nsamples;
}
static void
diff --git a/osc_inspector_ui.c b/osc_inspector_ui.c
index e32c3b1..955ddae 100644
--- a/osc_inspector_ui.c
+++ b/osc_inspector_ui.c
@@ -50,6 +50,7 @@ struct _UI {
Evas_Object *autoblock;
Evas_Object *popup;
+ Elm_Genlist_Item_Class *itc_group;
Elm_Genlist_Item_Class *itc_packet;
Elm_Genlist_Item_Class *itc_item;
@@ -401,7 +402,7 @@ _packet_content_get(void *data, Evas_Object *obj, const char *part)
}
static void
-_packet_del(void *data, Evas_Object *obj)
+_del(void *data, Evas_Object *obj)
{
free(data);
}
@@ -532,6 +533,49 @@ _item_contracted(void *data, Evas_Object *obj, void *event_info)
elm_genlist_item_subitems_clear(itm);
}
+static Evas_Object *
+_group_item_content_get(void *data, Evas_Object *obj, const char *part)
+{
+ UI *ui = evas_object_data_get(obj, "ui");
+ const position_t *pos = data;
+
+ if(!ui)
+ return NULL;
+
+ if(!strcmp(part, "elm.swallow.icon"))
+ {
+ char *buf = ui->string_buf;
+
+ sprintf(buf, "<color=#000 font=Mono>0x%"PRIx64"</color>", pos->offset);
+
+ Evas_Object *label = elm_label_add(obj);
+ if(label)
+ {
+ elm_object_part_text_set(label, "default", buf);
+ evas_object_show(label);
+ }
+
+ return label;
+ }
+ else if(!strcmp(part, "elm.swallow.end"))
+ {
+ char *buf = ui->string_buf;
+
+ sprintf(buf, "<color=#0bb font=Mono>%"PRIu32"</color>", pos->nsamples);
+
+ Evas_Object *label = elm_label_add(obj);
+ if(label)
+ {
+ elm_object_part_text_set(label, "default", buf);
+ evas_object_show(label);
+ }
+
+ return label;
+ }
+
+ return NULL;
+}
+
static void
_clear_update(UI *ui, int count)
{
@@ -762,7 +806,7 @@ instantiate(const LV2UI_Descriptor *descriptor, const char *plugin_uri,
ui->itc_packet->func.text_get = _packet_label_get;
ui->itc_packet->func.content_get = _packet_content_get;
ui->itc_packet->func.state_get = NULL;
- ui->itc_packet->func.del = _packet_del;
+ ui->itc_packet->func.del = _del;
}
ui->itc_item = elm_genlist_item_class_new();
@@ -775,6 +819,16 @@ instantiate(const LV2UI_Descriptor *descriptor, const char *plugin_uri,
ui->itc_item->func.del = NULL;
}
+ ui->itc_group = elm_genlist_item_class_new();
+ if(ui->itc_group)
+ {
+ ui->itc_group->item_style = "default_style";
+ ui->itc_group->func.text_get = NULL;
+ ui->itc_group->func.content_get = _group_item_content_get;
+ ui->itc_group->func.state_get = NULL;
+ ui->itc_group->func.del = _del;
+ }
+
sprintf(ui->string_buf, "%s/omk_logo_256x256.png", bundle_path);
ui->logo_path = strdup(ui->string_buf);
@@ -814,9 +868,27 @@ port_event(LV2UI_Handle handle, uint32_t i, uint32_t size, uint32_t urid,
if( (i == 2) && (urid == ui->event_transfer) && ui->list)
{
- const LV2_Atom_Sequence *seq = buf;
+ const LV2_Atom_Tuple *tup = buf;
+ const LV2_Atom_Long *offset = (const LV2_Atom_Long *)lv2_atom_tuple_begin(tup);
+ const LV2_Atom_Int *nsamples = (const LV2_Atom_Int *)lv2_atom_tuple_next(&offset->atom);
+ const LV2_Atom_Sequence *seq = (const LV2_Atom_Sequence *)lv2_atom_tuple_next(&nsamples->atom);
int n = elm_genlist_items_count(ui->list);
+ Elm_Object_Item *itm = NULL;
+ if(seq->atom.size > sizeof(LV2_Atom_Sequence_Body)) // there are events
+ {
+ position_t *pos = malloc(sizeof(position_t));
+ if(pos)
+ {
+ pos->offset = offset->body;
+ pos->nsamples = nsamples->body;
+
+ itm = elm_genlist_item_append(ui->list, ui->itc_group,
+ pos, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
+ elm_genlist_item_select_mode_set(itm, ELM_OBJECT_SELECT_MODE_NONE);
+ }
+ }
+
LV2_ATOM_SEQUENCE_FOREACH(seq, elmnt)
{
size_t len = sizeof(LV2_Atom_Event) + elmnt->body.size;
@@ -846,7 +918,7 @@ port_event(LV2UI_Handle handle, uint32_t i, uint32_t size, uint32_t urid,
const LV2_Atom_Object *obj = (const LV2_Atom_Object *)&ev->body;
Elm_Object_Item *itm2 = elm_genlist_item_append(ui->list, ui->itc_packet,
- ev, NULL, ELM_GENLIST_ITEM_TREE, NULL, NULL);
+ ev, itm, ELM_GENLIST_ITEM_TREE, NULL, NULL);
elm_genlist_item_select_mode_set(itm2, ELM_OBJECT_SELECT_MODE_DEFAULT);
elm_genlist_item_expanded_set(itm2, EINA_FALSE);
n++;
diff --git a/sherlock.h b/sherlock.h
index f4df7d6..5944a08 100644
--- a/sherlock.h
+++ b/sherlock.h
@@ -68,4 +68,11 @@ extern const LV2UI_Descriptor osc_inspector_ui;
extern const LV2UI_Descriptor osc_inspector_x11;
extern const LV2UI_Descriptor osc_inspector_kx;
+typedef struct _position_t position_t;
+
+struct _position_t {
+ uint64_t offset;
+ uint32_t nsamples;
+};
+
#endif // _SHERLOCK_LV2_H