Mercurial > hg > vamp-plugin-sdk
comparison vamp-sdk/hostext/PluginChannelAdapter.h @ 59:fa79c4ec847d host-factory-stuff
* Put hostext stuff in the HostExt sub-namespace
* Tidy up system-specific stuff in PluginLoader
* Make PluginLoader return a deletion-notifying wrapper which permits the
library to be unloaded when no longer in use
* Add PluginChannelAdapter
* Make vamp-simple-host use PluginChannelAdapter, and use the PluginLoader
for plugin-running task. Also some other enhancements to host
author | cannam |
---|---|
date | Thu, 24 May 2007 15:17:07 +0000 |
parents | |
children | fe5486ee1c70 |
comparison
equal
deleted
inserted
replaced
58:0284955e31e5 | 59:fa79c4ec847d |
---|---|
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 Chris Cannam. | |
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 * PluginChannelAdapter implements a policy for management of plugins | |
48 * that expect a different number of input channels from the number | |
49 * actually available in the source audio data. | |
50 * | |
51 * A host using PluginChannelAdapter may ignore the getMinChannelCount | |
52 * and getMaxChannelCount reported by the plugin, and still expect the | |
53 * plugin to run. | |
54 * | |
55 * PluginChannelAdapter implements the following policy: | |
56 * | |
57 * -- If the plugin supports the provided number of channels directly, | |
58 * PluginChannelAdapter will just run the plugin as normal. | |
59 * | |
60 * -- If the plugin only supports exactly one channel but more than | |
61 * one channel is provided, PluginChannelAdapter will use the mean of | |
62 * the channels. This ensures that the resulting values remain within | |
63 * the same magnitude range as expected for mono data. | |
64 * | |
65 * -- If the plugin requires more than one channel but exactly one is | |
66 * provided, the provided channel will be duplicated across all the | |
67 * plugin input channels. | |
68 * | |
69 * If none of the above apply: | |
70 * | |
71 * -- If the plugin requires more channels than are provided, the | |
72 * minimum acceptable number of channels will be produced by adding | |
73 * empty (zero valued) channels to those provided. | |
74 * | |
75 * -- If the plugin requires fewer channels than are provided, the | |
76 * maximum acceptable number of channels will be produced by | |
77 * discarding the excess channels. | |
78 * | |
79 * Hosts requiring a different channel policy from the above will need | |
80 * to implement it themselves, instead of using PluginChannelAdapter. | |
81 */ | |
82 | |
83 class PluginChannelAdapter : public PluginWrapper | |
84 { | |
85 public: | |
86 PluginChannelAdapter(Plugin *plugin); // I take ownership of plugin | |
87 virtual ~PluginChannelAdapter(); | |
88 | |
89 bool initialise(size_t channels, size_t stepSize, size_t blockSize); | |
90 | |
91 FeatureSet process(const float *const *inputBuffers, RealTime timestamp); | |
92 | |
93 protected: | |
94 size_t m_blockSize; | |
95 size_t m_inputChannels; | |
96 size_t m_pluginChannels; | |
97 float **m_buffer; | |
98 const float **m_forwardPtrs; | |
99 }; | |
100 | |
101 } | |
102 | |
103 } | |
104 | |
105 #endif |