annotate src/vamp-plugin-sdk-2.4/vamp-hostsdk/PluginLoader.h @ 169:223a55898ab9 tip default

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