1use std::ffi::c_void;
2use std::mem;
3use std::os::raw::c_char;
4
5pub const fn cconst(a: u8, b: u8, c: u8, d: u8) -> i32 {
6 ((a as i32) << 24) | ((b as i32) << 16) | ((c as i32) << 8) | ((d as i32) << 0)
7}
8
9pub mod host_opcodes {
10 pub const AUTOMATE: i32 = 0;
11 pub const VERSION: i32 = 1;
12 pub const CURRENT_ID: i32 = 2;
13 pub const IDLE: i32 = 3;
14 pub const PIN_CONNECTED: i32 = 4;
15 pub const WANT_MIDI: i32 = 6;
16 pub const GET_TIME: i32 = 7;
17 pub const PROCESS_EVENTS: i32 = 8;
18 pub const SET_TIME: i32 = 9;
19 pub const TEMPO_AT: i32 = 10;
20 pub const GET_NUM_AUTOMATABLE_PARAMETERS: i32 = 11;
21 pub const GET_PARAMETER_QUANTIZATION: i32 = 12;
22 pub const IO_CHANGED: i32 = 13;
23 pub const NEED_IDLE: i32 = 14;
24 pub const SIZE_WINDOW: i32 = 15;
25 pub const GET_SAMPLE_RATE: i32 = 16;
26 pub const GET_BLOCK_SIZE: i32 = 17;
27 pub const GET_INPUT_LATENCY: i32 = 18;
28 pub const GET_OUTPUT_LATENCY: i32 = 19;
29 pub const GET_PREVIOUS_PLUG: i32 = 20;
30 pub const GET_NEXT_PLUG: i32 = 21;
31 pub const WILL_REPLACE_OR_ACCUMULATE: i32 = 22;
32 pub const GET_CURRENT_PROCESS_LEVEL: i32 = 23;
33 pub const GET_AUTOMATION_STATE: i32 = 24;
34 pub const OFFLINE_START: i32 = 25;
35 pub const OFFLINE_READ: i32 = 26;
36 pub const OFFLINE_WRITE: i32 = 27;
37 pub const OFFLINE_GET_CURRENT_PASS: i32 = 28;
38 pub const OFFLINE_GET_CURRENT_META_PASS: i32 = 29;
39 pub const SET_OUTPUT_SAMPLE_RATE: i32 = 30;
40 pub const GET_SPEAKER_ARRANGEMENT: i32 = 31;
41 pub const GET_VENDOR_STRING: i32 = 32;
42 pub const GET_PRODUCT_STRING: i32 = 33;
43 pub const GET_VENDOR_VERSION: i32 = 34;
44 pub const VENDOR_SPECIFIC: i32 = 35;
45 pub const SET_ICON: i32 = 36;
46 pub const CAN_DO: i32 = 37;
47 pub const GET_LANGUAGE: i32 = 38;
48 pub const OPEN_WINDOW: i32 = 39;
49 pub const CLOSE_WINDOW: i32 = 40;
50 pub const GET_DIRECTORY: i32 = 41;
51 pub const UPDATE_DISPLAY: i32 = 42;
52 pub const BEGIN_EDIT: i32 = 43;
53 pub const END_EDIT: i32 = 44;
54 pub const OPEN_FILE_SELECTOR: i32 = 45;
55 pub const CLOSE_FILE_SELECTOR: i32 = 46;
56 pub const EDIT_FILE: i32 = 47;
57 pub const GET_CHUNK_FILE: i32 = 48;
58 pub const GET_INPUT_SPEAKER_ARRANGEMENT: i32 = 49;
59}
60
61pub mod effect_flags {
62 pub const HAS_EDITOR: i32 = 1;
63 pub const CAN_REPLACING: i32 = 1 << 4;
64 pub const PROGRAM_CHUNKS: i32 = 1 << 5;
65 pub const IS_SYNTH: i32 = 1 << 8;
66}
67
68pub mod effect_opcodes {
69 pub const OPEN: i32 = 0;
70 pub const CLOSE: i32 = 1;
71 pub const SET_PROGRAM: i32 = 2;
72 pub const GET_PROGRAM: i32 = 3;
73 pub const GET_PROGRAM_NAME: i32 = 5;
74 pub const GET_PARAM_LABEL: i32 = 6;
75 pub const GET_PARAM_DISPLAY: i32 = 7;
76 pub const GET_PARAM_NAME: i32 = 8;
77 pub const SET_SAMPLE_RATE: i32 = 10;
78 pub const SET_BLOCK_SIZE: i32 = 11;
79 pub const MAINS_CHANGED: i32 = 12;
80 pub const EDIT_GET_RECT: i32 = 13;
81 pub const EDIT_OPEN: i32 = 14;
82 pub const EDIT_CLOSE: i32 = 15;
83 pub const EDIT_IDLE: i32 = 19;
84 pub const EDIT_TOP: i32 = 20;
85 pub const GET_CHUNK: i32 = 23;
86 pub const SET_CHUNK: i32 = 24;
87 pub const PROCESS_EVENTS: i32 = 25;
88 pub const CAN_BE_AUTOMATED: i32 = 26;
89 pub const STRING_TO_PARAMETER: i32 = 27;
90 pub const GET_PLUG_CATEGORY: i32 = 35;
91 pub const SET_BYPASS: i32 = 44;
92 pub const GET_EFFECT_NAME: i32 = 45;
93 pub const GET_VENDOR_STRING: i32 = 47;
94 pub const GET_PRODUCT_STRING: i32 = 48;
95 pub const GET_VENDOR_VERSION: i32 = 49;
96 pub const VENDOR_SPECIFIC: i32 = 50;
97 pub const CAN_DO: i32 = 51;
98 pub const IDLE: i32 = 53;
99 pub const GET_PARAMETER_PROPERTIES: i32 = 56;
100 pub const GET_VST_VERSION: i32 = 58;
101 pub const SHELL_GET_NEXT_PLUGIN: i32 = 70;
102 pub const START_PROCESS: i32 = 71;
103 pub const STOP_PROCESS: i32 = 72;
104 pub const BEGIN_SET_PROGRAM: i32 = 67;
105 pub const END_SET_PROGRAM: i32 = 68;
106}
107
108pub const MAGIC: i32 = cconst(b'V', b's', b't', b'P');
109pub const LANG_ENGLISH: i32 = 1;
110pub const MIDI_TYPE: i32 = 1;
111pub const SYSEX_TYPE: i32 = 6;
112
113pub mod transport {
114 pub const CHANGED: i32 = 1;
115 pub const PLAYING: i32 = 1 << 1;
116 pub const CYCLE_ACTIVE: i32 = 1 << 2;
117 pub const RECORDING: i32 = 1 << 3;
118}
119
120pub mod automation {
121 pub const WRITING: i32 = 1 << 6;
122 pub const READING: i32 = 1 << 7;
123}
124
125pub mod time_info_flags {
126 pub const NANOS_VALID: i32 = 1 << 8;
127 pub const PPQ_POS_VALID: i32 = 1 << 9;
128 pub const TEMPO_VALID: i32 = 1 << 10;
129 pub const BARS_VALID: i32 = 1 << 11;
130 pub const CYCLE_POS_VALID: i32 = 1 << 12;
131 pub const TIME_SIG_VALID: i32 = 1 << 13;
132 pub const SMPTE_VALID: i32 = 1 << 14;
133 pub const CLOCK_VALID: i32 = 1 << 15;
134}
135
136#[repr(C)]
137#[derive(Copy, Clone)]
138pub struct MidiEvent {
139 pub event_type: i32,
140 pub byte_size: i32,
141 pub delta_frames: i32,
142 pub flags: i32,
143 pub note_length: i32,
144 pub note_offset: i32,
145 pub midi_data: [u8; 4],
146 pub detune: i8,
147 pub note_off_velocity: u8,
148 pub reserved_1: u8,
149 pub reserved_2: u8,
150}
151
152#[repr(C)]
153#[derive(Copy, Clone)]
154pub struct SysExEvent {
155 pub event_type: i32,
156 pub byte_size: i32,
157 pub delta_frames: i32,
158 pub flags: i32,
159 pub dump_bytes: i32,
160 pub reserved_1: *const c_void,
161 pub sysex_dump: *const i8,
162 pub reserved_2: *const c_void,
163}
164
165#[repr(C)]
166#[derive(Copy, Clone)]
167pub struct Event {
168 pub dump: [u8; mem::size_of::<MidiEvent>()],
169}
170
171#[repr(C)]
172#[derive(Copy, Clone)]
173pub struct Events {
174 pub num_events: i32,
175 pub reserved: *const c_void,
176 pub events: [*const Event; 2],
177}
178
179pub mod string_constants {
180 pub const MAX_NAME_LEN: usize = 64;
181 pub const MAX_LABEL_LEN: usize = 64;
182 pub const MAX_SHORT_LABEL_LEN: usize = 8;
183 pub const MAX_CATEG_LABEL_LEN: usize = 24;
184 pub const MAX_FILE_NAME_LEN: usize = 100;
185}
186
187pub mod plug_category {
188 pub const UNKNOWN: i32 = 0;
189 pub const EFFECT: i32 = 1;
190 pub const SYNTH: i32 = 2;
191 pub const ANALYSIS: i32 = 3;
192 pub const MASTERING: i32 = 4;
193 pub const SPACIALIZER: i32 = 5;
194 pub const ROOM_FX: i32 = 6;
195 pub const SURROUND_FX: i32 = 7;
196 pub const RESTORATION: i32 = 8;
197 pub const OFFLINE_PROCESS: i32 = 9;
198 pub const SHELL: i32 = 10;
199 pub const GENERATOR: i32 = 11;
200 pub const MAX_COUNT: i32 = 12;
201}
202
203#[repr(C)]
204#[derive(Copy, Clone)]
205pub struct ParameterProperties {
206 pub step_float: f32,
207 pub small_step_float: f32,
208 pub large_step_float: f32,
209 pub label: [c_char; string_constants::MAX_LABEL_LEN],
210 pub flags: i32,
211 pub min_integer: i32,
212 pub max_integer: i32,
213 pub step_integer: i32,
214 pub large_step_integer: i32,
215 pub short_label: [c_char; string_constants::MAX_SHORT_LABEL_LEN],
216 pub display_index: i16,
217 pub category: i16,
218 pub num_parameters_in_category: i16,
219 pub reserved: i16,
220 pub category_label: [c_char; string_constants::MAX_CATEG_LABEL_LEN],
221 pub future: [u8; 16],
222}
223
224pub mod parameter_flags {
225 pub const IS_SWITCH: i32 = 1 << 0;
226 pub const USES_INTEGER_MIN_MAX: i32 = 1 << 1;
227 pub const USES_FLOAT_STEP: i32 = 1 << 2;
228 pub const USES_INT_STEP: i32 = 1 << 3;
229 pub const SUPPORTS_DISPLAY_INDEX: i32 = 1 << 4;
230 pub const SUPPORTS_DISPLAY_CATEGORY: i32 = 1 << 5;
231 pub const CAN_RAMP: i32 = 1 << 6;
232}
233
234#[repr(C)]
235#[derive(Copy, Clone)]
236pub struct AEffect {
237 pub magic: i32,
238 pub dispatcher: extern "C" fn(*mut AEffect, i32, i32, isize, *mut c_void, f32) -> isize,
239 pub process: extern "C" fn(*mut AEffect, *const *const f32, *mut *mut f32, i32),
240 pub set_parameter: extern "C" fn(*mut AEffect, i32, f32),
241 pub get_parameter: extern "C" fn(*mut AEffect, i32) -> f32,
242 pub num_programs: i32,
243 pub num_params: i32,
244 pub num_inputs: i32,
245 pub num_outputs: i32,
246 pub flags: i32,
247 pub ptr_1: *mut c_void,
248 pub ptr_2: *mut c_void,
249 pub initial_delay: i32,
250 pub empty_2: [u8; 4 + 4],
251 pub unknown_float: f32,
252 pub object: *mut c_void,
253 pub user: *mut c_void,
254 pub unique_id: i32,
255 pub version: i32,
256 pub process_replacing: extern "C" fn(*mut AEffect, *const *const f32, *mut *mut f32, i32),
257 pub process_double_replacing: extern "C" fn(*mut AEffect, *const *const f64, *mut *mut f64, i32),
258}
259
260#[repr(C)]
261#[derive(Copy, Clone)]
262pub struct TimeInfo {
263 pub sample_pos: f64,
264 pub sample_rate: f64,
265 pub nano_seconds: f64,
266 pub ppq_pos: f64,
267 pub tempo: f64,
268 pub bar_start_pos: f64,
269 pub cycle_start_pos: f64,
270 pub cycle_end_pos: f64,
271 pub time_sig_numerator: i32,
272 pub time_sig_denominator: i32,
273 pub smpte_offset: i32,
274 pub smpte_frame_rate: i32,
275 pub samples_to_next_clock: i32,
276 pub flags: i32,
277}
278
279#[repr(C)]
280#[derive(Copy, Clone)]
281pub struct Rect {
282 pub top: i16,
283 pub left: i16,
284 pub bottom: i16,
285 pub right: i16,
286}
287
288pub type HostCallbackProc = extern "C" fn(*mut AEffect, i32, i32, isize, *mut c_void, f32) -> isize;