clap_sys/
events.rs

1use crate::{fixedpoint::*, id::*};
2
3use std::ffi::c_void;
4
5#[repr(C)]
6#[derive(Debug, Copy, Clone)]
7pub struct clap_event_header {
8    pub size: u32,
9    pub time: u32,
10    pub space_id: u16,
11    pub type_: clap_event_type,
12    pub flags: u32,
13}
14
15pub const CLAP_CORE_EVENT_SPACE_ID: u16 = 0;
16
17pub const CLAP_EVENT_IS_LIVE: clap_event_flags = 1 << 0;
18pub const CLAP_EVENT_DONT_RECORD: clap_event_flags = 1 << 1;
19
20pub type clap_event_flags = u32;
21
22pub const CLAP_EVENT_NOTE_ON: clap_event_type = 0;
23pub const CLAP_EVENT_NOTE_OFF: clap_event_type = 1;
24pub const CLAP_EVENT_NOTE_CHOKE: clap_event_type = 2;
25pub const CLAP_EVENT_NOTE_END: clap_event_type = 3;
26pub const CLAP_EVENT_NOTE_EXPRESSION: clap_event_type = 4;
27pub const CLAP_EVENT_PARAM_VALUE: clap_event_type = 5;
28pub const CLAP_EVENT_PARAM_MOD: clap_event_type = 6;
29pub const CLAP_EVENT_PARAM_GESTURE_BEGIN: clap_event_type = 7;
30pub const CLAP_EVENT_PARAM_GESTURE_END: clap_event_type = 8;
31pub const CLAP_EVENT_TRANSPORT: clap_event_type = 9;
32pub const CLAP_EVENT_MIDI: clap_event_type = 10;
33pub const CLAP_EVENT_MIDI_SYSEX: clap_event_type = 11;
34pub const CLAP_EVENT_MIDI2: clap_event_type = 12;
35
36pub type clap_event_type = u16;
37
38#[repr(C)]
39#[derive(Debug, Copy, Clone)]
40pub struct clap_event_note {
41    pub header: clap_event_header,
42    pub note_id: i32,
43    pub port_index: i16,
44    pub channel: i16,
45    pub key: i16,
46    pub velocity: f64,
47}
48
49pub const CLAP_NOTE_EXPRESSION_VOLUME: clap_note_expression = 0;
50pub const CLAP_NOTE_EXPRESSION_PAN: clap_note_expression = 1;
51pub const CLAP_NOTE_EXPRESSION_TUNING: clap_note_expression = 2;
52pub const CLAP_NOTE_EXPRESSION_VIBRATO: clap_note_expression = 3;
53pub const CLAP_NOTE_EXPRESSION_EXPRESSION: clap_note_expression = 4;
54pub const CLAP_NOTE_EXPRESSION_BRIGHTNESS: clap_note_expression = 5;
55pub const CLAP_NOTE_EXPRESSION_PRESSURE: clap_note_expression = 6;
56
57pub type clap_note_expression = i32;
58
59#[repr(C)]
60#[derive(Debug, Copy, Clone)]
61pub struct clap_event_note_expression {
62    pub header: clap_event_header,
63    pub expression_id: clap_note_expression,
64    pub note_id: i32,
65    pub port_index: i16,
66    pub channel: i16,
67    pub key: i16,
68    pub value: f64,
69}
70
71#[repr(C)]
72#[derive(Debug, Copy, Clone)]
73pub struct clap_event_param_value {
74    pub header: clap_event_header,
75    pub param_id: clap_id,
76    pub cookie: *mut c_void,
77    pub note_id: i32,
78    pub port_index: i16,
79    pub channel: i16,
80    pub key: i16,
81    pub value: f64,
82}
83
84unsafe impl Send for clap_event_param_value {}
85unsafe impl Sync for clap_event_param_value {}
86
87#[repr(C)]
88#[derive(Debug, Copy, Clone)]
89pub struct clap_event_param_mod {
90    pub header: clap_event_header,
91    pub param_id: clap_id,
92    pub cookie: *mut c_void,
93    pub note_id: i32,
94    pub port_index: i16,
95    pub channel: i16,
96    pub key: i16,
97    pub amount: f64,
98}
99
100unsafe impl Send for clap_event_param_mod {}
101unsafe impl Sync for clap_event_param_mod {}
102
103#[repr(C)]
104#[derive(Debug, Copy, Clone)]
105pub struct clap_event_param_gesture {
106    pub header: clap_event_header,
107    pub param_id: clap_id,
108}
109
110pub const CLAP_TRANSPORT_HAS_TEMPO: clap_transport_flags = 1 << 0;
111pub const CLAP_TRANSPORT_HAS_BEATS_TIMELINE: clap_transport_flags = 1 << 1;
112pub const CLAP_TRANSPORT_HAS_SECONDS_TIMELINE: clap_transport_flags = 1 << 2;
113pub const CLAP_TRANSPORT_HAS_TIME_SIGNATURE: clap_transport_flags = 1 << 3;
114pub const CLAP_TRANSPORT_IS_PLAYING: clap_transport_flags = 1 << 4;
115pub const CLAP_TRANSPORT_IS_RECORDING: clap_transport_flags = 1 << 5;
116pub const CLAP_TRANSPORT_IS_LOOP_ACTIVE: clap_transport_flags = 1 << 6;
117pub const CLAP_TRANSPORT_IS_WITHIN_PRE_ROLL: clap_transport_flags = 1 << 7;
118
119pub type clap_transport_flags = u32;
120
121#[repr(C)]
122#[derive(Debug, Copy, Clone)]
123pub struct clap_event_transport {
124    pub header: clap_event_header,
125    pub flags: clap_transport_flags,
126    pub song_pos_beats: clap_beattime,
127    pub song_pos_seconds: clap_sectime,
128    pub tempo: f64,
129    pub tempo_inc: f64,
130    pub loop_start_beats: clap_beattime,
131    pub loop_end_beats: clap_beattime,
132    pub loop_start_seconds: clap_sectime,
133    pub loop_end_seconds: clap_sectime,
134    pub bar_start: clap_beattime,
135    pub bar_number: i32,
136    pub tsig_num: u16,
137    pub tsig_denom: u16,
138}
139
140#[repr(C)]
141#[derive(Debug, Copy, Clone)]
142pub struct clap_event_midi {
143    pub header: clap_event_header,
144    pub port_index: u16,
145    pub data: [u8; 3],
146}
147
148#[repr(C)]
149#[derive(Debug, Copy, Clone)]
150pub struct clap_event_midi_sysex {
151    pub header: clap_event_header,
152    pub port_index: u16,
153    pub buffer: *const u8,
154    pub size: u32,
155}
156
157unsafe impl Send for clap_event_midi_sysex {}
158unsafe impl Sync for clap_event_midi_sysex {}
159
160#[repr(C)]
161#[derive(Debug, Copy, Clone)]
162pub struct clap_event_midi2 {
163    pub header: clap_event_header,
164    pub port_index: u16,
165    pub data: [u32; 4],
166}
167
168#[repr(C)]
169#[derive(Debug, Copy, Clone)]
170pub struct clap_input_events {
171    pub ctx: *mut c_void,
172    pub size: Option<unsafe extern "C" fn(list: *const clap_input_events) -> u32>,
173    pub get: Option<
174        unsafe extern "C" fn(
175            list: *const clap_input_events,
176            index: u32,
177        ) -> *const clap_event_header,
178    >,
179}
180
181unsafe impl Send for clap_input_events {}
182unsafe impl Sync for clap_input_events {}
183
184#[repr(C)]
185#[derive(Debug, Copy, Clone)]
186pub struct clap_output_events {
187    pub ctx: *mut c_void,
188    pub try_push: Option<
189        unsafe extern "C" fn(
190            list: *const clap_output_events,
191            event: *const clap_event_header,
192        ) -> bool,
193    >,
194}
195
196unsafe impl Send for clap_output_events {}
197unsafe impl Sync for clap_output_events {}