To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / vamp-hostsdk / PluginSummarisingAdapter.h @ 538:8ffb8985ae8f
History | View | Annotate | Download (7.54 KB)
| 1 |
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
|---|---|
| 2 |
|
| 3 |
/*
|
| 4 |
Vamp
|
| 5 |
|
| 6 |
An API for audio analysis and feature extraction plugins.
|
| 7 |
|
| 8 |
Centre for Digital Music, Queen Mary, University of London.
|
| 9 |
Copyright 2006-2009 Chris Cannam and QMUL.
|
| 10 |
|
| 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:
|
| 18 |
|
| 19 |
The above copyright notice and this permission notice shall be
|
| 20 |
included in all copies or substantial portions of the Software.
|
| 21 |
|
| 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.
|
| 29 |
|
| 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
|
| 34 |
authorization.
|
| 35 |
*/
|
| 36 |
|
| 37 |
#ifndef _VAMP_PLUGIN_SUMMARISING_ADAPTER_H_
|
| 38 |
#define _VAMP_PLUGIN_SUMMARISING_ADAPTER_H_
|
| 39 |
|
| 40 |
#include "hostguard.h" |
| 41 |
#include "PluginWrapper.h" |
| 42 |
|
| 43 |
#include <set> |
| 44 |
|
| 45 |
_VAMP_SDK_HOSTSPACE_BEGIN(PluginSummarisingAdapter.h) |
| 46 |
|
| 47 |
namespace Vamp {
|
| 48 |
|
| 49 |
namespace HostExt {
|
| 50 |
|
| 51 |
/**
|
| 52 |
* \class PluginSummarisingAdapter PluginSummarisingAdapter.h <vamp-hostsdk/PluginSummarisingAdapter.h>
|
| 53 |
*
|
| 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
|
| 58 |
* sort of aggregate.
|
| 59 |
*
|
| 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.
|
| 67 |
*
|
| 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.
|
| 74 |
*
|
| 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.
|
| 82 |
*
|
| 83 |
* \note This class was introduced in version 2.0 of the Vamp plugin SDK.
|
| 84 |
*/
|
| 85 |
|
| 86 |
class PluginSummarisingAdapter : public PluginWrapper |
| 87 |
{
|
| 88 |
public:
|
| 89 |
/**
|
| 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. If you wish to prevent
|
| 93 |
* this, call disownPlugin().
|
| 94 |
*/
|
| 95 |
PluginSummarisingAdapter(Plugin *plugin); |
| 96 |
virtual ~PluginSummarisingAdapter(); |
| 97 |
|
| 98 |
bool initialise(size_t channels, size_t stepSize, size_t blockSize);
|
| 99 |
|
| 100 |
void reset();
|
| 101 |
|
| 102 |
FeatureSet process(const float *const *inputBuffers, RealTime timestamp); |
| 103 |
FeatureSet getRemainingFeatures(); |
| 104 |
|
| 105 |
typedef std::set<RealTime> SegmentBoundaries;
|
| 106 |
|
| 107 |
/**
|
| 108 |
* Specify a series of segment boundaries, such that one summary
|
| 109 |
* will be returned for each of the contiguous intra-boundary
|
| 110 |
* segments. This function must be called before
|
| 111 |
* getSummaryForOutput or getSummaryForAllOutputs.
|
| 112 |
*
|
| 113 |
* Note that you cannot retrieve results with multiple different
|
| 114 |
* segmentations by repeatedly calling this function followed by
|
| 115 |
* one of the getSummary functions. The summaries are all
|
| 116 |
* calculated at the first call to any getSummary function, and
|
| 117 |
* once the summaries have been calculated, they remain
|
| 118 |
* calculated.
|
| 119 |
*/
|
| 120 |
void setSummarySegmentBoundaries(const SegmentBoundaries &); |
| 121 |
|
| 122 |
enum SummaryType {
|
| 123 |
Minimum = 0,
|
| 124 |
Maximum = 1,
|
| 125 |
Mean = 2,
|
| 126 |
Median = 3,
|
| 127 |
Mode = 4,
|
| 128 |
Sum = 5,
|
| 129 |
Variance = 6,
|
| 130 |
StandardDeviation = 7,
|
| 131 |
Count = 8,
|
| 132 |
|
| 133 |
UnknownSummaryType = 999
|
| 134 |
}; |
| 135 |
|
| 136 |
/**
|
| 137 |
* AveragingMethod indicates how the adapter should handle
|
| 138 |
* average-based summaries of features whose results are not
|
| 139 |
* equally spaced in time.
|
| 140 |
*
|
| 141 |
* If SampleAverage is specified, summary types based on averages
|
| 142 |
* will be calculated by treating each result individually without
|
| 143 |
* regard to its time: for example, the mean will be the sum of
|
| 144 |
* all values divided by the number of values.
|
| 145 |
*
|
| 146 |
* If ContinuousTimeAverage is specified, each feature will be
|
| 147 |
* considered to have a duration, either as specified in the
|
| 148 |
* feature's duration field, or until the following feature: thus,
|
| 149 |
* for example, the mean will be the sum of the products of values
|
| 150 |
* and durations, divided by the total duration.
|
| 151 |
*
|
| 152 |
* Although SampleAverage is useful for many types of feature,
|
| 153 |
* ContinuousTimeAverage is essential for some situations, for
|
| 154 |
* example finding the result that spans the largest proportion of
|
| 155 |
* the input given a feature that emits a new result only when the
|
| 156 |
* value changes (the modal value integrated over time).
|
| 157 |
*/
|
| 158 |
enum AveragingMethod {
|
| 159 |
SampleAverage = 0,
|
| 160 |
ContinuousTimeAverage = 1
|
| 161 |
}; |
| 162 |
|
| 163 |
/**
|
| 164 |
* Return summaries of the features that were returned on the
|
| 165 |
* given output, using the given SummaryType and AveragingMethod.
|
| 166 |
*
|
| 167 |
* The plugin must have been fully run (process() and
|
| 168 |
* getRemainingFeatures() calls all made as appropriate) before
|
| 169 |
* this function is called.
|
| 170 |
*/
|
| 171 |
FeatureList getSummaryForOutput(int output,
|
| 172 |
SummaryType type, |
| 173 |
AveragingMethod method = SampleAverage); |
| 174 |
|
| 175 |
/**
|
| 176 |
* Return summaries of the features that were returned on all of
|
| 177 |
* the plugin's outputs, using the given SummaryType and
|
| 178 |
* AveragingMethod.
|
| 179 |
*
|
| 180 |
* The plugin must have been fully run (process() and
|
| 181 |
* getRemainingFeatures() calls all made as appropriate) before
|
| 182 |
* this function is called.
|
| 183 |
*/
|
| 184 |
FeatureSet getSummaryForAllOutputs(SummaryType type, |
| 185 |
AveragingMethod method = SampleAverage); |
| 186 |
|
| 187 |
protected:
|
| 188 |
class Impl; |
| 189 |
Impl *m_impl; |
| 190 |
}; |
| 191 |
|
| 192 |
} |
| 193 |
|
| 194 |
} |
| 195 |
|
| 196 |
_VAMP_SDK_HOSTSPACE_END(PluginSummarisingAdapter.h) |
| 197 |
|
| 198 |
#endif
|