clap_sys/ext/
params.rs

1use crate::{cstr, events::*, host::*, id::*, plugin::*, string_sizes::*};
2
3use std::ffi::{c_char, c_void, CStr};
4
5pub const CLAP_EXT_PARAMS: &CStr = cstr!("clap.params");
6
7pub const CLAP_PARAM_IS_STEPPED: clap_param_info_flags = 1 << 0;
8pub const CLAP_PARAM_IS_PERIODIC: clap_param_info_flags = 1 << 1;
9pub const CLAP_PARAM_IS_HIDDEN: clap_param_info_flags = 1 << 2;
10pub const CLAP_PARAM_IS_READONLY: clap_param_info_flags = 1 << 3;
11pub const CLAP_PARAM_IS_BYPASS: clap_param_info_flags = 1 << 4;
12pub const CLAP_PARAM_IS_AUTOMATABLE: clap_param_info_flags = 1 << 5;
13pub const CLAP_PARAM_IS_AUTOMATABLE_PER_NOTE_ID: clap_param_info_flags = 1 << 6;
14pub const CLAP_PARAM_IS_AUTOMATABLE_PER_KEY: clap_param_info_flags = 1 << 7;
15pub const CLAP_PARAM_IS_AUTOMATABLE_PER_CHANNEL: clap_param_info_flags = 1 << 8;
16pub const CLAP_PARAM_IS_AUTOMATABLE_PER_PORT: clap_param_info_flags = 1 << 9;
17pub const CLAP_PARAM_IS_MODULATABLE: clap_param_info_flags = 1 << 10;
18pub const CLAP_PARAM_IS_MODULATABLE_PER_NOTE_ID: clap_param_info_flags = 1 << 11;
19pub const CLAP_PARAM_IS_MODULATABLE_PER_KEY: clap_param_info_flags = 1 << 12;
20pub const CLAP_PARAM_IS_MODULATABLE_PER_CHANNEL: clap_param_info_flags = 1 << 13;
21pub const CLAP_PARAM_IS_MODULATABLE_PER_PORT: clap_param_info_flags = 1 << 14;
22pub const CLAP_PARAM_REQUIRES_PROCESS: clap_param_info_flags = 1 << 15;
23pub const CLAP_PARAM_IS_ENUM: clap_param_info_flags = 1 << 16;
24
25pub type clap_param_info_flags = u32;
26
27#[repr(C)]
28#[derive(Debug, Copy, Clone)]
29pub struct clap_param_info {
30    pub id: clap_id,
31    pub flags: clap_param_info_flags,
32    pub cookie: *mut c_void,
33    pub name: [c_char; CLAP_NAME_SIZE],
34    pub module: [c_char; CLAP_PATH_SIZE],
35    pub min_value: f64,
36    pub max_value: f64,
37    pub default_value: f64,
38}
39
40unsafe impl Send for clap_param_info {}
41unsafe impl Sync for clap_param_info {}
42
43#[repr(C)]
44#[derive(Debug, Copy, Clone)]
45pub struct clap_plugin_params {
46    pub count: Option<unsafe extern "C" fn(plugin: *const clap_plugin) -> u32>,
47    pub get_info: Option<
48        unsafe extern "C" fn(
49            plugin: *const clap_plugin,
50            param_index: u32,
51            param_info: *mut clap_param_info,
52        ) -> bool,
53    >,
54    pub get_value: Option<
55        unsafe extern "C" fn(
56            plugin: *const clap_plugin,
57            param_id: clap_id,
58            out_value: *mut f64,
59        ) -> bool,
60    >,
61    pub value_to_text: Option<
62        unsafe extern "C" fn(
63            plugin: *const clap_plugin,
64            param_id: clap_id,
65            value: f64,
66            out_buffer: *mut c_char,
67            out_buffer_capacity: u32,
68        ) -> bool,
69    >,
70    pub text_to_value: Option<
71        unsafe extern "C" fn(
72            plugin: *const clap_plugin,
73            param_id: clap_id,
74            param_value_text: *const c_char,
75            out_value: *mut f64,
76        ) -> bool,
77    >,
78    pub flush: Option<
79        unsafe extern "C" fn(
80            plugin: *const clap_plugin,
81            in_: *const clap_input_events,
82            out: *const clap_output_events,
83        ),
84    >,
85}
86
87pub const CLAP_PARAM_RESCAN_VALUES: clap_param_rescan_flags = 1 << 0;
88pub const CLAP_PARAM_RESCAN_TEXT: clap_param_rescan_flags = 1 << 1;
89pub const CLAP_PARAM_RESCAN_INFO: clap_param_rescan_flags = 1 << 2;
90pub const CLAP_PARAM_RESCAN_ALL: clap_param_rescan_flags = 1 << 3;
91
92pub type clap_param_rescan_flags = u32;
93
94pub const CLAP_PARAM_CLEAR_ALL: clap_param_clear_flags = 1 << 0;
95pub const CLAP_PARAM_CLEAR_AUTOMATIONS: clap_param_clear_flags = 1 << 1;
96pub const CLAP_PARAM_CLEAR_MODULATIONS: clap_param_clear_flags = 1 << 2;
97
98pub type clap_param_clear_flags = u32;
99
100#[repr(C)]
101#[derive(Debug, Copy, Clone)]
102pub struct clap_host_params {
103    pub rescan:
104        Option<unsafe extern "C" fn(host: *const clap_host, flags: clap_param_rescan_flags)>,
105    pub clear: Option<
106        unsafe extern "C" fn(
107            host: *const clap_host,
108            param_id: clap_id,
109            flags: clap_param_clear_flags,
110        ),
111    >,
112    pub request_flush: Option<unsafe extern "C" fn(host: *const clap_host)>,
113}