Mercurial > hg > vamp-plugin-sdk
comparison sdk/PluginBase.h @ 0:6479539d1b32
* Importing first cut of Sonic Visualiser's Vamp plugin format SDK
author | cannam |
---|---|
date | Fri, 31 Mar 2006 14:21:51 +0000 |
parents | |
children | 274e883b5975 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:6479539d1b32 |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Sonic Visualiser | |
5 An audio file viewer and annotation editor. | |
6 Centre for Digital Music, Queen Mary, University of London. | |
7 This file copyright 2006 Chris Cannam. | |
8 | |
9 This program is free software; you can redistribute it and/or | |
10 modify it under the terms of the GNU General Public License as | |
11 published by the Free Software Foundation; either version 2 of the | |
12 License, or (at your option) any later version. See the file | |
13 COPYING included with this distribution for more information. | |
14 */ | |
15 | |
16 #ifndef _VAMP_PLUGIN_BASE_H_ | |
17 #define _VAMP_PLUGIN_BASE_H_ | |
18 | |
19 #include <string> | |
20 #include <vector> | |
21 | |
22 namespace Vamp { | |
23 | |
24 /** | |
25 * A base class for plugins with optional configurable parameters, | |
26 * programs, etc. | |
27 * | |
28 * This does not provide the necessary interfaces to instantiate or | |
29 * run a plugin -- that depends on the plugin subclass, as different | |
30 * plugin types may have quite different operating structures. This | |
31 * class just specifies the necessary interface to show editable | |
32 * controls for the plugin to the user. | |
33 */ | |
34 | |
35 class PluginBase | |
36 { | |
37 public: | |
38 /** | |
39 * Get the computer-usable name of the plugin. This should be | |
40 * reasonably short and contain no whitespace or punctuation | |
41 * characters. It may be shown to the user, but it won't be the | |
42 * main method for a user to identify a plugin (that will be the | |
43 * description, below). | |
44 */ | |
45 virtual std::string getName() const = 0; | |
46 | |
47 /** | |
48 * Get a human-readable description of the plugin. This should be | |
49 * self-contained, as it may be shown to the user in isolation | |
50 * without also showing the plugin's "name". | |
51 */ | |
52 virtual std::string getDescription() const = 0; | |
53 | |
54 /** | |
55 * Get the name of the author or vendor of the plugin in | |
56 * human-readable form. | |
57 */ | |
58 virtual std::string getMaker() const = 0; | |
59 | |
60 /** | |
61 * Get the version number of the plugin. | |
62 */ | |
63 virtual int getPluginVersion() const = 0; | |
64 | |
65 /** | |
66 * Get the copyright statement or licensing summary of the plugin. | |
67 */ | |
68 virtual std::string getCopyright() const = 0; | |
69 | |
70 /** | |
71 * Get the type of plugin (e.g. DSSI, etc). This is likely to be | |
72 * implemented by the immediate subclass, not by actual plugins. | |
73 */ | |
74 virtual std::string getType() const = 0; | |
75 | |
76 | |
77 struct ParameterDescriptor | |
78 { | |
79 /** | |
80 * The name of the parameter, in computer-usable form. Should | |
81 * be reasonably short, and may only contain the characters | |
82 * [a-zA-Z0-9_]. | |
83 */ | |
84 std::string name; | |
85 | |
86 /** | |
87 * The human-readable name of the parameter. | |
88 */ | |
89 std::string description; | |
90 | |
91 /** | |
92 * The unit of the parameter, in human-readable form. | |
93 */ | |
94 std::string unit; | |
95 | |
96 /** | |
97 * The minimum value of the parameter. | |
98 */ | |
99 float minValue; | |
100 | |
101 /** | |
102 * The maximum value of the parameter. | |
103 */ | |
104 float maxValue; | |
105 | |
106 /** | |
107 * The default value of the parameter. | |
108 */ | |
109 float defaultValue; | |
110 | |
111 /** | |
112 * True if the parameter values are quantized to a particular | |
113 * resolution. | |
114 */ | |
115 bool isQuantized; | |
116 | |
117 /** | |
118 * Quantization resolution of the parameter values (e.g. 1.0 | |
119 * if they are all integers). Undefined if isQuantized is | |
120 * false. | |
121 */ | |
122 float quantizeStep; | |
123 }; | |
124 | |
125 typedef std::vector<ParameterDescriptor> ParameterList; | |
126 | |
127 /** | |
128 * Get the controllable parameters of this plugin. | |
129 */ | |
130 virtual ParameterList getParameterDescriptors() const { | |
131 return ParameterList(); | |
132 } | |
133 | |
134 /** | |
135 * Get the value of a named parameter. The argument is the name | |
136 * field from that parameter's descriptor. | |
137 */ | |
138 virtual float getParameter(std::string) const { return 0.0; } | |
139 | |
140 /** | |
141 * Set a named parameter. The first argument is the name field | |
142 * from that parameter's descriptor. | |
143 */ | |
144 virtual void setParameter(std::string, float) { } | |
145 | |
146 | |
147 typedef std::vector<std::string> ProgramList; | |
148 | |
149 /** | |
150 * Get the program settings available in this plugin. | |
151 * The programs must have unique names. | |
152 */ | |
153 virtual ProgramList getPrograms() const { return ProgramList(); } | |
154 | |
155 /** | |
156 * Get the current program. | |
157 */ | |
158 virtual std::string getCurrentProgram() const { return ""; } | |
159 | |
160 /** | |
161 * Select a program. (If the given program name is not one of the | |
162 * available programs, do nothing.) | |
163 */ | |
164 virtual void selectProgram(std::string) { } | |
165 }; | |
166 | |
167 } | |
168 | |
169 #endif |