annotate vamp-test-plugin.cpp @ 40:a734a7e976fa jsonrpc

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