aboutsummaryrefslogtreecommitdiff
path: root/widgets.h
diff options
context:
space:
mode:
Diffstat (limited to 'widgets.h')
-rw-r--r--widgets.h90
1 files changed, 90 insertions, 0 deletions
diff --git a/widgets.h b/widgets.h
new file mode 100644
index 0000000..1572bca
--- /dev/null
+++ b/widgets.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2018 Hanspeter Portner (dev@open-music-kontrollers.ch)
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the Artistic License 2.0 as published by
+ * The Perl Foundation.
+ *
+ * This source is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Artistic License 2.0 for more details.
+ *
+ * You should have received a copy of the Artistic License 2.0
+ * along the source as a COPYING file. If not, obtain it from
+ * http://www.perlfoundation.org/artistic_license_2_0.
+ */
+
+#ifndef _WIDGETS_LV2_H
+#define _WIDGETS_LV2_H
+
+#include <stdint.h>
+#if !defined(_WIN32)
+# include <sys/mman.h>
+#else
+# define mlock(...)
+# define munlock(...)
+#endif
+
+#include <lv2/lv2plug.in/ns/ext/atom/atom.h>
+#include <lv2/lv2plug.in/ns/ext/atom/forge.h>
+#include <lv2/lv2plug.in/ns/ext/urid/urid.h>
+#include <lv2/lv2plug.in/ns/ext/state/state.h>
+#include <lv2/lv2plug.in/ns/ext/log/log.h>
+#include <lv2/lv2plug.in/ns/ext/log/logger.h>
+#include <lv2/lv2plug.in/ns/ext/options/options.h>
+#include <lv2/lv2plug.in/ns/extensions/ui/ui.h>
+#include <lv2/lv2plug.in/ns/lv2core/lv2.h>
+
+#define WIDGETS_URI "http://open-music-kontrollers.ch/lv2/widgets"
+#define WIDGETS_PREFIX WIDGETS_URI"#"
+
+// plugin uris
+#define WIDGETS__xy_pad WIDGETS_PREFIX"xy_pad"
+#define WIDGETS__x WIDGETS_PREFIX"x"
+#define WIDGETS__y WIDGETS_PREFIX"y"
+
+extern const LV2_Descriptor widgets_xy_pad;
+
+typedef struct _craft_t craft_t;
+
+struct _craft_t {
+ union {
+ LV2_Atom_Sequence *seq;
+ uint8_t *buf;
+ };
+ LV2_Atom_Forge forge;
+ LV2_Atom_Forge_Frame frame;
+ LV2_Atom_Forge_Ref ref;
+};
+
+static inline void
+_craft_init(craft_t *craft, LV2_URID_Map *map)
+{
+ lv2_atom_forge_init(&craft->forge, map);
+}
+
+static inline void
+_craft_connect(craft_t *craft, LV2_Atom_Sequence *seq)
+{
+ craft->seq = seq;
+}
+
+static inline void
+_craft_in(craft_t *craft)
+{
+ const uint32_t capacity = craft->seq->atom.size;
+ lv2_atom_forge_set_buffer(&craft->forge, craft->buf, capacity);
+ craft->ref = lv2_atom_forge_sequence_head(&craft->forge, &craft->frame, 0);
+}
+
+static inline void
+_craft_out(craft_t *craft)
+{
+ if(craft->ref)
+ lv2_atom_forge_pop(&craft->forge, &craft->frame);
+ else
+ lv2_atom_sequence_clear(craft->seq);
+}
+
+#endif // _WIDGETS_LV2_H