Fix build with gcc 4.7
[cadence.git] / src / carla / lv2_rdf.h
blobbef424bfd20291237d8d9f8a7bf76efb89b2f8b6
1 /* Custom types to store LV2 information */
3 #ifndef LV2_RDF_INCLUDED
4 #define LV2_RDF_INCLUDED
6 #include <stdint.h>
8 // Base Types
9 typedef float LV2_Data;
10 typedef const char* LV2_URI;
11 typedef uint32_t LV2_Property;
12 typedef unsigned long long LV2_PluginType;
14 // Port MIDI Map Types
15 #define LV2_PORT_MIDI_MAP_CC 0x1
16 #define LV2_PORT_MIDI_MAP_NRPN 0x2
18 #define LV2_IS_PORT_MIDI_MAP_CC(x) ((x) == LV2_PORT_MIDI_MAP_CC)
19 #define LV2_IS_PORT_MIDI_MAP_NRPN(x) ((x) == LV2_PORT_MIDI_MAP_NRPN)
21 // A Port Midi Map
22 struct LV2_RDF_PortMidiMap {
23 LV2_Property Type;
24 uint32_t Number;
27 // Port Point Hints
28 #define LV2_PORT_POINT_DEFAULT 0x1
29 #define LV2_PORT_POINT_MINIMUM 0x2
30 #define LV2_PORT_POINT_MAXIMUM 0x4
32 #define LV2_HAVE_DEFAULT_PORT_POINT(x) ((x) & LV2_PORT_POINT_DEFAULT)
33 #define LV2_HAVE_MINIMUM_PORT_POINT(x) ((x) & LV2_PORT_POINT_MINIMUM)
34 #define LV2_HAVE_MAXIMUM_PORT_POINT(x) ((x) & LV2_PORT_POINT_MAXIMUM)
36 // Port Points
37 struct LV2_RDF_PortPoints {
38 LV2_Property Hints;
39 LV2_Data Default;
40 LV2_Data Minimum;
41 LV2_Data Maximum;
44 // Port Unit Types
45 #define LV2_UNIT_BAR 0x01
46 #define LV2_UNIT_BEAT 0x02
47 #define LV2_UNIT_BPM 0x03
48 #define LV2_UNIT_CENT 0x04
49 #define LV2_UNIT_CM 0x05
50 #define LV2_UNIT_COEF 0x06
51 #define LV2_UNIT_DB 0x07
52 #define LV2_UNIT_DEGREE 0x08
53 #define LV2_UNIT_HZ 0x09
54 #define LV2_UNIT_INCH 0x0A
55 #define LV2_UNIT_KHZ 0x0B
56 #define LV2_UNIT_KM 0x0C
57 #define LV2_UNIT_M 0x0D
58 #define LV2_UNIT_MHZ 0x0E
59 #define LV2_UNIT_MIDINOTE 0x0F
60 #define LV2_UNIT_MILE 0x10
61 #define LV2_UNIT_MIN 0x11
62 #define LV2_UNIT_MM 0x12
63 #define LV2_UNIT_MS 0x13
64 #define LV2_UNIT_OCT 0x14
65 #define LV2_UNIT_PC 0x15
66 #define LV2_UNIT_S 0x16
67 #define LV2_UNIT_SEMITONE 0x17
69 #define LV2_IS_UNIT_BAR(x) ((x) == LV2_UNIT_BAR)
70 #define LV2_IS_UNIT_BEAT(x) ((x) == LV2_UNIT_BEAT)
71 #define LV2_IS_UNIT_BPM(x) ((x) == LV2_UNIT_BPM)
72 #define LV2_IS_UNIT_CENT(x) ((x) == LV2_UNIT_CENT)
73 #define LV2_IS_UNIT_CM(x) ((x) == LV2_UNIT_CM)
74 #define LV2_IS_UNIT_COEF(x) ((x) == LV2_UNIT_COEF)
75 #define LV2_IS_UNIT_DB(x) ((x) == LV2_UNIT_DB)
76 #define LV2_IS_UNIT_DEGREE(x) ((x) == LV2_UNIT_DEGREE)
77 #define LV2_IS_UNIT_HZ(x) ((x) == LV2_UNIT_HZ)
78 #define LV2_IS_UNIT_INCH(x) ((x) == LV2_UNIT_INCH)
79 #define LV2_IS_UNIT_KHZ(x) ((x) == LV2_UNIT_KHZ)
80 #define LV2_IS_UNIT_KM(x) ((x) == LV2_UNIT_KM)
81 #define LV2_IS_UNIT_M(x) ((x) == LV2_UNIT_M)
82 #define LV2_IS_UNIT_MHZ(x) ((x) == LV2_UNIT_MHZ)
83 #define LV2_IS_UNIT_MIDINOTE(x) ((x) == LV2_UNIT_MIDINOTE)
84 #define LV2_IS_UNIT_MILE(x) ((x) == LV2_UNIT_MILE)
85 #define LV2_IS_UNIT_MIN(x) ((x) == LV2_UNIT_MIN)
86 #define LV2_IS_UNIT_MM(x) ((x) == LV2_UNIT_MM)
87 #define LV2_IS_UNIT_MS(x) ((x) == LV2_UNIT_MS)
88 #define LV2_IS_UNIT_OCT(x) ((x) == LV2_UNIT_OCT)
89 #define LV2_IS_UNIT_PC(x) ((x) == LV2_UNIT_PC)
90 #define LV2_IS_UNIT_S(x) ((x) == LV2_UNIT_S)
91 #define LV2_IS_UNIT_SEMITONE(x) ((x) == LV2_UNIT_SEMITONE)
93 // Port Unit Hints
94 #define LV2_PORT_UNIT 0x1
95 #define LV2_PORT_UNIT_NAME 0x2
96 #define LV2_PORT_UNIT_RENDER 0x4
97 #define LV2_PORT_UNIT_SYMBOL 0x8
99 #define LV2_HAVE_UNIT(x) ((x) & LV2_PORT_UNIT)
100 #define LV2_HAVE_UNIT_NAME(x) ((x) & LV2_PORT_UNIT_NAME)
101 #define LV2_HAVE_UNIT_RENDER(x) ((x) & LV2_PORT_UNIT_RENDER)
102 #define LV2_HAVE_UNIT_SYMBOL(x) ((x) & LV2_PORT_UNIT_SYMBOL)
104 // A Port Unit
105 struct LV2_RDF_PortUnit {
106 LV2_Property Type;
107 LV2_Property Hints;
108 const char* Name;
109 const char* Render;
110 const char* Symbol;
113 // A Port Scale Point
114 struct LV2_RDF_PortScalePoint {
115 const char* Label;
116 LV2_Data Value;
119 // Port Types
120 #define LV2_PORT_INPUT 0x01
121 #define LV2_PORT_OUTPUT 0x02
122 #define LV2_PORT_CONTROL 0x04
123 #define LV2_PORT_AUDIO 0x08
124 #define LV2_PORT_CV 0x10
125 #define LV2_PORT_EVENT 0x20
127 // Port Event Types
128 #define LV2_PORT_EVENT_MIDI 0x1000
129 #define LV2_PORT_EVENT_TIME 0x2000
131 #define LV2_IS_PORT_INPUT(x) ((x) & LV2_PORT_INPUT)
132 #define LV2_IS_PORT_OUTPUT(x) ((x) & LV2_PORT_OUTPUT)
133 #define LV2_IS_PORT_CONTROL(x) ((x) & LV2_PORT_CONTROL)
134 #define LV2_IS_PORT_AUDIO(x) ((x) & LV2_PORT_AUDIO)
135 #define LV2_IS_PORT_CV(x) ((x) & LV2_PORT_CV)
136 #define LV2_IS_PORT_EVENT(x) ((x) & LV2_PORT_EVENT)
137 #define LV2_IS_PORT_EVENT_MIDI(x) ((x) & LV2_PORT_EVENT_MIDI)
138 #define LV2_IS_PORT_EVENT_TIME(x) ((x) & LV2_PORT_EVENT_TIME)
140 // Port Properties
141 #define LV2_PORT_OPTIONAL 0x00001
142 #define LV2_PORT_LATENCY 0x00002
143 #define LV2_PORT_TOGGLED 0x00004
144 #define LV2_PORT_SAMPLE_RATE 0x00008
145 #define LV2_PORT_INTEGER 0x00010
146 #define LV2_PORT_ENUMERATION 0x00020
147 #define LV2_PORT_CAUSES_ARTIFACTS 0x00040
148 #define LV2_PORT_CONTINUOUS_CV 0x00080
149 #define LV2_PORT_DISCRETE_CV 0x00100
150 #define LV2_PORT_EXPENSIVE 0x00200
151 #define LV2_PORT_HAS_STRICT_BOUNDS 0x00400
152 #define LV2_PORT_LOGARITHMIC 0x00800
153 #define LV2_PORT_NOT_AUTOMATIC 0x01000
154 #define LV2_PORT_NOT_ON_GUI 0x02000
155 #define LV2_PORT_REPORTS_BEATS_PER_BAR 0x04000
156 #define LV2_PORT_REPORTS_BEAT_UNIT 0x08000
157 #define LV2_PORT_REPORTS_BPM 0x10000
158 #define LV2_PORT_TRIGGER 0x20000
160 #define LV2_IS_PORT_OPTIONAL(x) ((x) & LV2_PORT_OPTIONAL)
161 #define LV2_IS_PORT_LATENCY(x) ((x) & LV2_PORT_LATENCY)
162 #define LV2_IS_PORT_TOGGLED(x) ((x) & LV2_PORT_TOGGLED)
163 #define LV2_IS_PORT_SAMPLE_RATE(x) ((x) & LV2_PORT_SAMPLE_RATE)
164 #define LV2_IS_PORT_INTEGER(x) ((x) & LV2_PORT_INTEGER)
165 #define LV2_IS_PORT_ENUMERATION(x) ((x) & LV2_PORT_ENUMERATION)
166 #define LV2_IS_PORT_CAUSES_ARTIFACTS(x) ((x) & LV2_PORT_CAUSES_ARTIFACTS)
167 #define LV2_IS_PORT_CONTINUOUS_CV(x) ((x) & LV2_PORT_CONTINUOUS_CV)
168 #define LV2_IS_PORT_DISCRETE_CV(x) ((x) & LV2_PORT_DISCRETE_CV)
169 #define LV2_IS_PORT_EXPENSIVE(x) ((x) & LV2_PORT_EXPENSIVE)
170 #define LV2_IS_PORT_HAS_STRICT_BOUNDS(x) ((x) & LV2_PORT_HAS_STRICT_BOUNDS)
171 #define LV2_IS_PORT_LOGARITHMIC(x) ((x) & LV2_PORT_LOGARITHMIC)
172 #define LV2_IS_PORT_NOT_AUTOMATIC(x) ((x) & LV2_PORT_NOT_AUTOMATIC)
173 #define LV2_IS_PORT_NOT_ON_GUI(x) ((x) & LV2_PORT_NOT_ON_GUI)
174 #define LV2_IS_PORT_REPORTS_BEATS_PER_BAR(x) ((x) & LV2_PORT_REPORTS_BEATS_PER_BAR)
175 #define LV2_IS_PORT_REPORTS_BEAT_UNIT(x) ((x) & LV2_PORT_REPORTS_BEAT_UNIT)
176 #define LV2_IS_PORT_REPORTS_BPM(x) ((x) & LV2_PORT_REPORTS_BPM)
177 #define LV2_IS_PORT_TRIGGER(x) ((x) & LV2_PORT_TRIGGER)
179 // A Port
180 struct LV2_RDF_Port {
181 LV2_Property Type;
182 LV2_Property Properties;
183 const char* Name;
184 const char* Symbol;
186 LV2_RDF_PortMidiMap MidiMap;
187 LV2_RDF_PortPoints Points;
188 LV2_RDF_PortUnit Unit;
190 uint32_t ScalePointCount;
191 LV2_RDF_PortScalePoint* ScalePoints;
194 // A Preset Port
195 struct LV2_RDF_PresetPort {
196 const char* Symbol;
197 LV2_Data Value;
200 // A Preset State
201 struct LV2_RDF_PresetState {
202 const char* Key;
203 const char* Value;
206 // A Preset
207 struct LV2_RDF_Preset {
208 LV2_URI URI;
209 const char* Label;
211 uint32_t PortCount;
212 LV2_RDF_PresetPort* Ports;
214 uint32_t StateCount;
215 LV2_RDF_PresetState* States;
218 // Feature Types
219 #define LV2_FEATURE_OPTIONAL 0x1
220 #define LV2_FEATURE_REQUIRED 0x2
222 #define LV2_IS_FEATURE_OPTIONAL(x) ((x) == LV2_FEATURE_OPTIONAL)
223 #define LV2_IS_FEATURE_REQUIRED(x) ((x) == LV2_FEATURE_REQUIRED)
225 // A Feature
226 struct LV2_RDF_Feature {
227 LV2_Property Type;
228 LV2_URI URI;
231 // UI Types
232 #define LV2_UI_X11 0x1
233 #define LV2_UI_GTK2 0x2
234 #define LV2_UI_QT4 0x3
235 #define LV2_UI_EXTERNAL 0x4
236 #define LV2_UI_OLD_EXTERNAL 0x5
238 #define LV2_IS_UI_X11(x) ((x) == LV2_UI_X11)
239 #define LV2_IS_UI_GTK2(x) ((x) == LV2_UI_GTK2)
240 #define LV2_IS_UI_QT4(x) ((x) == LV2_UI_QT4)
241 #define LV2_IS_UI_EXTERNAL(x) ((x) == LV2_UI_EXTERNAL)
242 #define LV2_IS_UI_OLD_EXTERNAL(x) ((x) == LV2_UI_OLD_EXTERNAL)
244 // An UI
245 struct LV2_RDF_UI {
246 LV2_Property Type;
247 LV2_URI URI;
248 const char* Binary;
249 const char* Bundle;
251 uint32_t FeatureCount;
252 LV2_RDF_Feature* Features;
254 uint32_t ExtensionCount;
255 LV2_URI* Extensions;
258 // Plugin Types
259 #define LV2_CLASS_GENERATOR 0x000000001
260 #define LV2_CLASS_INSTRUMENT 0x000000002
261 #define LV2_CLASS_OSCILLATOR 0x000000004
262 #define LV2_CLASS_UTILITY 0x000000008
263 #define LV2_CLASS_CONVERTER 0x000000010
264 #define LV2_CLASS_ANALYSER 0x000000020
265 #define LV2_CLASS_MIXER 0x000000040
266 #define LV2_CLASS_SIMULATOR 0x000000080
267 #define LV2_CLASS_DELAY 0x000000100
268 #define LV2_CLASS_MODULATOR 0x000000200
269 #define LV2_CLASS_REVERB 0x000000400
270 #define LV2_CLASS_PHASER 0x000000800
271 #define LV2_CLASS_FLANGER 0x000001000
272 #define LV2_CLASS_CHORUS 0x000002000
273 #define LV2_CLASS_FILTER 0x000004000
274 #define LV2_CLASS_LOWPASS 0x000008000
275 #define LV2_CLASS_BANDPASS 0x000010000
276 #define LV2_CLASS_HIGHPASS 0x000020000
277 #define LV2_CLASS_COMB 0x000040000
278 #define LV2_CLASS_ALLPASS 0x000080000
279 #define LV2_CLASS_EQUALISER 0x000100000
280 #define LV2_CLASS_PARAMETRIC 0x000200000
281 #define LV2_CLASS_MULTIBAND 0x000400000
282 #define LV2_CLASS_SPACIAL 0x000800000
283 #define LV2_CLASS_SPECTRAL 0x001000000
284 #define LV2_CLASS_PITCH_SHIFTER 0x002000000
285 #define LV2_CLASS_AMPLIFIER 0x004000000
286 #define LV2_CLASS_DISTORTION 0x008000000
287 #define LV2_CLASS_WAVESHAPER 0x010000000
288 #define LV2_CLASS_DYNAMICS 0x020000000
289 #define LV2_CLASS_COMPRESSOR 0x040000000
290 #define LV2_CLASS_EXPANDER 0x080000000
291 #define LV2_CLASS_LIMITER 0x100000000LL
292 #define LV2_CLASS_GATE 0x200000000LL
293 #define LV2_CLASS_FUNCTION 0x400000000LL
294 #define LV2_CLASS_CONSTANT 0x800000000LL
296 #define LV2_GROUP_GENERATOR (LV2_CLASS_GENERATOR|LV2_CLASS_INSTRUMENT|LV2_CLASS_OSCILLATOR)
297 #define LV2_GROUP_UTILITY (LV2_CLASS_UTILITY|LV2_CLASS_CONVERTER|LV2_CLASS_ANALYSER|LV2_CLASS_MIXER|LV2_CLASS_FUNCTION|LV2_CLASS_CONSTANT)
298 #define LV2_GROUP_SIMULATOR (LV2_CLASS_SIMULATOR|LV2_CLASS_REVERB)
299 #define LV2_GROUP_DELAY (LV2_CLASS_DELAY|LV2_CLASS_REVERB)
300 #define LV2_GROUP_MODULATOR (LV2_CLASS_MODULATOR|LV2_CLASS_PHASER|LV2_CLASS_FLANGER|LV2_CLASS_CHORUS)
301 #define LV2_GROUP_FILTER (LV2_CLASS_FILTER|LV2_CLASS_LOWPASS|LV2_CLASS_BANDPASS|LV2_CLASS_HIGHPASS|LV2_CLASS_COMB|LV2_CLASS_ALLPASS|LV2_CLASS_EQUALISER|LV2_CLASS_PARAMETRIC|LV2_CLASS_MULTIBAND)
302 #define LV2_GROUP_EQUALISER (LV2_CLASS_EQUALISER|LV2_CLASS_PARAMETRIC|LV2_CLASS_MULTIBAND)
303 #define LV2_GROUP_SPECTRAL (LV2_CLASS_SPECTRAL|LV2_CLASS_PITCH_SHIFTER)
304 #define LV2_GROUP_DISTORTION (LV2_CLASS_DISTORTION|LV2_CLASS_WAVESHAPER)
305 #define LV2_GROUP_DYNAMICS (LV2_CLASS_DYNAMICS|LV2_CLASS_AMPLIFIER|LV2_CLASS_COMPRESSOR|LV2_CLASS_EXPANDER|LV2_CLASS_LIMITER|LV2_CLASS_GATE)
307 #define LV2_IS_GENERATOR(x) ((x) & LV2_GROUP_GENERATOR)
308 #define LV2_IS_UTILITY(x) ((x) & LV2_GROUP_UTILITY)
309 #define LV2_IS_SIMULATOR(x) ((x) & LV2_GROUP_SIMULATOR)
310 #define LV2_IS_DELAY(x) ((x) & LV2_GROUP_DELAY)
311 #define LV2_IS_MODULATOR(x) ((x) & LV2_GROUP_MODULATOR)
312 #define LV2_IS_FILTER(x) ((x) & LV2_GROUP_FILTER)
313 #define LV2_IS_EQUALISER(x) ((x) & LV2_GROUP_EQUALISER)
314 #define LV2_IS_SPECTRAL(x) ((x) & LV2_GROUP_SPECTRAL)
315 #define LV2_IS_DISTORTION(x) ((x) & LV2_GROUP_DISTORTION)
316 #define LV2_IS_DYNAMICS(x) ((x) & LV2_GROUP_DYNAMICS)
318 // A Plugin
319 struct LV2_RDF_Descriptor {
320 LV2_PluginType Type;
321 LV2_URI URI;
322 const char* Name;
323 const char* Author;
324 const char* License;
325 const char* Binary;
326 const char* Bundle;
327 unsigned long UniqueID;
329 uint32_t PortCount;
330 LV2_RDF_Port* Ports;
332 uint32_t PresetCount;
333 LV2_RDF_Preset* Presets;
335 uint32_t FeatureCount;
336 LV2_RDF_Feature* Features;
338 uint32_t ExtensionCount;
339 LV2_URI* Extensions;
341 uint32_t UICount;
342 LV2_RDF_UI* UIs;
346 // Copy RDF object
347 inline const LV2_RDF_Descriptor* lv2_rdf_dup(LV2_RDF_Descriptor* rdf_descriptor)
349 uint32_t i, j;
350 LV2_RDF_Descriptor* new_descriptor = new LV2_RDF_Descriptor;
352 new_descriptor->Type = rdf_descriptor->Type;
353 new_descriptor->UniqueID = rdf_descriptor->UniqueID;
355 new_descriptor->PortCount = rdf_descriptor->PortCount;
356 new_descriptor->PresetCount = rdf_descriptor->PresetCount;
357 new_descriptor->FeatureCount = rdf_descriptor->FeatureCount;
358 new_descriptor->ExtensionCount = rdf_descriptor->ExtensionCount;
359 new_descriptor->UICount = rdf_descriptor->UICount;
361 new_descriptor->URI = strdup(rdf_descriptor->URI);
362 new_descriptor->Name = strdup(rdf_descriptor->Name);
363 new_descriptor->Author = strdup(rdf_descriptor->Author);
364 new_descriptor->License = strdup(rdf_descriptor->License);
365 new_descriptor->Binary = strdup(rdf_descriptor->Binary);
366 new_descriptor->Bundle = strdup(rdf_descriptor->Bundle);
368 // Ports
369 if (new_descriptor->PortCount > 0)
371 new_descriptor->Ports = new LV2_RDF_Port[new_descriptor->PortCount];
373 for (i=0; i < new_descriptor->PortCount; i++)
375 LV2_RDF_Port* Port = &new_descriptor->Ports[i];
377 Port->Type = rdf_descriptor->Ports[i].Type;
378 Port->Properties = rdf_descriptor->Ports[i].Properties;
380 Port->MidiMap.Type = rdf_descriptor->Ports[i].MidiMap.Type;
381 Port->MidiMap.Number = rdf_descriptor->Ports[i].MidiMap.Number;
383 Port->Points.Hints = rdf_descriptor->Ports[i].Points.Hints;
384 Port->Points.Default = rdf_descriptor->Ports[i].Points.Default;
385 Port->Points.Minimum = rdf_descriptor->Ports[i].Points.Minimum;
386 Port->Points.Maximum = rdf_descriptor->Ports[i].Points.Maximum;
388 Port->Unit.Type = rdf_descriptor->Ports[i].Unit.Type;
389 Port->Unit.Hints = rdf_descriptor->Ports[i].Unit.Hints;
391 Port->ScalePointCount = rdf_descriptor->Ports[i].ScalePointCount;
393 Port->Name = strdup(rdf_descriptor->Ports[i].Name);
394 Port->Symbol = strdup(rdf_descriptor->Ports[i].Symbol);
396 if (rdf_descriptor->Ports[i].Unit.Name)
397 Port->Unit.Name = strdup(rdf_descriptor->Ports[i].Unit.Name);
398 else
399 Port->Unit.Name = nullptr;
401 if (rdf_descriptor->Ports[i].Unit.Render)
402 Port->Unit.Render = strdup(rdf_descriptor->Ports[i].Unit.Render);
403 else
404 Port->Unit.Render = nullptr;
406 if (rdf_descriptor->Ports[i].Unit.Symbol)
407 Port->Unit.Symbol = strdup(rdf_descriptor->Ports[i].Unit.Symbol);
408 else
409 Port->Unit.Symbol = nullptr;
411 if (Port->ScalePointCount > 0)
413 Port->ScalePoints = new LV2_RDF_PortScalePoint[Port->ScalePointCount];
415 for (j=0; j < Port->ScalePointCount; j++)
417 Port->ScalePoints[j].Value = rdf_descriptor->Ports[i].ScalePoints[j].Value;
418 Port->ScalePoints[j].Label = strdup(rdf_descriptor->Ports[i].ScalePoints[j].Label);
421 else
422 Port->ScalePoints = nullptr;
425 else
426 new_descriptor->Ports = nullptr;
428 // Presets
429 if (new_descriptor->PresetCount > 0)
431 new_descriptor->Presets = new LV2_RDF_Preset[new_descriptor->PresetCount];
433 for (i=0; i < new_descriptor->PresetCount; i++)
435 LV2_RDF_Preset* Preset = &new_descriptor->Presets[i];
437 Preset->PortCount = rdf_descriptor->Presets[i].PortCount;
438 Preset->StateCount = rdf_descriptor->Presets[i].StateCount;
440 Preset->URI = strdup(rdf_descriptor->Presets[i].URI);
441 Preset->Label = strdup(rdf_descriptor->Presets[i].Label);
443 // Ports
444 if (Preset->PortCount > 0)
446 Preset->Ports = new LV2_RDF_PresetPort[Preset->PortCount];
448 for (j=0; j < Preset->PortCount; j++)
450 Preset->Ports[j].Value = rdf_descriptor->Presets[i].Ports[j].Value;
451 Preset->Ports[j].Symbol = strdup(rdf_descriptor->Presets[i].Ports[j].Symbol);
454 else
455 Preset->Ports = nullptr;
457 // States
458 if (Preset->StateCount > 0)
460 Preset->States = new LV2_RDF_PresetState[Preset->StateCount];
462 for (j=0; j < Preset->StateCount; j++)
464 Preset->States[j].Key = strdup(rdf_descriptor->Presets[i].States[j].Key);
465 Preset->States[j].Value = strdup(rdf_descriptor->Presets[i].States[j].Value);
468 else
469 Preset->States = nullptr;
472 else
473 new_descriptor->Presets = nullptr;
475 // Features
476 if (new_descriptor->FeatureCount > 0)
478 new_descriptor->Features = new LV2_RDF_Feature[new_descriptor->FeatureCount];
480 for (i=0; i < new_descriptor->FeatureCount; i++)
482 new_descriptor->Features[i].Type = rdf_descriptor->Features[i].Type;
483 new_descriptor->Features[i].URI = strdup(rdf_descriptor->Features[i].URI);
486 else
487 new_descriptor->Features = nullptr;
489 // Extensions
490 if (new_descriptor->ExtensionCount > 0)
492 new_descriptor->Extensions = new LV2_URI[new_descriptor->ExtensionCount];
494 for (i=0; i < new_descriptor->ExtensionCount; i++)
496 new_descriptor->Extensions[i] = strdup(rdf_descriptor->Extensions[i]);
499 else
500 new_descriptor->Extensions = nullptr;
502 // UIs
503 if (new_descriptor->UICount > 0)
505 new_descriptor->UIs = new LV2_RDF_UI[new_descriptor->UICount];
507 for (i=0; i < new_descriptor->UICount; i++)
509 LV2_RDF_UI* UI = &new_descriptor->UIs[i];
511 UI->Type = rdf_descriptor->UIs[i].Type;
513 UI->FeatureCount = rdf_descriptor->UIs[i].FeatureCount;
514 UI->ExtensionCount = rdf_descriptor->UIs[i].ExtensionCount;
516 UI->URI = strdup(rdf_descriptor->UIs[i].URI);
517 UI->Binary = strdup(rdf_descriptor->UIs[i].Binary);
518 UI->Bundle = strdup(rdf_descriptor->UIs[i].Bundle);
520 // UI Features
521 if (UI->FeatureCount > 0)
523 UI->Features = new LV2_RDF_Feature[UI->FeatureCount];
525 for (j=0; j < UI->FeatureCount; j++)
527 UI->Features[j].Type = rdf_descriptor->UIs[i].Features[j].Type;
528 UI->Features[j].URI = strdup(rdf_descriptor->UIs[i].Features[j].URI);
531 else
532 UI->Features = nullptr;
534 // UI Extensions
535 if (UI->ExtensionCount > 0)
537 UI->Extensions = new LV2_URI[UI->ExtensionCount];
539 for (j=0; j < UI->ExtensionCount; j++)
541 UI->Extensions[j] = strdup(rdf_descriptor->UIs[i].Extensions[j]);
544 else
545 UI->Extensions = nullptr;
548 else
549 new_descriptor->UIs = 0;
551 return new_descriptor;
554 // Delete copied object
555 inline void lv2_rdf_free(const LV2_RDF_Descriptor* rdf_descriptor)
557 uint32_t i, j;
559 free((void*)rdf_descriptor->URI);
560 free((void*)rdf_descriptor->Name);
561 free((void*)rdf_descriptor->Author);
562 free((void*)rdf_descriptor->License);
563 free((void*)rdf_descriptor->Binary);
564 free((void*)rdf_descriptor->Bundle);
566 if (rdf_descriptor->PortCount > 0)
568 for (i=0; i < rdf_descriptor->PortCount; i++)
570 LV2_RDF_Port* Port = &rdf_descriptor->Ports[i];
572 free((void*)Port->Name);
573 free((void*)Port->Symbol);
575 if (Port->Unit.Name)
576 free((void*)Port->Unit.Name);
578 if (Port->Unit.Render)
579 free((void*)Port->Unit.Render);
581 if (Port->Unit.Symbol)
582 free((void*)Port->Unit.Symbol);
584 if (Port->ScalePointCount > 0)
586 for (j=0; j < Port->ScalePointCount; j++)
587 free((void*)Port->ScalePoints[j].Label);
589 delete[] Port->ScalePoints;
592 delete[] rdf_descriptor->Ports;
595 if (rdf_descriptor->PresetCount > 0)
597 for (i=0; i < rdf_descriptor->PresetCount; i++)
599 LV2_RDF_Preset* Preset = &rdf_descriptor->Presets[i];
601 free((void*)Preset->URI);
602 free((void*)Preset->Label);
604 for (j=0; j < Preset->PortCount; j++)
606 if (Preset->Ports[j].Symbol)
607 free((void*)Preset->Ports[j].Symbol);
610 for (j=0; j < Preset->StateCount; j++)
612 free((void*)Preset->States[j].Key);
613 free((void*)Preset->States[j].Value);
616 delete[] rdf_descriptor->Presets;
619 if (rdf_descriptor->FeatureCount > 0)
621 for (i=0; i < rdf_descriptor->FeatureCount; i++)
622 free((void*)rdf_descriptor->Features[i].URI);
624 delete[] rdf_descriptor->Features;
627 if (rdf_descriptor->ExtensionCount > 0)
629 for (i=0; i < rdf_descriptor->ExtensionCount; i++)
630 free((void*)rdf_descriptor->Extensions[i]);
632 delete[] rdf_descriptor->Extensions;
635 if (rdf_descriptor->UICount > 0)
637 for (i=0; i < rdf_descriptor->UICount; i++)
639 LV2_RDF_UI* UI = &rdf_descriptor->UIs[i];
641 free((void*)UI->URI);
642 free((void*)UI->Binary);
643 free((void*)UI->Bundle);
645 if (UI->FeatureCount > 0)
647 for (j=0; j < UI->FeatureCount; j++)
648 free((void*)UI->Features[j].URI);
650 delete[] UI->Features;
653 if (UI->ExtensionCount > 0)
655 for (j=0; j < UI->ExtensionCount; j++)
656 free((void*)UI->Extensions[j]);
658 delete[] UI->Extensions;
661 delete[] rdf_descriptor->UIs;
664 delete rdf_descriptor;
667 inline bool is_lv2_feature_supported(const char *uri)
669 if (strcmp(uri, "http://lv2plug.in/ns/lv2core#hardRTCapable") == 0)
670 return true;
671 else if (strcmp(uri, "http://lv2plug.in/ns/lv2core#inPlaceBroken") == 0)
672 return true;
673 else if (strcmp(uri, "http://lv2plug.in/ns/lv2core#isLive") == 0)
674 return true;
675 else if (strcmp(uri, "http://lv2plug.in/ns/ext/event") == 0)
676 return true;
677 else if (strcmp(uri, "http://lv2plug.in/ns/ext/state#makePath") == 0)
678 return false; // TODO
679 else if (strcmp(uri, "http://lv2plug.in/ns/ext/state#mapPath") == 0)
680 return false; // TODO
681 else if (strcmp(uri, "http://lv2plug.in/ns/ext/uri-map") == 0)
682 return true;
683 else if (strcmp(uri, "http://lv2plug.in/ns/ext/urid#map") == 0)
684 return true;
685 else if (strcmp(uri, "http://lv2plug.in/ns/ext/urid#unmap") == 0)
686 return true;
687 else if (strcmp(uri, "http://home.gna.org/lv2dynparam/rtmempool/v1") == 0)
688 return true;
689 else
690 return false;
693 inline bool is_lv2_ui_feature_supported(const char *uri)
695 if (strcmp(uri, "http://lv2plug.in/ns/lv2core#hardRTCapable") == 0)
696 return true;
697 else if (strcmp(uri, "http://lv2plug.in/ns/lv2core#inPlaceBroken") == 0)
698 return true;
699 else if (strcmp(uri, "http://lv2plug.in/ns/lv2core#isLive") == 0)
700 return true;
701 else if (strcmp(uri, "http://lv2plug.in/ns/ext/event") == 0)
702 return true;
703 else if (strcmp(uri, "http://lv2plug.in/ns/ext/state#makePath") == 0)
704 return false; // TODO
705 else if (strcmp(uri, "http://lv2plug.in/ns/ext/state#mapPath") == 0)
706 return false; // TODO
707 else if (strcmp(uri, "http://lv2plug.in/ns/ext/uri-map") == 0)
708 return true;
709 else if (strcmp(uri, "http://lv2plug.in/ns/ext/urid#map") == 0)
710 return true;
711 else if (strcmp(uri, "http://lv2plug.in/ns/ext/urid#unmap") == 0)
712 return true;
713 else if (strcmp(uri, "http://lv2plug.in/ns/ext/data-access") == 0)
714 return true;
715 else if (strcmp(uri, "http://lv2plug.in/ns/ext/instance-access") == 0)
716 return true;
717 else if (strcmp(uri, "http://lv2plug.in/ns/ext/ui-resize") == 0)
718 return true;
719 else if (strcmp(uri, "http://lv2plug.in/ns/extensions/ui#Events") == 0)
720 return true;
721 else if (strcmp(uri, "http://lv2plug.in/ns/extensions/ui#makeResident") == 0)
722 return true;
723 else if (strcmp(uri, "http://lv2plug.in/ns/extensions/ui#makeSONameResident") == 0)
724 return true;
725 else if (strcmp(uri, "http://lv2plug.in/ns/extensions/ui#noUserResize") == 0)
726 return true;
727 else if (strcmp(uri, "http://lv2plug.in/ns/extensions/ui#fixedSize") == 0)
728 return true;
729 else if (strcmp(uri, "http://lv2plug.in/ns/extensions/ui#external") == 0)
730 return true;
731 else if (strcmp(uri, "http://nedko.arnaudov.name/lv2/external_ui/") == 0)
732 return true;
733 else
734 return false;
737 inline const char* lv2_get_ui_uri(int UiType)
739 #define NS_LV2UI "http://lv2plug.in/ns/extensions/ui#"
740 switch(UiType)
742 case LV2_UI_X11:
743 return NS_LV2UI "X11UI";
744 case LV2_UI_GTK2:
745 return NS_LV2UI "GtkUI";
746 case LV2_UI_QT4:
747 return NS_LV2UI "Qt4UI";
748 case LV2_UI_EXTERNAL:
749 return "http://nedko.arnaudov.name/lv2/external_ui/";
750 case LV2_UI_OLD_EXTERNAL:
751 return NS_LV2UI "external";
752 default:
753 return "UI URI Type Not Supported in LV2_RDF";
757 #endif /* #ifndef LV2_RDF_INCLUDED */