/[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 2340 - (show annotations) (download) (as text)
Fri Mar 30 23:54:44 2012 UTC (12 years ago) by capela
File MIME type: text/x-c++hdr
File size: 4443 byte(s)
* Update to latest LV2 state extension (by David Robillard).
1 /***************************************************************************
2 * *
3 * Copyright (C) 2008 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 #include <lv2.h>
25 #include "lv2_event.h"
26 #include "lv2_state.h"
27 #include "lv2_uri_map.h"
28 #include "../../drivers/Plugin.h"
29
30 namespace {
31
32 class PluginLv2 : public LinuxSampler::Plugin {
33 public:
34 PluginLv2(const LV2_Descriptor* Descriptor,
35 double SampleRate, const char* BundlePath,
36 const LV2_Feature* const* Features);
37 void ConnectPort(uint32_t Port, void* DataLocation);
38 void Activate();
39 void Run(uint32_t SampleCount);
40 void Deactivate();
41 LV2_State_Status Save(LV2_State_Store_Function store, void* data,
42 uint32_t flags, const LV2_Feature* const* features);
43 LV2_State_Status Restore(LV2_State_Retrieve_Function retrieve, void* data,
44 uint32_t flags, const LV2_Feature* const* features);
45
46 protected:
47 virtual String PathToState(const String& string);
48 virtual String PathFromState(const String& string);
49
50 private:
51 uint32_t uri_to_id(const char* map, const char* uri) {
52 return UriMap->uri_to_id(UriMap->callback_data, map, uri);
53 }
54
55 void SetStateFeatures(const LV2_Feature* const* Features);
56
57 float* Out[2];
58 LV2_Event_Buffer* MidiBuf;
59 LV2_URI_Map_Feature* UriMap;
60 LV2_State_Map_Path* MapPath;
61 LV2_State_Make_Path* MakePath;
62
63 String DefaultState;
64 };
65
66 class PluginInfo {
67 public:
68 static const LV2_Descriptor* Lv2Descriptor() {
69 return &Instance.Lv2;
70 }
71 static const LV2_State_Interface* Lv2StateInterface() {
72 return &Instance.StateInterface;
73 }
74 private:
75 LV2_Descriptor Lv2;
76 LV2_State_Interface StateInterface;
77
78 PluginInfo();
79 static PluginInfo Instance;
80 };
81
82 extern "C" {
83 static LV2_Handle instantiate(const LV2_Descriptor* descriptor,
84 double sample_rate, const char* bundle_path,
85 const LV2_Feature* const* features);
86 static void connect_port(LV2_Handle instance, uint32_t port,
87 void* data_location);
88 static void activate(LV2_Handle instance);
89 static void run(LV2_Handle instance, uint32_t sample_count);
90 static void deactivate(LV2_Handle instance);
91 static void cleanup(LV2_Handle instance);
92 static const void* extension_data(const char* uri);
93
94 static LV2_State_Status save(LV2_Handle handle,
95 LV2_State_Store_Function store,
96 void* data);
97
98 static LV2_State_Status restore(LV2_Handle handle,
99 LV2_State_Retrieve_Function retrieve,
100 void* data);
101 }
102 }
103
104 #endif

  ViewVC Help
Powered by ViewVC