cannam@227
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
cannam@227
|
2
|
cannam@227
|
3 /*
|
cannam@227
|
4 Vamp
|
cannam@227
|
5
|
cannam@227
|
6 An API for audio analysis and feature extraction plugins.
|
cannam@227
|
7
|
cannam@227
|
8 Centre for Digital Music, Queen Mary, University of London.
|
cannam@227
|
9 Copyright 2006-2008 Chris Cannam and QMUL.
|
cannam@227
|
10
|
cannam@227
|
11 Permission is hereby granted, free of charge, to any person
|
cannam@227
|
12 obtaining a copy of this software and associated documentation
|
cannam@227
|
13 files (the "Software"), to deal in the Software without
|
cannam@227
|
14 restriction, including without limitation the rights to use, copy,
|
cannam@227
|
15 modify, merge, publish, distribute, sublicense, and/or sell copies
|
cannam@227
|
16 of the Software, and to permit persons to whom the Software is
|
cannam@227
|
17 furnished to do so, subject to the following conditions:
|
cannam@227
|
18
|
cannam@227
|
19 The above copyright notice and this permission notice shall be
|
cannam@227
|
20 included in all copies or substantial portions of the Software.
|
cannam@227
|
21
|
cannam@227
|
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
cannam@227
|
23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
cannam@227
|
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
cannam@227
|
25 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
|
cannam@227
|
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
cannam@227
|
27 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
cannam@227
|
28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
cannam@227
|
29
|
cannam@227
|
30 Except as contained in this notice, the names of the Centre for
|
cannam@227
|
31 Digital Music; Queen Mary, University of London; and Chris Cannam
|
cannam@227
|
32 shall not be used in advertising or otherwise to promote the sale,
|
cannam@227
|
33 use or other dealings in this Software without prior written
|
cannam@227
|
34 authorization.
|
cannam@227
|
35 */
|
cannam@227
|
36
|
cannam@227
|
37 #ifndef _VAMP_PLUGIN_SUMMARISING_ADAPTER_H_
|
cannam@227
|
38 #define _VAMP_PLUGIN_SUMMARISING_ADAPTER_H_
|
cannam@227
|
39
|
cannam@227
|
40 #include "PluginWrapper.h"
|
cannam@227
|
41
|
cannam@227
|
42 #include <set>
|
cannam@227
|
43
|
cannam@227
|
44 namespace Vamp {
|
cannam@227
|
45
|
cannam@227
|
46 namespace HostExt {
|
cannam@227
|
47
|
cannam@227
|
48 /**
|
cannam@227
|
49 * \class PluginSummarisingAdapter PluginSummarisingAdapter.h <vamp-sdk/hostext/PluginSummarisingAdapter.h>
|
cannam@227
|
50 *
|
cannam@227
|
51 * \note This class was introduced in version 2.0 of the Vamp plugin SDK.
|
cannam@227
|
52 */
|
cannam@227
|
53
|
cannam@227
|
54 class PluginSummarisingAdapter : public PluginWrapper
|
cannam@227
|
55 {
|
cannam@227
|
56 public:
|
cannam@227
|
57 PluginSummarisingAdapter(Plugin *plugin); // I take ownership of plugin
|
cannam@227
|
58 virtual ~PluginSummarisingAdapter();
|
cannam@227
|
59
|
cannam@227
|
60 bool initialise(size_t channels, size_t stepSize, size_t blockSize);
|
cannam@227
|
61
|
cannam@227
|
62 FeatureSet process(const float *const *inputBuffers, RealTime timestamp);
|
cannam@227
|
63 FeatureSet getRemainingFeatures();
|
cannam@227
|
64
|
cannam@227
|
65 typedef std::set<RealTime> SegmentBoundaries;
|
cannam@227
|
66 void setSummarySegmentBoundaries(const SegmentBoundaries &);
|
cannam@227
|
67
|
cannam@227
|
68 enum SummaryType {
|
cannam@227
|
69 Minimum = 0,
|
cannam@227
|
70 Maximum = 1,
|
cannam@227
|
71 Mean = 2,
|
cannam@227
|
72 Median = 3,
|
cannam@227
|
73 Mode = 4,
|
cannam@227
|
74 Sum = 5,
|
cannam@227
|
75 Variance = 6,
|
cannam@227
|
76 StandardDeviation = 7,
|
cannam@227
|
77 Count = 8,
|
cannam@227
|
78
|
cannam@227
|
79 UnknownSummaryType = 999
|
cannam@227
|
80 };
|
cannam@227
|
81
|
cannam@227
|
82 /**
|
cannam@227
|
83 * AveragingMethod indicates how the adapter should handle
|
cannam@227
|
84 * average-based summaries of features whose results are not
|
cannam@227
|
85 * equally spaced in time.
|
cannam@227
|
86 *
|
cannam@227
|
87 * If SampleAverage is specified, summary types based on averages
|
cannam@227
|
88 * will be calculated by treating each result individually without
|
cannam@227
|
89 * regard to its time: for example, the mean will be the sum of
|
cannam@227
|
90 * all values divided by the number of values.
|
cannam@227
|
91 *
|
cannam@227
|
92 * If ContinuousTimeAverage is specified, each feature will be
|
cannam@227
|
93 * considered to have a duration, either as specified in the
|
cannam@227
|
94 * feature's duration field, or until the following feature: thus,
|
cannam@227
|
95 * for example, the mean will be the sum of the products of values
|
cannam@227
|
96 * and durations, divided by the total duration.
|
cannam@227
|
97 *
|
cannam@227
|
98 * Although SampleAverage is useful for many types of feature,
|
cannam@227
|
99 * ContinuousTimeAverage is essential for some situations, for
|
cannam@227
|
100 * example finding the result that spans the largest proportion of
|
cannam@227
|
101 * the input given a feature that emits a new result only when the
|
cannam@227
|
102 * value changes (the modal value integrated over time).
|
cannam@227
|
103 */
|
cannam@227
|
104 enum AveragingMethod {
|
cannam@227
|
105 SampleAverage = 0,
|
cannam@227
|
106 ContinuousTimeAverage = 1,
|
cannam@227
|
107 };
|
cannam@227
|
108
|
cannam@227
|
109 FeatureList getSummaryForOutput(int output,
|
cannam@227
|
110 SummaryType type,
|
cannam@227
|
111 AveragingMethod method = SampleAverage);
|
cannam@227
|
112
|
cannam@227
|
113 FeatureSet getSummaryForAllOutputs(SummaryType type,
|
cannam@227
|
114 AveragingMethod method = SampleAverage);
|
cannam@227
|
115
|
cannam@227
|
116 protected:
|
cannam@227
|
117 class Impl;
|
cannam@227
|
118 Impl *m_impl;
|
cannam@227
|
119 };
|
cannam@227
|
120
|
cannam@227
|
121 }
|
cannam@227
|
122
|
cannam@227
|
123 }
|
cannam@227
|
124
|
cannam@227
|
125 #endif
|