Mercurial > hg > vampy
comparison PyPlugin.h @ 24:7d28bed0864e
* Rearrange Python plugin construction.
Formerly, the PyPluginAdapter has retained a single plugin instance pointer
for each plugin found, and its createPlugin method has simply returned a new
PyPlugin object wrapping the same instance pointer. This has a couple of
negative consequences:
- Because construction of the actual Python instance occurred before the
wrapper was constructed, it was not possible to pass arguments (i.e.
the sample rate) from the wrapper constructor to the Python plugin
instance constructor -- they had to be passed later, to initialise,
disadvantaging those plugins that would like to use the sample rate
for parameter & step/block size calculations etc
- Because there was only a single Python plugin instance, it was not
possible to run more than one instance at once with any isolation
This rework instead stores the Python class pointer (rather than instance
pointer) in the PyPluginAdapter, and each PyPlugin wrapper instance creates
its own Python plugin instance. What could possibly go wrong?
author | cannam |
---|---|
date | Mon, 17 Aug 2009 15:22:06 +0000 |
parents | 1ae350e97f93 |
children | 4f1894c7591b |
comparison
equal
deleted
inserted
replaced
23:535d559300dc | 24:7d28bed0864e |
---|---|
106 }; | 106 }; |
107 | 107 |
108 class PyPlugin : public Vamp::Plugin | 108 class PyPlugin : public Vamp::Plugin |
109 { | 109 { |
110 public: | 110 public: |
111 PyPlugin(std::string plugin,float inputSampleRate, PyObject *pyInstance); | 111 PyPlugin(std::string plugin,float inputSampleRate, PyObject *pyClass); |
112 virtual ~PyPlugin(); | 112 virtual ~PyPlugin(); |
113 | 113 |
114 bool initialise(size_t channels, size_t stepSize, size_t blockSize); | 114 bool initialise(size_t channels, size_t stepSize, size_t blockSize); |
115 void reset(); | 115 void reset(); |
116 | 116 |
136 Vamp::RealTime timestamp); | 136 Vamp::RealTime timestamp); |
137 | 137 |
138 FeatureSet getRemainingFeatures(); | 138 FeatureSet getRemainingFeatures(); |
139 | 139 |
140 protected: | 140 protected: |
141 PyObject *m_pyClass; | |
141 PyObject *m_pyInstance; | 142 PyObject *m_pyInstance; |
142 size_t m_stepSize; | 143 size_t m_stepSize; |
143 size_t m_blockSize; | 144 size_t m_blockSize; |
144 size_t m_channels; | 145 size_t m_channels; |
145 std::string m_plugin; | 146 std::string m_plugin; |