/[svn]/linuxsampler/trunk/src/hostplugins/lv2/PluginLv2.h
ViewVC logotype

Contents of /linuxsampler/trunk/src/hostplugins/lv2/PluginLv2.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2343 - (show annotations) (download) (as text)
Sun Apr 29 16:14:45 2012 UTC (6 years ago) by persson
File MIME type: text/x-c++hdr
File size: 4668 byte(s)
* fixed configure script error with old autoconf versions
* LV2: use the new lv2 package if present
* lsatomic.h: use gcc provided atomic functions if building with gcc
  4.7 and C++11
* added comments in lsatomic.h

1 /***************************************************************************
2 * *
3 * Copyright (C) 2008 - 2012 Andreas Persson *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software *
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
18 * MA 02110-1301 USA *
19 ***************************************************************************/
20
21 #ifndef LS_PLUGINLV2_H
22 #define LS_PLUGINLV2_H
23
24 #ifdef HAVE_LV2_PACKAGE
25 #include <lv2/lv2plug.in/ns/lv2core/lv2.h>
26 #include <lv2/lv2plug.in/ns/ext/event/event.h>
27 #include <lv2/lv2plug.in/ns/ext/state/state.h>
28 #include <lv2/lv2plug.in/ns/ext/uri-map/uri-map.h>
29 #else
30 #include <lv2.h>
31 #include "lv2_event.h"
32 #include "lv2_state.h"
33 #include "lv2_uri_map.h"
34 #endif
35 #include "../../drivers/Plugin.h"
36
37 namespace {
38
39 class PluginLv2 : public LinuxSampler::Plugin {
40 public:
41 PluginLv2(const LV2_Descriptor* Descriptor,
42 double SampleRate, const char* BundlePath,
43 const LV2_Feature* const* Features);
44 void ConnectPort(uint32_t Port, void* DataLocation);
45 void Activate();
46 void Run(uint32_t SampleCount);
47 void Deactivate();
48 LV2_State_Status Save(LV2_State_Store_Function store, void* data,
49 uint32_t flags, const LV2_Feature* const* features);
50 LV2_State_Status Restore(LV2_State_Retrieve_Function retrieve, void* data,
51 uint32_t flags, const LV2_Feature* const* features);
52
53 protected:
54 virtual String PathToState(const String& string);
55 virtual String PathFromState(const String& string);
56
57 private:
58 uint32_t uri_to_id(const char* map, const char* uri) {
59 return UriMap->uri_to_id(UriMap->callback_data, map, uri);
60 }
61
62 void SetStateFeatures(const LV2_Feature* const* Features);
63
64 float* Out[2];
65 LV2_Event_Buffer* MidiBuf;
66 LV2_URI_Map_Feature* UriMap;
67 LV2_State_Map_Path* MapPath;
68 LV2_State_Make_Path* MakePath;
69
70 String DefaultState;
71 };
72
73 class PluginInfo {
74 public:
75 static const LV2_Descriptor* Lv2Descriptor() {
76 return &Instance.Lv2;
77 }
78 static const LV2_State_Interface* Lv2StateInterface() {
79 return &Instance.StateInterface;
80 }
81 private:
82 LV2_Descriptor Lv2;
83 LV2_State_Interface StateInterface;
84
85 PluginInfo();
86 static PluginInfo Instance;
87 };
88
89 extern "C" {
90 static LV2_Handle instantiate(const LV2_Descriptor* descriptor,
91 double sample_rate, const char* bundle_path,
92 const LV2_Feature* const* features);
93 static void connect_port(LV2_Handle instance, uint32_t port,
94 void* data_location);
95 static void activate(LV2_Handle instance);
96 static void run(LV2_Handle instance, uint32_t sample_count);
97 static void deactivate(LV2_Handle instance);
98 static void cleanup(LV2_Handle instance);
99 static const void* extension_data(const char* uri);
100
101 static LV2_State_Status save(LV2_Handle handle,
102 LV2_State_Store_Function store,
103 void* data);
104
105 static LV2_State_Status restore(LV2_Handle handle,
106 LV2_State_Retrieve_Function retrieve,
107 void* data);
108 }
109 }
110
111 #endif

  ViewVC Help
Powered by ViewVC