annotate PyPlugin.h @ 23:535d559300dc

* fix incorrect default values for parameters (must match declared defaults)
author cannam
date Thu, 16 Jul 2009 13:19:20 +0000
parents 1ae350e97f93
children 7d28bed0864e
rev   line source
cannam@18 1 /* -*- c-basic-offset: 8 indent-tabs-mode: t -*- */
fazekasgy@0 2 /*
fazekasgy@0 3 Vamp
fazekasgy@0 4
fazekasgy@0 5 An API for audio analysis and feature extraction plugins.
fazekasgy@0 6
fazekasgy@0 7 Centre for Digital Music, Queen Mary, University of London.
fazekasgy@0 8 Copyright 2006 Chris Cannam.
fazekasgy@0 9
fazekasgy@0 10 Permission is hereby granted, free of charge, to any person
fazekasgy@0 11 obtaining a copy of this software and associated documentation
fazekasgy@0 12 files (the "Software"), to deal in the Software without
fazekasgy@0 13 restriction, including without limitation the rights to use, copy,
fazekasgy@0 14 modify, merge, publish, distribute, sublicense, and/or sell copies
fazekasgy@0 15 of the Software, and to permit persons to whom the Software is
fazekasgy@0 16 furnished to do so, subject to the following conditions:
fazekasgy@0 17
fazekasgy@0 18 The above copyright notice and this permission notice shall be
fazekasgy@0 19 included in all copies or substantial portions of the Software.
fazekasgy@0 20
fazekasgy@0 21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
fazekasgy@0 22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
fazekasgy@0 23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
fazekasgy@0 24 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
fazekasgy@0 25 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
fazekasgy@0 26 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
fazekasgy@0 27 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
fazekasgy@0 28
fazekasgy@0 29 Except as contained in this notice, the names of the Centre for
fazekasgy@0 30 Digital Music; Queen Mary, University of London; and Chris Cannam
fazekasgy@0 31 shall not be used in advertising or otherwise to promote the sale,
fazekasgy@0 32 use or other dealings in this Software without prior written
fazekasgy@0 33 authorization.
fazekasgy@0 34 */
fazekasgy@0 35
fazekasgy@0 36 /**
cannam@7 37 * This plugin abstracts appropriate Python Scripts as a Vamp plugin.
fazekasgy@0 38 */
fazekasgy@0 39
fazekasgy@0 40 #ifndef _PYTHON_WRAPPER_PLUGIN_H_
fazekasgy@0 41 #define _PYTHON_WRAPPER_PLUGIN_H_
fazekasgy@0 42
fazekasgy@0 43 #include "vamp-sdk/Plugin.h"
cannam@3 44 #include <Python.h>
cannam@3 45
cannam@3 46 #include "Mutex.h"
fazekasgy@0 47
fazekasgy@0 48 //fields in OutputDescriptor
cannam@18 49 namespace o {
fazekasgy@0 50 enum eOutDescriptors {
fazekasgy@0 51 not_found,
fazekasgy@0 52 identifier,
fazekasgy@0 53 name,
fazekasgy@0 54 description,
fazekasgy@0 55 unit,
fazekasgy@0 56 hasFixedBinCount,
fazekasgy@0 57 binCount,
fazekasgy@0 58 binNames,
fazekasgy@0 59 hasKnownExtents,
fazekasgy@0 60 minValue,
fazekasgy@0 61 maxValue,
fazekasgy@0 62 isQuantized,
fazekasgy@0 63 quantizeStep,
fazekasgy@0 64 sampleType,
fazekasgy@0 65 sampleRate,
cannam@18 66 hasDuration,
fazekasgy@0 67 endNode
fazekasgy@0 68 };
cannam@18 69 }
fazekasgy@0 70
fazekasgy@0 71 namespace p {
fazekasgy@0 72 enum eParmDescriptors {
fazekasgy@0 73 not_found,
fazekasgy@0 74 identifier,
fazekasgy@0 75 name,
fazekasgy@0 76 description,
fazekasgy@0 77 unit,
fazekasgy@0 78 minValue,
fazekasgy@0 79 maxValue,
fazekasgy@0 80 defaultValue,
cannam@22 81 isQuantized,
cannam@22 82 quantizeStep
fazekasgy@0 83 };
fazekasgy@0 84 }
fazekasgy@0 85
fazekasgy@0 86 enum eSampleTypes {
fazekasgy@0 87 OneSamplePerStep,
fazekasgy@0 88 FixedSampleRate,
fazekasgy@0 89 VariableSampleRate
fazekasgy@0 90 };
fazekasgy@0 91
fazekasgy@0 92 enum eFeatureFields {
fazekasgy@0 93 unknown,
fazekasgy@0 94 hasTimestamp,
fazekasgy@0 95 timeStamp,
cannam@18 96 hasDuration,
cannam@18 97 duration,
fazekasgy@0 98 values,
fazekasgy@0 99 label
fazekasgy@0 100 };
fazekasgy@0 101
fazekasgy@6 102 enum eProcessType {
fazekasgy@6 103 not_implemented,
fazekasgy@6 104 legacyProcess,
fazekasgy@6 105 numpyProcess
fazekasgy@6 106 };
fazekasgy@0 107
fazekasgy@0 108 class PyPlugin : public Vamp::Plugin
fazekasgy@0 109 {
fazekasgy@0 110 public:
cannam@18 111 PyPlugin(std::string plugin,float inputSampleRate, PyObject *pyInstance);
cannam@18 112 virtual ~PyPlugin();
fazekasgy@0 113
cannam@18 114 bool initialise(size_t channels, size_t stepSize, size_t blockSize);
cannam@18 115 void reset();
fazekasgy@6 116
fazekasgy@0 117 InputDomain getInputDomain() const;
fazekasgy@0 118 size_t getPreferredBlockSize() const;
fazekasgy@0 119 size_t getPreferredStepSize() const;
fazekasgy@0 120 size_t getMinChannelCount() const;
fazekasgy@0 121 size_t getMaxChannelCount() const;
fazekasgy@0 122
cannam@18 123 std::string getIdentifier() const;
cannam@18 124 std::string getName() const;
cannam@18 125 std::string getDescription() const;
cannam@18 126 std::string getMaker() const;
cannam@18 127 int getPluginVersion() const;
cannam@18 128 std::string getCopyright() const;
cannam@18 129
cannam@18 130 OutputList getOutputDescriptors() const;
cannam@18 131 ParameterList getParameterDescriptors() const;
fazekasgy@0 132 float getParameter(std::string paramid) const;
fazekasgy@0 133 void setParameter(std::string paramid, float newval);
fazekasgy@0 134
cannam@18 135 FeatureSet process(const float *const *inputBuffers,
cannam@18 136 Vamp::RealTime timestamp);
fazekasgy@0 137
cannam@18 138 FeatureSet getRemainingFeatures();
fazekasgy@0 139
fazekasgy@0 140 protected:
fazekasgy@0 141 PyObject *m_pyInstance;
cannam@18 142 size_t m_stepSize;
cannam@18 143 size_t m_blockSize;
cannam@18 144 size_t m_channels;
fazekasgy@0 145 std::string m_plugin;
fazekasgy@0 146 std::string m_class;
fazekasgy@0 147 std::string m_path;
fazekasgy@6 148 int m_processType;
fazekasgy@6 149 PyObject *m_pyProcess;
fazekasgy@6 150 InputDomain m_inputDomain;
fazekasgy@6 151
fazekasgy@6 152 bool initMaps() const;
fazekasgy@6 153 std::vector<std::string> PyList_To_StringVector (PyObject *inputList) const;
fazekasgy@6 154 std::vector<float> PyList_As_FloatVector (PyObject *inputList) const;
cannam@3 155
cannam@3 156 static Mutex m_pythonInterpreterMutex;
fazekasgy@0 157 };
fazekasgy@0 158
fazekasgy@0 159
fazekasgy@0 160 #endif