commit 0b0b4169fe5518ba2b6857f62badeb0dedec20da
parent 73896baad650185a49dd4b85449251c553fcbdce
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date: Sun, 9 Jan 2022 14:56:22 +0100
Rework audio ports channel types
Diffstat:
8 files changed, 69 insertions(+), 39 deletions(-)
diff --git a/include/clap/chmap.h b/include/clap/chmap.h
@@ -1,26 +0,0 @@
-#pragma once
-
-#include "private/std.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-enum {
- CLAP_CHMAP_UNSPECIFIED = 0,
- CLAP_CHMAP_MONO = 1,
-
- // left, right
- CLAP_CHMAP_STEREO = 2,
-
- // see clap_plugin_surround to inspect the exact channel layout
- CLAP_CHMAP_SURROUND = 3,
-
- // see clap_plugin_ambisonic to inspect the mapping
- CLAP_CHMAP_AMBISONIC = 4,
-};
-typedef int32_t clap_chmap;
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/include/clap/clap.h b/include/clap/clap.h
@@ -60,6 +60,8 @@
#include "ext/draft/file-reference.h"
#include "ext/draft/midi-mappings.h"
#include "ext/draft/surround.h"
+#include "ext/draft/cv.h"
+#include "ext/draft/ambisonic.h"
#include "converters/vst2-converter.h"
#include "converters/vst3-converter.h"
diff --git a/include/clap/ext/audio-ports-config.h b/include/clap/ext/audio-ports-config.h
@@ -1,6 +1,5 @@
#pragma once
-#include "../chmap.h"
#include "../string-sizes.h"
#include "../plugin.h"
@@ -37,11 +36,11 @@ typedef struct clap_audio_ports_config {
// main input info
alignas(4) uint32_t input_channel_count;
- alignas(4) clap_chmap input_channel_map;
+ const char *input_port_type;
// main output info
alignas(4) uint32_t output_channel_count;
- alignas(4) clap_chmap output_channel_map;
+ const char * output_port_type;
} clap_audio_ports_config_t;
// The audio ports config scan has to be done while the plugin is deactivated.
diff --git a/include/clap/ext/audio-ports.h b/include/clap/ext/audio-ports.h
@@ -1,7 +1,6 @@
#pragma once
#include "../plugin.h"
-#include "../chmap.h"
#include "../string-sizes.h"
/// @page Audio Ports
@@ -14,6 +13,8 @@
/// The plugin is only allowed to change its ports configuration while it is deactivated.
static CLAP_CONSTEXPR const char CLAP_EXT_AUDIO_PORTS[] = "clap.audio-ports";
+static CLAP_CONSTEXPR const char CLAP_PORT_MONO[] = "mono";
+static CLAP_CONSTEXPR const char CLAP_PORT_STEREO[] = "stereo";
#ifdef __cplusplus
extern "C" {
@@ -26,12 +27,8 @@ enum {
// There can be only one main input and main output.
CLAP_AUDIO_PORT_IS_MAIN = 1 << 0,
- // Indicates that the host can use 64 bits audio with this port
- CLAP_AUDIO_PORTS_SUPPORT_64BITS = 1 << 1,
-
- // Indicates that the host should use 64 bits audio with this port.
- // For this port, the extra precision will lead to better processing.
- CLAP_AUDIO_PORTS_PREFERS_64BITS = (1 << 2) | CLAP_AUDIO_PORTS_SUPPORT_64BITS,
+ // The prefers 64 bits audio with this port.
+ CLAP_AUDIO_PORTS_PREFERS_64BITS = 1 << 1,
};
typedef struct clap_audio_port_info {
@@ -40,7 +37,17 @@ typedef struct clap_audio_port_info {
alignas(4) uint32_t flags;
alignas(4) uint32_t channel_count;
- alignas(4) clap_chmap channel_map;
+
+ // If null or empty then it is unspecified (arbitrary audio).
+ // This filed can be compared against:
+ // - CLAP_PORT_MONO
+ // - CLAP_PORT_STEREO
+ // - CLAP_PORT_SURROUND (defined in the surround extension)
+ // - CLAP_PORT_AMBISONIC (defined in the ambisonic extension)
+ // - CLAP_PORT_CV (defined in the cv extension)
+ //
+ // An extension can provide its own port type and way to inspect the channels.
+ const char *port_type;
// in-place processing: allow the host to use the same buffer for input and output
// if supported set the pair port id.
diff --git a/include/clap/ext/draft/ambisonic.h b/include/clap/ext/draft/ambisonic.h
@@ -6,6 +6,8 @@
static CLAP_CONSTEXPR const char CLAP_EXT_AMBISONIC[] = "clap.ambisonic.draft/0";
+static CLAP_CONSTEXPR const char CLAP_PORT_AMBISONIC[] = "ambisonic";
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/include/clap/ext/draft/cv.h b/include/clap/ext/draft/cv.h
@@ -0,0 +1,45 @@
+#pragma once
+
+#include "../../plugin.h"
+
+// This extension can be used to specify the channel mapping used by the plugin.
+// Work in progress, suggestions are welcome
+
+static CLAP_CONSTEXPR const char CLAP_EXT_CV[] = "clap.cv.draft/0";
+static CLAP_CONSTEXPR const char CLAP_PORT_CV[] = "cv";
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#pragma pack(push, CLAP_ALIGN)
+
+enum {
+ // TODO: standardize values?
+ CLAP_CV_GATE = 0,
+ CLAP_CV_PITCH = 1,
+ CLAP_CV_VALUE = 2,
+};
+
+typedef struct clap_plugin_cv {
+ // Stores into the channel_map array, the surround identifer of each channels.
+ // Returns the number of elements stored in channel_map
+ // [main-thread]
+ uint32_t (*get_channel_type)(const clap_plugin_t *plugin,
+ bool is_input,
+ uint32_t port_index,
+ uint32_t channel_index);
+} clap_plugin_cv_t;
+
+typedef struct clap_host_cv {
+ // Informs the host that the channels type have changed.
+ // The channels type can only change when the plugin is de-activated.
+ // [main-thread,!active]
+ void (*changed)(const clap_host_t *host);
+} clap_host_cv_t;
+
+#pragma pack(pop)
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/include/clap/ext/draft/surround.h b/include/clap/ext/draft/surround.h
@@ -26,6 +26,8 @@
static CLAP_CONSTEXPR const char CLAP_EXT_SURROUND[] = "clap.surround.draft/1";
+static CLAP_CONSTEXPR const char CLAP_PORT_SURROUND[] = "surround";
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/include/clap/ext/draft/track-info.h b/include/clap/ext/draft/track-info.h
@@ -1,7 +1,6 @@
#pragma once
#include "../../plugin.h"
-#include "../../chmap.h"
#include "../../color.h"
#include "../../string-sizes.h"
@@ -19,7 +18,7 @@ typedef struct clap_track_info {
alignas(1) char name[CLAP_NAME_SIZE];
alignas(1) char path[CLAP_MODULE_SIZE]; // Like "/group1/group2/drum-machine/drum-pad-13"
alignas(4) int32_t channel_count;
- alignas(4) clap_chmap channel_map;
+ const char *audio_port_type;
alignas(4) clap_color_t color;
alignas(4) bool is_return_track;
} clap_track_info_t;