comparison vamp-sdk/hostext/PluginInputDomainAdapter.cpp @ 190:1982246a3902

* Provide PluginWrapper method for getting hold of a nested wrapper directly (a bit gross, but useful) * Use the above to enable the simple host to adjust timestamps appropriately when printing out results from input domain adapter wrapped plugins
author cannam
date Wed, 17 Sep 2008 13:16:09 +0000
parents 2cb46126ef59
children
comparison
equal deleted inserted replaced
189:5ce2c3f79a45 190:1982246a3902
84 84
85 size_t getPreferredStepSize() const; 85 size_t getPreferredStepSize() const;
86 size_t getPreferredBlockSize() const; 86 size_t getPreferredBlockSize() const;
87 87
88 FeatureSet process(const float *const *inputBuffers, RealTime timestamp); 88 FeatureSet process(const float *const *inputBuffers, RealTime timestamp);
89
90 RealTime getTimestampAdjustment() const;
89 91
90 protected: 92 protected:
91 Plugin *m_plugin; 93 Plugin *m_plugin;
92 float m_inputSampleRate; 94 float m_inputSampleRate;
93 int m_channels; 95 int m_channels;
148 Plugin::FeatureSet 150 Plugin::FeatureSet
149 PluginInputDomainAdapter::process(const float *const *inputBuffers, RealTime timestamp) 151 PluginInputDomainAdapter::process(const float *const *inputBuffers, RealTime timestamp)
150 { 152 {
151 return m_impl->process(inputBuffers, timestamp); 153 return m_impl->process(inputBuffers, timestamp);
152 } 154 }
155
156 RealTime
157 PluginInputDomainAdapter::getTimestampAdjustment() const
158 {
159 return m_impl->getTimestampAdjustment();
160 }
161
153 162
154 PluginInputDomainAdapter::Impl::Impl(Plugin *plugin, float inputSampleRate) : 163 PluginInputDomainAdapter::Impl::Impl(Plugin *plugin, float inputSampleRate) :
155 m_plugin(plugin), 164 m_plugin(plugin),
156 m_inputSampleRate(inputSampleRate), 165 m_inputSampleRate(inputSampleRate),
157 m_channels(0), 166 m_channels(0),
334 343
335 #endif 344 #endif
336 } 345 }
337 346
338 return blockSize; 347 return blockSize;
348 }
349
350 RealTime
351 PluginInputDomainAdapter::Impl::getTimestampAdjustment() const
352 {
353 if (m_plugin->getInputDomain() == TimeDomain) {
354 return RealTime::zeroTime;
355 } else {
356 return RealTime::frame2RealTime
357 (m_blockSize/2, int(m_inputSampleRate + 0.5));
358 }
339 } 359 }
340 360
341 Plugin::FeatureSet 361 Plugin::FeatureSet
342 PluginInputDomainAdapter::Impl::process(const float *const *inputBuffers, 362 PluginInputDomainAdapter::Impl::process(const float *const *inputBuffers,
343 RealTime timestamp) 363 RealTime timestamp)
388 // particular that this means some results can differ from those 408 // particular that this means some results can differ from those
389 // produced by SV. 409 // produced by SV.
390 410
391 // std::cerr << "PluginInputDomainAdapter: sampleRate " << m_inputSampleRate << ", blocksize " << m_blockSize << ", adjusting time from " << timestamp; 411 // std::cerr << "PluginInputDomainAdapter: sampleRate " << m_inputSampleRate << ", blocksize " << m_blockSize << ", adjusting time from " << timestamp;
392 412
393 timestamp = timestamp + RealTime::frame2RealTime 413 timestamp = timestamp + getTimestampAdjustment();
394 (m_blockSize/2, int(m_inputSampleRate + 0.5));
395 414
396 // std::cerr << " to " << timestamp << std::endl; 415 // std::cerr << " to " << timestamp << std::endl;
397 416
398 for (int c = 0; c < m_channels; ++c) { 417 for (int c = 0; c < m_channels; ++c) {
399 418