annotate osx/include/vamp-hostsdk/PluginChannelAdapter.h @ 116:e448888319fc

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