LMMS
Loading...
Searching...
No Matches
events.h
Go to the documentation of this file.
1#pragma once
2
3#include "private/std.h"
4#include "fixedpoint.h"
5#include "id.h"
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11// event header
12// must be the first attribute of the event
13typedef struct clap_event_header {
14 uint32_t size; // event size including this header, eg: sizeof (clap_event_note)
15 uint32_t time; // sample offset within the buffer for this event
16 uint16_t space_id; // event space, see clap_host_event_registry
17 uint16_t type; // event type
18 uint32_t flags; // see clap_event_flags
20
21// The clap core event space
23
25 // Indicate a live user event, for example a user turning a physical knob
26 // or playing a physical key.
28
29 // Indicate that the event should not be recorded.
30 // For example this is useful when a parameter changes because of a MIDI CC,
31 // because if the host records both the MIDI CC automation and the parameter
32 // automation there will be a conflict.
34};
35
36// Some of the following events overlap, a note on can be expressed with:
37// - CLAP_EVENT_NOTE_ON
38// - CLAP_EVENT_MIDI
39// - CLAP_EVENT_MIDI2
40//
41// The preferred way of sending a note event is to use CLAP_EVENT_NOTE_*.
42//
43// The same event must not be sent twice: it is forbidden to send a the same note on
44// encoded with both CLAP_EVENT_NOTE_ON and CLAP_EVENT_MIDI.
45//
46// The plugins are encouraged to be able to handle note events encoded as raw midi or midi2,
47// or implement clap_plugin_event_filter and reject raw midi and midi2 events.
48enum {
49 // NOTE_ON and NOTE_OFF represent a key pressed and key released event, respectively.
50 // A NOTE_ON with a velocity of 0 is valid and should not be interpreted as a NOTE_OFF.
51 //
52 // NOTE_CHOKE is meant to choke the voice(s), like in a drum machine when a closed hihat
53 // chokes an open hihat. This event can be sent by the host to the plugin. Here are two use cases:
54 // - a plugin is inside a drum pad in Bitwig Studio's drum machine, and this pad is choked by
55 // another one
56 // - the user double clicks the DAW's stop button in the transport which then stops the sound on
57 // every tracks
58 //
59 // NOTE_END is sent by the plugin to the host. The port, channel, key and note_id are those given
60 // by the host in the NOTE_ON event. In other words, this event is matched against the
61 // plugin's note input port.
62 // NOTE_END is useful to help the host to match the plugin's voice life time.
63 //
64 // When using polyphonic modulations, the host has to allocate and release voices for its
65 // polyphonic modulator. Yet only the plugin effectively knows when the host should terminate
66 // a voice. NOTE_END solves that issue in a non-intrusive and cooperative way.
67 //
68 // CLAP assumes that the host will allocate a unique voice on NOTE_ON event for a given port,
69 // channel and key. This voice will run until the plugin will instruct the host to terminate
70 // it by sending a NOTE_END event.
71 //
72 // Consider the following sequence:
73 // - process()
74 // Host->Plugin NoteOn(port:0, channel:0, key:16, time:t0)
75 // Host->Plugin NoteOn(port:0, channel:0, key:64, time:t0)
76 // Host->Plugin NoteOff(port:0, channel:0, key:16, t1)
77 // Host->Plugin NoteOff(port:0, channel:0, key:64, t1)
78 // # on t2, both notes did terminate
79 // Host->Plugin NoteOn(port:0, channel:0, key:64, t3)
80 // # Here the plugin finished processing all the frames and will tell the host
81 // # to terminate the voice on key 16 but not 64, because a note has been started at t3
82 // Plugin->Host NoteEnd(port:0, channel:0, key:16, time:ignored)
83 //
84 // These four events use clap_event_note.
89
90 // Represents a note expression.
91 // Uses clap_event_note_expression.
93
94 // PARAM_VALUE sets the parameter's value; uses clap_event_param_value.
95 // PARAM_MOD sets the parameter's modulation amount; uses clap_event_param_mod.
96 //
97 // The value heard is: param_value + param_mod.
98 //
99 // In case of a concurrent global value/modulation versus a polyphonic one,
100 // the voice should only use the polyphonic one and the polyphonic modulation
101 // amount will already include the monophonic signal.
104
105 // Indicates that the user started or finished adjusting a knob.
106 // This is not mandatory to wrap parameter changes with gesture events, but this improves
107 // the user experience a lot when recording automation or overriding automation playback.
108 // Uses clap_event_param_gesture.
111
112 CLAP_EVENT_TRANSPORT, // update the transport info; clap_event_transport
113 CLAP_EVENT_MIDI, // raw midi event; clap_event_midi
114 CLAP_EVENT_MIDI_SYSEX, // raw midi sysex event; clap_event_midi_sysex
115 CLAP_EVENT_MIDI2, // raw midi 2 event; clap_event_midi2
116};
117
118// Note on, off, end and choke events.
119// In the case of note choke or end events:
120// - the velocity is ignored.
121// - key and channel are used to match active notes, a value of -1 matches all.
122typedef struct clap_event_note {
124
125 int32_t note_id; // -1 if unspecified, otherwise >=0
127 int16_t channel; // 0..15
128 int16_t key; // 0..127
129 double velocity; // 0..1
131
132enum {
133 // with 0 < x <= 4, plain = 20 * log(x)
135
136 // pan, 0 left, 0.5 center, 1 right
138
139 // relative tuning in semitone, from -120 to +120
141
142 // 0..1
147};
149
152
154
155 // target a specific note_id, port, key and channel, -1 for global
160
161 double value; // see expression for the range
163
166
167 // target parameter
168 clap_id param_id; // @ref clap_param_info.id
169 void *cookie; // @ref clap_param_info.cookie
170
171 // target a specific note_id, port, key and channel, -1 for global
176
177 double value;
179
180typedef struct clap_event_param_mod {
182
183 // target parameter
184 clap_id param_id; // @ref clap_param_info.id
185 void *cookie; // @ref clap_param_info.cookie
186
187 // target a specific note_id, port, key and channel, -1 for global
192
193 double amount; // modulation amount
195
198
199 // target parameter
200 clap_id param_id; // @ref clap_param_info.id
202
213
214typedef struct clap_event_transport {
216
217 uint32_t flags; // see clap_transport_flags
218
219 clap_beattime song_pos_beats; // position in beats
220 clap_sectime song_pos_seconds; // position in seconds
221
222 double tempo; // in bpm
223 double tempo_inc; // tempo increment for each samples and until the next
224 // time info event
225
230
231 clap_beattime bar_start; // start pos of the current bar
232 int32_t bar_number; // bar at song pos 0 has the number 0
233
234 uint16_t tsig_num; // time signature numerator
235 uint16_t tsig_denom; // time signature denominator
237
244
252
253// While it is possible to use a series of midi2 event to send a sysex,
254// prefer clap_event_midi_sysex if possible for efficiency.
261
262// Input event list, events must be sorted by time.
263typedef struct clap_input_events {
264 void *ctx; // reserved pointer for the list
265
266 uint32_t (CLAP_ABI *size)(const struct clap_input_events *list);
267
268 // Don't free the returned event, it belongs to the list
269 const clap_event_header_t *(CLAP_ABI *get)(const struct clap_input_events *list, uint32_t index);
271
272// Output event list, events must be sorted by time.
273typedef struct clap_output_events {
274 void *ctx; // reserved pointer for the list
275
276 // Pushes a copy of the event
277 // returns false if the event could not be pushed to the queue (out of memory?)
278 bool (CLAP_ABI *try_push)(const struct clap_output_events *list, const clap_event_header_t *event);
280
281#ifdef __cplusplus
282}
283#endif
struct clap_event_param_value clap_event_param_value_t
struct clap_event_header clap_event_header_t
struct clap_event_midi clap_event_midi_t
struct clap_event_param_gesture clap_event_param_gesture_t
struct clap_event_note_expression clap_event_note_expression_t
int32_t clap_note_expression
Definition events.h:148
@ CLAP_NOTE_EXPRESSION_BRIGHTNESS
Definition events.h:145
@ CLAP_NOTE_EXPRESSION_PRESSURE
Definition events.h:146
@ CLAP_NOTE_EXPRESSION_PAN
Definition events.h:137
@ CLAP_NOTE_EXPRESSION_EXPRESSION
Definition events.h:144
@ CLAP_NOTE_EXPRESSION_VIBRATO
Definition events.h:143
@ CLAP_NOTE_EXPRESSION_TUNING
Definition events.h:140
@ CLAP_NOTE_EXPRESSION_VOLUME
Definition events.h:134
clap_event_flags
Definition events.h:24
@ CLAP_EVENT_DONT_RECORD
Definition events.h:33
@ CLAP_EVENT_IS_LIVE
Definition events.h:27
struct clap_input_events clap_input_events_t
struct clap_event_midi_sysex clap_event_midi_sysex_t
struct clap_output_events clap_output_events_t
struct clap_event_note clap_event_note_t
clap_transport_flags
Definition events.h:203
@ CLAP_TRANSPORT_IS_RECORDING
Definition events.h:209
@ CLAP_TRANSPORT_IS_WITHIN_PRE_ROLL
Definition events.h:211
@ CLAP_TRANSPORT_HAS_BEATS_TIMELINE
Definition events.h:205
@ CLAP_TRANSPORT_IS_LOOP_ACTIVE
Definition events.h:210
@ CLAP_TRANSPORT_HAS_TEMPO
Definition events.h:204
@ CLAP_TRANSPORT_HAS_SECONDS_TIMELINE
Definition events.h:206
@ CLAP_TRANSPORT_IS_PLAYING
Definition events.h:208
@ CLAP_TRANSPORT_HAS_TIME_SIGNATURE
Definition events.h:207
static const CLAP_CONSTEXPR uint16_t CLAP_CORE_EVENT_SPACE_ID
Definition events.h:22
@ CLAP_EVENT_MIDI_SYSEX
Definition events.h:114
@ CLAP_EVENT_NOTE_CHOKE
Definition events.h:87
@ CLAP_EVENT_PARAM_MOD
Definition events.h:103
@ CLAP_EVENT_PARAM_GESTURE_END
Definition events.h:110
@ CLAP_EVENT_NOTE_ON
Definition events.h:85
@ CLAP_EVENT_PARAM_VALUE
Definition events.h:102
@ CLAP_EVENT_MIDI
Definition events.h:113
@ CLAP_EVENT_NOTE_END
Definition events.h:88
@ CLAP_EVENT_PARAM_GESTURE_BEGIN
Definition events.h:109
@ CLAP_EVENT_NOTE_OFF
Definition events.h:86
@ CLAP_EVENT_NOTE_EXPRESSION
Definition events.h:92
@ CLAP_EVENT_MIDI2
Definition events.h:115
@ CLAP_EVENT_TRANSPORT
Definition events.h:112
struct clap_event_midi2 clap_event_midi2_t
struct clap_event_param_mod clap_event_param_mod_t
struct clap_event_transport clap_event_transport_t
int64_t clap_sectime
Definition fixedpoint.h:16
int64_t clap_beattime
Definition fixedpoint.h:15
uint32_t clap_id
Definition id.h:6
#define CLAP_ABI
Definition macros.h:24
#define CLAP_CONSTEXPR
Definition macros.h:32
unsigned short uint16_t
Definition mid.cpp:99
int int32_t
Definition mid.cpp:97
unsigned int uint32_t
Definition mid.cpp:100
short int16_t
Definition mid.cpp:96
unsigned char uint8_t
Definition mid.cpp:98
Definition events.h:13
uint32_t time
Definition events.h:15
uint16_t space_id
Definition events.h:16
uint32_t flags
Definition events.h:18
uint16_t type
Definition events.h:17
uint32_t size
Definition events.h:14
Definition events.h:255
clap_event_header_t header
Definition events.h:256
uint16_t port_index
Definition events.h:258
uint32_t data[4]
Definition events.h:259
Definition events.h:245
uint16_t port_index
Definition events.h:248
clap_event_header_t header
Definition events.h:246
const uint8_t * buffer
Definition events.h:249
uint32_t size
Definition events.h:250
Definition events.h:238
clap_event_header_t header
Definition events.h:239
uint8_t data[3]
Definition events.h:242
uint16_t port_index
Definition events.h:241
Definition events.h:150
int16_t channel
Definition events.h:158
int32_t note_id
Definition events.h:156
int16_t port_index
Definition events.h:157
double value
Definition events.h:161
clap_event_header_t header
Definition events.h:151
clap_note_expression expression_id
Definition events.h:153
int16_t key
Definition events.h:159
Definition events.h:122
int16_t port_index
Definition events.h:126
double velocity
Definition events.h:129
int16_t channel
Definition events.h:127
int16_t key
Definition events.h:128
clap_event_header_t header
Definition events.h:123
int32_t note_id
Definition events.h:125
Definition events.h:196
clap_event_header_t header
Definition events.h:197
clap_id param_id
Definition events.h:200
Definition events.h:180
clap_event_header_t header
Definition events.h:181
int16_t port_index
Definition events.h:189
void * cookie
Definition events.h:185
int16_t key
Definition events.h:191
int32_t note_id
Definition events.h:188
double amount
Definition events.h:193
clap_id param_id
Definition events.h:184
int16_t channel
Definition events.h:190
Definition events.h:164
double value
Definition events.h:177
int16_t key
Definition events.h:175
int32_t note_id
Definition events.h:172
int16_t channel
Definition events.h:174
int16_t port_index
Definition events.h:173
void * cookie
Definition events.h:169
clap_id param_id
Definition events.h:168
clap_event_header_t header
Definition events.h:165
Definition events.h:214
clap_sectime loop_end_seconds
Definition events.h:229
double tempo
Definition events.h:222
uint32_t flags
Definition events.h:217
clap_beattime bar_start
Definition events.h:231
int32_t bar_number
Definition events.h:232
uint16_t tsig_num
Definition events.h:234
uint16_t tsig_denom
Definition events.h:235
double tempo_inc
Definition events.h:223
clap_sectime loop_start_seconds
Definition events.h:228
clap_beattime loop_start_beats
Definition events.h:226
clap_sectime song_pos_seconds
Definition events.h:220
clap_beattime song_pos_beats
Definition events.h:219
clap_beattime loop_end_beats
Definition events.h:227
clap_event_header_t header
Definition events.h:215
Definition events.h:263
void * ctx
Definition events.h:264
uint32_t(CLAP_ABI *size)(const struct clap_input_events *list)
const clap_event_header_t *CLAP_ABI * get(const struct clap_input_events *list, uint32_t index)
Definition events.h:273
const clap_event_header_t * event
Definition events.h:278
bool(CLAP_ABI *try_push)(const struct clap_output_events *list
void * ctx
Definition events.h:274
ulg size
Definition extract.c:2350