annotate examples/vamp-test-plugin.cpp @ 133:2255741a934c

Add test target
author Chris Cannam <c.cannam@qmul.ac.uk>
date Fri, 11 Nov 2016 11:08:10 +0000
parents c678dd8cf811
children
rev   line source
c@117 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
c@117 2 /*
c@117 3 Vamp Test Plugin
c@117 4 Copyright (c) 2013-2016 Queen Mary, University of London
c@117 5
c@117 6 Permission is hereby granted, free of charge, to any person
c@117 7 obtaining a copy of this software and associated documentation
c@117 8 files (the "Software"), to deal in the Software without
c@117 9 restriction, including without limitation the rights to use, copy,
c@117 10 modify, merge, publish, distribute, sublicense, and/or sell copies
c@117 11 of the Software, and to permit persons to whom the Software is
c@117 12 furnished to do so, subject to the following conditions:
c@117 13
c@117 14 The above copyright notice and this permission notice shall be
c@117 15 included in all copies or substantial portions of the Software.
c@117 16
c@117 17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
c@117 18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
c@117 19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
c@117 20 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
c@117 21 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
c@117 22 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
c@117 23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
c@117 24
c@117 25 Except as contained in this notice, the names of the Centre for
c@117 26 Digital Music and Queen Mary, University of London shall not be
c@117 27 used in advertising or otherwise to promote the sale, use or other
c@117 28 dealings in this Software without prior written authorization.
c@117 29 */
c@117 30
c@117 31 #include "PiperAdapter.h"
c@117 32 #include "PiperPluginLibrary.h"
c@117 33
c@117 34 #include "VampTestPlugin.h"
c@117 35
c@126 36 using piper_vamp_js::PiperAdapter;
c@126 37 using piper_vamp_js::PiperAdapterBase;
c@126 38 using piper_vamp_js::PiperPluginLibrary;
c@117 39
c@117 40 static std::string soname("vamp-test-plugin");
c@117 41
c@117 42 class Adapter : public PiperAdapterBase<VampTestPlugin>
c@117 43 {
c@117 44 public:
c@117 45 Adapter(bool freq) :
c@117 46 PiperAdapterBase<VampTestPlugin>(soname),
c@117 47 m_freq(freq) { }
c@117 48
c@117 49 protected:
c@117 50 bool m_freq;
c@117 51
c@117 52 Vamp::Plugin *createPlugin(float inputSampleRate) const {
c@117 53 return new VampTestPlugin(inputSampleRate, m_freq);
c@117 54 }
c@117 55 };
c@117 56
c@117 57 static Adapter timeAdapter(false);
c@117 58 static Adapter freqAdapter(true);
c@117 59
c@117 60 static PiperPluginLibrary library({
c@117 61 &timeAdapter,
c@117 62 &freqAdapter
c@117 63 });
c@117 64
c@117 65 extern "C" {
c@117 66
c@117 67 const char *piperRequestJson(const char *request) {
c@117 68 return library.requestJson(request);
c@117 69 }
c@117 70
c@117 71 const char *piperProcessRaw(int handle,
c@117 72 const float *const *inputBuffers,
c@117 73 int sec,
c@117 74 int nsec) {
c@117 75 return library.processRaw(handle, inputBuffers, sec, nsec);
c@117 76 }
c@117 77
c@117 78 void piperFreeJson(const char *json) {
c@117 79 return library.freeJson(json);
c@117 80 }
c@117 81
c@117 82 }
c@117 83