annotate src/vamp-plugin-sdk-2.5/skeleton/MyPlugin.cpp @ 169:223a55898ab9 tip default

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