comparison PyPlugin.h @ 0:e20e214bdfb5

Added VAMP-Python binding project vampy
author fazekasgy
date Tue, 11 Mar 2008 19:47:34 +0000
parents
children 134313c59d82
comparison
equal deleted inserted replaced
-1:000000000000 0:e20e214bdfb5
1 /*
2 Vamp
3
4 An API for audio analysis and feature extraction plugins.
5
6 Centre for Digital Music, Queen Mary, University of London.
7 Copyright 2006 Chris Cannam.
8
9 Permission is hereby granted, free of charge, to any person
10 obtaining a copy of this software and associated documentation
11 files (the "Software"), to deal in the Software without
12 restriction, including without limitation the rights to use, copy,
13 modify, merge, publish, distribute, sublicense, and/or sell copies
14 of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be
18 included in all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
24 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
25 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
28 Except as contained in this notice, the names of the Centre for
29 Digital Music; Queen Mary, University of London; and Chris Cannam
30 shall not be used in advertising or otherwise to promote the sale,
31 use or other dealings in this Software without prior written
32 authorization.
33 */
34
35 /**
36 * This plugin abstracts appropriate Python Scripts as a VAMP plugin.
37 */
38
39 #ifndef _PYTHON_WRAPPER_PLUGIN_H_
40 #define _PYTHON_WRAPPER_PLUGIN_H_
41
42 #include "vamp-sdk/Plugin.h"
43 #include "/usr/include/python/Python.h"
44
45 //fields in OutputDescriptor
46 enum eOutDescriptors {
47 not_found,
48 identifier,
49 name,
50 description,
51 unit,
52 hasFixedBinCount,
53 binCount,
54 binNames,
55 hasKnownExtents,
56 minValue,
57 maxValue,
58 isQuantized,
59 quantizeStep,
60 sampleType,
61 sampleRate,
62 endNode
63 };
64
65 namespace p {
66 enum eParmDescriptors {
67 not_found,
68 identifier,
69 name,
70 description,
71 unit,
72 minValue,
73 maxValue,
74 defaultValue,
75 isQuantized
76 };
77 }
78
79 enum eSampleTypes {
80 OneSamplePerStep,
81 FixedSampleRate,
82 VariableSampleRate
83 };
84
85 enum eFeatureFields {
86 unknown,
87 hasTimestamp,
88 timeStamp,
89 values,
90 label
91 };
92
93
94 class PyPlugin : public Vamp::Plugin
95 {
96 public:
97 PyPlugin(std::string plugin,float inputSampleRate, PyObject *pyInstance);
98 virtual ~PyPlugin();
99
100 bool initialise(size_t channels, size_t stepSize, size_t blockSize);
101 void reset();
102 //virtuals:
103 InputDomain getInputDomain() const;
104 size_t getPreferredBlockSize() const;
105 size_t getPreferredStepSize() const;
106 size_t getMinChannelCount() const;
107 size_t getMaxChannelCount() const;
108
109 std::string getIdentifier() const;
110 std::string getName() const;
111 std::string getDescription() const;
112 std::string getMaker() const;
113 int getPluginVersion() const;
114 std::string getCopyright() const;
115
116 OutputList getOutputDescriptors() const;
117 ParameterList getParameterDescriptors() const;
118 float getParameter(std::string paramid) const;
119 void setParameter(std::string paramid, float newval);
120
121 FeatureSet process(const float *const *inputBuffers,
122 Vamp::RealTime timestamp);
123
124 FeatureSet getRemainingFeatures();
125
126 protected:
127 PyObject *m_pyInstance;
128 size_t m_stepSize;
129 float m_previousSample;
130 std::string m_plugin;
131 std::string m_class;
132 std::string m_path;
133 };
134
135
136 #endif