annotate osx/include/vamp-hostsdk/PluginChannelAdapter.h @ 36:55ece8862b6d

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