annotate osx/include/vamp-sdk/PluginAdapter.h @ 113:61395f486647

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