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