forked from free-audio/clap
/
surround.h
89 lines (77 loc) · 3.38 KB
/
surround.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#pragma once
#include "../../plugin.h"
// This extension can be used to specify the channel mapping used by the plugin.
//
// To have a consistent surround features across all the plugin instances,
// here is the proposed workflow:
// 1. the plugin queries the host preferred channel mapping and
// adjusts its configuration to match it.
// 2. the host checks how the plugin is effectively configured and honors it.
//
// If the host decides to change the project's surround setup:
// 1. deactivate the plugin
// 2. host calls clap_plugin_surround->changed()
// 3. plugin calls clap_host_surround->get_preferred_channel_map()
// 4. plugin eventualy calls clap_host_surround->changed()
// 5. host calls clap_plugin_surround->get_channel_map() if changed
// 6. host activates the plugin and can start processing audio
//
// If the plugin wants to change its surround setup:
// 1. call host->request_restart() if the plugin is active
// 2. once deactivated plugin calls clap_host_surround->changed()
// 3. host calls clap_plugin_surround->get_channel_map()
// 4. host activates the plugin and can start processing audio
static CLAP_CONSTEXPR const char CLAP_EXT_SURROUND[] = "clap.surround.draft/1";
#ifdef __cplusplus
extern "C" {
#endif
#pragma pack(push, CLAP_ALIGN)
enum {
CLAP_SURROUND_FL = 0, // Front Left
CLAP_SURROUND_FR = 1, // Front Right
CLAP_SURROUND_FC = 2, // Front Center
CLAP_SURROUND_LFE = 3, // Low Frequency
CLAP_SURROUND_BL = 4, // Back Left
CLAP_SURROUND_BR = 5, // Back Right
CLAP_SURROUND_FLC = 6, // Front Left of Center
CLAP_SURROUND_FRC = 7, // Front Right of Center
CLAP_SURROUND_BC = 8, // Back Center
CLAP_SURROUND_SL = 9, // Side Left
CLAP_SURROUND_SR = 10, // Side Right
CLAP_SURROUND_TC = 11, // Top Center
CLAP_SURROUND_TFL = 12, // Front Left Height
CLAP_SURROUND_TFC = 13, // Front Center Height
CLAP_SURROUND_TFR = 14, // Front Right Height
CLAP_SURROUND_TBL = 15, // Rear Left Height
CLAP_SURROUND_TBC = 16, // Rear Center Height
CLAP_SURROUND_TBR = 17, // Rear Right Height
};
typedef struct clap_plugin_surround {
// 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_map)(const clap_plugin_t *plugin,
bool is_input,
uint32_t port_index,
uint8_t *channel_map,
uint32_t channel_map_capacity);
// Informs the plugin that the host preferred channel map has changed.
// [main-thread]
void (*changed)(const clap_plugin_t *plugin);
} clap_plugin_surround_t;
typedef struct clap_host_surround {
// Informs the host that the channel map have changed.
// The channel map can only change when the plugin is de-activated.
// [main-thread]
void (*changed)(const clap_host_t *host);
// Ask the host what is the prefered/project surround channel map.
// [main-thread]
void (*get_preferred_channel_map)(const clap_host_t *host,
uint8_t *channel_map,
uint32_t channel_map_capacity,
uint32_t *channel_count);
} clap_host_surround_t;
#pragma pack(pop)
#ifdef __cplusplus
}
#endif