1
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
6
An API for audio analysis and feature extraction plugins.
8
Centre for Digital Music, Queen Mary, University of London.
9
Copyright 2006-2009 Chris Cannam and QMUL.
11
Permission is hereby granted, free of charge, to any person
12
obtaining a copy of this software and associated documentation
13
files (the "Software"), to deal in the Software without
14
restriction, including without limitation the rights to use, copy,
15
modify, merge, publish, distribute, sublicense, and/or sell copies
16
of the Software, and to permit persons to whom the Software is
17
furnished to do so, subject to the following conditions:
19
The above copyright notice and this permission notice shall be
20
included in all copies or substantial portions of the Software.
22
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
26
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
27
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
Except as contained in this notice, the names of the Centre for
31
Digital Music; Queen Mary, University of London; and Chris Cannam
32
shall not be used in advertising or otherwise to promote the sale,
33
use or other dealings in this Software without prior written
37
#ifndef _VAMP_PLUGIN_SUMMARISING_ADAPTER_H_
38
#define _VAMP_PLUGIN_SUMMARISING_ADAPTER_H_
40
#include "hostguard.h"
41
#include "PluginWrapper.h"
45
_VAMP_SDK_HOSTSPACE_BEGIN(PluginSummarisingAdapter.h)
52
* \class PluginSummarisingAdapter PluginSummarisingAdapter.h <vamp-hostsdk/PluginSummarisingAdapter.h>
54
* PluginSummarisingAdapter is a Vamp plugin adapter that provides
55
* summarisation methods such as mean and median averages of output
56
* features, for use in any context where an available plugin produces
57
* individual values but the result that is actually needed is some
60
* To make use of PluginSummarisingAdapter, the host should configure,
61
* initialise and run the plugin through the adapter interface just as
62
* normal. Then, after the process and getRemainingFeatures methods
63
* have been properly called and processing is complete, the host may
64
* call getSummaryForOutput or getSummaryForAllOutputs to obtain
65
* summarised features: averages, maximum values, etc, depending on
66
* the SummaryType passed to the function.
68
* By default PluginSummarisingAdapter calculates a single summary of
69
* each output's feature across the whole duration of processed audio.
70
* A host needing summaries of sub-segments of the whole audio may
71
* call setSummarySegmentBoundaries before retrieving the summaries,
72
* providing a list of times such that one summary will be provided
73
* for each segment between two consecutive times.
75
* PluginSummarisingAdapter is straightforward rather than fast. It
76
* calculates all of the summary types for all outputs always, and
77
* then returns only the ones that are requested. It is designed on
78
* the basis that, for most features, summarising and storing
79
* summarised results is far cheaper than calculating the results in
80
* the first place. If this is not true for your particular feature,
81
* PluginSummarisingAdapter may not be the best approach for you.
83
* \note This class was introduced in version 2.0 of the Vamp plugin SDK.
86
class PluginSummarisingAdapter : public PluginWrapper
90
* Construct a PluginSummarisingAdapter wrapping the given plugin.
91
* The adapter takes ownership of the plugin, which will be
92
* deleted when the adapter is deleted.
94
PluginSummarisingAdapter(Plugin *plugin);
95
virtual ~PluginSummarisingAdapter();
97
bool initialise(size_t channels, size_t stepSize, size_t blockSize);
101
FeatureSet process(const float *const *inputBuffers, RealTime timestamp);
102
FeatureSet getRemainingFeatures();
104
typedef std::set<RealTime> SegmentBoundaries;
107
* Specify a series of segment boundaries, such that one summary
108
* will be returned for each of the contiguous intra-boundary
109
* segments. This function must be called before
110
* getSummaryForOutput or getSummaryForAllOutputs.
112
* Note that you cannot retrieve results with multiple different
113
* segmentations by repeatedly calling this function followed by
114
* one of the getSummary functions. The summaries are all
115
* calculated at the first call to any getSummary function, and
116
* once the summaries have been calculated, they remain
119
void setSummarySegmentBoundaries(const SegmentBoundaries &);
129
StandardDeviation = 7,
132
UnknownSummaryType = 999
136
* AveragingMethod indicates how the adapter should handle
137
* average-based summaries of features whose results are not
138
* equally spaced in time.
140
* If SampleAverage is specified, summary types based on averages
141
* will be calculated by treating each result individually without
142
* regard to its time: for example, the mean will be the sum of
143
* all values divided by the number of values.
145
* If ContinuousTimeAverage is specified, each feature will be
146
* considered to have a duration, either as specified in the
147
* feature's duration field, or until the following feature: thus,
148
* for example, the mean will be the sum of the products of values
149
* and durations, divided by the total duration.
151
* Although SampleAverage is useful for many types of feature,
152
* ContinuousTimeAverage is essential for some situations, for
153
* example finding the result that spans the largest proportion of
154
* the input given a feature that emits a new result only when the
155
* value changes (the modal value integrated over time).
157
enum AveragingMethod {
159
ContinuousTimeAverage = 1
163
* Return summaries of the features that were returned on the
164
* given output, using the given SummaryType and AveragingMethod.
166
* The plugin must have been fully run (process() and
167
* getRemainingFeatures() calls all made as appropriate) before
168
* this function is called.
170
FeatureList getSummaryForOutput(int output,
172
AveragingMethod method = SampleAverage);
175
* Return summaries of the features that were returned on all of
176
* the plugin's outputs, using the given SummaryType and
179
* The plugin must have been fully run (process() and
180
* getRemainingFeatures() calls all made as appropriate) before
181
* this function is called.
183
FeatureSet getSummaryForAllOutputs(SummaryType type,
184
AveragingMethod method = SampleAverage);
195
_VAMP_SDK_HOSTSPACE_END(PluginSummarisingAdapter.h)