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