Mercurial > hg > vamp-plugin-sdk
comparison vamp-hostsdk/hostext/PluginChannelAdapter.h @ 227:6b30e064cab7 distinct-libraries
* more moving
author | cannam |
---|---|
date | Thu, 06 Nov 2008 14:13:12 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
226:14029eb08472 | 227:6b30e064cab7 |
---|---|
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 | |
11 Permission is hereby granted, free of charge, to any person | |
12 obtaining a copy of this software and associated documentation | |
13 files (the "Software"), to deal in the Software without | |
14 restriction, including without limitation the rights to use, copy, | |
15 modify, merge, publish, distribute, sublicense, and/or sell copies | |
16 of the Software, and to permit persons to whom the Software is | |
17 furnished to do so, subject to the following conditions: | |
18 | |
19 The above copyright notice and this permission notice shall be | |
20 included in all copies or substantial portions of the Software. | |
21 | |
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
23 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
25 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR | |
26 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |
27 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
28 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
29 | |
30 Except as contained in this notice, the names of the Centre for | |
31 Digital Music; Queen Mary, University of London; and Chris Cannam | |
32 shall not be used in advertising or otherwise to promote the sale, | |
33 use or other dealings in this Software without prior written | |
34 authorization. | |
35 */ | |
36 | |
37 #ifndef _VAMP_PLUGIN_CHANNEL_ADAPTER_H_ | |
38 #define _VAMP_PLUGIN_CHANNEL_ADAPTER_H_ | |
39 | |
40 #include "PluginWrapper.h" | |
41 | |
42 namespace Vamp { | |
43 | |
44 namespace HostExt { | |
45 | |
46 /** | |
47 * \class PluginChannelAdapter PluginChannelAdapter.h <vamp-sdk/hostext/PluginChannelAdapter.h> | |
48 * | |
49 * PluginChannelAdapter is a Vamp plugin adapter that implements a | |
50 * policy for management of plugins that expect a different number of | |
51 * input channels from the number actually available in the source | |
52 * audio data. | |
53 * | |
54 * A host using PluginChannelAdapter may ignore the getMinChannelCount | |
55 * and getMaxChannelCount reported by the plugin, and still expect the | |
56 * plugin to run. | |
57 * | |
58 * PluginChannelAdapter implements the following policy: | |
59 * | |
60 * - If the plugin supports the provided number of channels directly, | |
61 * PluginChannelAdapter will just run the plugin as normal. | |
62 * | |
63 * - If the plugin only supports exactly one channel but more than | |
64 * one channel is provided, PluginChannelAdapter will use the mean of | |
65 * the channels. This ensures that the resulting values remain | |
66 * within the same magnitude range as expected for mono data. | |
67 * | |
68 * - If the plugin requires more than one channel but exactly one is | |
69 * provided, the provided channel will be duplicated across all the | |
70 * plugin input channels. | |
71 * | |
72 * If none of the above apply: | |
73 * | |
74 * - If the plugin requires more channels than are provided, the | |
75 * minimum acceptable number of channels will be produced by adding | |
76 * empty (zero valued) channels to those provided. | |
77 * | |
78 * - If the plugin requires fewer channels than are provided, the | |
79 * maximum acceptable number of channels will be produced by | |
80 * discarding the excess channels. | |
81 * | |
82 * Hosts requiring a different channel policy from the above will need | |
83 * to implement it themselves, instead of using PluginChannelAdapter. | |
84 * | |
85 * Note that PluginChannelAdapter does not override the minimum and | |
86 * maximum channel counts returned by the wrapped plugin. The host | |
87 * will need to be aware that it is using a PluginChannelAdapter, and | |
88 * be prepared to ignore these counts as necessary. (This contrasts | |
89 * with the approach used in PluginInputDomainAdapter, which aims to | |
90 * make the host completely unaware of which underlying input domain | |
91 * is in fact in use.) | |
92 * | |
93 * (The rationale for this is that a host may wish to use the | |
94 * PluginChannelAdapter but still discriminate in some way on the | |
95 * basis of the number of channels actually supported. For example, a | |
96 * simple stereo audio host may prefer to reject plugins that require | |
97 * more than two channels on the grounds that doesn't actually | |
98 * understand what they are for, rather than allow the channel adapter | |
99 * to make a potentially meaningless channel conversion for them.) | |
100 * | |
101 * In every respect other than its management of channels, the | |
102 * PluginChannelAdapter behaves identically to the plugin that it | |
103 * wraps. The wrapped plugin will be deleted when the wrapper is | |
104 * deleted. | |
105 * | |
106 * \note This class was introduced in version 1.1 of the Vamp plugin SDK. | |
107 */ | |
108 | |
109 class PluginChannelAdapter : public PluginWrapper | |
110 { | |
111 public: | |
112 PluginChannelAdapter(Plugin *plugin); // I take ownership of plugin | |
113 virtual ~PluginChannelAdapter(); | |
114 | |
115 bool initialise(size_t channels, size_t stepSize, size_t blockSize); | |
116 | |
117 FeatureSet process(const float *const *inputBuffers, RealTime timestamp); | |
118 | |
119 /** | |
120 * Call process(), providing interleaved audio data with the | |
121 * number of channels passed to initialise(). The adapter will | |
122 * de-interleave into temporary buffers as appropriate before | |
123 * calling process(). | |
124 * | |
125 * \note This function was introduced in version 1.4 of the Vamp | |
126 * plugin SDK. | |
127 */ | |
128 FeatureSet processInterleaved(const float *inputBuffer, RealTime timestamp); | |
129 | |
130 protected: | |
131 class Impl; | |
132 Impl *m_impl; | |
133 }; | |
134 | |
135 } | |
136 | |
137 } | |
138 | |
139 #endif |