/[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 2291 - (show annotations) (download) (as text)
Thu Nov 24 17:00:29 2011 UTC (12 years, 5 months ago) by capela
File MIME type: text/x-c++hdr
File size: 4106 byte(s)
* LV2 State extension;
  replaces LV2 Persist and LV2 Files extensions (patch by David Robilard).
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 void Save(LV2_State_Store_Function store, void* data);
42 void Restore(LV2_State_Retrieve_Function retrieve, void* data);
43
44 protected:
45 virtual String PathToState(const String& string);
46 virtual String PathFromState(const String& string);
47
48 private:
49 uint32_t uri_to_id(const char* map, const char* uri) {
50 return UriMap->uri_to_id(UriMap->callback_data, map, uri);
51 }
52
53 float* Out[2];
54 LV2_Event_Buffer* MidiBuf;
55 LV2_URI_Map_Feature* UriMap;
56 LV2_State_Map_Path* MapPath;
57 LV2_State_Make_Path* MakePath;
58
59 String DefaultState;
60 };
61
62 class PluginInfo {
63 public:
64 static const LV2_Descriptor* Lv2Descriptor() {
65 return &Instance.Lv2;
66 }
67 static const LV2_State_Interface* Lv2StateInterface() {
68 return &Instance.StateInterface;
69 }
70 private:
71 LV2_Descriptor Lv2;
72 LV2_State_Interface StateInterface;
73
74 PluginInfo();
75 static PluginInfo Instance;
76 };
77
78 extern "C" {
79 static LV2_Handle instantiate(const LV2_Descriptor* descriptor,
80 double sample_rate, const char* bundle_path,
81 const LV2_Feature* const* features);
82 static void connect_port(LV2_Handle instance, uint32_t port,
83 void* data_location);
84 static void activate(LV2_Handle instance);
85 static void run(LV2_Handle instance, uint32_t sample_count);
86 static void deactivate(LV2_Handle instance);
87 static void cleanup(LV2_Handle instance);
88 static const void* extension_data(const char* uri);
89
90 static void save(LV2_Handle handle,
91 LV2_State_Store_Function store,
92 void* data);
93
94 static void restore(LV2_Handle handle,
95 LV2_State_Retrieve_Function retrieve,
96 void* data);
97 }
98 }
99
100 #endif

  ViewVC Help
Powered by ViewVC