comparison skeleton/MyPlugin.cpp @ 283:6c9f10b8a53a

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