annotate example.cpp @ 43:90bf9d9f9c95

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