annotate src/vamp-plugin-sdk-2.4/vamp-hostsdk/PluginBufferingAdapter.h @ 83:ae30d91d2ffe

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