annotate osx/include/vamp-hostsdk/PluginBufferingAdapter.h @ 36:55ece8862b6d

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