annotate src/vamp-plugin-sdk-2.4/vamp-hostsdk/PluginSummarisingAdapter.h @ 83:ae30d91d2ffe

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