annotate sdk/PluginBase.h @ 1:ad9aa1881a70

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