To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / vamp-hostsdk / host-c.h
History | View | Annotate | Download (5.59 KB)
| 1 |
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
|---|---|
| 2 |
|
| 3 |
/*
|
| 4 |
Vamp
|
| 5 |
|
| 6 |
An API for audio analysis and feature extraction plugins.
|
| 7 |
|
| 8 |
Centre for Digital Music, Queen Mary, University of London.
|
| 9 |
Copyright 2006-2015 Chris Cannam and QMUL.
|
| 10 |
|
| 11 |
Permission is hereby granted, free of charge, to any person
|
| 12 |
obtaining a copy of this software and associated documentation
|
| 13 |
files (the "Software"), to deal in the Software without
|
| 14 |
restriction, including without limitation the rights to use, copy,
|
| 15 |
modify, merge, publish, distribute, sublicense, and/or sell copies
|
| 16 |
of the Software, and to permit persons to whom the Software is
|
| 17 |
furnished to do so, subject to the following conditions:
|
| 18 |
|
| 19 |
The above copyright notice and this permission notice shall be
|
| 20 |
included in all copies or substantial portions of the Software.
|
| 21 |
|
| 22 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
| 23 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 24 |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
| 25 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
|
| 26 |
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
| 27 |
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
| 28 |
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 29 |
|
| 30 |
Except as contained in this notice, the names of the Centre for
|
| 31 |
Digital Music; Queen Mary, University of London; and Chris Cannam
|
| 32 |
shall not be used in advertising or otherwise to promote the sale,
|
| 33 |
use or other dealings in this Software without prior written
|
| 34 |
authorization.
|
| 35 |
*/
|
| 36 |
|
| 37 |
/*
|
| 38 |
This file defines a low-level API for enumerating and loading
|
| 39 |
plugin libraries using C calling conventions. It could be used in
|
| 40 |
C programs, or in languages with C-compatible foreign-function
|
| 41 |
interfaces. Note that this works by calling to the C++ Vamp host
|
| 42 |
SDK, so any program using this interface must still link against
|
| 43 |
the rest of the Vamp plugin library and the C++ standard library.
|
| 44 |
|
| 45 |
This is not the simplest or easiest interface for hosting Vamp
|
| 46 |
plugins -- if you have the capability to use the C++ API, please
|
| 47 |
do that instead. (Most programs should not even include this
|
| 48 |
header.)
|
| 49 |
|
| 50 |
The C and C++ interfaces provide different abstraction levels:
|
| 51 |
|
| 52 |
In the C++ interface, the class PluginLoader provides a list of
|
| 53 |
keys corresponding to the installed plugins (where a key combines
|
| 54 |
the plugin's library name and plugin identifier into a single
|
| 55 |
string) plus a method to load a single plugin based on its key
|
| 56 |
(obtaining an instance of class Plugin). With the C++ interface
|
| 57 |
you go straight from the key to a live instance of the plugin. The
|
| 58 |
PluginLoader also provides various facilities to adapt the plugin
|
| 59 |
based on your requirements (e.g. to do time- to frequency-domain
|
| 60 |
conversion for you if the plugin requires it).
|
| 61 |
|
| 62 |
This low-level C interface, on the other hand, deals only in
|
| 63 |
plugin libraries and static descriptors, not in plugin
|
| 64 |
instances. You can enumerate the installed libraries, getting just
|
| 65 |
the base .soname of each library. Then you can retrieve each of
|
| 66 |
the raw C plugin descriptors from a library, and use the
|
| 67 |
descriptor (whose interface is defined in vamp/vamp.h) to
|
| 68 |
instantiate the plugin.
|
| 69 |
|
| 70 |
So this header corresponds to the first part of the PluginLoader
|
| 71 |
class interface: finding and loading plugin libraries and
|
| 72 |
retrieving plugin descriptors from them. But it does not do any of
|
| 73 |
the rest, i.e. instantiating and adapting the plugins themselves.
|
| 74 |
Although this makes the API appear very simple, it means the
|
| 75 |
resulting plugins are relatively hard to use compared to those
|
| 76 |
obtained by the PluginLoader API. There is no way to get to the
|
| 77 |
full C++ abstraction using this API.
|
| 78 |
|
| 79 |
This API is not thread-safe; use it from a single application
|
| 80 |
thread, or guard access to it with a mutex.
|
| 81 |
|
| 82 |
This header was introduced in version 2.6 of the Vamp plugin SDK.
|
| 83 |
*/
|
| 84 |
|
| 85 |
#ifndef VAMPHOST_C_H_INCLUDED
|
| 86 |
#define VAMPHOST_C_H_INCLUDED
|
| 87 |
|
| 88 |
#include <vamp/vamp.h> |
| 89 |
|
| 90 |
#ifdef __cplusplus
|
| 91 |
extern "C" { |
| 92 |
#endif
|
| 93 |
|
| 94 |
typedef struct vhLibrary_t *vhLibrary; |
| 95 |
|
| 96 |
/**
|
| 97 |
* Return the number of Vamp plugin libraries discovered in the
|
| 98 |
* installation path. This number will remain fixed after the first
|
| 99 |
* call -- plugins are only discovered once, the first time this
|
| 100 |
* function is called.
|
| 101 |
*/
|
| 102 |
extern int vhGetLibraryCount(); |
| 103 |
|
| 104 |
/**
|
| 105 |
* Return the library name (base soname) of the library with the given
|
| 106 |
* index, in the range 0..(vhGetLibraryCount()-1).
|
| 107 |
*/
|
| 108 |
extern const char *vhGetLibraryName(int library); |
| 109 |
|
| 110 |
/**
|
| 111 |
* Return the library index for the given library name, or -1 if the
|
| 112 |
* name is not known.
|
| 113 |
*/
|
| 114 |
extern int vhGetLibraryIndex(const char *name); |
| 115 |
|
| 116 |
/**
|
| 117 |
* Load the library with the given index. If the library cannot be
|
| 118 |
* loaded for any reason, the return value is 0; otherwise it is an
|
| 119 |
* opaque pointer suitable for passing to other functions in this API.
|
| 120 |
*/
|
| 121 |
extern vhLibrary vhLoadLibrary(int library); |
| 122 |
|
| 123 |
/**
|
| 124 |
* Return the number of Vamp plugins in the given library.
|
| 125 |
*/
|
| 126 |
extern int vhGetPluginCount(vhLibrary library); |
| 127 |
|
| 128 |
/**
|
| 129 |
* Return a Vamp plugin descriptor for a plugin in a given
|
| 130 |
* library. This simply calls the vampGetPluginDescriptor function in
|
| 131 |
* that library with the given plugin index and returns the
|
| 132 |
* result. See vamp/vamp.h for details about the plugin descriptor.
|
| 133 |
*/
|
| 134 |
extern const VampPluginDescriptor *vhGetPluginDescriptor(vhLibrary library, |
| 135 |
int plugin);
|
| 136 |
|
| 137 |
/**
|
| 138 |
* Unload a plugin library. Do not do this while any of its plugins
|
| 139 |
* are still in use.
|
| 140 |
*/
|
| 141 |
extern void vhUnloadLibrary(vhLibrary); |
| 142 |
|
| 143 |
#ifdef __cplusplus
|
| 144 |
} |
| 145 |
#endif
|
| 146 |
|
| 147 |
#endif
|