comparison vamp-sdk/hostext/PluginChannelAdapter.cpp @ 197:fe30a25ee4f8

* Add processInterleaved to PluginChannelAdapter
author cannam
date Tue, 07 Oct 2008 21:07:04 +0000
parents 64697dca0d48
children
comparison
equal deleted inserted replaced
196:5c202da82a46 197:fe30a25ee4f8
47 ~Impl(); 47 ~Impl();
48 48
49 bool initialise(size_t channels, size_t stepSize, size_t blockSize); 49 bool initialise(size_t channels, size_t stepSize, size_t blockSize);
50 50
51 FeatureSet process(const float *const *inputBuffers, RealTime timestamp); 51 FeatureSet process(const float *const *inputBuffers, RealTime timestamp);
52 FeatureSet processInterleaved(const float *inputBuffers, RealTime timestamp);
52 53
53 protected: 54 protected:
54 Plugin *m_plugin; 55 Plugin *m_plugin;
55 size_t m_blockSize; 56 size_t m_blockSize;
56 size_t m_inputChannels; 57 size_t m_inputChannels;
57 size_t m_pluginChannels; 58 size_t m_pluginChannels;
58 float **m_buffer; 59 float **m_buffer;
60 float **m_deinterleave;
59 const float **m_forwardPtrs; 61 const float **m_forwardPtrs;
60 }; 62 };
61 63
62 PluginChannelAdapter::PluginChannelAdapter(Plugin *plugin) : 64 PluginChannelAdapter::PluginChannelAdapter(Plugin *plugin) :
63 PluginWrapper(plugin) 65 PluginWrapper(plugin)
79 PluginChannelAdapter::FeatureSet 81 PluginChannelAdapter::FeatureSet
80 PluginChannelAdapter::process(const float *const *inputBuffers, 82 PluginChannelAdapter::process(const float *const *inputBuffers,
81 RealTime timestamp) 83 RealTime timestamp)
82 { 84 {
83 return m_impl->process(inputBuffers, timestamp); 85 return m_impl->process(inputBuffers, timestamp);
86 }
87
88 PluginChannelAdapter::FeatureSet
89 PluginChannelAdapter::processInterleaved(const float *inputBuffers,
90 RealTime timestamp)
91 {
92 return m_impl->processInterleaved(inputBuffers, timestamp);
84 } 93 }
85 94
86 PluginChannelAdapter::Impl::Impl(Plugin *plugin) : 95 PluginChannelAdapter::Impl::Impl(Plugin *plugin) :
87 m_plugin(plugin), 96 m_plugin(plugin),
88 m_blockSize(0), 97 m_blockSize(0),
89 m_inputChannels(0), 98 m_inputChannels(0),
90 m_pluginChannels(0), 99 m_pluginChannels(0),
91 m_buffer(0), 100 m_buffer(0),
101 m_deinterleave(0),
92 m_forwardPtrs(0) 102 m_forwardPtrs(0)
93 { 103 {
94 } 104 }
95 105
96 PluginChannelAdapter::Impl::~Impl() 106 PluginChannelAdapter::Impl::~Impl()
105 delete[] m_buffer[i]; 115 delete[] m_buffer[i];
106 } 116 }
107 } 117 }
108 delete[] m_buffer; 118 delete[] m_buffer;
109 m_buffer = 0; 119 m_buffer = 0;
120 }
121
122 if (m_deinterleave) {
123 for (size_t i = 0; i < m_inputChannels; ++i) {
124 delete[] m_deinterleave[i];
125 }
126 delete[] m_deinterleave;
127 m_deinterleave = 0;
110 } 128 }
111 129
112 if (m_forwardPtrs) { 130 if (m_forwardPtrs) {
113 delete[] m_forwardPtrs; 131 delete[] m_forwardPtrs;
114 m_forwardPtrs = 0; 132 m_forwardPtrs = 0;
172 190
173 return m_plugin->initialise(m_pluginChannels, stepSize, blockSize); 191 return m_plugin->initialise(m_pluginChannels, stepSize, blockSize);
174 } 192 }
175 193
176 PluginChannelAdapter::FeatureSet 194 PluginChannelAdapter::FeatureSet
195 PluginChannelAdapter::Impl::processInterleaved(const float *inputBuffers,
196 RealTime timestamp)
197 {
198 if (!m_deinterleave) {
199 m_deinterleave = new float *[m_inputChannels];
200 for (size_t i = 0; i < m_inputChannels; ++i) {
201 m_deinterleave[i] = new float[m_blockSize];
202 }
203 }
204
205 for (size_t i = 0; i < m_inputChannels; ++i) {
206 for (size_t j = 0; j < m_blockSize; ++j) {
207 m_deinterleave[i][j] = inputBuffers[j * m_inputChannels + i];
208 }
209 }
210
211 return process(m_deinterleave, timestamp);
212 }
213
214 PluginChannelAdapter::FeatureSet
177 PluginChannelAdapter::Impl::process(const float *const *inputBuffers, 215 PluginChannelAdapter::Impl::process(const float *const *inputBuffers,
178 RealTime timestamp) 216 RealTime timestamp)
179 { 217 {
180 // std::cerr << "PluginChannelAdapter::process: " << m_inputChannels << " -> " << m_pluginChannels << " channels" << std::endl; 218 // std::cerr << "PluginChannelAdapter::process: " << m_inputChannels << " -> " << m_pluginChannels << " channels" << std::endl;
181 219