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