annotate src/vamp-plugin-sdk-2.4/vamp-hostsdk/PluginInputDomainAdapter.h @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents efb4b8187266
children
rev   line source
cannam@97 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
cannam@97 2
cannam@97 3 /*
cannam@97 4 Vamp
cannam@97 5
cannam@97 6 An API for audio analysis and feature extraction plugins.
cannam@97 7
cannam@97 8 Centre for Digital Music, Queen Mary, University of London.
cannam@97 9 Copyright 2006-2009 Chris Cannam and QMUL.
cannam@97 10
cannam@97 11 Permission is hereby granted, free of charge, to any person
cannam@97 12 obtaining a copy of this software and associated documentation
cannam@97 13 files (the "Software"), to deal in the Software without
cannam@97 14 restriction, including without limitation the rights to use, copy,
cannam@97 15 modify, merge, publish, distribute, sublicense, and/or sell copies
cannam@97 16 of the Software, and to permit persons to whom the Software is
cannam@97 17 furnished to do so, subject to the following conditions:
cannam@97 18
cannam@97 19 The above copyright notice and this permission notice shall be
cannam@97 20 included in all copies or substantial portions of the Software.
cannam@97 21
cannam@97 22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
cannam@97 23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
cannam@97 24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
cannam@97 25 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
cannam@97 26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
cannam@97 27 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
cannam@97 28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
cannam@97 29
cannam@97 30 Except as contained in this notice, the names of the Centre for
cannam@97 31 Digital Music; Queen Mary, University of London; and Chris Cannam
cannam@97 32 shall not be used in advertising or otherwise to promote the sale,
cannam@97 33 use or other dealings in this Software without prior written
cannam@97 34 authorization.
cannam@97 35 */
cannam@97 36
cannam@97 37 #ifndef _VAMP_PLUGIN_INPUT_DOMAIN_ADAPTER_H_
cannam@97 38 #define _VAMP_PLUGIN_INPUT_DOMAIN_ADAPTER_H_
cannam@97 39
cannam@97 40 #include "hostguard.h"
cannam@97 41 #include "PluginWrapper.h"
cannam@97 42
cannam@97 43 _VAMP_SDK_HOSTSPACE_BEGIN(PluginInputDomainAdapter.h)
cannam@97 44
cannam@97 45 namespace Vamp {
cannam@97 46
cannam@97 47 namespace HostExt {
cannam@97 48
cannam@97 49 /**
cannam@97 50 * \class PluginInputDomainAdapter PluginInputDomainAdapter.h <vamp-hostsdk/PluginInputDomainAdapter.h>
cannam@97 51 *
cannam@97 52 * PluginInputDomainAdapter is a Vamp plugin adapter that converts
cannam@97 53 * time-domain input into frequency-domain input for plugins that need
cannam@97 54 * it. This permits a host to use time- and frequency-domain plugins
cannam@97 55 * interchangeably without needing to handle the conversion itself.
cannam@97 56 *
cannam@97 57 * This adapter uses a basic windowed FFT (using Hann window by
cannam@97 58 * default) that supports power-of-two block sizes only. If a
cannam@97 59 * frequency domain plugin requests a non-power-of-two blocksize, the
cannam@97 60 * adapter will adjust it to a nearby power of two instead. Thus,
cannam@97 61 * getPreferredBlockSize() will always return a power of two if the
cannam@97 62 * wrapped plugin is a frequency domain one. If the plugin doesn't
cannam@97 63 * accept the adjusted power of two block size, initialise() will
cannam@97 64 * fail.
cannam@97 65 *
cannam@97 66 * The adapter provides no way for the host to discover whether the
cannam@97 67 * underlying plugin is actually a time or frequency domain plugin
cannam@97 68 * (except that if the preferred block size is not a power of two, it
cannam@97 69 * must be a time domain plugin).
cannam@97 70 *
cannam@97 71 * The FFT implementation is simple and self-contained, but unlikely
cannam@97 72 * to be the fastest available: a host can usually do better if it
cannam@97 73 * cares enough.
cannam@97 74 *
cannam@97 75 * The window shape for the FFT frame can be set using setWindowType
cannam@97 76 * and the current shape retrieved using getWindowType. (This was
cannam@97 77 * added in v2.3 of the SDK.)
cannam@97 78 *
cannam@97 79 * In every respect other than its input domain handling, the
cannam@97 80 * PluginInputDomainAdapter behaves identically to the plugin that it
cannam@97 81 * wraps. The wrapped plugin will be deleted when the wrapper is
cannam@97 82 * deleted.
cannam@97 83 *
cannam@97 84 * \note This class was introduced in version 1.1 of the Vamp plugin SDK.
cannam@97 85 */
cannam@97 86
cannam@97 87 class PluginInputDomainAdapter : public PluginWrapper
cannam@97 88 {
cannam@97 89 public:
cannam@97 90 /**
cannam@97 91 * Construct a PluginInputDomainAdapter wrapping the given plugin.
cannam@97 92 * The adapter takes ownership of the plugin, which will be
cannam@97 93 * deleted when the adapter is deleted.
cannam@97 94 */
cannam@97 95 PluginInputDomainAdapter(Plugin *plugin);
cannam@97 96 virtual ~PluginInputDomainAdapter();
cannam@97 97
cannam@97 98 bool initialise(size_t channels, size_t stepSize, size_t blockSize);
cannam@97 99 void reset();
cannam@97 100
cannam@97 101 InputDomain getInputDomain() const;
cannam@97 102
cannam@97 103 size_t getPreferredStepSize() const;
cannam@97 104 size_t getPreferredBlockSize() const;
cannam@97 105
cannam@97 106 FeatureSet process(const float *const *inputBuffers, RealTime timestamp);
cannam@97 107
cannam@97 108 /**
cannam@97 109 * ProcessTimestampMethod determines how the
cannam@97 110 * PluginInputDomainAdapter handles timestamps for the data passed
cannam@97 111 * to the process() function of the plugin it wraps, in the case
cannam@97 112 * where the plugin is expecting frequency-domain data.
cannam@97 113 *
cannam@97 114 * The Vamp specification requires that the timestamp passed to
cannam@97 115 * the plugin for frequency-domain input should be that of the
cannam@97 116 * centre of the processing block, rather than the start as is the
cannam@97 117 * case for time-domain input.
cannam@97 118 *
cannam@97 119 * Since PluginInputDomainAdapter aims to be transparent in use,
cannam@97 120 * it needs to handle this timestamp adjustment itself. However,
cannam@97 121 * some control is available over the method used for adjustment,
cannam@97 122 * by means of the ProcessTimestampMethod setting.
cannam@97 123 *
cannam@97 124 * If ProcessTimestampMethod is set to ShiftTimestamp (the
cannam@97 125 * default), then the data passed to the wrapped plugin will be
cannam@97 126 * calculated from the same input data block as passed to the
cannam@97 127 * wrapper, but the timestamp passed to the plugin will be
cannam@97 128 * advanced by half of the window size.
cannam@97 129 *
cannam@97 130 * If ProcessTimestampMethod is set to ShiftData, then the
cannam@97 131 * timestamp passed to the wrapped plugin will be the same as that
cannam@97 132 * passed to the process call of the wrapper, but the data block
cannam@97 133 * used to calculate the input will be shifted back (earlier) by
cannam@97 134 * half of the window size, with half a block of zero padding at
cannam@97 135 * the start of the first process call. This has the advantage of
cannam@97 136 * preserving the first half block of audio without any
cannam@97 137 * deterioration from window shaping.
cannam@97 138 *
cannam@97 139 * If ProcessTimestampMethod is set to NoShift, then no adjustment
cannam@97 140 * will be made and the timestamps will be incorrect.
cannam@97 141 */
cannam@97 142 enum ProcessTimestampMethod {
cannam@97 143 ShiftTimestamp,
cannam@97 144 ShiftData,
cannam@97 145 NoShift
cannam@97 146 };
cannam@97 147
cannam@97 148 /**
cannam@97 149 * Set the method used for timestamp adjustment in plugins taking
cannam@97 150 * frequency-domain input. See the ProcessTimestampMethod
cannam@97 151 * documentation for details.
cannam@97 152 *
cannam@97 153 * This function must be called before the first call to
cannam@97 154 * process().
cannam@97 155 */
cannam@97 156 void setProcessTimestampMethod(ProcessTimestampMethod);
cannam@97 157
cannam@97 158 /**
cannam@97 159 * Retrieve the method used for timestamp adjustment in plugins
cannam@97 160 * taking frequency-domain input. See the ProcessTimestampMethod
cannam@97 161 * documentation for details.
cannam@97 162 */
cannam@97 163 ProcessTimestampMethod getProcessTimestampMethod() const;
cannam@97 164
cannam@97 165 /**
cannam@97 166 * Return the amount by which the timestamps supplied to process()
cannam@97 167 * are being incremented when they are passed to the plugin's own
cannam@97 168 * process() implementation.
cannam@97 169 *
cannam@97 170 * The Vamp API mandates that the timestamp passed to the plugin
cannam@97 171 * for time-domain input should be the time of the first sample in
cannam@97 172 * the block, but the timestamp passed for frequency-domain input
cannam@97 173 * should be the timestamp of the centre of the block.
cannam@97 174 *
cannam@97 175 * The PluginInputDomainAdapter adjusts its timestamps properly so
cannam@97 176 * that the plugin receives correct times, but in some
cannam@97 177 * circumstances (such as for establishing the correct timing of
cannam@97 178 * implicitly-timed features, i.e. features without their own
cannam@97 179 * timestamps) the host may need to be aware that this adjustment
cannam@97 180 * is taking place.
cannam@97 181 *
cannam@97 182 * If the plugin requires time-domain input or the
cannam@97 183 * PluginInputDomainAdapter is configured with its
cannam@97 184 * ProcessTimestampMethod set to ShiftData instead of
cannam@97 185 * ShiftTimestamp, then this function will return zero.
cannam@97 186 *
cannam@97 187 * The result of calling this function before initialise() has
cannam@97 188 * been called is undefined.
cannam@97 189 */
cannam@97 190 RealTime getTimestampAdjustment() const;
cannam@97 191
cannam@97 192 /**
cannam@97 193 * The set of supported window shapes.
cannam@97 194 */
cannam@97 195 enum WindowType {
cannam@97 196
cannam@97 197 RectangularWindow = 0,
cannam@97 198
cannam@97 199 BartlettWindow = 1, /// synonym for RectangularWindow
cannam@97 200 TriangularWindow = 1, /// synonym for BartlettWindow
cannam@97 201
cannam@97 202 HammingWindow = 2,
cannam@97 203
cannam@97 204 HanningWindow = 3, /// synonym for HannWindow
cannam@97 205 HannWindow = 3, /// synonym for HanningWindow
cannam@97 206
cannam@97 207 BlackmanWindow = 4,
cannam@97 208
cannam@97 209 NuttallWindow = 7,
cannam@97 210
cannam@97 211 BlackmanHarrisWindow = 8
cannam@97 212 };
cannam@97 213
cannam@97 214 /**
cannam@97 215 * Return the current window shape. The default is HanningWindow.
cannam@97 216 */
cannam@97 217 WindowType getWindowType() const;
cannam@97 218
cannam@97 219 /**
cannam@97 220 * Set the current window shape.
cannam@97 221 */
cannam@97 222 void setWindowType(WindowType type);
cannam@97 223
cannam@97 224
cannam@97 225 protected:
cannam@97 226 class Impl;
cannam@97 227 Impl *m_impl;
cannam@97 228 };
cannam@97 229
cannam@97 230 }
cannam@97 231
cannam@97 232 }
cannam@97 233
cannam@97 234 _VAMP_SDK_HOSTSPACE_END(PluginInputDomainAdapter.h)
cannam@97 235
cannam@97 236 #endif