Mtp2 » History » Version 3

Chris Cannam, 2012-02-23 05:34 PM

1 1 Chris Cannam
h1. From Method to Plugin: Building a new plugin on Windows using Visual C++
2 1 Chris Cannam
3 1 Chris Cannam
**Note:** This tutorial is specific to **Windows with Visual C++**.  Go [[mtp1|here]] for a version that uses Mac OS/X.
4 1 Chris Cannam
5 1 Chris Cannam
We're going to walk through the process of making, and compiling, a new Vamp plugin based on the skeleton files included with the Vamp plugin SDK.
6 1 Chris Cannam
7 1 Chris Cannam
After downloading the various bits and pieces of code we'll need, we will start by setting up a new Visual C++ project in which we just get the skeleton plugin to compile without it doing any actual work, and then we'll add some substance to it afterwards.
8 1 Chris Cannam
9 1 Chris Cannam
This tutorial assumes the use of Microsoft Visual C++ 2008 Express Edition (free with registration from http://www.microsoft.com/Express/VC/), though it should generally apply to other versions as well.
10 1 Chris Cannam
11 1 Chris Cannam
The focus here is on the practical details of what you need to put in a plugin and how to get it to build and run -- not on the real mathematical or signal-processing aspect.  We will pick a very simple method (time-domain signal power, block by block) for this example.  Please refer to the [[http://vamp-plugins.org/guide.pdf|Vamp plugin API programmer's guide]] for further reading, with information about returning more sophisticated features.
12 1 Chris Cannam
13 1 Chris Cannam
h2.  1. Download and unpack the SDK headers and pre-built libraries 
14 1 Chris Cannam
15 1 Chris Cannam
Download the Vamp plugin SDK version 2.2 from the "development headers and source code" link on the developer page at http://vamp-plugins.org/develop.html -- the file you want is called @vamp-plugin-sdk-2.2.zip@.  Unpack this into your Visual Studio projects folder, which by default is found in your @Documents@ folder, at @Documents\Visual Studio 2008\Projects@.  You should now have a new folder in this location called @vamp-plugin-sdk-2.2@.  This picture shows the older version 2.1, but the principle is the same.
16 1 Chris Cannam
17 1 Chris Cannam
{{:mtp2-sdk-folder.png|Newly unpacked SDK folder in the Projects folder}}
18 1 Chris Cannam
19 1 Chris Cannam
We're not going to compile the SDK, only draw the header files from it.  To go with them, download the file @vamp-plugin-sdk-2.1-staticlibs-win32-msvc.zip@ from the same location, which contains some pre-compiled SDK libraries, and unpack it in the @Projects@ folder as well.  Note that, although the binaries file is marked as version 2.1, the binaries are unchanged between 2.1 and 2.2 (so there is no separate release marked 2.2).
20 1 Chris Cannam
21 1 Chris Cannam
h2.  2. Make a new project based on the skeleton files 
22 1 Chris Cannam
23 1 Chris Cannam
We're going to build our plugin in a new project called @tutorial@, which initially will contain the skeleton plugin code from the SDK.
24 1 Chris Cannam
25 1 Chris Cannam
There are various ways to accomplish this; here's one.
26 1 Chris Cannam
27 1 Chris Cannam
Drag-copy the @skeleton@ folder from within @vamp-plugin-sdk-2.2@ directly into the @Projects@ folder...
28 1 Chris Cannam
29 1 Chris Cannam
{{:mtp2-skeleton-copy.png|Copy the skeleton files to a new project folder}}
30 1 Chris Cannam
31 1 Chris Cannam
... and then rename @skeleton@ to @tutorial@ ...
32 1 Chris Cannam
33 1 Chris Cannam
{{:mtp2-skeleton-rename.png|Rename skeleton project to tutorial}}
34 1 Chris Cannam
35 1 Chris Cannam
Now open Visual Studio, select @File@ -> @New@ -> @Project From Existing Code...@...
36 1 Chris Cannam
37 1 Chris Cannam
{{:mtp2-new-project-from.png|New Project From Existing Code}}
38 1 Chris Cannam
39 1 Chris Cannam
... and in the new-project wizard do the following:
40 2 Chris Cannam
41 3 Chris Cannam
  * On the first page, choose the _Visual C++ Project_ type
42 3 Chris Cannam
  * On the next page, under _Specify Project Location and Source Files_, navigate to the new @tutorial@ folder in your @Projects@ directory and _Select Folder_
43 2 Chris Cannam
44 1 Chris Cannam
            {{:mtp2-project-location.png|Setting the project location and name}}
45 2 Chris Cannam
46 3 Chris Cannam
  * Under _Project Name_ enter @Tutorial@
47 3 Chris Cannam
  * **Important:** In the _Project Settings_ page under _How do you want to build the project?_, select @Use Visual Studio@ and @Dynamically linked library (DLL) project@
48 2 Chris Cannam
49 1 Chris Cannam
            {{:mtp2-project-type.png|Setting the project target type}}
50 2 Chris Cannam
51 3 Chris Cannam
  * **Important:** In the _Configuration Settings_ page under _Include search paths (/I)_, type @..\vamp-plugin-sdk-2.2@
52 1 Chris Cannam
  * Finish
53 1 Chris Cannam
54 1 Chris Cannam
Now save the project (Ctrl+S or equivalent).  Once the project has been created, we still have a couple more properties to set.  These are found in the @Project@ -> @Properties@ window:
55 1 Chris Cannam
56 1 Chris Cannam
  * Under @Configuration Properties@ -> @Linker@ -> @General@ -> @Additional Library Directories@, navigate to the directory containing the **Debug** versions of the pre-compiled libraries you downloaded earlier (e.g. in my case this would be @C:\Users\cannam\Documents\Visual Studio 2008\Projects\vamp-plugin-sdk-2.1-staticlibs-win32-msvc\debug@) and add it to the list
57 1 Chris Cannam
  * Under @Configuration Properties@ -> @Linker@ -> @Input@ -> @Additional Dependencies@, add @VampPluginSDK.lib@
58 1 Chris Cannam
  * Under @Configuration Properties@ -> @Linker@ -> @Command Line@ -> @Additional options@, add @/EXPORT:vampGetPluginDescriptor@
59 1 Chris Cannam
60 1 Chris Cannam
You should now be able to build the project (press F7).
61 1 Chris Cannam
62 1 Chris Cannam
In the above, it's critically important that the Debug configuration of your project uses the Debug version of the pre-compiled library folder, and the Release configuration (when you come to that) uses the Release version.  If you get this wrong, your plugin will build but will crash when you try to use it!
63 1 Chris Cannam
64 1 Chris Cannam
The bulk of the skeleton plugin code is contained in the files @MyPlugin.cpp@ and @MyPlugin.h@.  These two files implement a single C++ class, called @MyPlugin@.  For the sake of brevity in the tutorial we'll leave these names unchanged, but you might prefer to change them!  To do so, rename the two files as you wish, and replace every occurrence of the text @MyPlugin@ in both of them, and in @plugins.cpp@, with your preferred plugin class name.
65 1 Chris Cannam
66 1 Chris Cannam
The file @plugins.cpp@ contains the entry point for the plugin library.  A library can hold more than one plugin, and the job of @plugins.cpp@ is to provide a single known public function (@vampGetPluginDescriptor@) which the host can use to find out what plugins are available in the library.  The skeleton version of @plugins.cpp@ just returns the single MyPlugin plugin class.
67 1 Chris Cannam
68 1 Chris Cannam
Note that it makes absolutely no difference to the operation of the plugin what its class is called, or what any of these files is called; MyPlugin is (in purely technical terms) as good a name as any.  It also shouldn't matter if two different libraries happen to use the same class name.  But if you have more than one plugin in the same library, they'll need to have different class names then!
69 1 Chris Cannam
70 1 Chris Cannam
h2.  3. Check that the plugin works with some test programs 
71 1 Chris Cannam
72 1 Chris Cannam
The next thing to do is gather some programs we can use to test our plugin, so that we can check it built correctly, and so that we'll be well placed to test it properly when it actually does something.
73 1 Chris Cannam
74 1 Chris Cannam
h3. vamp-plugin-tester 
75 1 Chris Cannam
76 1 Chris Cannam
One host worth setting up at the start is @vamp-plugin-tester@, a program that tests your plugin for a number of possible problems and pitfalls.  You can download this from http://vamp-plugins.org/develop.html as well; you're looking for the file @vamp-plugin-tester-1.0-win32.zip@.  Unpack it somewhere convenient, and (for now) copy the @vamp-plugin-tester.exe@ program into the @tutorial@ project folder for easy reference.
77 1 Chris Cannam
78 1 Chris Cannam
We can then run the tester from the command prompt (go to the Start menu and type @cmd@ to get the command prompt up).
79 1 Chris Cannam
80 1 Chris Cannam
First go to the @tutorial\Debug@ folder which is where our newly built plugin lives:
81 1 Chris Cannam
82 1 Chris Cannam
<pre>
83 1 Chris Cannam
C:\Users\cannam>cd "Documents\Visual Studio 2008\Projects\tutorial\Debug"
84 1 Chris Cannam
C:\Users\cannam\Documents\Visual Studio 2008\Projects\tutorial\Debug>
85 1 Chris Cannam
</pre>
86 1 Chris Cannam
87 1 Chris Cannam
If you type @dir *.dll@, you should see @Tutorial.dll@, the plugin library we just built.
88 1 Chris Cannam
89 1 Chris Cannam
Like all Vamp hosts, @vamp-plugin-tester@ understands the @VAMP_PATH@ environment variable to tell it where to look for Vamp plugins.  We need to set that, at least temporarily, to point to our new plugin in the current directory:
90 1 Chris Cannam
91 1 Chris Cannam
<pre>
92 1 Chris Cannam
C:\Users\cannam\Documents\Visual Studio 2008\Projects\tutorial\Debug>set VAMP_PATH=.
93 1 Chris Cannam
</pre>
94 1 Chris Cannam
95 1 Chris Cannam
And run the tester:
96 1 Chris Cannam
97 1 Chris Cannam
<pre>
98 1 Chris Cannam
C:\Users\cannam\Documents\Visual Studio 2008\Projects\tutorial\Debug>..\vamp-plugin-tester.exe -a
99 1 Chris Cannam
</pre>
100 1 Chris Cannam
101 1 Chris Cannam
{{:mtp2-tester.png|Running the Vamp plugin tester}}
102 1 Chris Cannam
103 1 Chris Cannam
As you see, @vamp-plugin-tester@ runs quite a number of tests -- see its @README@ file for more details about the error and warning messages it might give.  It's a good idea to use the tester right from the start of plugin development.
104 1 Chris Cannam
105 1 Chris Cannam
h3. vamp-simple-host 
106 1 Chris Cannam
107 1 Chris Cannam
The tester gives some instant feedback, but the simplest way to run a plugin and see what happens is to use @vamp-simple-host@.  This is also part of the Vamp SDK, and is available as a binary executable in the @vamp-plugin-sdk-2.1-binaries-win32-mingw.zip@ package (the "Pre-compiled library and host binaries" link on the [[http://vamp-plugins.org/develop.html|developer page]]).  Extract only the @vamp-simple-host.exe@ program from this package, and drop it into the @tutorial@ folder as before.
108 1 Chris Cannam
109 1 Chris Cannam
We set the @VAMP_PATH@ environment variable already when using @vamp-plugin-tester.exe@ above, but if you skipped that part:
110 1 Chris Cannam
111 1 Chris Cannam
<pre>
112 1 Chris Cannam
C:\Users\cannam>cd "Documents\Visual Studio 2008\Projects\tutorial\Debug"
113 1 Chris Cannam
C:\Users\cannam\Documents\Visual Studio 2008\Projects\tutorial\Debug>set VAMP_PATH=.
114 1 Chris Cannam
</pre>
115 1 Chris Cannam
116 1 Chris Cannam
Now, with the @-l@ option, we can ask the host to list the plugins it finds there.
117 1 Chris Cannam
118 1 Chris Cannam
<pre>
119 1 Chris Cannam
C:\Users\cannam\Documents\Visual Studio 2008\Projects\tutorial\Debug>..\vamp-simple-host.exe -l
120 1 Chris Cannam
Vamp plugin search path: [.]
121 1 Chris Cannam
122 1 Chris Cannam
Vamp plugin libraries found in search path:
123 1 Chris Cannam
124 1 Chris Cannam
  ./tutorial.dll:
125 1 Chris Cannam
    [A] [v2] My Plugin, "myplugin" []
126 1 Chris Cannam
127 1 Chris Cannam
C:\Users\cannam\Documents\Visual Studio 2008\Projects\tutorial\Debug>
128 1 Chris Cannam
</pre>
129 1 Chris Cannam
130 1 Chris Cannam
Huzzah.  We can use this host to run the plugin on some test audio files, not just list it -- but there isn't much point yet.
131 1 Chris Cannam
132 1 Chris Cannam
h2.  4. Now, the code! 
133 1 Chris Cannam
134 1 Chris Cannam
Right, let's make the plugin do something.  We're going to calculate the mean power for each processing block.  The work we do in this section will involve making a few edits to the @MyPlugin.cpp@ file (and at one point also @MyPlugins.h@) and rebuilding the project.
135 1 Chris Cannam
136 1 Chris Cannam
The calculation we want is @sum(x[i]^2) / N@, where @x[i]@ is audio sample number @i@, for @i@ in the range 0 to @N-1@, with @N@ the number of samples in the processing block.
137 1 Chris Cannam
138 1 Chris Cannam
h3. Describing the input and output formats 
139 1 Chris Cannam
140 1 Chris Cannam
Our calculation is a time-domain one (working directly from the PCM audio data), which means we don't need to change this function (found at line 63 of MyPlugin.cpp):
141 1 Chris Cannam
142 1 Chris Cannam
<pre>
143 1 Chris Cannam
MyPlugin::InputDomain
144 1 Chris Cannam
MyPlugin::getInputDomain() const
145 1 Chris Cannam
{
146 1 Chris Cannam
    return TimeDomain;
147 1 Chris Cannam
}
148 1 Chris Cannam
</pre>
149 1 Chris Cannam
150 1 Chris Cannam
We are going to write code to handle a single audio channel only, and leave it to the host to decide what to do if more than one channel is provided (most hosts will mix-down the input for us).  So that means we don't need to change these functions either:
151 1 Chris Cannam
152 1 Chris Cannam
<pre>
153 1 Chris Cannam
size_t
154 1 Chris Cannam
MyPlugin::getMinChannelCount() const
155 1 Chris Cannam
{
156 1 Chris Cannam
    return 1;
157 1 Chris Cannam
}
158 1 Chris Cannam
159 1 Chris Cannam
size_t
160 1 Chris Cannam
MyPlugin::getMaxChannelCount() const
161 1 Chris Cannam
{
162 1 Chris Cannam
    return 1;
163 1 Chris Cannam
}
164 1 Chris Cannam
</pre>
165 1 Chris Cannam
166 1 Chris Cannam
Nothing about our calculation requires us to constrain the processing block size -- we can handle any block size.  So we can leave this function unchanged as well:
167 1 Chris Cannam
168 1 Chris Cannam
<pre>
169 1 Chris Cannam
size_t
170 1 Chris Cannam
MyPlugin::getPreferredBlockSize() const
171 1 Chris Cannam
{
172 1 Chris Cannam
    return 0; // 0 means "I can handle any block size"
173 1 Chris Cannam
}
174 1 Chris Cannam
</pre>
175 1 Chris Cannam
176 1 Chris Cannam
The function @getOutputDescriptors@ describes what sort of features we intend to return.  As it happens, the skeleton already contains pretty much the description we are going to need: a single feature, with a single value, returned for each processing block.  We should probably change the name of the output, at least:
177 1 Chris Cannam
178 1 Chris Cannam
<pre>
179 1 Chris Cannam
MyPlugin::OutputList
180 1 Chris Cannam
MyPlugin::getOutputDescriptors() const
181 1 Chris Cannam
{
182 1 Chris Cannam
    OutputList list;
183 1 Chris Cannam
184 1 Chris Cannam
    OutputDescriptor d;
185 1 Chris Cannam
    d.identifier = "power";
186 1 Chris Cannam
    d.name = "Power";
187 1 Chris Cannam
    d.description = "";
188 1 Chris Cannam
    d.unit = "";
189 1 Chris Cannam
    d.hasFixedBinCount = true;
190 1 Chris Cannam
    d.binCount = 1;
191 1 Chris Cannam
    d.hasKnownExtents = false;
192 1 Chris Cannam
    d.isQuantized = false;
193 1 Chris Cannam
    d.sampleType = OutputDescriptor::OneSamplePerStep;
194 1 Chris Cannam
    d.hasDuration = false;
195 1 Chris Cannam
    list.push_back(d);
196 1 Chris Cannam
197 1 Chris Cannam
    return list;
198 1 Chris Cannam
}
199 1 Chris Cannam
</pre>
200 1 Chris Cannam
201 1 Chris Cannam
h3. Initialisation 
202 1 Chris Cannam
203 1 Chris Cannam
We said that we can **accept** any block size -- but we do need to know what the block size is.
204 1 Chris Cannam
205 1 Chris Cannam
This is told to us in the @initialise@ function.  Looking at that function, we can see the argument is @size_t blockSize@.  It's our job to remember the value of this.
206 1 Chris Cannam
207 1 Chris Cannam
We need to add a class data member for this.  In @MyPlugin.h@, look for this line at line 54 (near the bottom of the file):
208 1 Chris Cannam
209 1 Chris Cannam
<pre>
210 1 Chris Cannam
    // plugin-specific data and methods go here
211 1 Chris Cannam
</pre>
212 1 Chris Cannam
213 1 Chris Cannam
and add a line after it:
214 1 Chris Cannam
215 1 Chris Cannam
<pre>
216 1 Chris Cannam
    // plugin-specific data and methods go here
217 1 Chris Cannam
    size_t m_blockSize;
218 1 Chris Cannam
</pre>
219 1 Chris Cannam
220 1 Chris Cannam
Then, back in @MyPlugin.cpp@, find this line at line 187 in the @initialise@ function:
221 1 Chris Cannam
222 1 Chris Cannam
<pre>
223 1 Chris Cannam
    // Real initialisation work goes here!
224 1 Chris Cannam
</pre>
225 1 Chris Cannam
226 1 Chris Cannam
and add a line to set the data member:
227 1 Chris Cannam
228 1 Chris Cannam
<pre>
229 1 Chris Cannam
    // Real initialisation work goes here!
230 1 Chris Cannam
    m_blockSize = blockSize;
231 1 Chris Cannam
</pre>
232 1 Chris Cannam
233 1 Chris Cannam
Also it's very good practice to make sure the data member is initialised to zero in the class constructor.  That, at line 10 of @MyPlugin.cpp@, initially reads:
234 1 Chris Cannam
235 1 Chris Cannam
<pre>
236 1 Chris Cannam
MyPlugin::MyPlugin(float inputSampleRate) :
237 1 Chris Cannam
    Plugin(inputSampleRate)
238 1 Chris Cannam
{
239 1 Chris Cannam
}
240 1 Chris Cannam
</pre>
241 1 Chris Cannam
242 1 Chris Cannam
and we want it to read:
243 1 Chris Cannam
244 1 Chris Cannam
<pre>
245 1 Chris Cannam
MyPlugin::MyPlugin(float inputSampleRate) :
246 1 Chris Cannam
    Plugin(inputSampleRate),
247 1 Chris Cannam
    m_blockSize(0)
248 1 Chris Cannam
{
249 1 Chris Cannam
}
250 1 Chris Cannam
</pre>
251 1 Chris Cannam
252 1 Chris Cannam
At this point it's a good idea to try rebuilding the project and make sure it still compiles.
253 1 Chris Cannam
254 1 Chris Cannam
h3. Processing 
255 1 Chris Cannam
256 1 Chris Cannam
The core of our calculation happens in the @process@ method:
257 1 Chris Cannam
258 1 Chris Cannam
<pre>
259 1 Chris Cannam
MyPlugin::FeatureSet
260 1 Chris Cannam
MyPlugin::process(const float *const *inputBuffers, Vamp::RealTime timestamp)
261 1 Chris Cannam
{
262 1 Chris Cannam
    // Do actual work!
263 1 Chris Cannam
    return FeatureSet();
264 1 Chris Cannam
}
265 1 Chris Cannam
</pre>
266 1 Chris Cannam
267 1 Chris Cannam
Here @inputBuffers@ is effectively an array of arrays -- to retrieve a single audio sample, we index it first by audio channel number (we know that we only have one channel, so the only valid index is 0) and then by audio sample number (from 0 to the processing block size less 1).
268 1 Chris Cannam
269 1 Chris Cannam
What we want to do is add up the squares of the audio sample values, and divide by the number of samples.
270 1 Chris Cannam
271 1 Chris Cannam
<pre>
272 1 Chris Cannam
MyPlugin::FeatureSet
273 1 Chris Cannam
MyPlugin::process(const float *const *inputBuffers, Vamp::RealTime timestamp)
274 1 Chris Cannam
{
275 1 Chris Cannam
    float sumOfSquares = 0.0f;
276 1 Chris Cannam
277 1 Chris Cannam
    size_t i = 0; // note: same type as m_blockSize
278 1 Chris Cannam
279 1 Chris Cannam
    while (i < m_blockSize) {
280 1 Chris Cannam
        float sample = inputBuffers[0][i];
281 1 Chris Cannam
        sumOfSquares += sample * sample;
282 1 Chris Cannam
        ++i;
283 1 Chris Cannam
    }
284 1 Chris Cannam
285 1 Chris Cannam
    float meanPower = sumOfSquares / m_blockSize;
286 1 Chris Cannam
287 1 Chris Cannam
    // now what?
288 1 Chris Cannam
289 1 Chris Cannam
    return FeatureSet();
290 1 Chris Cannam
}
291 1 Chris Cannam
</pre>
292 1 Chris Cannam
293 1 Chris Cannam
So we've calculated the mean power value -- now how to return it?
294 1 Chris Cannam
295 1 Chris Cannam
In Vamp plugin terms, what we have is a plugin that has a single output, on which is returned a single audio feature for each process block, with one value.  We need to construct a @Feature@ object, give it a single value, and then push it as the only feature in output 0 (the first) of a new @FeatureSet@ object.  See the [[http://vamp-plugins.org/guide.pdf|Vamp plugin API programmer's guide]] for more information about feature representation.
296 1 Chris Cannam
297 1 Chris Cannam
Here's the code:
298 1 Chris Cannam
299 1 Chris Cannam
<pre>
300 1 Chris Cannam
MyPlugin::FeatureSet
301 1 Chris Cannam
MyPlugin::process(const float *const *inputBuffers, Vamp::RealTime timestamp)
302 1 Chris Cannam
{
303 1 Chris Cannam
    float sumOfSquares = 0.0f;
304 1 Chris Cannam
305 1 Chris Cannam
    size_t i = 0;
306 1 Chris Cannam
307 1 Chris Cannam
    while (i < m_blockSize) {
308 1 Chris Cannam
        float sample = inputBuffers[0][i];
309 1 Chris Cannam
        sumOfSquares += sample * sample;
310 1 Chris Cannam
        ++i;
311 1 Chris Cannam
    }
312 1 Chris Cannam
313 1 Chris Cannam
    float meanPower = sumOfSquares / m_blockSize;
314 1 Chris Cannam
315 1 Chris Cannam
    Feature f;
316 1 Chris Cannam
    f.hasTimestamp = false;
317 1 Chris Cannam
    f.values.push_back(meanPower);
318 1 Chris Cannam
319 1 Chris Cannam
    FeatureSet fs;
320 1 Chris Cannam
    fs[0].push_back(f);
321 1 Chris Cannam
    return fs;
322 1 Chris Cannam
}
323 1 Chris Cannam
</pre>
324 1 Chris Cannam
325 1 Chris Cannam
After making this change and rebuilding the project, we now have a plugin that actually does something.
326 1 Chris Cannam
327 1 Chris Cannam
Returning to our command prompt, and with the aid of a suitable input file (@.wav@ or a similar uncompressed format that @vamp-simple-host@ understands) in the @tutorial@ folder, we can now run it.  For example:
328 1 Chris Cannam
329 1 Chris Cannam
<pre>
330 1 Chris Cannam
C:\Users\cannam\Documents\Visual Studio 2008\Projects\tutorial\Debug>..\vamp-simple-host.exe Tutorial:myplugin ..\my-song.wav
331 1 Chris Cannam
vamp-simple-host: Running...
332 1 Chris Cannam
Reading file: "C:/Users/cannam/Documents/Visual Studio 2008/Projects/tutorial/my-song.wav", writing to standard output
333 1 Chris Cannam
Running plugin: "myplugin"...                                        
334 1 Chris Cannam
Using block size = 1024, step size = 1024                            
335 1 Chris Cannam
Plugin accepts 1 -> 1 channel(s)                                     
336 1 Chris Cannam
Sound file has 2 (will mix/augment if necessary)                     
337 1 Chris Cannam
Output is: "output"                                                  
338 1 Chris Cannam
 0.000000000: 0
339 1 Chris Cannam
 0.023219954: 0
340 1 Chris Cannam
 0.046439909: 0
341 1 Chris Cannam
 0.069659863: 0
342 1 Chris Cannam
 0.092879818: 0
343 1 Chris Cannam
 0.116099773: 0
344 1 Chris Cannam
 0.139319727: 0
345 1 Chris Cannam
 0.162539682: 1.56888e-11
346 1 Chris Cannam
 0.185759637: 4.90218e-09
347 1 Chris Cannam
 0.208979591: 2.135e-07
348 1 Chris Cannam
 0.232199546: 0.00666197
349 1 Chris Cannam
 ... and lots and lots and lots and lots more output ...
350 1 Chris Cannam
C:\Users\cannam\Documents\Visual Studio 2008\Projects\tutorial\Debug>
351 1 Chris Cannam
</pre>
352 1 Chris Cannam
353 1 Chris Cannam
Try using the @vamp-plugin-tester@ again as well.
354 1 Chris Cannam
355 1 Chris Cannam
356 1 Chris Cannam
h2.  5. Fill in descriptions and other metadata 
357 1 Chris Cannam
358 1 Chris Cannam
Now we have a working plugin, but it still has the rather awkward name of @MyPlugin@.  There are several functions at the top of @MyPlugin.cpp@ which we can use to give it a more sensible name and description.
359 1 Chris Cannam
360 1 Chris Cannam
For example:
361 1 Chris Cannam
362 1 Chris Cannam
<pre>
363 1 Chris Cannam
string
364 1 Chris Cannam
MyPlugin::getIdentifier() const
365 1 Chris Cannam
{
366 1 Chris Cannam
    return "myplugin";
367 1 Chris Cannam
}
368 1 Chris Cannam
</pre>
369 1 Chris Cannam
370 1 Chris Cannam
The identifier is a string that is not normally used by people (for example, it never appears when plugins are listed in a menu of a graphical application), but that uniquely identifies the plugin within its library.  Something like @"power"@ is perfectly appropriate here.
371 1 Chris Cannam
372 1 Chris Cannam
You should fill in all of @getIdentifier@, @getName@, @getDescription@, @getMaker@, @getPluginVersion@, and @getCopyright@ for every plugin you write.
373 1 Chris Cannam
374 1 Chris Cannam
In my case, I would need something like:
375 1 Chris Cannam
376 1 Chris Cannam
<pre>
377 1 Chris Cannam
string
378 1 Chris Cannam
MyPlugin::getIdentifier() const
379 1 Chris Cannam
{
380 1 Chris Cannam
    return "power";
381 1 Chris Cannam
}
382 1 Chris Cannam
383 1 Chris Cannam
string
384 1 Chris Cannam
MyPlugin::getName() const
385 1 Chris Cannam
{
386 1 Chris Cannam
    return "Signal power level";
387 1 Chris Cannam
}
388 1 Chris Cannam
389 1 Chris Cannam
string
390 1 Chris Cannam
MyPlugin::getDescription() const
391 1 Chris Cannam
{
392 1 Chris Cannam
    return "Calculate the mean signal power for each processing block";
393 1 Chris Cannam
}
394 1 Chris Cannam
395 1 Chris Cannam
string
396 1 Chris Cannam
MyPlugin::getMaker() const
397 1 Chris Cannam
{
398 1 Chris Cannam
    return "Chris Cannam";
399 1 Chris Cannam
}
400 1 Chris Cannam
401 1 Chris Cannam
int
402 1 Chris Cannam
MyPlugin::getPluginVersion() const
403 1 Chris Cannam
{
404 1 Chris Cannam
    return 1;
405 1 Chris Cannam
}
406 1 Chris Cannam
407 1 Chris Cannam
string
408 1 Chris Cannam
MyPlugin::getCopyright() const
409 1 Chris Cannam
{
410 1 Chris Cannam
    return "Freely redistributable (tutorial example code)";
411 1 Chris Cannam
}
412 1 Chris Cannam
</pre>