commit 992da92ba910f12f701477a1fb146d5f693bad9f
parent 357f5bde863f89e567b0a658309465af019d9515
Author: Alexandre Bique <bique.alexandre@gmail.com>
Date: Fri, 22 Dec 2023 10:52:32 +0100
Add a plugin state converter factory
Diffstat:
1 file changed, 63 insertions(+), 0 deletions(-)
diff --git a/include/clap/factory/draft/plugin-state-converter.h b/include/clap/factory/draft/plugin-state-converter.h
@@ -0,0 +1,63 @@
+#pragma once
+
+#include "../../id.h"
+#include "../../plugin-id.h"
+#include "../../stream.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// This interface provides helps the host to convert a plugin state and its automation
+// points to a new plugin.
+//
+// This is useful to convert from one plugin ABI to another one.
+// This is also useful to offer an upgrade path: from EQ version 1 to EQ version 2.
+// This can also be used to convert the state of a plugin that isn't maintained anymore into
+// another plugin that would be similar.
+typedef struct clap_plugin_state_converter {
+ const clap_plugin_id_t *src_plugin_id;
+ const clap_plugin_id_t *dst_plugin_id;
+
+ // Converts the input state to a state usable by the destination plugin.
+ // [thread-safe]
+ bool (*convert_state)(const struct clap_plugin_state_converter *converter,
+ const clap_istream_t *src,
+ const clap_ostream_t *dst);
+
+ // Converts a normalized value.
+ // [thread-safe]
+ bool (*convert_normalized_value)(const struct clap_plugin_state_converter *converter,
+ clap_id src_param_id,
+ double src_normalized_value,
+ clap_id *dst_param_id,
+ double *dst_normalized_value);
+
+ // Converts a plain value.
+ // [thread-safe]
+ bool (*convert_plain_value)(const struct clap_plugin_state_converter *converter,
+ clap_id src_param_id,
+ double src_plain_value,
+ clap_id *dst_param_id,
+ double *dst_plain_value);
+} clap_plugin_state_converter_t;
+
+// Factory identifier
+static CLAP_CONSTEXPR const char CLAP_CLAP_CONVERTER_FACTORY_ID[] =
+ "clap.plugin-state-converter-factory/1";
+
+// List all the plugin state converters available in the current DSO.
+typedef struct clap_plugin_state_converter_factory {
+ // Get the number of converters.
+ // [thread-safe]
+ uint32_t (*count)(const struct clap_plugin_state_converter_factory *factory);
+
+ // Get the converter at the given index.
+ // [thread-safe]
+ const clap_plugin_state_converter_t *(*get)(
+ const struct clap_plugin_state_converter_factory *factory, uint32_t index);
+} clap_clap_converter_factory_t;
+
+#ifdef __cplusplus
+}
+#endif