To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / vamp-hostsdk / PluginBufferingAdapter.h @ 538:8ffb8985ae8f
History | View | Annotate | Download (7.18 KB)
| 1 |
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
|---|---|
| 2 |
|
| 3 |
/*
|
| 4 |
Vamp
|
| 5 |
|
| 6 |
An API for audio analysis and feature extraction plugins.
|
| 7 |
|
| 8 |
Centre for Digital Music, Queen Mary, University of London.
|
| 9 |
Copyright 2006-2009 Chris Cannam and QMUL.
|
| 10 |
This file by Mark Levy and Chris Cannam, Copyright 2007-2008 QMUL.
|
| 11 |
|
| 12 |
Permission is hereby granted, free of charge, to any person
|
| 13 |
obtaining a copy of this software and associated documentation
|
| 14 |
files (the "Software"), to deal in the Software without
|
| 15 |
restriction, including without limitation the rights to use, copy,
|
| 16 |
modify, merge, publish, distribute, sublicense, and/or sell copies
|
| 17 |
of the Software, and to permit persons to whom the Software is
|
| 18 |
furnished to do so, subject to the following conditions:
|
| 19 |
|
| 20 |
The above copyright notice and this permission notice shall be
|
| 21 |
included in all copies or substantial portions of the Software.
|
| 22 |
|
| 23 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 24 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 25 |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 26 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
|
| 27 |
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
| 28 |
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
| 29 |
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 30 |
|
| 31 |
Except as contained in this notice, the names of the Centre for
|
| 32 |
Digital Music; Queen Mary, University of London; and Chris Cannam
|
| 33 |
shall not be used in advertising or otherwise to promote the sale,
|
| 34 |
use or other dealings in this Software without prior written
|
| 35 |
authorization.
|
| 36 |
*/
|
| 37 |
|
| 38 |
#ifndef _VAMP_PLUGIN_BUFFERING_ADAPTER_H_
|
| 39 |
#define _VAMP_PLUGIN_BUFFERING_ADAPTER_H_
|
| 40 |
|
| 41 |
#include "hostguard.h" |
| 42 |
#include "PluginWrapper.h" |
| 43 |
|
| 44 |
_VAMP_SDK_HOSTSPACE_BEGIN(PluginBufferingAdapter.h) |
| 45 |
|
| 46 |
namespace Vamp {
|
| 47 |
|
| 48 |
namespace HostExt {
|
| 49 |
|
| 50 |
/**
|
| 51 |
* \class PluginBufferingAdapter PluginBufferingAdapter.h <vamp-hostsdk/PluginBufferingAdapter.h>
|
| 52 |
*
|
| 53 |
* PluginBufferingAdapter is a Vamp plugin adapter that allows plugins
|
| 54 |
* to be used by a host supplying an audio stream in non-overlapping
|
| 55 |
* buffers of arbitrary size.
|
| 56 |
*
|
| 57 |
* A host using PluginBufferingAdapter may ignore the preferred step
|
| 58 |
* and block size reported by the plugin, and still expect the plugin
|
| 59 |
* to run. The value of blockSize and stepSize passed to initialise
|
| 60 |
* should be the size of the buffer which the host will supply; the
|
| 61 |
* stepSize should be equal to the blockSize.
|
| 62 |
*
|
| 63 |
* If the internal step size used for the plugin differs from that
|
| 64 |
* supplied by the host, the adapter will modify the sample type and
|
| 65 |
* rate specifications for the plugin outputs appropriately, and set
|
| 66 |
* timestamps on the output features for outputs that formerly used a
|
| 67 |
* different sample rate specification. This is necessary in order to
|
| 68 |
* obtain correct time stamping.
|
| 69 |
*
|
| 70 |
* In other respects, the PluginBufferingAdapter behaves identically
|
| 71 |
* to the plugin that it wraps. The wrapped plugin will be deleted
|
| 72 |
* when the wrapper is deleted. If you wish to prevent this, call
|
| 73 |
* disownPlugin().
|
| 74 |
*/
|
| 75 |
|
| 76 |
class PluginBufferingAdapter : public PluginWrapper |
| 77 |
{
|
| 78 |
public:
|
| 79 |
/**
|
| 80 |
* Construct a PluginBufferingAdapter wrapping the given plugin.
|
| 81 |
* The adapter takes ownership of the plugin, which will be
|
| 82 |
* deleted when the adapter is deleted. If you wish to prevent
|
| 83 |
* this, call disownPlugin().
|
| 84 |
*/
|
| 85 |
PluginBufferingAdapter(Plugin *plugin); |
| 86 |
virtual ~PluginBufferingAdapter(); |
| 87 |
|
| 88 |
/**
|
| 89 |
* Return the preferred step size for this adapter.
|
| 90 |
*
|
| 91 |
* Because of the way this adapter works, its preferred step size
|
| 92 |
* will always be the same as its preferred block size. This may
|
| 93 |
* or may not be the same as the preferred step size of the
|
| 94 |
* underlying plugin, which may be obtained by calling
|
| 95 |
* getPluginPreferredStepSize().
|
| 96 |
*/
|
| 97 |
size_t getPreferredStepSize() const;
|
| 98 |
|
| 99 |
/**
|
| 100 |
* Return the preferred block size for this adapter.
|
| 101 |
*
|
| 102 |
* This may or may not be the same as the preferred block size of
|
| 103 |
* the underlying plugin, which may be obtained by calling
|
| 104 |
* getPluginPreferredBlockSize().
|
| 105 |
*
|
| 106 |
* Note that this adapter may be initialised with any block size,
|
| 107 |
* not just its supposedly preferred one.
|
| 108 |
*/
|
| 109 |
size_t getPreferredBlockSize() const;
|
| 110 |
|
| 111 |
/**
|
| 112 |
* Initialise the adapter (and therefore the plugin) for the given
|
| 113 |
* number of channels. Initialise the adapter for the given step
|
| 114 |
* and block size, which must be equal.
|
| 115 |
*
|
| 116 |
* The step and block size used for the underlying plugin will
|
| 117 |
* depend on its preferences, or any values previously passed to
|
| 118 |
* setPluginStepSize and setPluginBlockSize.
|
| 119 |
*/
|
| 120 |
bool initialise(size_t channels, size_t stepSize, size_t blockSize);
|
| 121 |
|
| 122 |
/**
|
| 123 |
* Return the preferred step size of the plugin wrapped by this
|
| 124 |
* adapter.
|
| 125 |
*
|
| 126 |
* This is included mainly for informational purposes. This value
|
| 127 |
* is not likely to be a valid step size for the adapter itself,
|
| 128 |
* and it is not usually of any use in interpreting the results
|
| 129 |
* (because the adapter re-writes OneSamplePerStep outputs to
|
| 130 |
* FixedSampleRate so that the hop size no longer needs to be
|
| 131 |
* known beforehand in order to interpret them).
|
| 132 |
*/
|
| 133 |
size_t getPluginPreferredStepSize() const;
|
| 134 |
|
| 135 |
/**
|
| 136 |
* Return the preferred block size of the plugin wrapped by this
|
| 137 |
* adapter.
|
| 138 |
*
|
| 139 |
* This is included mainly for informational purposes.
|
| 140 |
*/
|
| 141 |
size_t getPluginPreferredBlockSize() const;
|
| 142 |
|
| 143 |
/**
|
| 144 |
* Set the step size that will be used for the underlying plugin
|
| 145 |
* when initialise() is called. If this is not set, the plugin's
|
| 146 |
* own preferred step size will be used. You will not usually
|
| 147 |
* need to call this function. If you do call it, it must be
|
| 148 |
* before the first call to initialise().
|
| 149 |
*/
|
| 150 |
void setPluginStepSize(size_t stepSize);
|
| 151 |
|
| 152 |
/**
|
| 153 |
* Set the block size that will be used for the underlying plugin
|
| 154 |
* when initialise() is called. If this is not set, the plugin's
|
| 155 |
* own preferred block size will be used. You will not usually
|
| 156 |
* need to call this function. If you do call it, it must be
|
| 157 |
* before the first call to initialise().
|
| 158 |
*/
|
| 159 |
void setPluginBlockSize(size_t blockSize);
|
| 160 |
|
| 161 |
/**
|
| 162 |
* Return the step and block sizes that were actually used when
|
| 163 |
* initialising the underlying plugin.
|
| 164 |
*
|
| 165 |
* This is included mainly for informational purposes. You will
|
| 166 |
* not usually need to call this function. If this is called
|
| 167 |
* before initialise(), it will return 0 for both values. If it
|
| 168 |
* is called after a failed call to initialise(), it will return
|
| 169 |
* the values that were used in the failed call to the plugin's
|
| 170 |
* initialise() function.
|
| 171 |
*/
|
| 172 |
void getActualStepAndBlockSizes(size_t &stepSize, size_t &blockSize);
|
| 173 |
|
| 174 |
void setParameter(std::string, float); |
| 175 |
void selectProgram(std::string);
|
| 176 |
|
| 177 |
OutputList getOutputDescriptors() const;
|
| 178 |
|
| 179 |
void reset();
|
| 180 |
|
| 181 |
FeatureSet process(const float *const *inputBuffers, RealTime timestamp); |
| 182 |
|
| 183 |
FeatureSet getRemainingFeatures(); |
| 184 |
|
| 185 |
protected:
|
| 186 |
class Impl; |
| 187 |
Impl *m_impl; |
| 188 |
}; |
| 189 |
|
| 190 |
} |
| 191 |
|
| 192 |
} |
| 193 |
|
| 194 |
_VAMP_SDK_HOSTSPACE_END(PluginBufferingAdapter.h) |
| 195 |
|
| 196 |
#endif
|