To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / skeleton / MyPlugin.cpp

History | View | Annotate | Download (4.53 KB)

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
    // Also be sure to set your plugin parameters (presumably stored
13
    // in member variables) to their default values here -- the host
14
    // will not do that for you
15
{
16
}
17

    
18
MyPlugin::~MyPlugin()
19
{
20
}
21

    
22
string
23
MyPlugin::getIdentifier() const
24
{
25
    return "myplugin";
26
}
27

    
28
string
29
MyPlugin::getName() const
30
{
31
    return "My Plugin";
32
}
33

    
34
string
35
MyPlugin::getDescription() const
36
{
37
    // Return something helpful here!
38
    return "";
39
}
40

    
41
string
42
MyPlugin::getMaker() const
43
{
44
    // Your name here
45
    return "";
46
}
47

    
48
int
49
MyPlugin::getPluginVersion() const
50
{
51
    // Increment this each time you release a version that behaves
52
    // differently from the previous one
53
    return 1;
54
}
55

    
56
string
57
MyPlugin::getCopyright() const
58
{
59
    // This function is not ideally named.  It does not necessarily
60
    // need to say who made the plugin -- getMaker does that -- but it
61
    // should indicate the terms under which it is distributed.  For
62
    // example, "Copyright (year). All Rights Reserved", or "GPL"
63
    return "";
64
}
65

    
66
MyPlugin::InputDomain
67
MyPlugin::getInputDomain() const
68
{
69
    return TimeDomain;
70
}
71

    
72
size_t
73
MyPlugin::getPreferredBlockSize() const
74
{
75
    return 0; // 0 means "I can handle any block size"
76
}
77

    
78
size_t 
79
MyPlugin::getPreferredStepSize() const
80
{
81
    return 0; // 0 means "anything sensible"; in practice this
82
              // means the same as the block size for TimeDomain
83
              // plugins, or half of it for FrequencyDomain plugins
84
}
85

    
86
size_t
87
MyPlugin::getMinChannelCount() const
88
{
89
    return 1;
90
}
91

    
92
size_t
93
MyPlugin::getMaxChannelCount() const
94
{
95
    return 1;
96
}
97

    
98
MyPlugin::ParameterList
99
MyPlugin::getParameterDescriptors() const
100
{
101
    ParameterList list;
102

    
103
    // If the plugin has no adjustable parameters, return an empty
104
    // list here (and there's no need to provide implementations of
105
    // getParameter and setParameter in that case either).
106

    
107
    // Note that it is your responsibility to make sure the parameters
108
    // start off having their default values (e.g. in the constructor
109
    // above).  The host needs to know the default value so it can do
110
    // things like provide a "reset to default" function, but it will
111
    // not explicitly set your parameters to their defaults for you if
112
    // they have not changed in the mean time.
113

    
114
    ParameterDescriptor d;
115
    d.identifier = "parameter";
116
    d.name = "Some Parameter";
117
    d.description = "";
118
    d.unit = "";
119
    d.minValue = 0;
120
    d.maxValue = 10;
121
    d.defaultValue = 5;
122
    d.isQuantized = false;
123
    list.push_back(d);
124

    
125
    return list;
126
}
127

    
128
float
129
MyPlugin::getParameter(string identifier) const
130
{
131
    if (identifier == "parameter") {
132
        return 5; // return the ACTUAL current value of your parameter here!
133
    }
134
    return 0;
135
}
136

    
137
void
138
MyPlugin::setParameter(string identifier, float value) 
139
{
140
    if (identifier == "parameter") {
141
        // set the actual value of your parameter
142
    }
143
}
144

    
145
MyPlugin::ProgramList
146
MyPlugin::getPrograms() const
147
{
148
    ProgramList list;
149

    
150
    // If you have no programs, return an empty list (or simply don't
151
    // implement this function or getCurrentProgram/selectProgram)
152

    
153
    return list;
154
}
155

    
156
string
157
MyPlugin::getCurrentProgram() const
158
{
159
    return ""; // no programs
160
}
161

    
162
void
163
MyPlugin::selectProgram(string name)
164
{
165
}
166

    
167
MyPlugin::OutputList
168
MyPlugin::getOutputDescriptors() const
169
{
170
    OutputList list;
171

    
172
    // See OutputDescriptor documentation for the possibilities here.
173
    // Every plugin must have at least one output.
174

    
175
    OutputDescriptor d;
176
    d.identifier = "output";
177
    d.name = "My Output";
178
    d.description = "";
179
    d.unit = "";
180
    d.hasFixedBinCount = true;
181
    d.binCount = 1;
182
    d.hasKnownExtents = false;
183
    d.isQuantized = false;
184
    d.sampleType = OutputDescriptor::OneSamplePerStep;
185
    d.hasDuration = false;
186
    list.push_back(d);
187

    
188
    return list;
189
}
190

    
191
bool
192
MyPlugin::initialise(size_t channels, size_t stepSize, size_t blockSize)
193
{
194
    if (channels < getMinChannelCount() ||
195
        channels > getMaxChannelCount()) return false;
196

    
197
    // Real initialisation work goes here!
198

    
199
    return true;
200
}
201

    
202
void
203
MyPlugin::reset()
204
{
205
    // Clear buffers, reset stored values, etc
206
}
207

    
208
MyPlugin::FeatureSet
209
MyPlugin::process(const float *const *inputBuffers, Vamp::RealTime timestamp)
210
{
211
    // Do actual work!
212
    return FeatureSet();
213
}
214

    
215
MyPlugin::FeatureSet
216
MyPlugin::getRemainingFeatures()
217
{
218
    return FeatureSet();
219
}
220