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