VampPluginSDK 2.10
|
Vamp::Plugin is a base class for plugin instance classes that provide feature extraction from audio or related data. More...
#include <vamp-sdk/Plugin.h>
Classes | |
struct | Feature |
struct | OutputDescriptor |
Public Types | |
enum | InputDomain { TimeDomain , FrequencyDomain } |
typedef std::vector< OutputDescriptor > | OutputList |
typedef std::vector< Feature > | FeatureList |
typedef std::map< int, FeatureList > | FeatureSet |
Public Member Functions | |
virtual | ~Plugin () |
virtual bool | initialise (size_t inputChannels, size_t stepSize, size_t blockSize)=0 |
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). | |
virtual void | reset ()=0 |
Reset the plugin after use, to prepare it for another clean run. | |
virtual InputDomain | getInputDomain () const=0 |
Get the plugin's required input domain. | |
virtual size_t | getPreferredBlockSize () const |
Get the preferred block size (window size – the number of sample frames passed in each block to the process() function). | |
virtual 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. | |
virtual size_t | getMinChannelCount () const |
Get the minimum supported number of input channels. | |
virtual size_t | getMaxChannelCount () const |
Get the maximum supported number of input channels. | |
virtual OutputList | getOutputDescriptors () const=0 |
Get the outputs of this plugin. | |
virtual FeatureSet | process (const float *const *inputBuffers, RealTime timestamp)=0 |
Process a single block of input data. | |
virtual FeatureSet | getRemainingFeatures ()=0 |
After all blocks have been processed, calculate and return any remaining features derived from the complete input. | |
virtual std::string | getType () const |
Used to distinguish between Vamp::Plugin and other potential sibling subclasses of PluginBase. | |
float | getInputSampleRate () const |
Retrieve the input sample rate set on construction. | |
Protected Member Functions | |
Plugin (float inputSampleRate) | |
Protected Attributes | |
float | m_inputSampleRate |
Vamp::Plugin is a base class for plugin instance classes that provide feature extraction from audio or related data.
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 PluginBase. These must be implemented by the subclass.
PLUGIN LIFECYCLE
Feature extraction plugins are managed differently from real-time plugins (such as VST effects). The main difference is that the parameters for a feature extraction plugin are configured before the plugin is used, and do not change during use.
A plugin does not need to handle the case where setParameter or selectProgram is called after initialise has been called. It's the host's responsibility not to do that. Similarly, the plugin may safely assume that initialise is called no more than once.
Definition at line 124 of file vamp-sdk/Plugin.h.
typedef std::vector<OutputDescriptor> Vamp::Plugin::OutputList |
Definition at line 335 of file vamp-sdk/Plugin.h.
typedef std::vector<Feature> Vamp::Plugin::FeatureList |
Definition at line 393 of file vamp-sdk/Plugin.h.
typedef std::map<int, FeatureList> Vamp::Plugin::FeatureSet |
Definition at line 395 of file vamp-sdk/Plugin.h.
Enumerator | |
---|---|
TimeDomain | |
FrequencyDomain |
Definition at line 152 of file vamp-sdk/Plugin.h.
|
inlinevirtual |
Definition at line 127 of file vamp-sdk/Plugin.h.
|
inlineprotected |
Definition at line 446 of file vamp-sdk/Plugin.h.
|
pure 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.
|
pure 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).
|
pure virtual |
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.
|
inlinevirtual |
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.
Definition at line 179 of file vamp-sdk/Plugin.h.
|
inlinevirtual |
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.
Definition at line 194 of file vamp-sdk/Plugin.h.
|
inlinevirtual |
Get the minimum supported number of input channels.
Definition at line 199 of file vamp-sdk/Plugin.h.
|
inlinevirtual |
Get the maximum supported number of input channels.
Definition at line 204 of file vamp-sdk/Plugin.h.
|
pure virtual |
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.
|
pure 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.)
|
pure virtual |
After all blocks have been processed, calculate and return any remaining features derived from the complete input.
|
inlinevirtual |
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 438 of file vamp-sdk/Plugin.h.
|
inline |
Retrieve the input sample rate set on construction.
Definition at line 443 of file vamp-sdk/Plugin.h.
|
protected |
Definition at line 449 of file vamp-sdk/Plugin.h.