Chris@20: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@20: /* Chris@20: Vamp Test Plugin Chris@20: Copyright (c) 2013-2016 Queen Mary, University of London Chris@20: Chris@20: Permission is hereby granted, free of charge, to any person Chris@20: obtaining a copy of this software and associated documentation Chris@20: files (the "Software"), to deal in the Software without Chris@20: restriction, including without limitation the rights to use, copy, Chris@20: modify, merge, publish, distribute, sublicense, and/or sell copies Chris@20: of the Software, and to permit persons to whom the Software is Chris@20: furnished to do so, subject to the following conditions: Chris@20: Chris@20: The above copyright notice and this permission notice shall be Chris@20: included in all copies or substantial portions of the Software. Chris@20: Chris@20: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, Chris@20: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF Chris@20: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND Chris@20: NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY Chris@20: CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF Chris@20: CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION Chris@20: WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Chris@20: Chris@20: Except as contained in this notice, the names of the Centre for Chris@20: Digital Music and Queen Mary, University of London shall not be Chris@20: used in advertising or otherwise to promote the sale, use or other Chris@20: dealings in this Software without prior written authorization. Chris@20: */ Chris@20: Chris@65: #include "PiperExport.h" Chris@20: Chris@20: #include "VampTestPlugin.h" Chris@20: Chris@57: using piper_vamp_js::PiperAdapter; Chris@57: using piper_vamp_js::PiperAdapterBase; Chris@57: using piper_vamp_js::PiperPluginLibrary; Chris@20: Chris@20: static std::string soname("vamp-test-plugin"); Chris@20: Chris@65: /* Chris@65: This is an example of a library that exports more than one "plugin" Chris@65: from a single C++ class. The VampTestPlugin class is constructed Chris@65: with an argument that determines whether it is a time- or Chris@65: frequency-domain plugin, and the library offers both. Chris@65: Chris@65: Where normally a library that offered two plugins would have two Chris@65: static PiperAdapters specialised with the two plugin classes, here Chris@65: we want two static PiperAdapters specialised with the same class Chris@65: but different constructor arguments. This is one way to do that, Chris@65: taking advantage of the fact that PiperAdapterBase exposes Chris@65: createPlugin as a virtual method. Chris@65: Chris@65: Note that a very similar mechanism is used in the standard Vamp Chris@65: version of this plugin library. Chris@65: */ Chris@65: Chris@43: class Adapter : public PiperAdapterBase Chris@20: { Chris@20: public: Chris@20: Adapter(bool freq) : Chris@43: PiperAdapterBase(soname), Chris@20: m_freq(freq) { } Chris@20: Chris@20: protected: Chris@20: bool m_freq; Chris@20: Chris@20: Vamp::Plugin *createPlugin(float inputSampleRate) const { Chris@20: return new VampTestPlugin(inputSampleRate, m_freq); Chris@20: } Chris@20: }; Chris@20: Chris@20: static Adapter timeAdapter(false); Chris@20: static Adapter freqAdapter(true); Chris@20: Chris@43: static PiperPluginLibrary library({ Chris@20: &timeAdapter, Chris@20: &freqAdapter Chris@20: }); Chris@20: Chris@65: PIPER_EXPORT_LIBRARY(library); Chris@20: