Mercurial > hg > pub > prymula > com
comparison DPF-Prymula-audioplugins/dpf/distrho/src/travesty/audio_processor.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 "events.h" | |
21 | |
22 #include "align_push.h" | |
23 | |
24 /** | |
25 * speakers | |
26 */ | |
27 | |
28 typedef uint64_t v3_speaker_arrangement; | |
29 | |
30 enum { | |
31 V3_SPEAKER_L = 1 << 0, | |
32 V3_SPEAKER_R = 1 << 1, | |
33 V3_SPEAKER_C = 1 << 2, | |
34 V3_SPEAKER_LFE = 1 << 3, | |
35 V3_SPEAKER_LS = 1 << 4, | |
36 V3_SPEAKER_RS = 1 << 5, | |
37 V3_SPEAKER_LC = 1 << 6, | |
38 V3_SPEAKER_RC = 1 << 7, | |
39 V3_SPEAKER_S = 1 << 8, | |
40 V3_SPEAKER_SL = 1 << 9, | |
41 V3_SPEAKER_SR = 1 << 10, | |
42 V3_SPEAKER_TC = 1 << 11, | |
43 V3_SPEAKER_TFL = 1 << 12, | |
44 V3_SPEAKER_TFC = 1 << 13, | |
45 V3_SPEAKER_TFR = 1 << 14, | |
46 V3_SPEAKER_TRL = 1 << 15, | |
47 V3_SPEAKER_TRC = 1 << 16, | |
48 V3_SPEAKER_TRR = 1 << 17, | |
49 V3_SPEAKER_LFE2 = 1 << 18, | |
50 V3_SPEAKER_M = 1 << 19 | |
51 }; | |
52 | |
53 /** | |
54 * process setup | |
55 */ | |
56 | |
57 enum v3_process_mode { | |
58 V3_REALTIME, | |
59 V3_PREFETCH, | |
60 V3_OFFLINE | |
61 }; | |
62 | |
63 static inline | |
64 const char* v3_process_mode_str(int32_t d) | |
65 { | |
66 switch (d) | |
67 { | |
68 case V3_REALTIME: | |
69 return "V3_REALTIME"; | |
70 case V3_PREFETCH: | |
71 return "V3_PREFETCH"; | |
72 case V3_OFFLINE: | |
73 return "V3_OFFLINE"; | |
74 default: | |
75 return "[unknown]"; | |
76 } | |
77 } | |
78 | |
79 enum { | |
80 V3_SAMPLE_32, | |
81 V3_SAMPLE_64 | |
82 }; | |
83 | |
84 static inline | |
85 const char* v3_sample_size_str(int32_t d) | |
86 { | |
87 switch (d) | |
88 { | |
89 case V3_SAMPLE_32: | |
90 return "V3_SAMPLE_32"; | |
91 case V3_SAMPLE_64: | |
92 return "V3_SAMPLE_64"; | |
93 default: | |
94 return "[unknown]"; | |
95 } | |
96 } | |
97 | |
98 struct v3_process_setup { | |
99 int32_t process_mode; | |
100 int32_t symbolic_sample_size; | |
101 int32_t max_block_size; | |
102 double sample_rate; | |
103 }; | |
104 | |
105 /** | |
106 * param changes | |
107 */ | |
108 | |
109 struct v3_param_value_queue { | |
110 #ifndef __cplusplus | |
111 struct v3_funknown; | |
112 #endif | |
113 v3_param_id (V3_API* get_param_id)(void* self); | |
114 int32_t (V3_API* get_point_count)(void* self); | |
115 v3_result (V3_API* get_point)(void* self, int32_t idx, int32_t* sample_offset, double* value); | |
116 v3_result (V3_API* add_point)(void* self, int32_t sample_offset, double value, int32_t* idx); | |
117 }; | |
118 | |
119 static constexpr const v3_tuid v3_param_value_queue_iid = | |
120 V3_ID(0x01263A18, 0xED074F6F, 0x98C9D356, 0x4686F9BA); | |
121 | |
122 struct v3_param_changes { | |
123 #ifndef __cplusplus | |
124 struct v3_funknown; | |
125 #endif | |
126 int32_t (V3_API* get_param_count)(void* self); | |
127 struct v3_param_value_queue** (V3_API* get_param_data)(void* self, int32_t idx); | |
128 struct v3_param_value_queue** (V3_API* add_param_data)(void* self, v3_param_id* id, int32_t* index); | |
129 }; | |
130 | |
131 static constexpr const v3_tuid v3_param_changes_iid = | |
132 V3_ID(0xA4779663, 0x0BB64A56, 0xB44384A8, 0x466FEB9D); | |
133 | |
134 /** | |
135 * process context | |
136 */ | |
137 | |
138 struct v3_frame_rate { | |
139 uint32_t fps; | |
140 uint32_t flags; | |
141 }; | |
142 | |
143 struct v3_chord { | |
144 uint8_t key_note; | |
145 uint8_t root_note; | |
146 int16_t chord_mask; | |
147 }; | |
148 | |
149 enum { | |
150 V3_PROCESS_CTX_PLAYING = 1 << 1, | |
151 V3_PROCESS_CTX_CYCLE_ACTIVE = 1 << 2, | |
152 V3_PROCESS_CTX_RECORDING = 1 << 3, | |
153 V3_PROCESS_CTX_SYSTEM_TIME_VALID = 1 << 8, | |
154 V3_PROCESS_CTX_PROJECT_TIME_VALID = 1 << 9, | |
155 V3_PROCESS_CTX_TEMPO_VALID = 1 << 10, | |
156 V3_PROCESS_CTX_BAR_POSITION_VALID = 1 << 11, | |
157 V3_PROCESS_CTX_CYCLE_VALID = 1 << 12, | |
158 V3_PROCESS_CTX_TIME_SIG_VALID = 1 << 13, | |
159 V3_PROCESS_CTX_SMPTE_VALID = 1 << 14, | |
160 V3_PROCESS_CTX_NEXT_CLOCK_VALID = 1 << 15, | |
161 V3_PROCESS_CTX_CONT_TIME_VALID = 1 << 17, | |
162 V3_PROCESS_CTX_CHORD_VALID = 1 << 18 | |
163 }; | |
164 | |
165 struct v3_process_context { | |
166 uint32_t state; | |
167 double sample_rate; | |
168 int64_t project_time_in_samples; // with loop | |
169 int64_t system_time_ns; | |
170 int64_t continuous_time_in_samples; // without loop | |
171 double project_time_quarters; | |
172 double bar_position_quarters; | |
173 double cycle_start_quarters; | |
174 double cycle_end_quarters; | |
175 double bpm; | |
176 int32_t time_sig_numerator; | |
177 int32_t time_sig_denom; | |
178 struct v3_chord chord; | |
179 int32_t smpte_offset_subframes; | |
180 struct v3_frame_rate frame_rate; | |
181 int32_t samples_to_next_clock; | |
182 }; | |
183 | |
184 /** | |
185 * process context requirements | |
186 */ | |
187 | |
188 enum { | |
189 V3_PROCESS_CTX_NEED_SYSTEM_TIME = 1 << 0, | |
190 V3_PROCESS_CTX_NEED_CONTINUOUS_TIME = 1 << 1, | |
191 V3_PROCESS_CTX_NEED_PROJECT_TIME = 1 << 2, | |
192 V3_PROCESS_CTX_NEED_BAR_POSITION = 1 << 3, | |
193 V3_PROCESS_CTX_NEED_CYCLE = 1 << 4, | |
194 V3_PROCESS_CTX_NEED_NEXT_CLOCK = 1 << 5, | |
195 V3_PROCESS_CTX_NEED_TEMPO = 1 << 6, | |
196 V3_PROCESS_CTX_NEED_TIME_SIG = 1 << 7, | |
197 V3_PROCESS_CTX_NEED_CHORD = 1 << 8, | |
198 V3_PROCESS_CTX_NEED_FRAME_RATE = 1 << 9, | |
199 V3_PROCESS_CTX_NEED_TRANSPORT_STATE = 1 << 10 | |
200 }; | |
201 | |
202 struct v3_process_context_requirements { | |
203 #ifndef __cplusplus | |
204 struct v3_funknown; | |
205 #endif | |
206 uint32_t (V3_API* get_process_context_requirements)(void* self); | |
207 }; | |
208 | |
209 static constexpr const v3_tuid v3_process_context_requirements_iid = | |
210 V3_ID(0x2A654303, 0xEF764E3D, 0x95B5FE83, 0x730EF6D0); | |
211 | |
212 /** | |
213 * process data and context | |
214 */ | |
215 | |
216 struct v3_audio_bus_buffers { | |
217 int32_t num_channels; | |
218 uint64_t channel_silence_bitset; | |
219 union { | |
220 float** channel_buffers_32; | |
221 double** channel_buffers_64; | |
222 }; | |
223 }; | |
224 | |
225 struct v3_process_data { | |
226 int32_t process_mode; | |
227 int32_t symbolic_sample_size; | |
228 int32_t nframes; | |
229 int32_t num_input_buses; | |
230 int32_t num_output_buses; | |
231 struct v3_audio_bus_buffers* inputs; | |
232 struct v3_audio_bus_buffers* outputs; | |
233 struct v3_param_changes** input_params; | |
234 struct v3_param_changes** output_params; | |
235 struct v3_event_list** input_events; | |
236 struct v3_event_list** output_events; | |
237 struct v3_process_context* ctx; | |
238 }; | |
239 | |
240 /** | |
241 * audio processor | |
242 */ | |
243 | |
244 struct v3_audio_processor { | |
245 #ifndef __cplusplus | |
246 struct v3_funknown; | |
247 #endif | |
248 v3_result (V3_API* set_bus_arrangements)(void* self, v3_speaker_arrangement* inputs, int32_t num_inputs, | |
249 v3_speaker_arrangement* outputs, int32_t num_outputs); | |
250 v3_result (V3_API* get_bus_arrangement)(void* self, int32_t bus_direction, int32_t idx, v3_speaker_arrangement*); | |
251 v3_result (V3_API* can_process_sample_size)(void* self, int32_t symbolic_sample_size); | |
252 uint32_t (V3_API* get_latency_samples)(void* self); | |
253 v3_result (V3_API* setup_processing)(void* self, struct v3_process_setup* setup); | |
254 v3_result (V3_API* set_processing)(void* self, v3_bool state); | |
255 v3_result (V3_API* process)(void* self, struct v3_process_data* data); | |
256 uint32_t (V3_API* get_tail_samples)(void* self); | |
257 }; | |
258 | |
259 static constexpr const v3_tuid v3_audio_processor_iid = | |
260 V3_ID(0x42043F99, 0xB7DA453C, 0xA569E79D, 0x9AAEC33D); | |
261 | |
262 #ifdef __cplusplus | |
263 | |
264 /** | |
265 * C++ variants | |
266 */ | |
267 | |
268 struct v3_param_value_queue_cpp : v3_funknown { | |
269 v3_param_value_queue queue; | |
270 }; | |
271 | |
272 struct v3_param_changes_cpp : v3_funknown { | |
273 v3_param_changes changes; | |
274 }; | |
275 | |
276 struct v3_process_context_requirements_cpp : v3_funknown { | |
277 v3_process_context_requirements req; | |
278 }; | |
279 | |
280 struct v3_audio_processor_cpp : v3_funknown { | |
281 v3_audio_processor proc; | |
282 }; | |
283 | |
284 #endif | |
285 | |
286 #include "align_pop.h" |