VampPluginSDK
2.10
|
PluginBufferingAdapter is a Vamp plugin adapter that allows plugins to be used by a host supplying an audio stream in non-overlapping buffers of arbitrary size. More...
#include <vamp-hostsdk/PluginBufferingAdapter.h>
Public Types | |
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 | |
PluginBufferingAdapter (Plugin *plugin) | |
Construct a PluginBufferingAdapter wrapping the given plugin. More... | |
virtual | ~PluginBufferingAdapter () |
size_t | getPreferredStepSize () const |
Return the preferred step size for this adapter. More... | |
size_t | getPreferredBlockSize () const |
Return the preferred block size for this adapter. More... | |
bool | initialise (size_t channels, size_t stepSize, size_t blockSize) |
Initialise the adapter (and therefore the plugin) for the given number of channels. More... | |
size_t | getPluginPreferredStepSize () const |
Return the preferred step size of the plugin wrapped by this adapter. More... | |
size_t | getPluginPreferredBlockSize () const |
Return the preferred block size of the plugin wrapped by this adapter. More... | |
void | setPluginStepSize (size_t stepSize) |
Set the step size that will be used for the underlying plugin when initialise() is called. More... | |
void | setPluginBlockSize (size_t blockSize) |
Set the block size that will be used for the underlying plugin when initialise() is called. More... | |
void | getActualStepAndBlockSizes (size_t &stepSize, size_t &blockSize) |
Return the step and block sizes that were actually used when initialising the underlying plugin. More... | |
void | setParameter (std::string, float) |
Set a named parameter. More... | |
void | selectProgram (std::string) |
Select a program. More... | |
OutputList | getOutputDescriptors () const |
Get the outputs of this plugin. More... | |
void | reset () |
Reset the plugin after use, to prepare it for another clean run. More... | |
FeatureSet | process (const float *const *inputBuffers, RealTime timestamp) |
Process a single block of input data. More... | |
FeatureSet | getRemainingFeatures () |
After all blocks have been processed, calculate and return any remaining features derived from the complete input. More... | |
InputDomain | getInputDomain () const |
Get the plugin's required input domain. More... | |
unsigned int | getVampApiVersion () const |
Get the Vamp API compatibility level of the plugin. More... | |
std::string | getIdentifier () const |
Get the computer-usable name of the plugin. More... | |
std::string | getName () const |
Get a human-readable name or title of the plugin. More... | |
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". More... | |
std::string | getMaker () const |
Get the name of the author or vendor of the plugin in human-readable form. More... | |
int | getPluginVersion () const |
Get the version number of the plugin. More... | |
std::string | getCopyright () const |
Get the copyright statement or licensing summary for the plugin. More... | |
ParameterList | getParameterDescriptors () const |
Get the controllable parameters of this plugin. More... | |
float | getParameter (std::string) const |
Get the value of a named parameter. More... | |
ProgramList | getPrograms () const |
Get the program settings available in this plugin. More... | |
std::string | getCurrentProgram () const |
Get the current program. More... | |
size_t | getMinChannelCount () const |
Get the minimum supported number of input channels. More... | |
size_t | getMaxChannelCount () const |
Get the maximum supported number of input channels. More... | |
template<typename WrapperType > | |
WrapperType * | getWrapper () |
Return a pointer to the plugin wrapper of type WrapperType surrounding this wrapper's plugin, if present. More... | |
void | disownPlugin () |
Disown the wrapped plugin, so that we no longer delete it on our own destruction. More... | |
virtual std::string | getType () const |
Used to distinguish between Vamp::Plugin and other potential sibling subclasses of PluginBase. More... | |
float | getInputSampleRate () const |
Retrieve the input sample rate set on construction. More... | |
Protected Attributes | |
Impl * | m_impl |
Plugin * | m_plugin |
bool | m_pluginIsOwned |
float | m_inputSampleRate |
Detailed Description
PluginBufferingAdapter is a Vamp plugin adapter that allows plugins to be used by a host supplying an audio stream in non-overlapping buffers of arbitrary size.
A host using PluginBufferingAdapter may ignore the preferred step and block size reported by the plugin, and still expect the plugin to run. The value of blockSize and stepSize passed to initialise should be the size of the buffer which the host will supply; the stepSize should be equal to the blockSize.
If the internal step size used for the plugin differs from that supplied by the host, the adapter will modify the sample type and rate specifications for the plugin outputs appropriately, and set timestamps on the output features for outputs that formerly used a different sample rate specification. This is necessary in order to obtain correct time stamping.
In other respects, the PluginBufferingAdapter behaves identically to the plugin that it wraps. The wrapped plugin will be deleted when the wrapper is deleted. If you wish to prevent this, call disownPlugin().
Definition at line 76 of file PluginBufferingAdapter.h.
Member Typedef Documentation
|
inherited |
Definition at line 335 of file vamp-sdk/Plugin.h.
|
inherited |
Definition at line 393 of file vamp-sdk/Plugin.h.
|
inherited |
Definition at line 395 of file vamp-sdk/Plugin.h.
|
inherited |
Definition at line 203 of file vamp-sdk/PluginBase.h.
|
inherited |
Definition at line 225 of file vamp-sdk/PluginBase.h.
Member Enumeration Documentation
|
inherited |
Enumerator | |
---|---|
TimeDomain | |
FrequencyDomain |
Definition at line 152 of file vamp-sdk/Plugin.h.
Constructor & Destructor Documentation
Vamp::HostExt::PluginBufferingAdapter::PluginBufferingAdapter | ( | Plugin * | plugin | ) |
Construct a PluginBufferingAdapter wrapping the given plugin.
The adapter takes ownership of the plugin, which will be deleted when the adapter is deleted. If you wish to prevent this, call disownPlugin().
|
virtual |
Member Function Documentation
|
virtual |
Return the preferred step size for this adapter.
Because of the way this adapter works, its preferred step size will always be the same as its preferred block size. This may or may not be the same as the preferred step size of the underlying plugin, which may be obtained by calling getPluginPreferredStepSize().
Reimplemented from Vamp::Plugin.
|
virtual |
Return the preferred block size for this adapter.
This may or may not be the same as the preferred block size of the underlying plugin, which may be obtained by calling getPluginPreferredBlockSize().
Note that this adapter may be initialised with any block size, not just its supposedly preferred one.
Reimplemented from Vamp::Plugin.
|
virtual |
Initialise the adapter (and therefore the plugin) for the given number of channels.
Initialise the adapter for the given step and block size, which must be equal.
The step and block size used for the underlying plugin will depend on its preferences, or any values previously passed to setPluginStepSize and setPluginBlockSize.
Implements Vamp::Plugin.
size_t Vamp::HostExt::PluginBufferingAdapter::getPluginPreferredStepSize | ( | ) | const |
Return the preferred step size of the plugin wrapped by this adapter.
This is included mainly for informational purposes. This value is not likely to be a valid step size for the adapter itself, and it is not usually of any use in interpreting the results (because the adapter re-writes OneSamplePerStep outputs to FixedSampleRate so that the hop size no longer needs to be known beforehand in order to interpret them).
size_t Vamp::HostExt::PluginBufferingAdapter::getPluginPreferredBlockSize | ( | ) | const |
Return the preferred block size of the plugin wrapped by this adapter.
This is included mainly for informational purposes.
void Vamp::HostExt::PluginBufferingAdapter::setPluginStepSize | ( | size_t | stepSize | ) |
Set the step size that will be used for the underlying plugin when initialise() is called.
If this is not set, the plugin's own preferred step size will be used. You will not usually need to call this function. If you do call it, it must be before the first call to initialise().
void Vamp::HostExt::PluginBufferingAdapter::setPluginBlockSize | ( | size_t | blockSize | ) |
Set the block size that will be used for the underlying plugin when initialise() is called.
If this is not set, the plugin's own preferred block size will be used. You will not usually need to call this function. If you do call it, it must be before the first call to initialise().
void Vamp::HostExt::PluginBufferingAdapter::getActualStepAndBlockSizes | ( | size_t & | stepSize, |
size_t & | blockSize | ||
) |
Return the step and block sizes that were actually used when initialising the underlying plugin.
This is included mainly for informational purposes. You will not usually need to call this function. If this is called before initialise(), it will return 0 for both values. If it is called after a failed call to initialise(), it will return the values that were used in the failed call to the plugin's initialise() function.
|
virtual |
Set a named parameter.
The first argument is the identifier field from that parameter's descriptor.
Reimplemented from Vamp::PluginBase.
|
virtual |
Select a program.
(If the given program name is not one of the available programs, do nothing.)
Reimplemented from Vamp::PluginBase.
|
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.
Implements Vamp::Plugin.
|
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).
Implements Vamp::Plugin.
|
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.)
Implements Vamp::Plugin.
|
virtual |
After all blocks have been processed, calculate and return any remaining features derived from the complete input.
Implements Vamp::Plugin.
|
virtualinherited |
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.
|
virtualinherited |
Get the Vamp API compatibility level of the plugin.
Reimplemented from Vamp::PluginBase.
|
virtualinherited |
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.
|
virtualinherited |
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.
|
virtualinherited |
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.
|
virtualinherited |
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.
|
virtualinherited |
Get the version number of the plugin.
Implements Vamp::PluginBase.
|
virtualinherited |
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.
|
virtualinherited |
Get the controllable parameters of this plugin.
Reimplemented from Vamp::PluginBase.
|
virtualinherited |
Get the value of a named parameter.
The argument is the identifier field from that parameter's descriptor.
Reimplemented from Vamp::PluginBase.
|
virtualinherited |
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.
|
virtualinherited |
Get the current program.
Reimplemented from Vamp::PluginBase.
|
virtualinherited |
Get the minimum supported number of input channels.
Reimplemented from Vamp::Plugin.
|
virtualinherited |
Get the maximum supported number of input channels.
Reimplemented from Vamp::Plugin.
|
inlineinherited |
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 119 of file PluginWrapper.h.
References Vamp::HostExt::PluginWrapper::getWrapper().
Referenced by Vamp::HostExt::PluginWrapper::getWrapper(), and runPlugin().
|
inherited |
Disown the wrapped plugin, so that we no longer delete it on our own destruction.
The identity of the wrapped plugin is unchanged, but this switches the expectation about ownership so that the caller is expected to handle the lifecycle of the wrapped plugin and to ensure that it outlasts this wrapper.
This is not the normal model, but could be useful in situations where a plugin is already managed using a smart pointer model before being adapted into this wrapper. Note that this can't be reversed - if you call this, you must subsequently take charge of the wrapped plugin yourself.
|
inlinevirtualinherited |
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.
|
inlineinherited |
Retrieve the input sample rate set on construction.
Definition at line 443 of file vamp-sdk/Plugin.h.
Member Data Documentation
|
protected |
Definition at line 186 of file PluginBufferingAdapter.h.
|
protectedinherited |
Definition at line 144 of file PluginWrapper.h.
|
protectedinherited |
Definition at line 145 of file PluginWrapper.h.
|
protectedinherited |
Definition at line 449 of file vamp-sdk/Plugin.h.
Referenced by ZeroCrossing::getOutputDescriptors(), PercussionOnsetDetector::getOutputDescriptors(), AmplitudeFollower::initialise(), SpectralCentroid::process(), ZeroCrossing::process(), and PercussionOnsetDetector::process().
The documentation for this class was generated from the following file:
Generated by 1.8.11