Mercurial > hg > vamp-plugin-sdk
comparison vamp-hostsdk/PluginSummarisingAdapter.h @ 248:c88a3cdb0215
* Tidy up --list-full output a bit
* Some documentation, including docs for PluginSummarisingAdapter
| author | cannam | 
|---|---|
| date | Tue, 11 Nov 2008 12:07:09 +0000 | 
| parents | 3cf5bd155e5b | 
| children | 4454843ff384 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 246:5bfed156b45d | 248:c88a3cdb0215 | 
|---|---|
| 47 namespace HostExt { | 47 namespace HostExt { | 
| 48 | 48 | 
| 49 /** | 49 /** | 
| 50 * \class PluginSummarisingAdapter PluginSummarisingAdapter.h <vamp-hostsdk/PluginSummarisingAdapter.h> | 50 * \class PluginSummarisingAdapter PluginSummarisingAdapter.h <vamp-hostsdk/PluginSummarisingAdapter.h> | 
| 51 * | 51 * | 
| 52 * PluginSummarisingAdapter is a Vamp plugin adapter that provides | |
| 53 * summarisation methods such as mean and median averages of output | |
| 54 * features, for use in any context where an available plugin produces | |
| 55 * individual values but the result that is actually needed is some | |
| 56 * sort of aggregate. | |
| 57 * | |
| 58 * To make use of PluginSummarisingAdapter, the host should configure, | |
| 59 * initialise and run the plugin through the adapter interface just as | |
| 60 * normal. Then, after the process and getRemainingFeatures methods | |
| 61 * have been properly called and processing is complete, the host may | |
| 62 * call getSummaryForOutput or getSummaryForAllOutputs to obtain | |
| 63 * summarised features: averages, maximum values, etc, depending on | |
| 64 * the SummaryType passed to the function. | |
| 65 * | |
| 66 * By default PluginSummarisingAdapter calculates a single summary of | |
| 67 * each output's feature across the whole duration of processed audio. | |
| 68 * A host needing summaries of sub-segments of the whole audio may | |
| 69 * call setSummarySegmentBoundaries before retrieving the summaries, | |
| 70 * providing a list of times such that one summary will be provided | |
| 71 * for each segment between two consecutive times. | |
| 72 * | |
| 73 * PluginSummarisingAdapter is straightforward rather than fast. It | |
| 74 * calculates all of the summary types for all outputs always, and | |
| 75 * then returns only the ones that are requested. It is designed on | |
| 76 * the basis that, for most features, summarising and storing | |
| 77 * summarised results is far cheaper than calculating the results in | |
| 78 * the first place. If this is not true for your particular feature, | |
| 79 * PluginSummarisingAdapter may not be the best approach for you. | |
| 80 * | |
| 52 * \note This class was introduced in version 2.0 of the Vamp plugin SDK. | 81 * \note This class was introduced in version 2.0 of the Vamp plugin SDK. | 
| 53 */ | 82 */ | 
| 54 | 83 | 
| 55 class PluginSummarisingAdapter : public PluginWrapper | 84 class PluginSummarisingAdapter : public PluginWrapper | 
| 56 { | 85 { | 
| 57 public: | 86 public: | 
| 58 PluginSummarisingAdapter(Plugin *plugin); // I take ownership of plugin | 87 /** | 
| 88 * Construct a PluginSummarisingAdapter wrapping the given plugin. | |
| 89 * The adapter takes ownership of the plugin, which will be | |
| 90 * deleted when the adapter is deleted. | |
| 91 */ | |
| 92 PluginSummarisingAdapter(Plugin *plugin); | |
| 59 virtual ~PluginSummarisingAdapter(); | 93 virtual ~PluginSummarisingAdapter(); | 
| 60 | 94 | 
| 61 bool initialise(size_t channels, size_t stepSize, size_t blockSize); | 95 bool initialise(size_t channels, size_t stepSize, size_t blockSize); | 
| 62 | 96 | 
| 63 FeatureSet process(const float *const *inputBuffers, RealTime timestamp); | 97 FeatureSet process(const float *const *inputBuffers, RealTime timestamp); | 
| 64 FeatureSet getRemainingFeatures(); | 98 FeatureSet getRemainingFeatures(); | 
| 65 | 99 | 
| 66 typedef std::set<RealTime> SegmentBoundaries; | 100 typedef std::set<RealTime> SegmentBoundaries; | 
| 101 | |
| 102 /** | |
| 103 * Specify a series of segment boundaries, such that one summary | |
| 104 * will be returned for each of the contiguous intra-boundary | |
| 105 * segments. This function must be called before | |
| 106 * getSummaryForOutput or getSummaryForAllOutputs. | |
| 107 * | |
| 108 * Note that you cannot retrieve results with multiple different | |
| 109 * segmentations by repeatedly calling this function followed by | |
| 110 * one of the getSummary functions. The summaries are all | |
| 111 * calculated at the first call to any getSummary function, and | |
| 112 * once the summaries have been calculated, they remain | |
| 113 * calculated. | |
| 114 */ | |
| 67 void setSummarySegmentBoundaries(const SegmentBoundaries &); | 115 void setSummarySegmentBoundaries(const SegmentBoundaries &); | 
| 68 | 116 | 
| 69 enum SummaryType { | 117 enum SummaryType { | 
| 70 Minimum = 0, | 118 Minimum = 0, | 
| 71 Maximum = 1, | 119 Maximum = 1, | 
| 105 enum AveragingMethod { | 153 enum AveragingMethod { | 
| 106 SampleAverage = 0, | 154 SampleAverage = 0, | 
| 107 ContinuousTimeAverage = 1, | 155 ContinuousTimeAverage = 1, | 
| 108 }; | 156 }; | 
| 109 | 157 | 
| 158 /** | |
| 159 * Return summaries of the features that were returned on the | |
| 160 * given output, using the given SummaryType and AveragingMethod. | |
| 161 * | |
| 162 * The plugin must have been fully run (process() and | |
| 163 * getRemainingFeatures() calls all made as appropriate) before | |
| 164 * this function is called. | |
| 165 */ | |
| 110 FeatureList getSummaryForOutput(int output, | 166 FeatureList getSummaryForOutput(int output, | 
| 111 SummaryType type, | 167 SummaryType type, | 
| 112 AveragingMethod method = SampleAverage); | 168 AveragingMethod method = SampleAverage); | 
| 113 | 169 | 
| 170 /** | |
| 171 * Return summaries of the features that were returned on all of | |
| 172 * the plugin's outputs, using the given SummaryType and | |
| 173 * AveragingMethod. | |
| 174 * | |
| 175 * The plugin must have been fully run (process() and | |
| 176 * getRemainingFeatures() calls all made as appropriate) before | |
| 177 * this function is called. | |
| 178 */ | |
| 114 FeatureSet getSummaryForAllOutputs(SummaryType type, | 179 FeatureSet getSummaryForAllOutputs(SummaryType type, | 
| 115 AveragingMethod method = SampleAverage); | 180 AveragingMethod method = SampleAverage); | 
| 116 | 181 | 
| 117 protected: | 182 protected: | 
| 118 class Impl; | 183 class Impl; | 
