annotate src/vamp-plugin-sdk-2.5/vamp-sdk/PluginAdapter.h @ 83:ae30d91d2ffe

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam
date Fri, 07 Feb 2020 11:51:13 +0000
parents 619f715526df
children
rev   line source
Chris@23 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@23 2
Chris@23 3 /*
Chris@23 4 Vamp
Chris@23 5
Chris@23 6 An API for audio analysis and feature extraction plugins.
Chris@23 7
Chris@23 8 Centre for Digital Music, Queen Mary, University of London.
Chris@23 9 Copyright 2006 Chris Cannam.
Chris@23 10
Chris@23 11 Permission is hereby granted, free of charge, to any person
Chris@23 12 obtaining a copy of this software and associated documentation
Chris@23 13 files (the "Software"), to deal in the Software without
Chris@23 14 restriction, including without limitation the rights to use, copy,
Chris@23 15 modify, merge, publish, distribute, sublicense, and/or sell copies
Chris@23 16 of the Software, and to permit persons to whom the Software is
Chris@23 17 furnished to do so, subject to the following conditions:
Chris@23 18
Chris@23 19 The above copyright notice and this permission notice shall be
Chris@23 20 included in all copies or substantial portions of the Software.
Chris@23 21
Chris@23 22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Chris@23 23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Chris@23 24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Chris@23 25 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
Chris@23 26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
Chris@23 27 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
Chris@23 28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Chris@23 29
Chris@23 30 Except as contained in this notice, the names of the Centre for
Chris@23 31 Digital Music; Queen Mary, University of London; and Chris Cannam
Chris@23 32 shall not be used in advertising or otherwise to promote the sale,
Chris@23 33 use or other dealings in this Software without prior written
Chris@23 34 authorization.
Chris@23 35 */
Chris@23 36
Chris@23 37 #ifndef _VAMP_PLUGIN_ADAPTER_H_
Chris@23 38 #define _VAMP_PLUGIN_ADAPTER_H_
Chris@23 39
Chris@23 40 #include <map>
Chris@23 41 #include <vamp/vamp.h>
Chris@23 42
Chris@23 43 #include "Plugin.h"
Chris@23 44
Chris@23 45 #include "plugguard.h"
Chris@23 46 _VAMP_SDK_PLUGSPACE_BEGIN(PluginAdapter.h)
Chris@23 47
Chris@23 48 namespace Vamp {
Chris@23 49
Chris@23 50 /**
Chris@23 51 * \class PluginAdapterBase PluginAdapter.h <vamp-sdk/PluginAdapter.h>
Chris@23 52 *
Chris@23 53 * PluginAdapter and PluginAdapterBase provide a wrapper class that a
Chris@23 54 * plugin library can use to make its C++ Vamp::Plugin objects
Chris@23 55 * available through the Vamp C API.
Chris@23 56 *
Chris@23 57 * Almost all Vamp plugin libraries will want to make use of this. To
Chris@23 58 * do so, all they need to do is declare a PluginAdapter<T> for each
Chris@23 59 * plugin class T in their library. It's very simple, and you need to
Chris@23 60 * know absolutely nothing about how it works in order to use it.
Chris@23 61 * Just cut and paste from an existing plugin's discovery function.
Chris@23 62 * \see vampGetPluginDescriptor
Chris@23 63 */
Chris@23 64
Chris@23 65 class PluginAdapterBase
Chris@23 66 {
Chris@23 67 public:
Chris@23 68 virtual ~PluginAdapterBase();
Chris@23 69
Chris@23 70 /**
Chris@23 71 * Return a VampPluginDescriptor describing the plugin that is
Chris@23 72 * wrapped by this adapter.
Chris@23 73 */
Chris@23 74 const VampPluginDescriptor *getDescriptor();
Chris@23 75
Chris@23 76 protected:
Chris@23 77 PluginAdapterBase();
Chris@23 78
Chris@23 79 virtual Plugin *createPlugin(float inputSampleRate) = 0;
Chris@23 80
Chris@23 81 class Impl;
Chris@23 82 Impl *m_impl;
Chris@23 83 };
Chris@23 84
Chris@23 85 /**
Chris@23 86 * \class PluginAdapter PluginAdapter.h <vamp-sdk/PluginAdapter.h>
Chris@23 87 *
Chris@23 88 * PluginAdapter turns a PluginAdapterBase into a specific wrapper for
Chris@23 89 * a particular plugin implementation.
Chris@23 90 *
Chris@23 91 * See PluginAdapterBase.
Chris@23 92 */
Chris@23 93
Chris@23 94 template <typename P>
Chris@23 95 class PluginAdapter : public PluginAdapterBase
Chris@23 96 {
Chris@23 97 public:
Chris@23 98 PluginAdapter() : PluginAdapterBase() { }
Chris@23 99 virtual ~PluginAdapter() { }
Chris@23 100
Chris@23 101 protected:
Chris@23 102 Plugin *createPlugin(float inputSampleRate) {
Chris@23 103 P *p = new P(inputSampleRate);
Chris@23 104 Plugin *plugin = dynamic_cast<Plugin *>(p);
Chris@23 105 if (!plugin) {
Chris@23 106 std::cerr << "ERROR: PluginAdapter::createPlugin: "
Chris@23 107 << "Template type is not a plugin!"
Chris@23 108 << std::endl;
Chris@23 109 delete p;
Chris@23 110 return 0;
Chris@23 111 }
Chris@23 112 return plugin;
Chris@23 113 }
Chris@23 114 };
Chris@23 115
Chris@23 116 }
Chris@23 117
Chris@23 118 _VAMP_SDK_PLUGSPACE_END(PluginAdapter.h)
Chris@23 119
Chris@23 120 #endif
Chris@23 121