VampPluginSDK
2.1
|
PluginSummarisingAdapter is a Vamp plugin adapter that provides summarisation methods such as mean and median averages of output features, for use in any context where an available plugin produces individual values but the result that is actually needed is some sort of aggregate. More...
#include <vamp-hostsdk/PluginSummarisingAdapter.h>
Public Types | |
enum | SummaryType { Minimum = 0, Maximum = 1, Mean = 2, Median = 3, Mode = 4, Sum = 5, Variance = 6, StandardDeviation = 7, Count = 8, UnknownSummaryType = 999 } |
enum | AveragingMethod { SampleAverage = 0, ContinuousTimeAverage = 1 } |
AveragingMethod indicates how the adapter should handle average-based summaries of features whose results are not equally spaced in time. More... | |
typedef std::set< RealTime > | SegmentBoundaries |
enum | InputDomain { TimeDomain, FrequencyDomain } |
typedef std::vector < OutputDescriptor > | OutputList |
typedef std::vector< Feature > | FeatureList |
typedef std::map< int, FeatureList > | FeatureSet |
typedef std::vector < ParameterDescriptor > | ParameterList |
typedef std::vector< std::string > | ProgramList |
Public Member Functions | |
PluginSummarisingAdapter (Plugin *plugin) | |
Construct a PluginSummarisingAdapter wrapping the given plugin. | |
virtual | ~PluginSummarisingAdapter () |
bool | initialise (size_t channels, size_t stepSize, size_t blockSize) |
Initialise a plugin to prepare it for use with the given number of input channels, step size (window increment, in sample frames) and block size (window size, in sample frames). | |
void | reset () |
Reset the plugin after use, to prepare it for another clean run. | |
FeatureSet | process (const float *const *inputBuffers, RealTime timestamp) |
Process a single block of input data. | |
FeatureSet | getRemainingFeatures () |
After all blocks have been processed, calculate and return any remaining features derived from the complete input. | |
void | setSummarySegmentBoundaries (const SegmentBoundaries &) |
Specify a series of segment boundaries, such that one summary will be returned for each of the contiguous intra-boundary segments. | |
FeatureList | getSummaryForOutput (int output, SummaryType type, AveragingMethod method=SampleAverage) |
Return summaries of the features that were returned on the given output, using the given SummaryType and AveragingMethod. | |
FeatureSet | getSummaryForAllOutputs (SummaryType type, AveragingMethod method=SampleAverage) |
Return summaries of the features that were returned on all of the plugin's outputs, using the given SummaryType and AveragingMethod. | |
InputDomain | getInputDomain () const |
Get the plugin's required input domain. | |
unsigned int | getVampApiVersion () const |
Get the Vamp API compatibility level of the plugin. | |
std::string | getIdentifier () const |
Get the computer-usable name of the plugin. | |
std::string | getName () const |
Get a human-readable name or title of the plugin. | |
std::string | getDescription () const |
Get a human-readable description for the plugin, typically a line of text that may optionally be displayed in addition to the plugin's "name". | |
std::string | getMaker () const |
Get the name of the author or vendor of the plugin in human-readable form. | |
int | getPluginVersion () const |
Get the version number of the plugin. | |
std::string | getCopyright () const |
Get the copyright statement or licensing summary for the plugin. | |
ParameterList | getParameterDescriptors () const |
Get the controllable parameters of this plugin. | |
float | getParameter (std::string) const |
Get the value of a named parameter. | |
void | setParameter (std::string, float) |
Set a named parameter. | |
ProgramList | getPrograms () const |
Get the program settings available in this plugin. | |
std::string | getCurrentProgram () const |
Get the current program. | |
void | selectProgram (std::string) |
Select a program. | |
size_t | getPreferredStepSize () const |
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. | |
size_t | getPreferredBlockSize () const |
Get the preferred block size (window size -- the number of sample frames passed in each block to the process() function). | |
size_t | getMinChannelCount () const |
Get the minimum supported number of input channels. | |
size_t | getMaxChannelCount () const |
Get the maximum supported number of input channels. | |
OutputList | getOutputDescriptors () const |
Get the outputs of this plugin. | |
template<typename WrapperType > | |
WrapperType * | getWrapper () |
Return a pointer to the plugin wrapper of type WrapperType surrounding this wrapper's plugin, if present. | |
virtual std::string | getType () const |
Used to distinguish between Vamp::Plugin and other potential sibling subclasses of PluginBase. | |
Protected Attributes | |
Impl * | m_impl |
Plugin * | m_plugin |
float | m_inputSampleRate |
PluginSummarisingAdapter is a Vamp plugin adapter that provides summarisation methods such as mean and median averages of output features, for use in any context where an available plugin produces individual values but the result that is actually needed is some sort of aggregate.
To make use of PluginSummarisingAdapter, the host should configure, initialise and run the plugin through the adapter interface just as normal. Then, after the process and getRemainingFeatures methods have been properly called and processing is complete, the host may call getSummaryForOutput or getSummaryForAllOutputs to obtain summarised features: averages, maximum values, etc, depending on the SummaryType passed to the function.
By default PluginSummarisingAdapter calculates a single summary of each output's feature across the whole duration of processed audio. A host needing summaries of sub-segments of the whole audio may call setSummarySegmentBoundaries before retrieving the summaries, providing a list of times such that one summary will be provided for each segment between two consecutive times.
PluginSummarisingAdapter is straightforward rather than fast. It calculates all of the summary types for all outputs always, and then returns only the ones that are requested. It is designed on the basis that, for most features, summarising and storing summarised results is far cheaper than calculating the results in the first place. If this is not true for your particular feature, PluginSummarisingAdapter may not be the best approach for you.
Definition at line 86 of file PluginSummarisingAdapter.h.
typedef std::set<RealTime> Vamp::HostExt::PluginSummarisingAdapter::SegmentBoundaries |
Definition at line 104 of file PluginSummarisingAdapter.h.
typedef std::vector<OutputDescriptor> Vamp::Plugin::OutputList [inherited] |
Definition at line 327 of file vamp-sdk/Plugin.h.
typedef std::vector<Feature> Vamp::Plugin::FeatureList [inherited] |
Definition at line 385 of file vamp-sdk/Plugin.h.
typedef std::map<int, FeatureList> Vamp::Plugin::FeatureSet [inherited] |
Definition at line 387 of file vamp-sdk/Plugin.h.
typedef std::vector<ParameterDescriptor> Vamp::PluginBase::ParameterList [inherited] |
Definition at line 203 of file vamp-sdk/PluginBase.h.
typedef std::vector<std::string> Vamp::PluginBase::ProgramList [inherited] |
Definition at line 225 of file vamp-sdk/PluginBase.h.
Minimum | |
Maximum | |
Mean | |
Median | |
Mode | |
Sum | |
Variance | |
StandardDeviation | |
Count | |
UnknownSummaryType |
Definition at line 121 of file PluginSummarisingAdapter.h.
AveragingMethod indicates how the adapter should handle average-based summaries of features whose results are not equally spaced in time.
If SampleAverage is specified, summary types based on averages will be calculated by treating each result individually without regard to its time: for example, the mean will be the sum of all values divided by the number of values.
If ContinuousTimeAverage is specified, each feature will be considered to have a duration, either as specified in the feature's duration field, or until the following feature: thus, for example, the mean will be the sum of the products of values and durations, divided by the total duration.
Although SampleAverage is useful for many types of feature, ContinuousTimeAverage is essential for some situations, for example finding the result that spans the largest proportion of the input given a feature that emits a new result only when the value changes (the modal value integrated over time).
Definition at line 157 of file PluginSummarisingAdapter.h.
enum Vamp::Plugin::InputDomain [inherited] |
Definition at line 152 of file vamp-sdk/Plugin.h.
Vamp::HostExt::PluginSummarisingAdapter::PluginSummarisingAdapter | ( | Plugin * | plugin | ) |
Construct a PluginSummarisingAdapter wrapping the given plugin.
The adapter takes ownership of the plugin, which will be deleted when the adapter is deleted.
virtual Vamp::HostExt::PluginSummarisingAdapter::~PluginSummarisingAdapter | ( | ) | [virtual] |
bool Vamp::HostExt::PluginSummarisingAdapter::initialise | ( | size_t | inputChannels, |
size_t | stepSize, | ||
size_t | blockSize | ||
) | [virtual] |
Initialise a plugin to prepare it for use with the given number of input channels, step size (window increment, in sample frames) and block size (window size, in sample frames).
The input sample rate should have been already specified at construction time.
Return true for successful initialisation, false if the number of input channels, step size and/or block size cannot be supported.
Reimplemented from Vamp::HostExt::PluginWrapper.
void Vamp::HostExt::PluginSummarisingAdapter::reset | ( | ) | [virtual] |
Reset the plugin after use, to prepare it for another clean run.
Not called for the first initialisation (i.e. initialise must also do a reset).
Reimplemented from Vamp::HostExt::PluginWrapper.
FeatureSet Vamp::HostExt::PluginSummarisingAdapter::process | ( | const float *const * | inputBuffers, |
RealTime | timestamp | ||
) | [virtual] |
Process a single block of input data.
If the plugin's inputDomain is TimeDomain, inputBuffers will point to one array of floats per input channel, and each of these arrays will contain blockSize consecutive audio samples (the host will zero-pad as necessary). The timestamp in this case will be the real time in seconds of the start of the supplied block of samples.
If the plugin's inputDomain is FrequencyDomain, inputBuffers will point to one array of floats per input channel, and each of these arrays will contain blockSize/2+1 consecutive pairs of real and imaginary component floats corresponding to bins 0..(blockSize/2) of the FFT output. That is, bin 0 (the first pair of floats) contains the DC output, up to bin blockSize/2 which contains the Nyquist-frequency output. There will therefore be blockSize+2 floats per channel in total. The timestamp will be the real time in seconds of the centre of the FFT input window (i.e. the very first block passed to process might contain the FFT of half a block of zero samples and the first half-block of the actual data, with a timestamp of zero).
Return any features that have become available after this process call. (These do not necessarily have to fall within the process block, except for OneSamplePerStep outputs.)
Reimplemented from Vamp::HostExt::PluginWrapper.
FeatureSet Vamp::HostExt::PluginSummarisingAdapter::getRemainingFeatures | ( | ) | [virtual] |
After all blocks have been processed, calculate and return any remaining features derived from the complete input.
Reimplemented from Vamp::HostExt::PluginWrapper.
void Vamp::HostExt::PluginSummarisingAdapter::setSummarySegmentBoundaries | ( | const SegmentBoundaries & | ) |
Specify a series of segment boundaries, such that one summary will be returned for each of the contiguous intra-boundary segments.
This function must be called before getSummaryForOutput or getSummaryForAllOutputs.
Note that you cannot retrieve results with multiple different segmentations by repeatedly calling this function followed by one of the getSummary functions. The summaries are all calculated at the first call to any getSummary function, and once the summaries have been calculated, they remain calculated.
FeatureList Vamp::HostExt::PluginSummarisingAdapter::getSummaryForOutput | ( | int | output, |
SummaryType | type, | ||
AveragingMethod | method = SampleAverage |
||
) |
Return summaries of the features that were returned on the given output, using the given SummaryType and AveragingMethod.
The plugin must have been fully run (process() and getRemainingFeatures() calls all made as appropriate) before this function is called.
FeatureSet Vamp::HostExt::PluginSummarisingAdapter::getSummaryForAllOutputs | ( | SummaryType | type, |
AveragingMethod | method = SampleAverage |
||
) |
Return summaries of the features that were returned on all of the plugin's outputs, using the given SummaryType and AveragingMethod.
The plugin must have been fully run (process() and getRemainingFeatures() calls all made as appropriate) before this function is called.
InputDomain Vamp::HostExt::PluginWrapper::getInputDomain | ( | ) | const [virtual, inherited] |
Get the plugin's required input domain.
If this is TimeDomain, the samples provided to the process() function (below) will be in the time domain, as for a traditional audio processing plugin.
If this is FrequencyDomain, the host will carry out a windowed FFT of size equal to the negotiated block size on the data before passing the frequency bin data in to process(). The input data for the FFT will be rotated so as to place the origin in the centre of the block. The plugin does not get to choose the window type -- the host will either let the user do so, or will use a Hanning window.
Implements Vamp::Plugin.
Reimplemented in Vamp::HostExt::PluginInputDomainAdapter.
unsigned int Vamp::HostExt::PluginWrapper::getVampApiVersion | ( | ) | const [virtual, inherited] |
Get the Vamp API compatibility level of the plugin.
Reimplemented from Vamp::PluginBase.
std::string Vamp::HostExt::PluginWrapper::getIdentifier | ( | ) | const [virtual, inherited] |
Get the computer-usable name of the plugin.
This should be reasonably short and contain no whitespace or punctuation characters. It may only contain the characters [a-zA-Z0-9_-]. This is the authoritative way for a program to identify a plugin within a given library.
This text may be visible to the user, but it should not be the main text used to identify a plugin to the user (that will be the name, below).
Example: "zero_crossings"
Implements Vamp::PluginBase.
std::string Vamp::HostExt::PluginWrapper::getName | ( | ) | const [virtual, inherited] |
Get a human-readable name or title of the plugin.
This should be brief and self-contained, as it may be used to identify the plugin to the user in isolation (i.e. without also showing the plugin's "identifier").
Example: "Zero Crossings"
Implements Vamp::PluginBase.
std::string Vamp::HostExt::PluginWrapper::getDescription | ( | ) | const [virtual, inherited] |
Get a human-readable description for the plugin, typically a line of text that may optionally be displayed in addition to the plugin's "name".
May be empty if the name has said it all already.
Example: "Detect and count zero crossing points"
Implements Vamp::PluginBase.
std::string Vamp::HostExt::PluginWrapper::getMaker | ( | ) | const [virtual, inherited] |
Get the name of the author or vendor of the plugin in human-readable form.
This should be a short identifying text, as it may be used to label plugins from the same source in a menu or similar.
Implements Vamp::PluginBase.
int Vamp::HostExt::PluginWrapper::getPluginVersion | ( | ) | const [virtual, inherited] |
Get the version number of the plugin.
Implements Vamp::PluginBase.
std::string Vamp::HostExt::PluginWrapper::getCopyright | ( | ) | const [virtual, inherited] |
Get the copyright statement or licensing summary for the plugin.
This can be an informative text, without the same presentation constraints as mentioned for getMaker above.
Implements Vamp::PluginBase.
ParameterList Vamp::HostExt::PluginWrapper::getParameterDescriptors | ( | ) | const [virtual, inherited] |
Get the controllable parameters of this plugin.
Reimplemented from Vamp::PluginBase.
float Vamp::HostExt::PluginWrapper::getParameter | ( | std::string | ) | const [virtual, inherited] |
Get the value of a named parameter.
The argument is the identifier field from that parameter's descriptor.
Reimplemented from Vamp::PluginBase.
void Vamp::HostExt::PluginWrapper::setParameter | ( | std::string | , |
float | |||
) | [virtual, inherited] |
Set a named parameter.
The first argument is the identifier field from that parameter's descriptor.
Reimplemented from Vamp::PluginBase.
Reimplemented in Vamp::HostExt::PluginBufferingAdapter.
ProgramList Vamp::HostExt::PluginWrapper::getPrograms | ( | ) | const [virtual, inherited] |
Get the program settings available in this plugin.
A program is a named shorthand for a set of parameter values; changing the program may cause the plugin to alter the values of its published parameters (and/or non-public internal processing parameters). The host should re-read the plugin's parameter values after setting a new program.
The programs must have unique names.
Reimplemented from Vamp::PluginBase.
std::string Vamp::HostExt::PluginWrapper::getCurrentProgram | ( | ) | const [virtual, inherited] |
Get the current program.
Reimplemented from Vamp::PluginBase.
void Vamp::HostExt::PluginWrapper::selectProgram | ( | std::string | ) | [virtual, inherited] |
Select a program.
(If the given program name is not one of the available programs, do nothing.)
Reimplemented from Vamp::PluginBase.
Reimplemented in Vamp::HostExt::PluginBufferingAdapter.
size_t Vamp::HostExt::PluginWrapper::getPreferredStepSize | ( | ) | const [virtual, inherited] |
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 be called before initialise().
A plugin may return 0 if it has no particular interest in the step size. In this case, the host should make the step size equal to the block size if the plugin is accepting input in the time domain. If the plugin is accepting input in the frequency domain, the host may use any step size. The final step size will be set in the initialise() call.
Reimplemented from Vamp::Plugin.
Reimplemented in Vamp::HostExt::PluginInputDomainAdapter, and Vamp::HostExt::PluginBufferingAdapter.
size_t Vamp::HostExt::PluginWrapper::getPreferredBlockSize | ( | ) | const [virtual, inherited] |
Get the preferred block size (window size -- the number of sample frames passed in each block to the process() function).
This should be called before initialise().
A plugin that can handle any block size may return 0. The final block size will be set in the initialise() call.
Reimplemented from Vamp::Plugin.
Reimplemented in Vamp::HostExt::PluginBufferingAdapter, and Vamp::HostExt::PluginInputDomainAdapter.
size_t Vamp::HostExt::PluginWrapper::getMinChannelCount | ( | ) | const [virtual, inherited] |
Get the minimum supported number of input channels.
Reimplemented from Vamp::Plugin.
size_t Vamp::HostExt::PluginWrapper::getMaxChannelCount | ( | ) | const [virtual, inherited] |
Get the maximum supported number of input channels.
Reimplemented from Vamp::Plugin.
OutputList Vamp::HostExt::PluginWrapper::getOutputDescriptors | ( | ) | const [virtual, inherited] |
Get the outputs of this plugin.
An output's index in this list is used as its numeric index when looking it up in the FeatureSet returned from the process() call.
Implements Vamp::Plugin.
Reimplemented in Vamp::HostExt::PluginBufferingAdapter.
WrapperType* Vamp::HostExt::PluginWrapper::getWrapper | ( | ) | [inline, inherited] |
Return a pointer to the plugin wrapper of type WrapperType surrounding this wrapper's plugin, if present.
This is useful in situations where a plugin is wrapped by multiple different wrappers (one inside another) and the host wants to call some wrapper-specific function on one of the layers without having to care about the order in which they are wrapped. For example, the plugin returned by PluginLoader::loadPlugin may have more than one wrapper; if the host wanted to query or fine-tune some property of one of them, it would be hard to do so without knowing the order of the wrappers. This function therefore gives direct access to the wrapper of a particular type.
Definition at line 116 of file PluginWrapper.h.
References Vamp::HostExt::PluginWrapper::getWrapper().
Referenced by Vamp::HostExt::PluginWrapper::getWrapper(), and runPlugin().
virtual std::string Vamp::Plugin::getType | ( | ) | const [inline, virtual, inherited] |
Used to distinguish between Vamp::Plugin and other potential sibling subclasses of PluginBase.
Do not reimplement this function in your subclass.
Implements Vamp::PluginBase.
Definition at line 430 of file vamp-sdk/Plugin.h.
Impl* Vamp::HostExt::PluginSummarisingAdapter::m_impl [protected] |
Definition at line 187 of file PluginSummarisingAdapter.h.
Plugin* Vamp::HostExt::PluginWrapper::m_plugin [protected, inherited] |
Definition at line 126 of file PluginWrapper.h.
float Vamp::Plugin::m_inputSampleRate [protected, inherited] |
Definition at line 436 of file vamp-sdk/Plugin.h.
Referenced by FixedTempoEstimator::D::assembleFeatures(), FixedTempoEstimator::D::calculate(), FixedTempoEstimator::D::getOutputDescriptors(), ZeroCrossing::getOutputDescriptors(), PercussionOnsetDetector::getOutputDescriptors(), AmplitudeFollower::initialise(), FixedTempoEstimator::D::initialise(), FixedTempoEstimator::D::lag2tempo(), ZeroCrossing::process(), SpectralCentroid::process(), PercussionOnsetDetector::process(), and FixedTempoEstimator::D::tempo2lag().