commit 9f95eed034857e6389d52b830693bf2306dc1eb3
parent 9ab4c3c7540a8310f1ddbd280436ca4bc5b2bbdc
Author: Alexandre Bique <bique.alexandre@gmail.com>
Date: Mon, 28 Nov 2022 13:11:09 +0100
Start to rework the remote-controls
Diffstat:
4 files changed, 97 insertions(+), 48 deletions(-)
diff --git a/include/clap/clap.h b/include/clap/clap.h
@@ -56,7 +56,7 @@
#include "ext/draft/file-reference.h"
#include "ext/draft/midi-mappings.h"
#include "ext/draft/preset-load.h"
-#include "ext/draft/quick-controls.h"
+#include "ext/draft/remote-controls.h"
#include "ext/draft/state-context.h"
#include "ext/draft/surround.h"
#include "ext/draft/track-info.h"
diff --git a/include/clap/ext/draft/param-indication.h b/include/clap/ext/draft/param-indication.h
@@ -0,0 +1,22 @@
+#pragma once
+
+#include "../params.h"
+#include "../../color.h"
+
+// This extension lets the host tell the plugin that a parameter is currently
+// mapped to a physical controller.
+//
+// It is common that those controllers works using a bank of 8 knobs, and to
+// improve readability the host may assign a color to each physical knobs and
+// indicate them on the GUI.
+
+static CLAP_CONSTEXPR const char CLAP_EXT_PARAM_INDICATION[] = "clap.param-indication.draft/0";
+
+typedef struct clap_plugin_param_indication {
+ // Sets or clears a mapping indication.
+ // [main-thread]
+ void(CLAP_ABI *set_indication)(const clap_plugin_t *plugin,
+ clap_id param_id,
+ bool is_mapped,
+ clap_color_t mapping_color);
+} clap_plugin_param_indication_t;
+\ No newline at end of file
diff --git a/include/clap/ext/draft/quick-controls.h b/include/clap/ext/draft/quick-controls.h
@@ -1,47 +0,0 @@
-#pragma once
-
-#include "../../plugin.h"
-#include "../../string-sizes.h"
-
-// This extensions provides a set of pages, where each page contains up to 8 controls.
-// Those controls are param_id, and they are meant to be mapped onto a physical controller.
-// We chose 8 because this what most controllers offer, and it is more or less a standard.
-
-static CLAP_CONSTEXPR const char CLAP_EXT_QUICK_CONTROLS[] = "clap.quick-controls.draft/0";
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-enum { CLAP_QUICK_CONTROLS_COUNT = 8 };
-
-typedef struct clap_quick_controls_page {
- clap_id id;
- char name[CLAP_NAME_SIZE];
- clap_id param_ids[CLAP_QUICK_CONTROLS_COUNT];
-} clap_quick_controls_page_t;
-
-typedef struct clap_plugin_quick_controls {
- // [main-thread]
- uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin);
-
- // [main-thread]
- bool(CLAP_ABI *get)(const clap_plugin_t *plugin,
- uint32_t page_index,
- clap_quick_controls_page_t *page);
-} clap_plugin_quick_controls_t;
-
-typedef struct clap_host_quick_controls {
- // Informs the host that the quick controls have changed.
- // [main-thread]
- void(CLAP_ABI *changed)(const clap_host_t *host);
-
- // Suggest a page to the host because it correspond to what the user is currently editing in the
- // plugin's GUI.
- // [main-thread]
- void(CLAP_ABI *suggest_page)(const clap_host_t *host, clap_id page_id);
-} clap_host_quick_controls_t;
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/include/clap/ext/draft/remote-controls.h b/include/clap/ext/draft/remote-controls.h
@@ -0,0 +1,73 @@
+#pragma once
+
+#include "../../plugin.h"
+#include "../../string-sizes.h"
+
+// This extensions let the plugin provide a structure way of mapping parameters to a physical control surface.
+//
+// This is done by providing a set of pages organized by section.
+// A page contains up to 8 controls, which references parameters using param_id.
+//
+// |`- [section:main]
+// | `- [name:main] performance controls
+// |`- [section:osc]
+// | |`- [name:osc1] osc1 page
+// | |`- [name:osc2] osc2 page
+// | |`- [name:osc-sync] osc sync page
+// | `- [name:osc-noise] osc noise page
+// |`- [section:filter]
+// | |`- [name:flt1] filter 1 page
+// | |`- [name:flt2] filter 2 page
+// |`- [section:env]
+// | |`- [name:env1] env1 page
+// | |`- [name:env2] env2 page
+// |`- [section:lfo]
+// | |`- [name:lfo1] env1 page
+// | |`- [name:lfo2] env2 page
+// `- etc...
+//
+// One possible workflow is to have a set of buttons, which correspond to a section.
+// Pressing that button once gets you to the first page of the section.
+// Press it again to cycle through the section's pages.
+
+static CLAP_CONSTEXPR const char CLAP_EXT_REMOTE_CONTROLS[] = "clap.remote-controls.draft/1";
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum { CLAP_REMOTE_CONTROLS_COUNT = 8 };
+
+typedef struct clap_remote_controls_page {
+ clap_id page_id;
+ char page_name[CLAP_NAME_SIZE];
+ char section_name[CLAP_NAME_SIZE];
+ clap_id param_ids[CLAP_REMOTE_CONTROLS_COUNT];
+} clap_remote_controls_page_t;
+
+typedef struct clap_plugin_remote_controls {
+ // Returns the number of pages.
+ // [main-thread]
+ uint32_t(CLAP_ABI *count)(const clap_plugin_t *plugin);
+
+ // Get a page by index.
+ // [main-thread]
+ bool(CLAP_ABI *get)(const clap_plugin_t *plugin,
+ uint32_t page_index,
+ clap_remote_controls_page_t *page);
+} clap_plugin_quick_controls_t;
+
+typedef struct clap_host_quick_controls {
+ // Informs the host that the quick controls have changed.
+ // [main-thread]
+ void(CLAP_ABI *changed)(const clap_host_t *host);
+
+ // Suggest a page to the host because it correspond to what the user is currently editing in the
+ // plugin's GUI.
+ // [main-thread]
+ void(CLAP_ABI *suggest_page)(const clap_host_t *host, clap_id page_id);
+} clap_host_quick_controls_t;
+
+#ifdef __cplusplus
+}
+#endif