Fix UI RDF info
[juce-lv2.git] / juce / source / src / audio / plugin_client / LV2 / includes / lv2_event.h
blob2c340ba6f29450e5c281ae63ff28a6d964d2f012
1 /*
2 LV2 Event Extension
3 Copyright 2008-2011 David Robillard <http://drobilla.net>
4 Copyright 2006-2007 Lars Luthman <lars.luthman@gmail.com>
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
10 THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #ifndef LV2_EVENT_H
20 #define LV2_EVENT_H
22 #define LV2_EVENT_URI "http://lv2plug.in/ns/ext/event"
23 #define LV2_EVENT_AUDIO_STAMP 0
25 #include <stdint.h>
27 /**
28 @file event.h
29 C API for the LV2 Event extension <http://lv2plug.in/ns/ext/event>.
31 This extension is a generic transport mechanism for time stamped events
32 of any type (e.g. MIDI, OSC, ramps, etc). Each port can transport mixed
33 events of any type; the type of events and timestamps are defined by a URI
34 which is mapped to an integer by the host for performance reasons.
36 This extension requires the host to support the LV2 URI Map extension.
37 Any host which supports this extension MUST guarantee that any call to
38 the LV2 URI Map uri_to_id function with the URI of this extension as the
39 'map' argument returns a value within the range of uint16_t.
42 /**
43 The best Pulses Per Quarter Note for tempo-based uint32_t timestamps.
44 Equal to 2^12 * 5 * 7 * 9 * 11 * 13 * 17, which is evenly divisble
45 by all integers from 1 through 18 inclusive, and powers of 2 up to 2^12.
47 static const uint32_t LV2_EVENT_PPQN = 3136573440U;
49 /**
50 An LV2 event (header only).
52 LV2 events are generic time-stamped containers for any type of event.
53 The type field defines the format of a given event's contents.
55 This struct defines the header of an LV2 event. An LV2 event is a single
56 chunk of POD (plain old data), usually contained in a flat buffer (see
57 LV2_EventBuffer below). Unless a required feature says otherwise, hosts may
58 assume a deep copy of an LV2 event can be created safely using a simple:
60 memcpy(ev_copy, ev, sizeof(LV2_Event) + ev->size); (or equivalent)
62 typedef struct {
64 /**
65 The frames portion of timestamp. The units used here can optionally be
66 set for a port (with the lv2ev:timeUnits property), otherwise this is
67 audio frames, corresponding to the sample_count parameter of the LV2 run
68 method (e.g. frame 0 is the first frame for that call to run).
70 uint32_t frames;
72 /**
73 The sub-frames portion of timestamp. The units used here can optionally
74 be set for a port (with the lv2ev:timeUnits property), otherwise this is
75 1/(2^32) of an audio frame.
77 uint32_t subframes;
79 /**
80 The type of this event, as a number which represents some URI
81 defining an event type. This value MUST be some value previously
82 returned from a call to the uri_to_id function defined in the LV2
83 URI map extension (see lv2_uri_map.h).
84 There are special rules which must be followed depending on the type
85 of an event. If the plugin recognizes an event type, the definition
86 of that event type will describe how to interpret the event, and
87 any required behaviour. Otherwise, if the type is 0, this event is a
88 non-POD event and lv2_event_unref MUST be called if the event is
89 'dropped' (see above). Even if the plugin does not understand an event,
90 it may pass the event through to an output by simply copying (and NOT
91 calling lv2_event_unref). These rules are designed to allow for generic
92 event handling plugins and large non-POD events, but with minimal hassle
93 on simple plugins that "don't care" about these more advanced features.
95 uint16_t type;
97 /**
98 The size of the data portion of this event in bytes, which immediately
99 follows. The header size (12 bytes) is not included in this value.
101 uint16_t size;
103 /* size bytes of data follow here */
105 } LV2_Event;
109 A buffer of LV2 events (header only).
111 Like events (which this contains) an event buffer is a single chunk of POD:
112 the entire buffer (including contents) can be copied with a single memcpy.
113 The first contained event begins sizeof(LV2_EventBuffer) bytes after the
114 start of this struct.
116 After this header, the buffer contains an event header (defined by struct
117 LV2_Event), followed by that event's contents (padded to 64 bits), followed
118 by another header, etc:
120 | | | | | | |
121 | | | | | | | | | | | | | | | | | | | | | | | | |
122 |FRAMES |SUBFRMS|TYP|LEN|DATA..DATA..PAD|FRAMES | ...
124 typedef struct {
127 The contents of the event buffer. This may or may not reside in the
128 same block of memory as this header, plugins must not assume either.
129 The host guarantees this points to at least capacity bytes of allocated
130 memory (though only size bytes of that are valid events).
132 uint8_t* data;
135 The size of this event header in bytes (including everything).
137 This is to allow for extending this header in the future without
138 breaking binary compatibility. Whenever this header is copied,
139 it MUST be done using this field (and NOT the sizeof this struct).
141 uint16_t header_size;
144 The type of the time stamps for events in this buffer.
145 As a special exception, '0' always means audio frames and subframes
146 (1/UINT32_MAX'th of a frame) in the sample rate passed to instantiate.
148 INPUTS: The host must set this field to the numeric ID of some URI
149 defining the meaning of the frames/subframes fields of contained events
150 (obtained by the LV2 URI Map uri_to_id function with the URI of this
151 extension as the 'map' argument, see lv2_uri_map.h). The host must
152 never pass a plugin a buffer which uses a stamp type the plugin does not
153 'understand'. The value of this field must never change, except when
154 connect_port is called on the input port, at which time the host MUST
155 have set the stamp_type field to the value that will be used for all
156 subsequent run calls.
158 OUTPUTS: The plugin may set this to any value that has been returned
159 from uri_to_id with the URI of this extension for a 'map' argument.
160 When connected to a buffer with connect_port, output ports MUST set this
161 field to the type of time stamp they will be writing. On any call to
162 connect_port on an event input port, the plugin may change this field on
163 any output port, it is the responsibility of the host to check if any of
164 these values have changed and act accordingly.
166 uint16_t stamp_type;
169 The number of events in this buffer.
171 INPUTS: The host must set this field to the number of events contained
172 in the data buffer before calling run(). The plugin must not change
173 this field.
175 OUTPUTS: The plugin must set this field to the number of events it has
176 written to the buffer before returning from run(). Any initial value
177 should be ignored by the plugin.
179 uint32_t event_count;
182 The size of the data buffer in bytes.
183 This is set by the host and must not be changed by the plugin.
184 The host is allowed to change this between run() calls.
186 uint32_t capacity;
189 The size of the initial portion of the data buffer containing data.
191 INPUTS: The host must set this field to the number of bytes used
192 by all events it has written to the buffer (including headers)
193 before calling the plugin's run().
194 The plugin must not change this field.
196 OUTPUTS: The plugin must set this field to the number of bytes
197 used by all events it has written to the buffer (including headers)
198 before returning from run().
199 Any initial value should be ignored by the plugin.
201 uint32_t size;
203 } LV2_Event_Buffer;
207 Opaque pointer to host data.
209 typedef void* LV2_Event_Callback_Data;
213 Non-POD events feature.
215 To support this feature the host must pass an LV2_Feature struct to the
216 plugin's instantiate method with URI "http://lv2plug.in/ns/ext/event"
217 and data pointed to an instance of this struct. Note this feature
218 is not mandatory to support the event extension.
220 typedef struct {
223 Opaque pointer to host data.
225 The plugin MUST pass this to any call to functions in this struct.
226 Otherwise, it must not be interpreted in any way.
228 LV2_Event_Callback_Data callback_data;
231 Take a reference to a non-POD event.
233 If a plugin receives an event with type 0, it means the event is a
234 pointer to some object in memory and not a flat sequence of bytes
235 in the buffer. When receiving a non-POD event, the plugin already
236 has an implicit reference to the event. If the event is stored AND
237 passed to an output, lv2_event_ref MUST be called on that event.
238 If the event is only stored OR passed through, this is not necessary
239 (as the plugin already has 1 implicit reference).
241 @param event An event received at an input that will not be copied to
242 an output or stored in any way.
244 @param context The calling context. Like event types, this is a mapped
245 URI, see lv2_context.h. Simple plugin with just a run() method should
246 pass 0 here (the ID of the 'standard' LV2 run context). The host
247 guarantees that this function is realtime safe iff @a context is
248 realtime safe.
250 PLUGINS THAT VIOLATE THESE RULES MAY CAUSE CRASHES AND MEMORY LEAKS.
252 uint32_t (*lv2_event_ref)(LV2_Event_Callback_Data callback_data,
253 LV2_Event* event);
256 Drop a reference to a non-POD event.
258 If a plugin receives an event with type 0, it means the event is a
259 pointer to some object in memory and not a flat sequence of bytes
260 in the buffer. If the plugin does not pass the event through to
261 an output or store it internally somehow, it MUST call this function
262 on the event (more information on using non-POD events below).
264 @param event An event received at an input that will not be copied to an
265 output or stored in any way.
267 @param context The calling context. Like event types, this is a mapped
268 URI, see lv2_context.h. Simple plugin with just a run() method should
269 pass 0 here (the ID of the 'standard' LV2 run context). The host
270 guarantees that this function is realtime safe iff @a context is
271 realtime safe.
273 PLUGINS THAT VIOLATE THESE RULES MAY CAUSE CRASHES AND MEMORY LEAKS.
275 uint32_t (*lv2_event_unref)(LV2_Event_Callback_Data callback_data,
276 LV2_Event* event);
278 } LV2_Event_Feature;
281 #endif /* LV2_EVENT_H */