annotate win32-mingw/include/vamp-hostsdk/PluginLoader.h @ 112:1e14aae10620

Add Vamp SDK for OS/X
author Chris Cannam <cannam@all-day-breakfast.com>
date Thu, 09 Jan 2014 09:17:21 +0000
parents c6e1ae789cfb
children
rev   line source
cannam@99 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
cannam@99 2
cannam@99 3 /*
cannam@99 4 Vamp
cannam@99 5
cannam@99 6 An API for audio analysis and feature extraction plugins.
cannam@99 7
cannam@99 8 Centre for Digital Music, Queen Mary, University of London.
cannam@99 9 Copyright 2006-2009 Chris Cannam and QMUL.
cannam@99 10
cannam@99 11 Permission is hereby granted, free of charge, to any person
cannam@99 12 obtaining a copy of this software and associated documentation
cannam@99 13 files (the "Software"), to deal in the Software without
cannam@99 14 restriction, including without limitation the rights to use, copy,
cannam@99 15 modify, merge, publish, distribute, sublicense, and/or sell copies
cannam@99 16 of the Software, and to permit persons to whom the Software is
cannam@99 17 furnished to do so, subject to the following conditions:
cannam@99 18
cannam@99 19 The above copyright notice and this permission notice shall be
cannam@99 20 included in all copies or substantial portions of the Software.
cannam@99 21
cannam@99 22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
cannam@99 23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
cannam@99 24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
cannam@99 25 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
cannam@99 26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
cannam@99 27 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
cannam@99 28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
cannam@99 29
cannam@99 30 Except as contained in this notice, the names of the Centre for
cannam@99 31 Digital Music; Queen Mary, University of London; and Chris Cannam
cannam@99 32 shall not be used in advertising or otherwise to promote the sale,
cannam@99 33 use or other dealings in this Software without prior written
cannam@99 34 authorization.
cannam@99 35 */
cannam@99 36
cannam@99 37 #ifndef _VAMP_PLUGIN_LOADER_H_
cannam@99 38 #define _VAMP_PLUGIN_LOADER_H_
cannam@99 39
cannam@99 40 #include <vector>
cannam@99 41 #include <string>
cannam@99 42 #include <map>
cannam@99 43
cannam@99 44 #include "hostguard.h"
cannam@99 45 #include "PluginWrapper.h"
cannam@99 46
cannam@99 47 _VAMP_SDK_HOSTSPACE_BEGIN(PluginLoader.h)
cannam@99 48
cannam@99 49 namespace Vamp {
cannam@99 50
cannam@99 51 class Plugin;
cannam@99 52
cannam@99 53 namespace HostExt {
cannam@99 54
cannam@99 55 /**
cannam@99 56 * \class PluginLoader PluginLoader.h <vamp-hostsdk/PluginLoader.h>
cannam@99 57 *
cannam@99 58 * Vamp::HostExt::PluginLoader is a convenience class for discovering
cannam@99 59 * and loading Vamp plugins using the typical plugin-path, library
cannam@99 60 * naming, and categorisation conventions described in the Vamp SDK
cannam@99 61 * documentation. This class is intended to greatly simplify the task
cannam@99 62 * of becoming a Vamp plugin host for any C++ application.
cannam@99 63 *
cannam@99 64 * Hosts are not required by the Vamp specification to use the same
cannam@99 65 * plugin search path and naming conventions as implemented by this
cannam@99 66 * class, and are certainly not required to use this actual class.
cannam@99 67 * But we do strongly recommend it.
cannam@99 68 *
cannam@99 69 * \note This class was introduced in version 1.1 of the Vamp plugin SDK.
cannam@99 70 */
cannam@99 71
cannam@99 72 class PluginLoader
cannam@99 73 {
cannam@99 74 public:
cannam@99 75 /**
cannam@99 76 * Obtain a pointer to the singleton instance of PluginLoader.
cannam@99 77 * Use this to obtain your loader object.
cannam@99 78 */
cannam@99 79 static PluginLoader *getInstance();
cannam@99 80
cannam@99 81 /**
cannam@99 82 * PluginKey is a string type that is used to identify a plugin
cannam@99 83 * uniquely within the scope of "the current system". It consists
cannam@99 84 * of the lower-cased base name of the plugin library, a colon
cannam@99 85 * separator, and the identifier string for the plugin. It is
cannam@99 86 * only meaningful in the context of a given plugin path (the one
cannam@99 87 * returned by PluginHostAdapter::getPluginPath()).
cannam@99 88 *
cannam@99 89 * Use composePluginKey() to construct a plugin key from a known
cannam@99 90 * plugin library name and identifier.
cannam@99 91 *
cannam@99 92 * Note: the fact that the library component of the key is
cannam@99 93 * lower-cased implies that library names are matched
cannam@99 94 * case-insensitively by the PluginLoader class, regardless of the
cannam@99 95 * case sensitivity of the underlying filesystem. (Plugin
cannam@99 96 * identifiers _are_ case sensitive, however.) Also, it is not
cannam@99 97 * possible to portably extract a working library name from a
cannam@99 98 * plugin key, as the result may fail on case-sensitive
cannam@99 99 * filesystems. Use getLibraryPathForPlugin() instead.
cannam@99 100 */
cannam@99 101 typedef std::string PluginKey;
cannam@99 102
cannam@99 103 /**
cannam@99 104 * PluginKeyList is a sequence of plugin keys, such as returned by
cannam@99 105 * listPlugins().
cannam@99 106 */
cannam@99 107 typedef std::vector<PluginKey> PluginKeyList;
cannam@99 108
cannam@99 109 /**
cannam@99 110 * PluginCategoryHierarchy is a sequence of general->specific
cannam@99 111 * category names, as may be associated with a single plugin.
cannam@99 112 * This sequence describes the location of a plugin within a
cannam@99 113 * category forest, containing the human-readable names of the
cannam@99 114 * plugin's category tree root, followed by each of the nodes down
cannam@99 115 * to the leaf containing the plugin.
cannam@99 116 *
cannam@99 117 * \see getPluginCategory()
cannam@99 118 */
cannam@99 119 typedef std::vector<std::string> PluginCategoryHierarchy;
cannam@99 120
cannam@99 121 /**
cannam@99 122 * Search for all available Vamp plugins, and return a list of
cannam@99 123 * them in the order in which they were found.
cannam@99 124 */
cannam@99 125 PluginKeyList listPlugins();
cannam@99 126
cannam@99 127 /**
cannam@99 128 * AdapterFlags contains a set of values that may be OR'd together
cannam@99 129 * to indicate in which circumstances PluginLoader should use a
cannam@99 130 * plugin adapter to make a plugin easier to use for a host that
cannam@99 131 * does not want to cater for complex features.
cannam@99 132 *
cannam@99 133 * The available flags are:
cannam@99 134 *
cannam@99 135 * ADAPT_INPUT_DOMAIN - If the plugin expects frequency domain
cannam@99 136 * input, wrap it in a PluginInputDomainAdapter that automatically
cannam@99 137 * converts the plugin to one that expects time-domain input.
cannam@99 138 * This enables a host to accommodate time- and frequency-domain
cannam@99 139 * plugins without needing to do any conversion itself.
cannam@99 140 *
cannam@99 141 * ADAPT_CHANNEL_COUNT - Wrap the plugin in a PluginChannelAdapter
cannam@99 142 * to handle any mismatch between the number of channels of audio
cannam@99 143 * the plugin can handle and the number available in the host.
cannam@99 144 * This enables a host to use plugins that may require the input
cannam@99 145 * to be mixed down to mono, etc., without having to worry about
cannam@99 146 * doing that itself.
cannam@99 147 *
cannam@99 148 * ADAPT_BUFFER_SIZE - Wrap the plugin in a PluginBufferingAdapter
cannam@99 149 * permitting the host to provide audio input using any block
cannam@99 150 * size, with no overlap, regardless of the plugin's preferred
cannam@99 151 * block size (suitable for hosts that read from non-seekable
cannam@99 152 * streaming media, for example). This adapter introduces some
cannam@99 153 * run-time overhead and also changes the semantics of the plugin
cannam@99 154 * slightly (see the PluginBufferingAdapter header documentation
cannam@99 155 * for details).
cannam@99 156 *
cannam@99 157 * ADAPT_ALL_SAFE - Perform all available adaptations that are
cannam@99 158 * meaningful for the plugin and "safe". Currently this means to
cannam@99 159 * ADAPT_INPUT_DOMAIN if the plugin wants FrequencyDomain input;
cannam@99 160 * ADAPT_CHANNEL_COUNT always; and ADAPT_BUFFER_SIZE never.
cannam@99 161 *
cannam@99 162 * ADAPT_ALL - Perform all available adaptations that are
cannam@99 163 * meaningful for the plugin.
cannam@99 164 *
cannam@99 165 * See PluginInputDomainAdapter, PluginChannelAdapter and
cannam@99 166 * PluginBufferingAdapter for more details of the classes that the
cannam@99 167 * loader may use if these flags are set.
cannam@99 168 */
cannam@99 169 enum AdapterFlags {
cannam@99 170
cannam@99 171 ADAPT_INPUT_DOMAIN = 0x01,
cannam@99 172 ADAPT_CHANNEL_COUNT = 0x02,
cannam@99 173 ADAPT_BUFFER_SIZE = 0x04,
cannam@99 174
cannam@99 175 ADAPT_ALL_SAFE = 0x03,
cannam@99 176
cannam@99 177 ADAPT_ALL = 0xff
cannam@99 178 };
cannam@99 179
cannam@99 180 /**
cannam@99 181 * Load a Vamp plugin, given its identifying key. If the plugin
cannam@99 182 * could not be loaded, returns 0.
cannam@99 183 *
cannam@99 184 * The returned plugin should be deleted (using the standard C++
cannam@99 185 * delete keyword) after use.
cannam@99 186 *
cannam@99 187 * \param adapterFlags a bitwise OR of the values in the AdapterFlags
cannam@99 188 * enumeration, indicating under which circumstances an adapter should be
cannam@99 189 * used to wrap the original plugin. If adapterFlags is 0, no
cannam@99 190 * optional adapters will be used. Otherwise, the returned plugin
cannam@99 191 * may be of an adapter class type which will behave identically
cannam@99 192 * to the original plugin, apart from any particular features
cannam@99 193 * implemented by the adapter itself.
cannam@99 194 *
cannam@99 195 * \see AdapterFlags, PluginInputDomainAdapter, PluginChannelAdapter
cannam@99 196 */
cannam@99 197 Plugin *loadPlugin(PluginKey key,
cannam@99 198 float inputSampleRate,
cannam@99 199 int adapterFlags = 0);
cannam@99 200
cannam@99 201 /**
cannam@99 202 * Given a Vamp plugin library name and plugin identifier, return
cannam@99 203 * the corresponding plugin key in a form suitable for passing in to
cannam@99 204 * loadPlugin().
cannam@99 205 */
cannam@99 206 PluginKey composePluginKey(std::string libraryName,
cannam@99 207 std::string identifier);
cannam@99 208
cannam@99 209 /**
cannam@99 210 * Return the category hierarchy for a Vamp plugin, given its
cannam@99 211 * identifying key.
cannam@99 212 *
cannam@99 213 * If the plugin has no category information, return an empty
cannam@99 214 * hierarchy.
cannam@99 215 *
cannam@99 216 * \see PluginCategoryHierarchy
cannam@99 217 */
cannam@99 218 PluginCategoryHierarchy getPluginCategory(PluginKey plugin);
cannam@99 219
cannam@99 220 /**
cannam@99 221 * Return the file path of the dynamic library from which the
cannam@99 222 * given plugin will be loaded (if available).
cannam@99 223 */
cannam@99 224 std::string getLibraryPathForPlugin(PluginKey plugin);
cannam@99 225
cannam@99 226 protected:
cannam@99 227 PluginLoader();
cannam@99 228 virtual ~PluginLoader();
cannam@99 229
cannam@99 230 class Impl;
cannam@99 231 Impl *m_impl;
cannam@99 232
cannam@99 233 static PluginLoader *m_instance;
cannam@99 234 };
cannam@99 235
cannam@99 236 }
cannam@99 237
cannam@99 238 }
cannam@99 239
cannam@99 240 _VAMP_SDK_HOSTSPACE_END(PluginLoader.h)
cannam@99 241
cannam@99 242 #endif
cannam@99 243