annotate skeleton/MyPlugin.cpp @ 283:6c9f10b8a53a

* Add skeleton
author cannam
date Thu, 23 Apr 2009 08:59:24 +0000
parents
children 71b6db22a8a8
rev   line source
cannam@283 1
cannam@283 2 // This is a skeleton file for use in creating your own plugin
cannam@283 3 // libraries. Replace MyPlugin and myPlugin throughout with the name
cannam@283 4 // of your first plugin class, and fill in the gaps as appropriate.
cannam@283 5
cannam@283 6
cannam@283 7 #include "MyPlugin.h"
cannam@283 8
cannam@283 9
cannam@283 10 MyPlugin::MyPlugin(float inputSampleRate) :
cannam@283 11 Plugin(inputSampleRate)
cannam@283 12 {
cannam@283 13 }
cannam@283 14
cannam@283 15 MyPlugin::~MyPlugin()
cannam@283 16 {
cannam@283 17 }
cannam@283 18
cannam@283 19 string
cannam@283 20 MyPlugin::getIdentifier() const
cannam@283 21 {
cannam@283 22 return "myplugin";
cannam@283 23 }
cannam@283 24
cannam@283 25 string
cannam@283 26 MyPlugin::getName() const
cannam@283 27 {
cannam@283 28 return "My Plugin";
cannam@283 29 }
cannam@283 30
cannam@283 31 string
cannam@283 32 MyPlugin::getDescription() const
cannam@283 33 {
cannam@283 34 // Return something helpful here!
cannam@283 35 return "";
cannam@283 36 }
cannam@283 37
cannam@283 38 string
cannam@283 39 MyPlugin::getMaker() const
cannam@283 40 {
cannam@283 41 // Your name here
cannam@283 42 return "";
cannam@283 43 }
cannam@283 44
cannam@283 45 int
cannam@283 46 MyPlugin::getPluginVersion() const
cannam@283 47 {
cannam@283 48 // Increment this each time you release a version that behaves
cannam@283 49 // differently from the previous one
cannam@283 50 return 1;
cannam@283 51 }
cannam@283 52
cannam@283 53 string
cannam@283 54 MyPlugin::getCopyright() const
cannam@283 55 {
cannam@283 56 // This function is not ideally named. It does not necessarily
cannam@283 57 // need to say who made the plugin -- getMaker does that -- but it
cannam@283 58 // should indicate the terms under which it is distributed. For
cannam@283 59 // example, "Copyright (year). All Rights Reserved", or "GPL"
cannam@283 60 return "";
cannam@283 61 }
cannam@283 62
cannam@283 63 MyPlugin::InputDomain
cannam@283 64 MyPlugin::getInputDomain() const
cannam@283 65 {
cannam@283 66 return TimeDomain;
cannam@283 67 }
cannam@283 68
cannam@283 69 size_t
cannam@283 70 MyPlugin::getPreferredBlockSize() const
cannam@283 71 {
cannam@283 72 return 0; // 0 means "I can handle any block size"
cannam@283 73 }
cannam@283 74
cannam@283 75 size_t
cannam@283 76 MyPlugin::getPreferredStepSize() const
cannam@283 77 {
cannam@283 78 return 0; // 0 means "anything sensible"; in practice this
cannam@283 79 // means the same as the block size for TimeDomain
cannam@283 80 // plugins, or half of it for FrequencyDomain plugins
cannam@283 81 }
cannam@283 82
cannam@283 83 size_t
cannam@283 84 MyPlugin::getMinChannelCount() const
cannam@283 85 {
cannam@283 86 return 1;
cannam@283 87 }
cannam@283 88
cannam@283 89 size_t
cannam@283 90 MyPlugin::getMaxChannelCount() const
cannam@283 91 {
cannam@283 92 return 1;
cannam@283 93 }
cannam@283 94
cannam@283 95 MyPlugin::ParameterList
cannam@283 96 MyPlugin::getParameterDescriptors() const
cannam@283 97 {
cannam@283 98 ParameterList list;
cannam@283 99
cannam@283 100 // If the plugin has no adjustable parameters, return an empty
cannam@283 101 // list here (and there's no need to provide implementations of
cannam@283 102 // getParameter and setParameter in that case either).
cannam@283 103
cannam@283 104 ParameterDescriptor d;
cannam@283 105 d.identifier = "parameter";
cannam@283 106 d.name = "Some Parameter";
cannam@283 107 d.description = "";
cannam@283 108 d.unit = "";
cannam@283 109 d.minValue = 0;
cannam@283 110 d.maxValue = 10;
cannam@283 111 d.defaultValue = 5;
cannam@283 112 d.isQuantized = false;
cannam@283 113 list.push_back(d);
cannam@283 114
cannam@283 115 return list;
cannam@283 116 }
cannam@283 117
cannam@283 118 float
cannam@283 119 MyPlugin::getParameter(string identifier) const
cannam@283 120 {
cannam@283 121 if (identifier == "parameter") {
cannam@283 122 return 5; // return the ACTUAL current value of your parameter here!
cannam@283 123 }
cannam@283 124 return 0;
cannam@283 125 }
cannam@283 126
cannam@283 127 void
cannam@283 128 MyPlugin::setParameter(string identifier, float value)
cannam@283 129 {
cannam@283 130 if (identifier == "parameter") {
cannam@283 131 // set the actual value of your parameter
cannam@283 132 }
cannam@283 133 }
cannam@283 134
cannam@283 135 MyPlugin::ProgramList
cannam@283 136 MyPlugin::getPrograms() const
cannam@283 137 {
cannam@283 138 ProgramList list;
cannam@283 139
cannam@283 140 // If you have no programs, return an empty list (or simply don't
cannam@283 141 // implement this function or getCurrentProgram/selectProgram)
cannam@283 142
cannam@283 143 return list;
cannam@283 144 }
cannam@283 145
cannam@283 146 string
cannam@283 147 MyPlugin::getCurrentProgram() const
cannam@283 148 {
cannam@283 149 return ""; // no programs
cannam@283 150 }
cannam@283 151
cannam@283 152 void
cannam@283 153 MyPlugin::selectProgram(string name)
cannam@283 154 {
cannam@283 155 }
cannam@283 156
cannam@283 157 MyPlugin::OutputList
cannam@283 158 MyPlugin::getOutputDescriptors() const
cannam@283 159 {
cannam@283 160 OutputList list;
cannam@283 161
cannam@283 162 // See OutputDescriptor documentation for the possibilities here.
cannam@283 163 // Every plugin must have at least one output.
cannam@283 164
cannam@283 165 OutputDescriptor d;
cannam@283 166 d.identifier = "output";
cannam@283 167 d.name = "My Output";
cannam@283 168 d.description = "";
cannam@283 169 d.unit = "";
cannam@283 170 d.hasFixedBinCount = true;
cannam@283 171 d.binCount = 1;
cannam@283 172 d.hasKnownExtents = false;
cannam@283 173 d.isQuantized = false;
cannam@283 174 d.sampleType = OutputDescriptor::OneSamplePerStep;
cannam@283 175 d.hasDuration = false;
cannam@283 176 list.push_back(d);
cannam@283 177
cannam@283 178 return list;
cannam@283 179 }
cannam@283 180
cannam@283 181 bool
cannam@283 182 MyPlugin::initialise(size_t channels, size_t stepSize, size_t blockSize)
cannam@283 183 {
cannam@283 184 if (channels < getMinChannelCount() ||
cannam@283 185 channels > getMaxChannelCount()) return false;
cannam@283 186
cannam@283 187 // Real initialisation work goes here!
cannam@283 188
cannam@283 189 return true;
cannam@283 190 }
cannam@283 191
cannam@283 192 void
cannam@283 193 MyPlugin::reset()
cannam@283 194 {
cannam@283 195 // Clear buffers, reset stored values, etc
cannam@283 196 }
cannam@283 197
cannam@283 198 MyPlugin::FeatureSet
cannam@283 199 MyPlugin::process(const float *const *inputBuffers, Vamp::RealTime timestamp)
cannam@283 200 {
cannam@283 201 // Do actual work!
cannam@283 202 return FeatureSet();
cannam@283 203 }
cannam@283 204
cannam@283 205 MyPlugin::FeatureSet
cannam@283 206 MyPlugin::getRemainingFeatures()
cannam@283 207 {
cannam@283 208 return FeatureSet();
cannam@283 209 }
cannam@283 210