Mercurial > hg > vamp-plugin-sdk
diff 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 |
line wrap: on
line diff
--- a/vamp-sdk/hostext/PluginInputDomainAdapter.cpp Wed Sep 17 11:00:51 2008 +0000 +++ b/vamp-sdk/hostext/PluginInputDomainAdapter.cpp Wed Sep 17 13:16:09 2008 +0000 @@ -86,6 +86,8 @@ size_t getPreferredBlockSize() const; FeatureSet process(const float *const *inputBuffers, RealTime timestamp); + + RealTime getTimestampAdjustment() const; protected: Plugin *m_plugin; @@ -151,6 +153,13 @@ return m_impl->process(inputBuffers, timestamp); } +RealTime +PluginInputDomainAdapter::getTimestampAdjustment() const +{ + return m_impl->getTimestampAdjustment(); +} + + PluginInputDomainAdapter::Impl::Impl(Plugin *plugin, float inputSampleRate) : m_plugin(plugin), m_inputSampleRate(inputSampleRate), @@ -338,6 +347,17 @@ return blockSize; } +RealTime +PluginInputDomainAdapter::Impl::getTimestampAdjustment() const +{ + if (m_plugin->getInputDomain() == TimeDomain) { + return RealTime::zeroTime; + } else { + return RealTime::frame2RealTime + (m_blockSize/2, int(m_inputSampleRate + 0.5)); + } +} + Plugin::FeatureSet PluginInputDomainAdapter::Impl::process(const float *const *inputBuffers, RealTime timestamp) @@ -390,8 +410,7 @@ // std::cerr << "PluginInputDomainAdapter: sampleRate " << m_inputSampleRate << ", blocksize " << m_blockSize << ", adjusting time from " << timestamp; - timestamp = timestamp + RealTime::frame2RealTime - (m_blockSize/2, int(m_inputSampleRate + 0.5)); + timestamp = timestamp + getTimestampAdjustment(); // std::cerr << " to " << timestamp << std::endl;