comparison vamp-sdk/hostext/PluginBufferingAdapter.cpp @ 104:08d8c8ee6097

* implement reset() in PluginBufferingAdapter
author cannam
date Thu, 31 Jan 2008 09:24:47 +0000
parents ca40f3bc99f0
children 92ca8e401044
comparison
equal deleted inserted replaced
103:2cb46126ef59 104:08d8c8ee6097
55 55
56 bool initialise(size_t channels, size_t stepSize, size_t blockSize); 56 bool initialise(size_t channels, size_t stepSize, size_t blockSize);
57 57
58 OutputList getOutputDescriptors() const; 58 OutputList getOutputDescriptors() const;
59 59
60 void reset();
61
60 FeatureSet process(const float *const *inputBuffers, RealTime timestamp); 62 FeatureSet process(const float *const *inputBuffers, RealTime timestamp);
61 63
62 FeatureSet getRemainingFeatures(); 64 FeatureSet getRemainingFeatures();
63 65
64 protected: 66 protected:
223 size_t m_blockSize; 225 size_t m_blockSize;
224 size_t m_channels; 226 size_t m_channels;
225 vector<RingBuffer *> m_queue; 227 vector<RingBuffer *> m_queue;
226 float **m_buffers; 228 float **m_buffers;
227 float m_inputSampleRate; 229 float m_inputSampleRate;
228 RealTime m_timestamp; 230 RealTime m_timestamp;
231 bool m_unrun;
229 OutputList m_outputs; 232 OutputList m_outputs;
230 233
231 void processBlock(FeatureSet& allFeatureSets, RealTime timestamp); 234 void processBlock(FeatureSet& allFeatureSets, RealTime timestamp);
232 }; 235 };
233 236
250 253
251 PluginBufferingAdapter::OutputList 254 PluginBufferingAdapter::OutputList
252 PluginBufferingAdapter::getOutputDescriptors() const 255 PluginBufferingAdapter::getOutputDescriptors() const
253 { 256 {
254 return m_impl->getOutputDescriptors(); 257 return m_impl->getOutputDescriptors();
258 }
259
260 void
261 PluginBufferingAdapter::reset()
262 {
263 m_impl->reset();
255 } 264 }
256 265
257 PluginBufferingAdapter::FeatureSet 266 PluginBufferingAdapter::FeatureSet
258 PluginBufferingAdapter::process(const float *const *inputBuffers, 267 PluginBufferingAdapter::process(const float *const *inputBuffers,
259 RealTime timestamp) 268 RealTime timestamp)
275 m_blockSize(0), 284 m_blockSize(0),
276 m_channels(0), 285 m_channels(0),
277 m_queue(0), 286 m_queue(0),
278 m_buffers(0), 287 m_buffers(0),
279 m_inputSampleRate(inputSampleRate), 288 m_inputSampleRate(inputSampleRate),
280 m_timestamp() 289 m_timestamp(RealTime::zeroTime),
290 m_unrun(true)
281 { 291 {
282 m_outputs = plugin->getOutputDescriptors(); 292 m_outputs = plugin->getOutputDescriptors();
283 } 293 }
284 294
285 PluginBufferingAdapter::Impl::~Impl() 295 PluginBufferingAdapter::Impl::~Impl()
363 outs[i].sampleType = OutputDescriptor::VariableSampleRate; 373 outs[i].sampleType = OutputDescriptor::VariableSampleRate;
364 } 374 }
365 return outs; 375 return outs;
366 } 376 }
367 377
378 void
379 PluginBufferingAdapter::Impl::reset()
380 {
381 m_timestamp = RealTime::zeroTime;
382 m_unrun = true;
383
384 for (size_t i = 0; i < m_queue.size(); ++i) {
385 m_queue[i]->reset();
386 }
387 }
388
368 PluginBufferingAdapter::FeatureSet 389 PluginBufferingAdapter::FeatureSet
369 PluginBufferingAdapter::Impl::process(const float *const *inputBuffers, 390 PluginBufferingAdapter::Impl::process(const float *const *inputBuffers,
370 RealTime timestamp) 391 RealTime timestamp)
371 { 392 {
372 FeatureSet allFeatureSets; 393 FeatureSet allFeatureSets;
394
395 if (m_unrun) {
396 m_timestamp = timestamp;
397 m_unrun = false;
398 }
373 399
374 // queue the new input 400 // queue the new input
375 401
376 for (size_t i = 0; i < m_channels; ++i) { 402 for (size_t i = 0; i < m_channels; ++i) {
377 int written = m_queue[i]->write(inputBuffers[i], m_inputBlockSize); 403 int written = m_queue[i]->write(inputBuffers[i], m_inputBlockSize);