annotate src/vamp-plugin-sdk-2.4/vamp-hostsdk/PluginChannelAdapter.h @ 23:619f715526df sv_v2.1

Update Vamp plugin SDK to 2.5
author Chris Cannam
date Thu, 09 May 2013 10:52:46 +0100
parents b7bda433d832
children
rev   line source
Chris@12 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@12 2
Chris@12 3 /*
Chris@12 4 Vamp
Chris@12 5
Chris@12 6 An API for audio analysis and feature extraction plugins.
Chris@12 7
Chris@12 8 Centre for Digital Music, Queen Mary, University of London.
Chris@12 9 Copyright 2006-2009 Chris Cannam and QMUL.
Chris@12 10
Chris@12 11 Permission is hereby granted, free of charge, to any person
Chris@12 12 obtaining a copy of this software and associated documentation
Chris@12 13 files (the "Software"), to deal in the Software without
Chris@12 14 restriction, including without limitation the rights to use, copy,
Chris@12 15 modify, merge, publish, distribute, sublicense, and/or sell copies
Chris@12 16 of the Software, and to permit persons to whom the Software is
Chris@12 17 furnished to do so, subject to the following conditions:
Chris@12 18
Chris@12 19 The above copyright notice and this permission notice shall be
Chris@12 20 included in all copies or substantial portions of the Software.
Chris@12 21
Chris@12 22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Chris@12 23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Chris@12 24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Chris@12 25 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
Chris@12 26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
Chris@12 27 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
Chris@12 28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Chris@12 29
Chris@12 30 Except as contained in this notice, the names of the Centre for
Chris@12 31 Digital Music; Queen Mary, University of London; and Chris Cannam
Chris@12 32 shall not be used in advertising or otherwise to promote the sale,
Chris@12 33 use or other dealings in this Software without prior written
Chris@12 34 authorization.
Chris@12 35 */
Chris@12 36
Chris@12 37 #ifndef _VAMP_PLUGIN_CHANNEL_ADAPTER_H_
Chris@12 38 #define _VAMP_PLUGIN_CHANNEL_ADAPTER_H_
Chris@12 39
Chris@12 40 #include "hostguard.h"
Chris@12 41 #include "PluginWrapper.h"
Chris@12 42
Chris@12 43 _VAMP_SDK_HOSTSPACE_BEGIN(PluginChannelAdapter.h)
Chris@12 44
Chris@12 45 namespace Vamp {
Chris@12 46
Chris@12 47 namespace HostExt {
Chris@12 48
Chris@12 49 /**
Chris@12 50 * \class PluginChannelAdapter PluginChannelAdapter.h <vamp-hostsdk/PluginChannelAdapter.h>
Chris@12 51 *
Chris@12 52 * PluginChannelAdapter is a Vamp plugin adapter that implements a
Chris@12 53 * policy for management of plugins that expect a different number of
Chris@12 54 * input channels from the number actually available in the source
Chris@12 55 * audio data.
Chris@12 56 *
Chris@12 57 * A host using PluginChannelAdapter may ignore the getMinChannelCount
Chris@12 58 * and getMaxChannelCount reported by the plugin, and still expect the
Chris@12 59 * plugin to run.
Chris@12 60 *
Chris@12 61 * PluginChannelAdapter implements the following policy:
Chris@12 62 *
Chris@12 63 * - If the plugin supports the provided number of channels directly,
Chris@12 64 * PluginChannelAdapter will just run the plugin as normal.
Chris@12 65 *
Chris@12 66 * - If the plugin only supports exactly one channel but more than
Chris@12 67 * one channel is provided, PluginChannelAdapter will use the mean of
Chris@12 68 * the channels. This ensures that the resulting values remain
Chris@12 69 * within the same magnitude range as expected for mono data.
Chris@12 70 *
Chris@12 71 * - If the plugin requires more than one channel but exactly one is
Chris@12 72 * provided, the provided channel will be duplicated across all the
Chris@12 73 * plugin input channels.
Chris@12 74 *
Chris@12 75 * If none of the above apply:
Chris@12 76 *
Chris@12 77 * - If the plugin requires more channels than are provided, the
Chris@12 78 * minimum acceptable number of channels will be produced by adding
Chris@12 79 * empty (zero valued) channels to those provided.
Chris@12 80 *
Chris@12 81 * - If the plugin requires fewer channels than are provided, the
Chris@12 82 * maximum acceptable number of channels will be produced by
Chris@12 83 * discarding the excess channels.
Chris@12 84 *
Chris@12 85 * Hosts requiring a different channel policy from the above will need
Chris@12 86 * to implement it themselves, instead of using PluginChannelAdapter.
Chris@12 87 *
Chris@12 88 * Note that PluginChannelAdapter does not override the minimum and
Chris@12 89 * maximum channel counts returned by the wrapped plugin. The host
Chris@12 90 * will need to be aware that it is using a PluginChannelAdapter, and
Chris@12 91 * be prepared to ignore these counts as necessary. (This contrasts
Chris@12 92 * with the approach used in PluginInputDomainAdapter, which aims to
Chris@12 93 * make the host completely unaware of which underlying input domain
Chris@12 94 * is in fact in use.)
Chris@12 95 *
Chris@12 96 * (The rationale for this is that a host may wish to use the
Chris@12 97 * PluginChannelAdapter but still discriminate in some way on the
Chris@12 98 * basis of the number of channels actually supported. For example, a
Chris@12 99 * simple stereo audio host may prefer to reject plugins that require
Chris@12 100 * more than two channels on the grounds that doesn't actually
Chris@12 101 * understand what they are for, rather than allow the channel adapter
Chris@12 102 * to make a potentially meaningless channel conversion for them.)
Chris@12 103 *
Chris@12 104 * In every respect other than its management of channels, the
Chris@12 105 * PluginChannelAdapter behaves identically to the plugin that it
Chris@12 106 * wraps. The wrapped plugin will be deleted when the wrapper is
Chris@12 107 * deleted.
Chris@12 108 *
Chris@12 109 * \note This class was introduced in version 1.1 of the Vamp plugin SDK.
Chris@12 110 */
Chris@12 111
Chris@12 112 class PluginChannelAdapter : public PluginWrapper
Chris@12 113 {
Chris@12 114 public:
Chris@12 115 /**
Chris@12 116 * Construct a PluginChannelAdapter wrapping the given plugin.
Chris@12 117 * The adapter takes ownership of the plugin, which will be
Chris@12 118 * deleted when the adapter is deleted.
Chris@12 119 */
Chris@12 120 PluginChannelAdapter(Plugin *plugin);
Chris@12 121 virtual ~PluginChannelAdapter();
Chris@12 122
Chris@12 123 bool initialise(size_t channels, size_t stepSize, size_t blockSize);
Chris@12 124
Chris@12 125 FeatureSet process(const float *const *inputBuffers, RealTime timestamp);
Chris@12 126
Chris@12 127 /**
Chris@12 128 * Call process(), providing interleaved audio data with the
Chris@12 129 * number of channels passed to initialise(). The adapter will
Chris@12 130 * de-interleave into temporary buffers as appropriate before
Chris@12 131 * calling process().
Chris@12 132 *
Chris@12 133 * \note This function was introduced in version 1.4 of the Vamp
Chris@12 134 * plugin SDK.
Chris@12 135 */
Chris@12 136 FeatureSet processInterleaved(const float *inputBuffer, RealTime timestamp);
Chris@12 137
Chris@12 138 protected:
Chris@12 139 class Impl;
Chris@12 140 Impl *m_impl;
Chris@12 141 };
Chris@12 142
Chris@12 143 }
Chris@12 144
Chris@12 145 }
Chris@12 146
Chris@12 147 _VAMP_SDK_HOSTSPACE_END(PluginChannelAdapter.h)
Chris@12 148
Chris@12 149 #endif