annotate win32-mingw/include/vamp-hostsdk/PluginBufferingAdapter.h @ 14:48209aa7aa51

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