annotate win32-mingw/include/vamp-hostsdk/PluginSummarisingAdapter.h @ 33:879bdc878826

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