comparison vamp-sdk/hostext/PluginChannelAdapter.cpp @ 70:fd58037b4a7b

* use m_impl for channel and input domain adapters as well
author cannam
date Wed, 06 Jun 2007 10:00:36 +0000
parents a712ed15d158
children 64697dca0d48
comparison
equal deleted inserted replaced
69:3456fe86d385 70:fd58037b4a7b
38 38
39 namespace Vamp { 39 namespace Vamp {
40 40
41 namespace HostExt { 41 namespace HostExt {
42 42
43 class PluginChannelAdapter::Impl
44 {
45 public:
46 Impl(Plugin *plugin);
47 ~Impl();
48
49 bool initialise(size_t channels, size_t stepSize, size_t blockSize);
50
51 FeatureSet process(const float *const *inputBuffers, RealTime timestamp);
52
53 protected:
54 Plugin *m_plugin;
55 size_t m_blockSize;
56 size_t m_inputChannels;
57 size_t m_pluginChannels;
58 float **m_buffer;
59 const float **m_forwardPtrs;
60 };
61
43 PluginChannelAdapter::PluginChannelAdapter(Plugin *plugin) : 62 PluginChannelAdapter::PluginChannelAdapter(Plugin *plugin) :
44 PluginWrapper(plugin), 63 PluginWrapper(plugin)
64 {
65 m_impl = new Impl(plugin);
66 }
67
68 PluginChannelAdapter::~PluginChannelAdapter()
69 {
70 delete m_impl;
71 }
72
73 bool
74 PluginChannelAdapter::initialise(size_t channels, size_t stepSize, size_t blockSize)
75 {
76 return m_impl->initialise(channels, stepSize, blockSize);
77 }
78
79 PluginChannelAdapter::FeatureSet
80 PluginChannelAdapter::process(const float *const *inputBuffers,
81 RealTime timestamp)
82 {
83 return m_impl->process(inputBuffers, timestamp);
84 }
85
86 PluginChannelAdapter::Impl::Impl(Plugin *plugin) :
87 m_plugin(plugin),
45 m_blockSize(0), 88 m_blockSize(0),
46 m_inputChannels(0), 89 m_inputChannels(0),
47 m_pluginChannels(0), 90 m_pluginChannels(0),
48 m_buffer(0), 91 m_buffer(0),
49 m_forwardPtrs(0) 92 m_forwardPtrs(0)
50 { 93 {
51 } 94 }
52 95
53 PluginChannelAdapter::~PluginChannelAdapter() 96 PluginChannelAdapter::Impl::~Impl()
54 { 97 {
98 // the adapter will delete the plugin
99
55 if (m_buffer) { 100 if (m_buffer) {
56 if (m_inputChannels > m_pluginChannels) { 101 if (m_inputChannels > m_pluginChannels) {
57 delete[] m_buffer[0]; 102 delete[] m_buffer[0];
58 } else { 103 } else {
59 for (size_t i = 0; i < m_pluginChannels - m_inputChannels; ++i) { 104 for (size_t i = 0; i < m_pluginChannels - m_inputChannels; ++i) {
69 m_forwardPtrs = 0; 114 m_forwardPtrs = 0;
70 } 115 }
71 } 116 }
72 117
73 bool 118 bool
74 PluginChannelAdapter::initialise(size_t channels, size_t stepSize, size_t blockSize) 119 PluginChannelAdapter::Impl::initialise(size_t channels, size_t stepSize, size_t blockSize)
75 { 120 {
76 m_blockSize = blockSize; 121 m_blockSize = blockSize;
77 122
78 size_t minch = m_plugin->getMinChannelCount(); 123 size_t minch = m_plugin->getMinChannelCount();
79 size_t maxch = m_plugin->getMaxChannelCount(); 124 size_t maxch = m_plugin->getMaxChannelCount();
127 172
128 return m_plugin->initialise(m_pluginChannels, stepSize, blockSize); 173 return m_plugin->initialise(m_pluginChannels, stepSize, blockSize);
129 } 174 }
130 175
131 PluginChannelAdapter::FeatureSet 176 PluginChannelAdapter::FeatureSet
132 PluginChannelAdapter::process(const float *const *inputBuffers, 177 PluginChannelAdapter::Impl::process(const float *const *inputBuffers,
133 RealTime timestamp) 178 RealTime timestamp)
134 { 179 {
135 // std::cerr << "PluginChannelAdapter::process: " << m_inputChannels << " -> " << m_pluginChannels << " channels" << std::endl; 180 // std::cerr << "PluginChannelAdapter::process: " << m_inputChannels << " -> " << m_pluginChannels << " channels" << std::endl;
136 181
137 if (m_inputChannels < m_pluginChannels) { 182 if (m_inputChannels < m_pluginChannels) {
138 183