annotate src/vamp-plugin-sdk-2.4/vamp-hostsdk/PluginChannelAdapter.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_CHANNEL_ADAPTER_H_
cannam@97 38 #define _VAMP_PLUGIN_CHANNEL_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(PluginChannelAdapter.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 PluginChannelAdapter PluginChannelAdapter.h <vamp-hostsdk/PluginChannelAdapter.h>
cannam@97 51 *
cannam@97 52 * PluginChannelAdapter is a Vamp plugin adapter that implements a
cannam@97 53 * policy for management of plugins that expect a different number of
cannam@97 54 * input channels from the number actually available in the source
cannam@97 55 * audio data.
cannam@97 56 *
cannam@97 57 * A host using PluginChannelAdapter may ignore the getMinChannelCount
cannam@97 58 * and getMaxChannelCount reported by the plugin, and still expect the
cannam@97 59 * plugin to run.
cannam@97 60 *
cannam@97 61 * PluginChannelAdapter implements the following policy:
cannam@97 62 *
cannam@97 63 * - If the plugin supports the provided number of channels directly,
cannam@97 64 * PluginChannelAdapter will just run the plugin as normal.
cannam@97 65 *
cannam@97 66 * - If the plugin only supports exactly one channel but more than
cannam@97 67 * one channel is provided, PluginChannelAdapter will use the mean of
cannam@97 68 * the channels. This ensures that the resulting values remain
cannam@97 69 * within the same magnitude range as expected for mono data.
cannam@97 70 *
cannam@97 71 * - If the plugin requires more than one channel but exactly one is
cannam@97 72 * provided, the provided channel will be duplicated across all the
cannam@97 73 * plugin input channels.
cannam@97 74 *
cannam@97 75 * If none of the above apply:
cannam@97 76 *
cannam@97 77 * - If the plugin requires more channels than are provided, the
cannam@97 78 * minimum acceptable number of channels will be produced by adding
cannam@97 79 * empty (zero valued) channels to those provided.
cannam@97 80 *
cannam@97 81 * - If the plugin requires fewer channels than are provided, the
cannam@97 82 * maximum acceptable number of channels will be produced by
cannam@97 83 * discarding the excess channels.
cannam@97 84 *
cannam@97 85 * Hosts requiring a different channel policy from the above will need
cannam@97 86 * to implement it themselves, instead of using PluginChannelAdapter.
cannam@97 87 *
cannam@97 88 * Note that PluginChannelAdapter does not override the minimum and
cannam@97 89 * maximum channel counts returned by the wrapped plugin. The host
cannam@97 90 * will need to be aware that it is using a PluginChannelAdapter, and
cannam@97 91 * be prepared to ignore these counts as necessary. (This contrasts
cannam@97 92 * with the approach used in PluginInputDomainAdapter, which aims to
cannam@97 93 * make the host completely unaware of which underlying input domain
cannam@97 94 * is in fact in use.)
cannam@97 95 *
cannam@97 96 * (The rationale for this is that a host may wish to use the
cannam@97 97 * PluginChannelAdapter but still discriminate in some way on the
cannam@97 98 * basis of the number of channels actually supported. For example, a
cannam@97 99 * simple stereo audio host may prefer to reject plugins that require
cannam@97 100 * more than two channels on the grounds that doesn't actually
cannam@97 101 * understand what they are for, rather than allow the channel adapter
cannam@97 102 * to make a potentially meaningless channel conversion for them.)
cannam@97 103 *
cannam@97 104 * In every respect other than its management of channels, the
cannam@97 105 * PluginChannelAdapter behaves identically to the plugin that it
cannam@97 106 * wraps. The wrapped plugin will be deleted when the wrapper is
cannam@97 107 * deleted.
cannam@97 108 *
cannam@97 109 * \note This class was introduced in version 1.1 of the Vamp plugin SDK.
cannam@97 110 */
cannam@97 111
cannam@97 112 class PluginChannelAdapter : public PluginWrapper
cannam@97 113 {
cannam@97 114 public:
cannam@97 115 /**
cannam@97 116 * Construct a PluginChannelAdapter wrapping the given plugin.
cannam@97 117 * The adapter takes ownership of the plugin, which will be
cannam@97 118 * deleted when the adapter is deleted.
cannam@97 119 */
cannam@97 120 PluginChannelAdapter(Plugin *plugin);
cannam@97 121 virtual ~PluginChannelAdapter();
cannam@97 122
cannam@97 123 bool initialise(size_t channels, size_t stepSize, size_t blockSize);
cannam@97 124
cannam@97 125 FeatureSet process(const float *const *inputBuffers, RealTime timestamp);
cannam@97 126
cannam@97 127 /**
cannam@97 128 * Call process(), providing interleaved audio data with the
cannam@97 129 * number of channels passed to initialise(). The adapter will
cannam@97 130 * de-interleave into temporary buffers as appropriate before
cannam@97 131 * calling process().
cannam@97 132 *
cannam@97 133 * \note This function was introduced in version 1.4 of the Vamp
cannam@97 134 * plugin SDK.
cannam@97 135 */
cannam@97 136 FeatureSet processInterleaved(const float *inputBuffer, RealTime timestamp);
cannam@97 137
cannam@97 138 protected:
cannam@97 139 class Impl;
cannam@97 140 Impl *m_impl;
cannam@97 141 };
cannam@97 142
cannam@97 143 }
cannam@97 144
cannam@97 145 }
cannam@97 146
cannam@97 147 _VAMP_SDK_HOSTSPACE_END(PluginChannelAdapter.h)
cannam@97 148
cannam@97 149 #endif