annotate skeleton/MyPlugin.cpp @ 488:286240e6d397

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