comparison src/vamp-hostsdk/PluginBufferingAdapter.cpp @ 287:f3b1ba71a305

* When calculating timestamps in order to write them into features that previously lacked them, from a buffering adapter, we need to take into account any timestamp adjustment used by other wrappers that are being wrapped by this one (i.e. input domain adapter)
author cannam
date Thu, 10 Sep 2009 15:21:34 +0000
parents e0b7a35ea18e
children c97e70ed5abc
comparison
equal deleted inserted replaced
286:91574fc544db 287:f3b1ba71a305
37 37
38 #include <vector> 38 #include <vector>
39 #include <map> 39 #include <map>
40 40
41 #include <vamp-hostsdk/PluginBufferingAdapter.h> 41 #include <vamp-hostsdk/PluginBufferingAdapter.h>
42 #include <vamp-hostsdk/PluginInputDomainAdapter.h>
42 43
43 using std::vector; 44 using std::vector;
44 using std::map; 45 using std::map;
45 46
46 _VAMP_SDK_HOSTSPACE_BEGIN(PluginBufferingAdapter.cpp) 47 _VAMP_SDK_HOSTSPACE_BEGIN(PluginBufferingAdapter.cpp)
650 RealTime timestamp = RealTime::frame2RealTime 651 RealTime timestamp = RealTime::frame2RealTime
651 (frame, int(m_inputSampleRate + 0.5)); 652 (frame, int(m_inputSampleRate + 0.5));
652 653
653 FeatureSet featureSet = m_plugin->process(m_buffers, timestamp); 654 FeatureSet featureSet = m_plugin->process(m_buffers, timestamp);
654 655
656 PluginWrapper *wrapper = dynamic_cast<PluginWrapper *>(m_plugin);
657 RealTime adjustment;
658 if (wrapper) {
659 PluginInputDomainAdapter *ida =
660 wrapper->getWrapper<PluginInputDomainAdapter>();
661 if (ida) adjustment = ida->getTimestampAdjustment();
662 }
663
655 for (FeatureSet::iterator iter = featureSet.begin(); 664 for (FeatureSet::iterator iter = featureSet.begin();
656 iter != featureSet.end(); ++iter) { 665 iter != featureSet.end(); ++iter) {
657 666
658 int outputNo = iter->first; 667 int outputNo = iter->first;
659 668
665 674
666 switch (m_outputs[outputNo].sampleType) { 675 switch (m_outputs[outputNo].sampleType) {
667 676
668 case OutputDescriptor::OneSamplePerStep: 677 case OutputDescriptor::OneSamplePerStep:
669 // use our internal timestamp, always 678 // use our internal timestamp, always
670 featureList[i].timestamp = timestamp; 679 featureList[i].timestamp = timestamp + adjustment;
671 featureList[i].hasTimestamp = true; 680 featureList[i].hasTimestamp = true;
672 break; 681 break;
673 682
674 case OutputDescriptor::FixedSampleRate: 683 case OutputDescriptor::FixedSampleRate:
675 // use our internal timestamp if feature lacks one 684 // use our internal timestamp if feature lacks one
676 if (!featureList[i].hasTimestamp) { 685 if (!featureList[i].hasTimestamp) {
677 featureList[i].timestamp = timestamp; 686 featureList[i].timestamp = timestamp + adjustment;
678 featureList[i].hasTimestamp = true; 687 featureList[i].hasTimestamp = true;
679 } 688 }
680 break; 689 break;
681 690
682 case OutputDescriptor::VariableSampleRate: 691 case OutputDescriptor::VariableSampleRate: