annotate osx/include/vamp-hostsdk/PluginBufferingAdapter.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 This file by Mark Levy and Chris Cannam, Copyright 2007-2008 QMUL.
cannam@112 11
cannam@112 12 Permission is hereby granted, free of charge, to any person
cannam@112 13 obtaining a copy of this software and associated documentation
cannam@112 14 files (the "Software"), to deal in the Software without
cannam@112 15 restriction, including without limitation the rights to use, copy,
cannam@112 16 modify, merge, publish, distribute, sublicense, and/or sell copies
cannam@112 17 of the Software, and to permit persons to whom the Software is
cannam@112 18 furnished to do so, subject to the following conditions:
cannam@112 19
cannam@112 20 The above copyright notice and this permission notice shall be
cannam@112 21 included in all copies or substantial portions of the Software.
cannam@112 22
cannam@112 23 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
cannam@112 24 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
cannam@112 25 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
cannam@112 26 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
cannam@112 27 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
cannam@112 28 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
cannam@112 29 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
cannam@112 30
cannam@112 31 Except as contained in this notice, the names of the Centre for
cannam@112 32 Digital Music; Queen Mary, University of London; and Chris Cannam
cannam@112 33 shall not be used in advertising or otherwise to promote the sale,
cannam@112 34 use or other dealings in this Software without prior written
cannam@112 35 authorization.
cannam@112 36 */
cannam@112 37
cannam@112 38 #ifndef _VAMP_PLUGIN_BUFFERING_ADAPTER_H_
cannam@112 39 #define _VAMP_PLUGIN_BUFFERING_ADAPTER_H_
cannam@112 40
cannam@112 41 #include "hostguard.h"
cannam@112 42 #include "PluginWrapper.h"
cannam@112 43
cannam@112 44 _VAMP_SDK_HOSTSPACE_BEGIN(PluginBufferingAdapter.h)
cannam@112 45
cannam@112 46 namespace Vamp {
cannam@112 47
cannam@112 48 namespace HostExt {
cannam@112 49
cannam@112 50 /**
cannam@112 51 * \class PluginBufferingAdapter PluginBufferingAdapter.h <vamp-hostsdk/PluginBufferingAdapter.h>
cannam@112 52 *
cannam@112 53 * PluginBufferingAdapter is a Vamp plugin adapter that allows plugins
cannam@112 54 * to be used by a host supplying an audio stream in non-overlapping
cannam@112 55 * buffers of arbitrary size.
cannam@112 56 *
cannam@112 57 * A host using PluginBufferingAdapter may ignore the preferred step
cannam@112 58 * and block size reported by the plugin, and still expect the plugin
cannam@112 59 * to run. The value of blockSize and stepSize passed to initialise
cannam@112 60 * should be the size of the buffer which the host will supply; the
cannam@112 61 * stepSize should be equal to the blockSize.
cannam@112 62 *
cannam@112 63 * If the internal step size used for the plugin differs from that
cannam@112 64 * supplied by the host, the adapter will modify the sample type and
cannam@112 65 * rate specifications for the plugin outputs appropriately, and set
cannam@112 66 * timestamps on the output features for outputs that formerly used a
cannam@112 67 * different sample rate specification. This is necessary in order to
cannam@112 68 * obtain correct time stamping.
cannam@112 69 *
cannam@112 70 * In other respects, the PluginBufferingAdapter behaves identically
cannam@112 71 * to the plugin that it wraps. The wrapped plugin will be deleted
cannam@112 72 * when the wrapper is deleted.
cannam@112 73 */
cannam@112 74
cannam@112 75 class PluginBufferingAdapter : public PluginWrapper
cannam@112 76 {
cannam@112 77 public:
cannam@112 78 /**
cannam@112 79 * Construct a PluginBufferingAdapter wrapping the given plugin.
cannam@112 80 * The adapter takes ownership of the plugin, which will be
cannam@112 81 * deleted when the adapter is deleted.
cannam@112 82 */
cannam@112 83 PluginBufferingAdapter(Plugin *plugin);
cannam@112 84 virtual ~PluginBufferingAdapter();
cannam@112 85
cannam@112 86 /**
cannam@112 87 * Return the preferred step size for this adapter.
cannam@112 88 *
cannam@112 89 * Because of the way this adapter works, its preferred step size
cannam@112 90 * will always be the same as its preferred block size. This may
cannam@112 91 * or may not be the same as the preferred step size of the
cannam@112 92 * underlying plugin, which may be obtained by calling
cannam@112 93 * getPluginPreferredStepSize().
cannam@112 94 */
cannam@112 95 size_t getPreferredStepSize() const;
cannam@112 96
cannam@112 97 /**
cannam@112 98 * Return the preferred block size for this adapter.
cannam@112 99 *
cannam@112 100 * This may or may not be the same as the preferred block size of
cannam@112 101 * the underlying plugin, which may be obtained by calling
cannam@112 102 * getPluginPreferredBlockSize().
cannam@112 103 *
cannam@112 104 * Note that this adapter may be initialised with any block size,
cannam@112 105 * not just its supposedly preferred one.
cannam@112 106 */
cannam@112 107 size_t getPreferredBlockSize() const;
cannam@112 108
cannam@112 109 /**
cannam@112 110 * Initialise the adapter (and therefore the plugin) for the given
cannam@112 111 * number of channels. Initialise the adapter for the given step
cannam@112 112 * and block size, which must be equal.
cannam@112 113 *
cannam@112 114 * The step and block size used for the underlying plugin will
cannam@112 115 * depend on its preferences, or any values previously passed to
cannam@112 116 * setPluginStepSize and setPluginBlockSize.
cannam@112 117 */
cannam@112 118 bool initialise(size_t channels, size_t stepSize, size_t blockSize);
cannam@112 119
cannam@112 120 /**
cannam@112 121 * Return the preferred step size of the plugin wrapped by this
cannam@112 122 * adapter.
cannam@112 123 *
cannam@112 124 * This is included mainly for informational purposes. This value
cannam@112 125 * is not likely to be a valid step size for the adapter itself,
cannam@112 126 * and it is not usually of any use in interpreting the results
cannam@112 127 * (because the adapter re-writes OneSamplePerStep outputs to
cannam@112 128 * FixedSampleRate so that the hop size no longer needs to be
cannam@112 129 * known beforehand in order to interpret them).
cannam@112 130 */
cannam@112 131 size_t getPluginPreferredStepSize() const;
cannam@112 132
cannam@112 133 /**
cannam@112 134 * Return the preferred block size of the plugin wrapped by this
cannam@112 135 * adapter.
cannam@112 136 *
cannam@112 137 * This is included mainly for informational purposes.
cannam@112 138 */
cannam@112 139 size_t getPluginPreferredBlockSize() const;
cannam@112 140
cannam@112 141 /**
cannam@112 142 * Set the step size that will be used for the underlying plugin
cannam@112 143 * when initialise() is called. If this is not set, the plugin's
cannam@112 144 * own preferred step size will be used. You will not usually
cannam@112 145 * need to call this function. If you do call it, it must be
cannam@112 146 * before the first call to initialise().
cannam@112 147 */
cannam@112 148 void setPluginStepSize(size_t stepSize);
cannam@112 149
cannam@112 150 /**
cannam@112 151 * Set the block size that will be used for the underlying plugin
cannam@112 152 * when initialise() is called. If this is not set, the plugin's
cannam@112 153 * own preferred block size will be used. You will not usually
cannam@112 154 * need to call this function. If you do call it, it must be
cannam@112 155 * before the first call to initialise().
cannam@112 156 */
cannam@112 157 void setPluginBlockSize(size_t blockSize);
cannam@112 158
cannam@112 159 /**
cannam@112 160 * Return the step and block sizes that were actually used when
cannam@112 161 * initialising the underlying plugin.
cannam@112 162 *
cannam@112 163 * This is included mainly for informational purposes. You will
cannam@112 164 * not usually need to call this function. If this is called
cannam@112 165 * before initialise(), it will return 0 for both values. If it
cannam@112 166 * is called after a failed call to initialise(), it will return
cannam@112 167 * the values that were used in the failed call to the plugin's
cannam@112 168 * initialise() function.
cannam@112 169 */
cannam@112 170 void getActualStepAndBlockSizes(size_t &stepSize, size_t &blockSize);
cannam@112 171
cannam@112 172 void setParameter(std::string, float);
cannam@112 173 void selectProgram(std::string);
cannam@112 174
cannam@112 175 OutputList getOutputDescriptors() const;
cannam@112 176
cannam@112 177 void reset();
cannam@112 178
cannam@112 179 FeatureSet process(const float *const *inputBuffers, RealTime timestamp);
cannam@112 180
cannam@112 181 FeatureSet getRemainingFeatures();
cannam@112 182
cannam@112 183 protected:
cannam@112 184 class Impl;
cannam@112 185 Impl *m_impl;
cannam@112 186 };
cannam@112 187
cannam@112 188 }
cannam@112 189
cannam@112 190 }
cannam@112 191
cannam@112 192 _VAMP_SDK_HOSTSPACE_END(PluginBufferingAdapter.h)
cannam@112 193
cannam@112 194 #endif