Mercurial > hg > vamp-plugin-sdk
comparison vamp-sdk/PluginAdapter.h @ 76:6683f99107cf
* Use m_impl structure for PluginAdapter as well
* Doc updates
author | cannam |
---|---|
date | Thu, 07 Jun 2007 14:15:24 +0000 |
parents | 74822738965b |
children | 5ee166dccfff |
comparison
equal
deleted
inserted
replaced
75:0f8524203677 | 76:6683f99107cf |
---|---|
44 #include <map> | 44 #include <map> |
45 | 45 |
46 namespace Vamp { | 46 namespace Vamp { |
47 | 47 |
48 /** | 48 /** |
49 * \class PluginAdapterBase PluginAdapter.h <vamp-sdk/PluginAdapter.h> | |
50 * | |
49 * PluginAdapter and PluginAdapterBase provide a wrapper class that a | 51 * PluginAdapter and PluginAdapterBase provide a wrapper class that a |
50 * plugin library can use to make its C++ Vamp::Plugin objects | 52 * plugin library can use to make its C++ Vamp::Plugin objects |
51 * available through the Vamp C API. | 53 * available through the Vamp C API. |
52 * | 54 * |
53 * Almost all Vamp plugin libraries will want to make use of this. To | 55 * Almost all Vamp plugin libraries will want to make use of this. To |
54 * do so, all they need to do is declare a PluginAdapter<T> for each | 56 * do so, all they need to do is declare a PluginAdapter<T> for each |
55 * plugin class T in their library. It's very simple, and you need to | 57 * plugin class T in their library. It's very simple, and you need to |
56 * know absolutely nothing about how it works in order to use it. | 58 * know absolutely nothing about how it works in order to use it. |
57 * Just cut and paste from an existing plugin's discovery function. | 59 * Just cut and paste from an existing plugin's discovery function. |
58 * @see vampGetPluginDescriptor | 60 * \see vampGetPluginDescriptor |
59 */ | 61 */ |
60 | 62 |
61 class PluginAdapterBase | 63 class PluginAdapterBase |
62 { | 64 { |
63 public: | 65 public: |
72 protected: | 74 protected: |
73 PluginAdapterBase(); | 75 PluginAdapterBase(); |
74 | 76 |
75 virtual Plugin *createPlugin(float inputSampleRate) = 0; | 77 virtual Plugin *createPlugin(float inputSampleRate) = 0; |
76 | 78 |
77 static VampPluginHandle vampInstantiate(const VampPluginDescriptor *desc, | 79 class Impl; |
78 float inputSampleRate); | 80 Impl *m_impl; |
79 | |
80 static void vampCleanup(VampPluginHandle handle); | |
81 | |
82 static int vampInitialise(VampPluginHandle handle, unsigned int channels, | |
83 unsigned int stepSize, unsigned int blockSize); | |
84 | |
85 static void vampReset(VampPluginHandle handle); | |
86 | |
87 static float vampGetParameter(VampPluginHandle handle, int param); | |
88 static void vampSetParameter(VampPluginHandle handle, int param, float value); | |
89 | |
90 static unsigned int vampGetCurrentProgram(VampPluginHandle handle); | |
91 static void vampSelectProgram(VampPluginHandle handle, unsigned int program); | |
92 | |
93 static unsigned int vampGetPreferredStepSize(VampPluginHandle handle); | |
94 static unsigned int vampGetPreferredBlockSize(VampPluginHandle handle); | |
95 static unsigned int vampGetMinChannelCount(VampPluginHandle handle); | |
96 static unsigned int vampGetMaxChannelCount(VampPluginHandle handle); | |
97 | |
98 static unsigned int vampGetOutputCount(VampPluginHandle handle); | |
99 | |
100 static VampOutputDescriptor *vampGetOutputDescriptor(VampPluginHandle handle, | |
101 unsigned int i); | |
102 | |
103 static void vampReleaseOutputDescriptor(VampOutputDescriptor *desc); | |
104 | |
105 static VampFeatureList *vampProcess(VampPluginHandle handle, | |
106 const float *const *inputBuffers, | |
107 int sec, | |
108 int nsec); | |
109 | |
110 static VampFeatureList *vampGetRemainingFeatures(VampPluginHandle handle); | |
111 | |
112 static void vampReleaseFeatureSet(VampFeatureList *fs); | |
113 | |
114 void cleanup(Plugin *plugin); | |
115 void checkOutputMap(Plugin *plugin); | |
116 unsigned int getOutputCount(Plugin *plugin); | |
117 VampOutputDescriptor *getOutputDescriptor(Plugin *plugin, | |
118 unsigned int i); | |
119 VampFeatureList *process(Plugin *plugin, | |
120 const float *const *inputBuffers, | |
121 int sec, int nsec); | |
122 VampFeatureList *getRemainingFeatures(Plugin *plugin); | |
123 VampFeatureList *convertFeatures(Plugin *plugin, | |
124 const Plugin::FeatureSet &features); | |
125 | |
126 // maps both plugins and descriptors to adapters | |
127 typedef std::map<const void *, PluginAdapterBase *> AdapterMap; | |
128 static AdapterMap *m_adapterMap; | |
129 static PluginAdapterBase *lookupAdapter(VampPluginHandle); | |
130 | |
131 bool m_populated; | |
132 VampPluginDescriptor m_descriptor; | |
133 Plugin::ParameterList m_parameters; | |
134 Plugin::ProgramList m_programs; | |
135 | |
136 typedef std::map<Plugin *, Plugin::OutputList *> OutputMap; | |
137 OutputMap m_pluginOutputs; | |
138 | |
139 std::map<Plugin *, VampFeatureList *> m_fs; | |
140 std::map<Plugin *, std::vector<size_t> > m_fsizes; | |
141 std::map<Plugin *, std::vector<std::vector<size_t> > > m_fvsizes; | |
142 void resizeFS(Plugin *plugin, int n); | |
143 void resizeFL(Plugin *plugin, int n, size_t sz); | |
144 void resizeFV(Plugin *plugin, int n, int j, size_t sz); | |
145 }; | 81 }; |
146 | 82 |
147 /** | 83 /** |
84 * \class PluginAdapter PluginAdapter.h <vamp-sdk/PluginAdapter.h> | |
85 * | |
148 * PluginAdapter turns a PluginAdapterBase into a specific wrapper for | 86 * PluginAdapter turns a PluginAdapterBase into a specific wrapper for |
149 * a particular plugin implementation. | 87 * a particular plugin implementation. |
150 * | 88 * |
151 * See PluginAdapterBase. | 89 * See PluginAdapterBase. |
152 */ | 90 */ |