comparison vamp-sdk/PluginBase.h @ 3:0133b3513e2b

* Renamed sdk to vamp-sdk
author cannam
date Fri, 31 Mar 2006 15:08:27 +0000
parents sdk/PluginBase.h@274e883b5975
children 8f10d35a4090
comparison
equal deleted inserted replaced
2:274e883b5975 3:0133b3513e2b
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Vamp
5
6 An API for audio analysis and feature extraction plugins.
7
8 Centre for Digital Music, Queen Mary, University of London.
9 Copyright 2006 Chris Cannam.
10
11 Permission is hereby granted, free of charge, to any person
12 obtaining a copy of this software and associated documentation
13 files (the "Software"), to deal in the Software without
14 restriction, including without limitation the rights to use, copy,
15 modify, merge, publish, distribute, sublicense, and/or sell copies
16 of the Software, and to permit persons to whom the Software is
17 furnished to do so, subject to the following conditions:
18
19 The above copyright notice and this permission notice shall be
20 included in all copies or substantial portions of the Software.
21
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
27 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 Except as contained in this notice, the names of the Centre for
31 Digital Music; Queen Mary, University of London; and Chris Cannam
32 shall not be used in advertising or otherwise to promote the sale,
33 use or other dealings in this Software without prior written
34 authorization.
35 */
36
37 #ifndef _VAMP_PLUGIN_BASE_H_
38 #define _VAMP_PLUGIN_BASE_H_
39
40 #include <string>
41 #include <vector>
42
43 namespace Vamp {
44
45 /**
46 * A base class for plugins with optional configurable parameters,
47 * programs, etc.
48 *
49 * This does not provide the necessary interfaces to instantiate or
50 * run a plugin -- that depends on the plugin subclass, as different
51 * plugin types may have quite different operating structures. This
52 * class just specifies the necessary interface to show editable
53 * controls for the plugin to the user.
54 */
55
56 class PluginBase
57 {
58 public:
59 /**
60 * Get the computer-usable name of the plugin. This should be
61 * reasonably short and contain no whitespace or punctuation
62 * characters. It may be shown to the user, but it won't be the
63 * main method for a user to identify a plugin (that will be the
64 * description, below).
65 */
66 virtual std::string getName() const = 0;
67
68 /**
69 * Get a human-readable description of the plugin. This should be
70 * self-contained, as it may be shown to the user in isolation
71 * without also showing the plugin's "name".
72 */
73 virtual std::string getDescription() const = 0;
74
75 /**
76 * Get the name of the author or vendor of the plugin in
77 * human-readable form.
78 */
79 virtual std::string getMaker() const = 0;
80
81 /**
82 * Get the version number of the plugin.
83 */
84 virtual int getPluginVersion() const = 0;
85
86 /**
87 * Get the copyright statement or licensing summary of the plugin.
88 */
89 virtual std::string getCopyright() const = 0;
90
91 /**
92 * Get the type of plugin (e.g. DSSI, etc). This is likely to be
93 * implemented by the immediate subclass, not by actual plugins.
94 */
95 virtual std::string getType() const = 0;
96
97
98 struct ParameterDescriptor
99 {
100 /**
101 * The name of the parameter, in computer-usable form. Should
102 * be reasonably short, and may only contain the characters
103 * [a-zA-Z0-9_].
104 */
105 std::string name;
106
107 /**
108 * The human-readable name of the parameter.
109 */
110 std::string description;
111
112 /**
113 * The unit of the parameter, in human-readable form.
114 */
115 std::string unit;
116
117 /**
118 * The minimum value of the parameter.
119 */
120 float minValue;
121
122 /**
123 * The maximum value of the parameter.
124 */
125 float maxValue;
126
127 /**
128 * The default value of the parameter.
129 */
130 float defaultValue;
131
132 /**
133 * True if the parameter values are quantized to a particular
134 * resolution.
135 */
136 bool isQuantized;
137
138 /**
139 * Quantization resolution of the parameter values (e.g. 1.0
140 * if they are all integers). Undefined if isQuantized is
141 * false.
142 */
143 float quantizeStep;
144 };
145
146 typedef std::vector<ParameterDescriptor> ParameterList;
147
148 /**
149 * Get the controllable parameters of this plugin.
150 */
151 virtual ParameterList getParameterDescriptors() const {
152 return ParameterList();
153 }
154
155 /**
156 * Get the value of a named parameter. The argument is the name
157 * field from that parameter's descriptor.
158 */
159 virtual float getParameter(std::string) const { return 0.0; }
160
161 /**
162 * Set a named parameter. The first argument is the name field
163 * from that parameter's descriptor.
164 */
165 virtual void setParameter(std::string, float) { }
166
167
168 typedef std::vector<std::string> ProgramList;
169
170 /**
171 * Get the program settings available in this plugin.
172 * The programs must have unique names.
173 */
174 virtual ProgramList getPrograms() const { return ProgramList(); }
175
176 /**
177 * Get the current program.
178 */
179 virtual std::string getCurrentProgram() const { return ""; }
180
181 /**
182 * Select a program. (If the given program name is not one of the
183 * available programs, do nothing.)
184 */
185 virtual void selectProgram(std::string) { }
186 };
187
188 }
189
190 #endif