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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
use crate::{events::*, host::*, id::*, plugin::*, string_sizes::*};

use std::ffi::c_void;
use std::ffi::CStr;
use std::os::raw::c_char;

pub const CLAP_EXT_PARAMS: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"clap.params\0") };

pub const CLAP_PARAM_IS_STEPPED: clap_param_info_flags = 1 << 0;
pub const CLAP_PARAM_IS_PERIODIC: clap_param_info_flags = 1 << 1;
pub const CLAP_PARAM_IS_HIDDEN: clap_param_info_flags = 1 << 2;
pub const CLAP_PARAM_IS_READONLY: clap_param_info_flags = 1 << 3;
pub const CLAP_PARAM_IS_BYPASS: clap_param_info_flags = 1 << 4;
pub const CLAP_PARAM_IS_AUTOMATABLE: clap_param_info_flags = 1 << 5;
pub const CLAP_PARAM_IS_AUTOMATABLE_PER_NOTE_ID: clap_param_info_flags = 1 << 6;
pub const CLAP_PARAM_IS_AUTOMATABLE_PER_KEY: clap_param_info_flags = 1 << 7;
pub const CLAP_PARAM_IS_AUTOMATABLE_PER_CHANNEL: clap_param_info_flags = 1 << 8;
pub const CLAP_PARAM_IS_AUTOMATABLE_PER_PORT: clap_param_info_flags = 1 << 9;
pub const CLAP_PARAM_IS_MODULATABLE: clap_param_info_flags = 1 << 10;
pub const CLAP_PARAM_IS_MODULATABLE_PER_NOTE_ID: clap_param_info_flags = 1 << 11;
pub const CLAP_PARAM_IS_MODULATABLE_PER_KEY: clap_param_info_flags = 1 << 12;
pub const CLAP_PARAM_IS_MODULATABLE_PER_CHANNEL: clap_param_info_flags = 1 << 13;
pub const CLAP_PARAM_IS_MODULATABLE_PER_PORT: clap_param_info_flags = 1 << 14;
pub const CLAP_PARAM_REQUIRES_PROCESS: clap_param_info_flags = 1 << 15;

pub type clap_param_info_flags = u32;

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct clap_param_info {
    pub id: clap_id,
    pub flags: clap_param_info_flags,
    pub cookie: *mut c_void,
    pub name: [c_char; CLAP_NAME_SIZE],
    pub module: [c_char; CLAP_PATH_SIZE],
    pub min_value: f64,
    pub max_value: f64,
    pub default_value: f64,
}

unsafe impl Send for clap_param_info {}
unsafe impl Sync for clap_param_info {}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct clap_plugin_params {
    pub count: Option<unsafe extern "C" fn(plugin: *const clap_plugin) -> u32>,
    pub get_info: Option<
        unsafe extern "C" fn(
            plugin: *const clap_plugin,
            param_index: u32,
            param_info: *mut clap_param_info,
        ) -> bool,
    >,
    pub get_value: Option<
        unsafe extern "C" fn(
            plugin: *const clap_plugin,
            param_id: clap_id,
            value: *mut f64,
        ) -> bool,
    >,
    pub value_to_text: Option<
        unsafe extern "C" fn(
            plugin: *const clap_plugin,
            param_id: clap_id,
            value: f64,
            display: *mut c_char,
            size: u32,
        ) -> bool,
    >,
    pub text_to_value: Option<
        unsafe extern "C" fn(
            plugin: *const clap_plugin,
            param_id: clap_id,
            display: *const c_char,
            value: *mut f64,
        ) -> bool,
    >,
    pub flush: Option<
        unsafe extern "C" fn(
            plugin: *const clap_plugin,
            in_: *const clap_input_events,
            out: *const clap_output_events,
        ),
    >,
}

pub const CLAP_PARAM_RESCAN_VALUES: clap_param_rescan_flags = 1 << 0;
pub const CLAP_PARAM_RESCAN_TEXT: clap_param_rescan_flags = 1 << 1;
pub const CLAP_PARAM_RESCAN_INFO: clap_param_rescan_flags = 1 << 2;
pub const CLAP_PARAM_RESCAN_ALL: clap_param_rescan_flags = 1 << 3;

pub type clap_param_rescan_flags = u32;

pub const CLAP_PARAM_CLEAR_ALL: clap_param_clear_flags = 1 << 0;
pub const CLAP_PARAM_CLEAR_AUTOMATIONS: clap_param_clear_flags = 1 << 1;
pub const CLAP_PARAM_CLEAR_MODULATIONS: clap_param_clear_flags = 1 << 2;

pub type clap_param_clear_flags = u32;

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct clap_host_params {
    pub rescan:
        Option<unsafe extern "C" fn(host: *const clap_host, flags: clap_param_rescan_flags)>,
    pub clear: Option<
        unsafe extern "C" fn(
            host: *const clap_host,
            param_id: clap_id,
            flags: clap_param_clear_flags,
        ),
    >,
    pub request_flush: Option<unsafe extern "C" fn(host: *const clap_host)>,
}