Don't redraw the summary every time the playhead moves (if it hasn't moved visibly...
[ardour.git] / libs / vamp-sdk / vamp-sdk / PluginBase.h
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 AUTHORS 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_SDK_PLUGIN_BASE_H_
38 #define _VAMP_SDK_PLUGIN_BASE_H_
39
40 #include <string>
41 #include <vector>
42
43 #define VAMP_SDK_VERSION "3.5"
44 #define VAMP_SDK_MAJOR_VERSION 2
45 #define VAMP_SDK_MINOR_VERSION 2
46
47 #include "plugguard.h"
48 _VAMP_SDK_PLUGSPACE_BEGIN(PluginBase.h)
49
50 namespace Vamp {
51
52 /**
53  * A base class for plugins with optional configurable parameters,
54  * programs, etc.  The Vamp::Plugin is derived from this, and
55  * individual Vamp plugins should derive from that.
56  *
57  * This class does not provide the necessary interfaces to instantiate
58  * or run a plugin.  It only specifies an interface for retrieving
59  * those controls that the host may wish to show to the user for
60  * editing.  It could meaningfully be subclassed by real-time plugins
61  * or other sorts of plugin as well as Vamp plugins.
62  */
63
64 class PluginBase 
65 {
66 public:
67     virtual ~PluginBase() { }
68
69     /**
70      * Get the Vamp API compatibility level of the plugin.
71      */
72     virtual unsigned int getVampApiVersion() const { return 2; }
73
74     /**
75      * Get the computer-usable name of the plugin.  This should be
76      * reasonably short and contain no whitespace or punctuation
77      * characters.  It may only contain the characters [a-zA-Z0-9_-].
78      * This is the authoritative way for a program to identify a
79      * plugin within a given library.
80      *
81      * This text may be visible to the user, but it should not be the
82      * main text used to identify a plugin to the user (that will be
83      * the name, below).
84      *
85      * Example: "zero_crossings"
86      */
87     virtual std::string getIdentifier() const = 0;
88
89     /**
90      * Get a human-readable name or title of the plugin.  This
91      * should be brief and self-contained, as it may be used to
92      * identify the plugin to the user in isolation (i.e. without also
93      * showing the plugin's "identifier").
94      *
95      * Example: "Zero Crossings"
96      */
97     virtual std::string getName() const = 0;
98
99     /**
100      * Get a human-readable description for the plugin, typically
101      * a line of text that may optionally be displayed in addition
102      * to the plugin's "name".  May be empty if the name has said
103      * it all already.
104      *
105      * Example: "Detect and count zero crossing points"
106      */
107     virtual std::string getDescription() const = 0;
108     
109     /**
110      * Get the name of the author or vendor of the plugin in
111      * human-readable form.  This should be a short identifying text,
112      * as it may be used to label plugins from the same source in a
113      * menu or similar.
114      */
115     virtual std::string getMaker() const = 0;
116
117     /**
118      * Get the copyright statement or licensing summary for the
119      * plugin.  This can be an informative text, without the same
120      * presentation constraints as mentioned for getMaker above.
121      */
122     virtual std::string getCopyright() const = 0;
123
124     /**
125      * Get the version number of the plugin.
126      */
127     virtual int getPluginVersion() const = 0;
128
129
130     struct ParameterDescriptor
131     {
132         /**
133          * The name of the parameter, in computer-usable form.  Should
134          * be reasonably short, and may only contain the characters
135          * [a-zA-Z0-9_-].
136          */
137         std::string identifier;
138
139         /**
140          * The human-readable name of the parameter.
141          */
142         std::string name;
143
144         /**
145          * A human-readable short text describing the parameter.  May be
146          * empty if the name has said it all already.
147          */
148         std::string description;
149
150         /**
151          * The unit of the parameter, in human-readable form.
152          */
153         std::string unit;
154
155         /**
156          * The minimum value of the parameter.
157          */
158         float minValue;
159
160         /**
161          * The maximum value of the parameter.
162          */
163         float maxValue;
164
165         /**
166          * The default value of the parameter.  The plugin should
167          * ensure that parameters have this value on initialisation
168          * (i.e. the host is not required to explicitly set parameters
169          * if it wants to use their default values).
170          */
171         float defaultValue;
172         
173         /**
174          * True if the parameter values are quantized to a particular
175          * resolution.
176          */
177         bool isQuantized;
178
179         /**
180          * Quantization resolution of the parameter values (e.g. 1.0
181          * if they are all integers).  Undefined if isQuantized is
182          * false.
183          */
184         float quantizeStep;
185
186         /**
187          * Names for the quantized values.  If isQuantized is true,
188          * this may either be empty or contain one string for each of
189          * the quantize steps from minValue up to maxValue inclusive.
190          * Undefined if isQuantized is false.
191          *
192          * If these names are provided, they should be shown to the
193          * user in preference to the values themselves.  The user may
194          * never see the actual numeric values unless they are also
195          * encoded in the names.
196          */
197         std::vector<std::string> valueNames;
198
199         ParameterDescriptor() : // the defaults are invalid: you must set them
200             minValue(0), maxValue(0), defaultValue(0), isQuantized(false) { }
201     };
202
203     typedef std::vector<ParameterDescriptor> ParameterList;
204
205     /**
206      * Get the controllable parameters of this plugin.
207      */
208     virtual ParameterList getParameterDescriptors() const {
209         return ParameterList();
210     }
211
212     /**
213      * Get the value of a named parameter.  The argument is the identifier
214      * field from that parameter's descriptor.
215      */
216     virtual float getParameter(std::string) const { return 0.0; }
217
218     /**
219      * Set a named parameter.  The first argument is the identifier field
220      * from that parameter's descriptor.
221      */
222     virtual void setParameter(std::string, float) { } 
223
224     
225     typedef std::vector<std::string> ProgramList;
226
227     /**
228      * Get the program settings available in this plugin.  A program
229      * is a named shorthand for a set of parameter values; changing
230      * the program may cause the plugin to alter the values of its
231      * published parameters (and/or non-public internal processing
232      * parameters).  The host should re-read the plugin's parameter
233      * values after setting a new program.
234      *
235      * The programs must have unique names.
236      */
237     virtual ProgramList getPrograms() const { return ProgramList(); }
238
239     /**
240      * Get the current program.
241      */
242     virtual std::string getCurrentProgram() const { return ""; }
243
244     /**
245      * Select a program.  (If the given program name is not one of the
246      * available programs, do nothing.)
247      */
248     virtual void selectProgram(std::string) { }
249
250     /**
251      * Get the type of plugin.  This is to be implemented by the
252      * immediate subclass, not by actual plugins.  Do not attempt to
253      * implement this in plugin code.
254      */
255     virtual std::string getType() const = 0;
256 };
257
258 }
259
260 _VAMP_SDK_PLUGSPACE_END(PluginBase.h)
261
262 #endif