1 // Licensed GNU LGPL v3 or later: http://www.gnu.org/licenses/lgpl.html
2 
3 #ifndef SPECTMORPH_LV2_COMMON_HH
4 #define SPECTMORPH_LV2_COMMON_HH
5 
6 #include "lv2/lv2plug.in/ns/lv2core/lv2.h"
7 #include "lv2/lv2plug.in/ns/ext/atom/atom.h"
8 #include "lv2/lv2plug.in/ns/ext/atom/forge.h"
9 #include "lv2/lv2plug.in/ns/ext/atom/util.h"
10 #include "lv2/lv2plug.in/ns/ext/midi/midi.h"
11 #include "lv2/lv2plug.in/ns/ext/urid/urid.h"
12 #include "lv2/lv2plug.in/ns/ext/patch/patch.h"
13 #include "lv2/lv2plug.in/ns/ext/state/state.h"
14 #include "lv2/lv2plug.in/ns/ext/time/time.h"
15 #include "lv2/lv2plug.in/ns/extensions/ui/ui.h"
16 #include "lv2/lv2plug.in/ns/ext/instance-access/instance-access.h"
17 
18 #include <string>
19 
20 #define SPECTMORPH_URI      "http://spectmorph.org/plugins/spectmorph"
21 #define SPECTMORPH_UI_URI   SPECTMORPH_URI "#ui"
22 
23 #define SPECTMORPH__plan    SPECTMORPH_URI "#plan"
24 #define SPECTMORPH__volume  SPECTMORPH_URI "#volume"
25 
26 #ifndef LV2_STATE__StateChanged
27 #define LV2_STATE__StateChanged LV2_STATE_PREFIX "StateChanged"
28 #endif
29 
30 namespace SpectMorph
31 {
32 
33 class LV2Common
34 {
35 public:
36   struct {
37     LV2_URID atom_eventTransfer;
38     LV2_URID atom_URID;
39     LV2_URID atom_Blank;
40     LV2_URID atom_Bool;
41     LV2_URID atom_Double;
42     LV2_URID atom_Float;
43     LV2_URID atom_Int;
44     LV2_URID atom_Long;
45     LV2_URID atom_Object;
46     LV2_URID atom_String;
47     LV2_URID midi_MidiEvent;
48     LV2_URID spectmorph_plan;
49     LV2_URID spectmorph_volume;
50     LV2_URID state_StateChanged;
51     LV2_URID time_bar;
52     LV2_URID time_barBeat;
53     LV2_URID time_beatUnit;
54     LV2_URID time_beatsPerBar;
55     LV2_URID time_beatsPerMinute;
56     LV2_URID time_speed;
57     LV2_URID time_Position;
58   } uris;
59   LV2_URID_Map* map;
60 
61   void
init_map(LV2_URID_Map * map)62   init_map (LV2_URID_Map *map)
63   {
64     this->map = map;
65 
66     uris.atom_eventTransfer = map->map (map->handle, LV2_ATOM__eventTransfer);
67     uris.atom_URID          = map->map (map->handle, LV2_ATOM__URID);
68     uris.atom_Blank         = map->map (map->handle, LV2_ATOM__Blank);
69     uris.atom_Bool          = map->map (map->handle, LV2_ATOM__Bool);
70     uris.atom_Double        = map->map (map->handle, LV2_ATOM__Double);
71     uris.atom_Float         = map->map (map->handle, LV2_ATOM__Float);
72     uris.atom_Int           = map->map (map->handle, LV2_ATOM__Int);
73     uris.atom_Long          = map->map (map->handle, LV2_ATOM__Long);
74     uris.atom_Object        = map->map (map->handle, LV2_ATOM__Object);
75     uris.atom_String        = map->map (map->handle, LV2_ATOM__String);
76     uris.midi_MidiEvent     = map->map (map->handle, LV2_MIDI__MidiEvent);
77     uris.spectmorph_plan    = map->map (map->handle, SPECTMORPH__plan);
78     uris.spectmorph_volume  = map->map (map->handle, SPECTMORPH__volume);
79     uris.state_StateChanged = map->map (map->handle, LV2_STATE__StateChanged);
80     uris.time_bar           = map->map (map->handle, LV2_TIME__bar);
81     uris.time_barBeat       = map->map (map->handle, LV2_TIME__barBeat);
82     uris.time_beatUnit      = map->map (map->handle, LV2_TIME__beatUnit);
83     uris.time_beatsPerBar   = map->map (map->handle, LV2_TIME__beatsPerBar);
84     uris.time_beatsPerMinute  = map->map (map->handle, LV2_TIME__beatsPerMinute);
85     uris.time_speed         = map->map (map->handle, LV2_TIME__speed);
86     uris.time_Position      = map->map (map->handle, LV2_TIME__Position);
87   }
88 };
89 
90 }
91 
92 #endif /* SPECTMORPH_LV2_COMMON_HH */
93