Mercurial > hg > vamp-plugin-sdk
comparison vamp-hostsdk/PluginBufferingAdapter.h @ 233:521734d2b498 distinct-libraries
* Flatten directory tree a bit, update doxygen
author | cannam |
---|---|
date | Fri, 07 Nov 2008 15:28:33 +0000 |
parents | |
children | 3cf5bd155e5b |
comparison
equal
deleted
inserted
replaced
232:71ea10a3cbe7 | 233:521734d2b498 |
---|---|
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-2007 Chris Cannam and QMUL. | |
10 This file by Mark Levy and Chris Cannam, Copyright 2007-2008 QMUL. | |
11 | |
12 Permission is hereby granted, free of charge, to any person | |
13 obtaining a copy of this software and associated documentation | |
14 files (the "Software"), to deal in the Software without | |
15 restriction, including without limitation the rights to use, copy, | |
16 modify, merge, publish, distribute, sublicense, and/or sell copies | |
17 of the Software, and to permit persons to whom the Software is | |
18 furnished to do so, subject to the following conditions: | |
19 | |
20 The above copyright notice and this permission notice shall be | |
21 included in all copies or substantial portions of the Software. | |
22 | |
23 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
24 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
25 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
26 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR | |
27 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |
28 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
29 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
30 | |
31 Except as contained in this notice, the names of the Centre for | |
32 Digital Music; Queen Mary, University of London; and Chris Cannam | |
33 shall not be used in advertising or otherwise to promote the sale, | |
34 use or other dealings in this Software without prior written | |
35 authorization. | |
36 */ | |
37 | |
38 #ifndef _VAMP_PLUGIN_BUFFERING_ADAPTER_H_ | |
39 #define _VAMP_PLUGIN_BUFFERING_ADAPTER_H_ | |
40 | |
41 #include "PluginWrapper.h" | |
42 | |
43 namespace Vamp { | |
44 | |
45 namespace HostExt { | |
46 | |
47 /** | |
48 * \class PluginBufferingAdapter PluginBufferingAdapter.h <vamp-hostsdk/PluginBufferingAdapter.h> | |
49 * | |
50 * PluginBufferingAdapter is a Vamp plugin adapter that allows plugins | |
51 * to be used by a host supplying an audio stream in non-overlapping | |
52 * buffers of arbitrary size. | |
53 * | |
54 * A host using PluginBufferingAdapter may ignore the preferred step | |
55 * and block size reported by the plugin, and still expect the plugin | |
56 * to run. The value of blockSize and stepSize passed to initialise | |
57 * should be the size of the buffer which the host will supply; the | |
58 * stepSize should be equal to the blockSize. | |
59 * | |
60 * If the internal step size used for the plugin differs from that | |
61 * supplied by the host, the adapter will modify the sample type and | |
62 * rate specifications for the plugin outputs appropriately, and set | |
63 * timestamps on the output features for outputs that formerly used a | |
64 * different sample rate specification. This is necessary in order to | |
65 * obtain correct time stamping. | |
66 * | |
67 * In other respects, the PluginBufferingAdapter behaves identically | |
68 * to the plugin that it wraps. The wrapped plugin will be deleted | |
69 * when the wrapper is deleted. | |
70 */ | |
71 | |
72 class PluginBufferingAdapter : public PluginWrapper | |
73 { | |
74 public: | |
75 PluginBufferingAdapter(Plugin *plugin); // I take ownership of plugin | |
76 virtual ~PluginBufferingAdapter(); | |
77 | |
78 /** | |
79 * Return the preferred step size for this adapter. | |
80 * | |
81 * Because of the way this adapter works, its preferred step size | |
82 * will always be the same as its preferred block size. This may | |
83 * or may not be the same as the preferred step size of the | |
84 * underlying plugin, which may be obtained by calling | |
85 * getPluginPreferredStepSize(). | |
86 */ | |
87 size_t getPreferredStepSize() const; | |
88 | |
89 /** | |
90 * Return the preferred block size for this adapter. | |
91 * | |
92 * This may or may not be the same as the preferred block size of | |
93 * the underlying plugin, which may be obtained by calling | |
94 * getPluginPreferredBlockSize(). | |
95 * | |
96 * Note that this adapter may be initialised with any block size, | |
97 * not just its supposedly preferred one. | |
98 */ | |
99 size_t getPreferredBlockSize() const; | |
100 | |
101 /** | |
102 * Initialise the adapter (and therefore the plugin) for the given | |
103 * number of channels. Initialise the adapter for the given step | |
104 * and block size, which must be equal. | |
105 * | |
106 * The step and block size used for the underlying plugin will | |
107 * depend on its preferences, or any values previously passed to | |
108 * setPluginStepSize and setPluginBlockSize. | |
109 */ | |
110 bool initialise(size_t channels, size_t stepSize, size_t blockSize); | |
111 | |
112 /** | |
113 * Return the preferred step size of the plugin wrapped by this | |
114 * adapter. | |
115 * | |
116 * This is included mainly for informational purposes. This value | |
117 * is not likely to be a valid step size for the adapter itself, | |
118 * and it is not usually of any use in interpreting the results | |
119 * (because the adapter re-writes OneSamplePerStep outputs to | |
120 * FixedSampleRate so that the hop size no longer needs to be | |
121 * known beforehand in order to interpret them). | |
122 */ | |
123 size_t getPluginPreferredStepSize() const; | |
124 | |
125 /** | |
126 * Return the preferred block size of the plugin wrapped by this | |
127 * adapter. | |
128 * | |
129 * This is included mainly for informational purposes. | |
130 */ | |
131 size_t getPluginPreferredBlockSize() const; | |
132 | |
133 /** | |
134 * Set the step size that will be used for the underlying plugin | |
135 * when initialise() is called. If this is not set, the plugin's | |
136 * own preferred step size will be used. You will not usually | |
137 * need to call this function. If you do call it, it must be | |
138 * before the first call to initialise(). | |
139 */ | |
140 void setPluginStepSize(size_t stepSize); | |
141 | |
142 /** | |
143 * Set the block size that will be used for the underlying plugin | |
144 * when initialise() is called. If this is not set, the plugin's | |
145 * own preferred block size will be used. You will not usually | |
146 * need to call this function. If you do call it, it must be | |
147 * before the first call to initialise(). | |
148 */ | |
149 void setPluginBlockSize(size_t blockSize); | |
150 | |
151 /** | |
152 * Return the step and block sizes that were actually used when | |
153 * initialising the underlying plugin. | |
154 * | |
155 * This is included mainly for informational purposes. You will | |
156 * not usually need to call this function. If this is called | |
157 * before initialise(), it will return 0 for both values. If it | |
158 * is called after a failed call to initialise(), it will return | |
159 * the values that were used in the failed call to the plugin's | |
160 * initialise() function. | |
161 */ | |
162 void getActualStepAndBlockSizes(size_t &stepSize, size_t &blockSize); | |
163 | |
164 OutputList getOutputDescriptors() const; | |
165 | |
166 void reset(); | |
167 | |
168 FeatureSet process(const float *const *inputBuffers, RealTime timestamp); | |
169 | |
170 FeatureSet getRemainingFeatures(); | |
171 | |
172 protected: | |
173 class Impl; | |
174 Impl *m_impl; | |
175 }; | |
176 | |
177 } | |
178 | |
179 } | |
180 | |
181 #endif |