Mercurial > hg > svcore
changeset 50:080ad875395a
* Pull out parameter/description query methods from FeatureExtractionPlugin
into new PluginInstance base class
author | Chris Cannam |
---|---|
date | Mon, 20 Mar 2006 12:04:06 +0000 |
parents | 39ae3dee27b9 |
children | c2913298cf94 |
files | plugin/FeatureExtractionPlugin.h plugin/PluginInstance.h |
diffstat | 2 files changed, 157 insertions(+), 104 deletions(-) [+] |
line wrap: on
line diff
--- a/plugin/FeatureExtractionPlugin.h Mon Mar 20 11:40:39 2006 +0000 +++ b/plugin/FeatureExtractionPlugin.h Mon Mar 20 12:04:06 2006 +0000 @@ -10,9 +10,7 @@ #ifndef _FEATURE_EXTRACTION_PLUGIN_H_ #define _FEATURE_EXTRACTION_PLUGIN_H_ -/** - * A base class for feature extraction plugins. - */ +#include "PluginInstance.h" #include <string> #include <vector> @@ -27,9 +25,12 @@ * In most cases, the input will be audio and the output will be a * stream of derived data at a lower sampling resolution than the * input. + * + * Note that this class inherits several abstract methods from + * PluginInstance, that must be implemented by the subclass. */ -class FeatureExtractionPlugin +class FeatureExtractionPlugin : public PluginInstance { public: /** @@ -56,36 +57,6 @@ virtual void reset() = 0; /** - * Get the computer-usable name of the plugin. This should be - * reasonably short and contain no whitespace or punctuation - * characters. - */ - virtual std::string getName() const = 0; - - /** - * Get a human-readable description of the plugin. This should be - * self-contained, as it may be shown to the user in isolation - * without also showing the plugin's "name". - */ - virtual std::string getDescription() const = 0; - - /** - * Get the name of the author or vendor of the plugin in - * human-readable form. - */ - virtual std::string getMaker() const = 0; - - /** - * Get the version number of the plugin. - */ - virtual int getPluginVersion() const = 0; - - /** - * Get the copyright statement or licensing summary of the plugin. - */ - virtual std::string getCopyright() const = 0; - - /** * Get the preferred step size (window increment -- the distance * in sample frames between the start frames of consecutive blocks * passed to the process() function) for the plugin. This should @@ -110,7 +81,6 @@ */ virtual size_t getMaxChannelCount() const { return 1; } - struct OutputDescriptor { /** @@ -225,75 +195,6 @@ */ virtual OutputList getOutputDescriptors() const = 0; - - struct ParameterDescriptor - { - /** - * The name of the parameter, in computer-usable form. Should - * be reasonably short and without whitespace or punctuation. - */ - std::string name; - - /** - * The human-readable name of the parameter. - */ - std::string description; - - /** - * The unit of the parameter, in human-readable form. - */ - std::string unit; - - /** - * The minimum value of the parameter. - */ - float minValue; - - /** - * The maximum value of the parameter. - */ - float maxValue; - - /** - * The default value of the parameter. - */ - float defaultValue; - - /** - * True if the parameter values are quantized to a particular - * resolution. - */ - bool isQuantized; - - /** - * Quantization resolution of the parameter values (e.g. 1.0 - * if they are all integers). Undefined if isQuantized is - * false. - */ - float quantizeStep; - }; - - typedef std::vector<ParameterDescriptor> ParameterList; - - /** - * Get the controllable parameters of this plugin. - */ - virtual ParameterList getParameterDescriptors() const { - return ParameterList(); - } - - /** - * Get the value of a named parameter. The argument is the name - * field from that parameter's descriptor. - */ - virtual float getParameter(std::string) const { return 0.0; } - - /** - * Set a named parameter. The first argument is the name field - * from that parameter's descriptor. - */ - virtual void setParameter(std::string, float) { } - struct Feature { /**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugin/PluginInstance.h Mon Mar 20 12:04:06 2006 +0000 @@ -0,0 +1,152 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + A waveform viewer and audio annotation editor. + Chris Cannam, Queen Mary University of London, 2005-2006 + + This is experimental software. Not for distribution. +*/ + +#ifndef _PLUGIN_INSTANCE_H_ +#define _PLUGIN_INSTANCE_H_ + +#include <string> +#include <vector> + +/** + * A base class for plugins with optional configurable parameters, + * programs, etc. + * + * This does not provide the necessary interfaces to instantiate or + * run a plugin -- that depends on the plugin subclass, as different + * plugin types may have quite different operating structures. This + * class just specifies the necessary interface to show editable + * controls for the plugin to the user. + */ + +class PluginInstance +{ +public: + /** + * Get the computer-usable name of the plugin. This should be + * reasonably short and contain no whitespace or punctuation + * characters. It may be shown to the user, but it won't be the + * main method for a user to identify a plugin (that will be the + * description, below). + */ + virtual std::string getName() const = 0; + + /** + * Get a human-readable description of the plugin. This should be + * self-contained, as it may be shown to the user in isolation + * without also showing the plugin's "name". + */ + virtual std::string getDescription() const = 0; + + /** + * Get the name of the author or vendor of the plugin in + * human-readable form. + */ + virtual std::string getMaker() const = 0; + + /** + * Get the version number of the plugin. + */ + virtual int getPluginVersion() const = 0; + + /** + * Get the copyright statement or licensing summary of the plugin. + */ + virtual std::string getCopyright() const = 0; + + + struct ParameterDescriptor + { + /** + * The name of the parameter, in computer-usable form. Should + * be reasonably short and without whitespace or punctuation. + */ + std::string name; + + /** + * The human-readable name of the parameter. + */ + std::string description; + + /** + * The unit of the parameter, in human-readable form. + */ + std::string unit; + + /** + * The minimum value of the parameter. + */ + float minValue; + + /** + * The maximum value of the parameter. + */ + float maxValue; + + /** + * The default value of the parameter. + */ + float defaultValue; + + /** + * True if the parameter values are quantized to a particular + * resolution. + */ + bool isQuantized; + + /** + * Quantization resolution of the parameter values (e.g. 1.0 + * if they are all integers). Undefined if isQuantized is + * false. + */ + float quantizeStep; + }; + + typedef std::vector<ParameterDescriptor> ParameterList; + + /** + * Get the controllable parameters of this plugin. + */ + virtual ParameterList getParameterDescriptors() const { + return ParameterList(); + } + + /** + * Get the value of a named parameter. The argument is the name + * field from that parameter's descriptor. + */ + virtual float getParameter(std::string) const { return 0.0; } + + /** + * Set a named parameter. The first argument is the name field + * from that parameter's descriptor. + */ + virtual void setParameter(std::string, float) { } + + + typedef std::vector<std::string> ProgramList; + + /** + * Get the program settings available in this plugin. + * The programs must have unique names. + */ + virtual ProgramList getPrograms() const { return ProgramList(); } + + /** + * Get the current program. + */ + virtual std::string getCurrentProgram() const { return ""; } + + /** + * Select a program. (If the given program name is not one of the + * available programs, do nothing.) + */ + virtual void selectProgram(std::string) { } +}; + +#endif