comparison DPF-Prymula-audioplugins/dpf/distrho/src/travesty/edit_controller.h @ 3:84e66ea83026

DPF-Prymula-audioplugins-0.231015-2
author prymula <prymula76@outlook.com>
date Mon, 16 Oct 2023 21:53:34 +0200
parents
children
comparison
equal deleted inserted replaced
2:cf2cb71d31dd 3:84e66ea83026
1 /*
2 * travesty, pure C VST3-compatible interface
3 * Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any purpose with
6 * or without fee is hereby granted, provided that the above copyright notice and this
7 * permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
10 * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
11 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
12 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #pragma once
18
19 #include "base.h"
20 #include "bstream.h"
21 #include "view.h"
22
23 #include "align_push.h"
24
25 /**
26 * component handler
27 */
28
29 enum {
30 V3_RESTART_RELOAD_COMPONENT = 1 << 0,
31 V3_RESTART_IO_CHANGED = 1 << 1,
32 V3_RESTART_PARAM_VALUES_CHANGED = 1 << 2,
33 V3_RESTART_LATENCY_CHANGED = 1 << 3,
34 V3_RESTART_PARAM_TITLES_CHANGED = 1 << 4,
35 V3_RESTART_MIDI_CC_ASSIGNMENT_CHANGED = 1 << 5,
36 V3_RESTART_NOTE_EXPRESSION_CHANGED = 1 << 6,
37 V3_RESTART_IO_TITLES_CHANGED = 1 << 7,
38 V3_RESTART_PREFETCHABLE_SUPPORT_CHANGED = 1 << 8,
39 V3_RESTART_ROUTING_INFO_CHANGED = 1 << 9
40 };
41
42 struct v3_component_handler {
43 #ifndef __cplusplus
44 struct v3_funknown;
45 #endif
46 v3_result (V3_API* begin_edit)(void* self, v3_param_id);
47 v3_result (V3_API* perform_edit)(void* self, v3_param_id, double value_normalised);
48 v3_result (V3_API* end_edit)(void* self, v3_param_id);
49 v3_result (V3_API* restart_component)(void* self, int32_t flags);
50 };
51
52 static constexpr const v3_tuid v3_component_handler_iid =
53 V3_ID(0x93A0BEA3, 0x0BD045DB, 0x8E890B0C, 0xC1E46AC6);
54
55 struct v3_component_handler2 {
56 #ifndef __cplusplus
57 struct v3_funknown;
58 #endif
59 v3_result (V3_API* set_dirty)(void* self, v3_bool state);
60 v3_result (V3_API* request_open_editor)(void* self, const char* name);
61 v3_result (V3_API* start_group_edit)(void* self);
62 v3_result (V3_API* finish_group_edit)(void* self);
63 };
64
65 static constexpr const v3_tuid v3_component_handler2_iid =
66 V3_ID(0xF040B4B3, 0xA36045EC, 0xABCDC045, 0xB4D5A2CC);
67
68 /**
69 * edit controller
70 */
71
72 enum {
73 V3_PARAM_CAN_AUTOMATE = 1 << 0,
74 V3_PARAM_READ_ONLY = 1 << 1,
75 V3_PARAM_WRAP_AROUND = 1 << 2,
76 V3_PARAM_IS_LIST = 1 << 3,
77 V3_PARAM_IS_HIDDEN = 1 << 4,
78 V3_PARAM_PROGRAM_CHANGE = 1 << 15,
79 V3_PARAM_IS_BYPASS = 1 << 16
80 };
81
82 struct v3_param_info {
83 v3_param_id param_id;
84 v3_str_128 title;
85 v3_str_128 short_title;
86 v3_str_128 units;
87 int32_t step_count;
88 double default_normalised_value;
89 int32_t unit_id;
90 int32_t flags;
91 };
92
93 struct v3_edit_controller {
94 #ifndef __cplusplus
95 struct v3_plugin_base;
96 #endif
97 v3_result (V3_API* set_component_state)(void* self, struct v3_bstream**);
98 v3_result (V3_API* set_state)(void* self, struct v3_bstream**);
99 v3_result (V3_API* get_state)(void* self, struct v3_bstream**);
100 int32_t (V3_API* get_parameter_count)(void* self);
101 v3_result (V3_API* get_parameter_info)(void* self, int32_t param_idx, struct v3_param_info*);
102 v3_result (V3_API* get_parameter_string_for_value)(void* self, v3_param_id, double normalised, v3_str_128 output);
103 v3_result (V3_API* get_parameter_value_for_string)(void* self, v3_param_id, int16_t* input, double* output);
104 double (V3_API* normalised_parameter_to_plain)(void* self, v3_param_id, double normalised);
105 double (V3_API* plain_parameter_to_normalised)(void* self, v3_param_id, double plain);
106 double (V3_API* get_parameter_normalised)(void* self, v3_param_id);
107 v3_result (V3_API* set_parameter_normalised)(void* self, v3_param_id, double normalised);
108 v3_result (V3_API* set_component_handler)(void* self, struct v3_component_handler**);
109 struct v3_plugin_view** (V3_API* create_view)(void* self, const char* name);
110 };
111
112 static constexpr const v3_tuid v3_edit_controller_iid =
113 V3_ID(0xDCD7BBE3, 0x7742448D, 0xA874AACC, 0x979C759E);
114
115 /**
116 * midi mapping
117 */
118
119 struct v3_midi_mapping {
120 #ifndef __cplusplus
121 struct v3_funknown;
122 #endif
123 v3_result (V3_API* get_midi_controller_assignment)(void* self, int32_t bus, int16_t channel, int16_t cc, v3_param_id* id);
124 };
125
126 static constexpr const v3_tuid v3_midi_mapping_iid =
127 V3_ID(0xDF0FF9F7, 0x49B74669, 0xB63AB732, 0x7ADBF5E5);
128
129 #ifdef __cplusplus
130
131 /**
132 * C++ variants
133 */
134
135 struct v3_edit_controller_cpp : v3_funknown {
136 v3_plugin_base base;
137 v3_edit_controller ctrl;
138 };
139
140 struct v3_midi_mapping_cpp : v3_funknown {
141 v3_midi_mapping map;
142 };
143
144 template<> inline
145 constexpr v3_edit_controller* v3_cpp_obj(v3_edit_controller** obj)
146 {
147 /**
148 * this ugly piece of code is required due to C++ assuming `reinterpret_cast` by default,
149 * but we need everything to be `static_cast` for it to be `constexpr` compatible.
150 */
151 return static_cast<v3_edit_controller*>(
152 static_cast<void*>(static_cast<uint8_t*>(static_cast<void*>(*obj)) + sizeof(void*)*5));
153 }
154
155 #endif
156
157 #include "align_pop.h"