Mercurial > hg > sonic-annotator
comparison runner/FeatureExtractionManager.cpp @ 233:9a10c3ffff47
Update summary code and tests -- fix multiple outputs when requesting both summary and non-summary for the same output; and values have been changed because of the coded file cache bit depth change. Also skip network-dependent tests if there is no network.
author | Chris Cannam |
---|---|
date | Thu, 25 Feb 2016 18:19:27 +0000 |
parents | 88044af67bd1 |
children | 857ce6ecb163 |
comparison
equal
deleted
inserted
replaced
232:e2519bd033e7 | 233:9a10c3ffff47 |
---|---|
321 << "\" with plugin step size " << actualStepSize | 321 << "\" with plugin step size " << actualStepSize |
322 << " and block size " << actualBlockSize | 322 << " and block size " << actualBlockSize |
323 << " (adapter step and block size " << m_blockSize << ")" | 323 << " (adapter step and block size " << m_blockSize << ")" |
324 << endl; | 324 << endl; |
325 | 325 |
326 // cerr << "NOTE: That transform is: " << transform.toXmlString() << endl; | |
327 | |
326 if (pida) { | 328 if (pida) { |
327 cerr << "NOTE: PluginInputDomainAdapter timestamp adjustment is " | 329 cerr << "NOTE: PluginInputDomainAdapter timestamp adjustment is " |
328 | 330 |
329 << pida->getTimestampAdjustment() << endl; | 331 << pida->getTimestampAdjustment() << endl; |
330 } | 332 } |
380 } | 382 } |
381 } | 383 } |
382 | 384 |
383 m_transformPluginMap[transform] = plugin; | 385 m_transformPluginMap[transform] = plugin; |
384 | 386 |
387 // cerr << "NOTE: Assigned plugin " << plugin << " for transform: " << transform.toXmlString() << endl; | |
388 | |
385 if (!(originalTransform == transform)) { | 389 if (!(originalTransform == transform)) { |
386 m_transformPluginMap[originalTransform] = plugin; | 390 m_transformPluginMap[originalTransform] = plugin; |
391 // cerr << "NOTE: Also assigned plugin " << plugin << " for original transform: " << originalTransform.toXmlString() << endl; | |
387 } | 392 } |
388 | 393 |
389 } else { | 394 } else { |
390 | 395 |
391 plugin = m_transformPluginMap[transform]; | 396 plugin = m_transformPluginMap[transform]; |
740 | 745 |
741 foreach (Plugin *plugin, m_orderedPlugins) { | 746 foreach (Plugin *plugin, m_orderedPlugins) { |
742 | 747 |
743 PluginMap::iterator pi = m_plugins.find(plugin); | 748 PluginMap::iterator pi = m_plugins.find(plugin); |
744 | 749 |
745 std::cerr << "Calling reset on " << plugin << std::endl; | 750 // std::cerr << "Calling reset on " << plugin << std::endl; |
746 plugin->reset(); | 751 plugin->reset(); |
747 | 752 |
748 for (TransformWriterMap::iterator ti = pi->second.begin(); | 753 for (TransformWriterMap::iterator ti = pi->second.begin(); |
749 ti != pi->second.end(); ++ti) { | 754 ti != pi->second.end(); ++ti) { |
750 | 755 |
921 if (!m_summariesOnly) { | 926 if (!m_summariesOnly) { |
922 writeFeatures(audioSource, plugin, featureSet); | 927 writeFeatures(audioSource, plugin, featureSet); |
923 } | 928 } |
924 | 929 |
925 if (!m_summaries.empty()) { | 930 if (!m_summaries.empty()) { |
931 // Summaries requested on the command line, for all transforms | |
926 PluginSummarisingAdapter *adapter = | 932 PluginSummarisingAdapter *adapter = |
927 dynamic_cast<PluginSummarisingAdapter *>(plugin); | 933 dynamic_cast<PluginSummarisingAdapter *>(plugin); |
928 if (!adapter) { | 934 if (!adapter) { |
929 cerr << "WARNING: Summaries requested, but plugin is not a summarising adapter" << endl; | 935 cerr << "WARNING: Summaries requested, but plugin is not a summarising adapter" << endl; |
930 } else { | 936 } else { |
937 //!!! on whether their features have duration or | 943 //!!! on whether their features have duration or |
938 //!!! not | 944 //!!! not |
939 featureSet = adapter->getSummaryForAllOutputs | 945 featureSet = adapter->getSummaryForAllOutputs |
940 (getSummaryType(*sni), | 946 (getSummaryType(*sni), |
941 PluginSummarisingAdapter::ContinuousTimeAverage); | 947 PluginSummarisingAdapter::ContinuousTimeAverage); |
942 writeFeatures(audioSource, plugin, featureSet,//!!! *sni); | 948 writeFeatures(audioSource, plugin, featureSet, |
943 Transform::stringToSummaryType(sni->c_str())); | 949 Transform::stringToSummaryType(sni->c_str())); |
944 } | 950 } |
945 } | 951 } |
946 } | 952 } |
947 | 953 |
954 // Summaries specified in transform definitions themselves | |
948 writeSummaries(audioSource, plugin); | 955 writeSummaries(audioSource, plugin); |
949 } | 956 } |
950 | 957 |
951 extractionProgress.done(); | 958 extractionProgress.done(); |
952 | 959 |
964 for (TransformWriterMap::const_iterator ti = pi->second.begin(); | 971 for (TransformWriterMap::const_iterator ti = pi->second.begin(); |
965 ti != pi->second.end(); ++ti) { | 972 ti != pi->second.end(); ++ti) { |
966 | 973 |
967 const Transform &transform = ti->first; | 974 const Transform &transform = ti->first; |
968 | 975 |
976 // cerr << "FeatureExtractionManager::writeSummaries: plugin is " << plugin | |
977 // << ", found transform: " << transform.toXmlString() << endl; | |
978 | |
969 Transform::SummaryType summaryType = transform.getSummaryType(); | 979 Transform::SummaryType summaryType = transform.getSummaryType(); |
970 PluginSummarisingAdapter::SummaryType pType = | 980 PluginSummarisingAdapter::SummaryType pType = |
971 (PluginSummarisingAdapter::SummaryType)summaryType; | 981 (PluginSummarisingAdapter::SummaryType)summaryType; |
972 | 982 |
973 if (transform.getSummaryType() == Transform::NoSummary) { | 983 if (transform.getSummaryType() == Transform::NoSummary) { |
984 // cerr << "(no summary, continuing)" << endl; | |
974 continue; | 985 continue; |
975 } | 986 } |
976 | 987 |
977 PluginSummarisingAdapter *adapter = | 988 PluginSummarisingAdapter *adapter = |
978 dynamic_cast<PluginSummarisingAdapter *>(plugin); | 989 dynamic_cast<PluginSummarisingAdapter *>(plugin); |
982 } | 993 } |
983 | 994 |
984 Plugin::FeatureSet featureSet = adapter->getSummaryForAllOutputs | 995 Plugin::FeatureSet featureSet = adapter->getSummaryForAllOutputs |
985 (pType, PluginSummarisingAdapter::ContinuousTimeAverage); | 996 (pType, PluginSummarisingAdapter::ContinuousTimeAverage); |
986 | 997 |
987 // cout << "summary type " << int(pType) << " for transform:" << endl << transform.toXmlString().toStdString()<< endl << "... feature set with " << featureSet.size() << " elts" << endl; | 998 // cerr << "summary type " << int(pType) << " for transform:" << endl << transform.toXmlString().toStdString()<< endl << "... feature set with " << featureSet.size() << " elts" << endl; |
988 | 999 |
989 writeFeatures(audioSource, plugin, featureSet, summaryType); | 1000 writeFeatures(audioSource, plugin, featureSet, summaryType); |
990 } | 1001 } |
991 } | 1002 } |
992 | 1003 |
996 Transform::SummaryType summaryType) | 1007 Transform::SummaryType summaryType) |
997 { | 1008 { |
998 // caller should have ensured plugin is in m_plugins | 1009 // caller should have ensured plugin is in m_plugins |
999 PluginMap::iterator pi = m_plugins.find(plugin); | 1010 PluginMap::iterator pi = m_plugins.find(plugin); |
1000 | 1011 |
1012 // Write features from the feature set passed in, according to the | |
1013 // transforms listed for the given plugin with the given summary type | |
1014 | |
1001 for (TransformWriterMap::const_iterator ti = pi->second.begin(); | 1015 for (TransformWriterMap::const_iterator ti = pi->second.begin(); |
1002 ti != pi->second.end(); ++ti) { | 1016 ti != pi->second.end(); ++ti) { |
1003 | 1017 |
1004 const Transform &transform = ti->first; | 1018 const Transform &transform = ti->first; |
1005 const vector<FeatureWriter *> &writers = ti->second; | 1019 const vector<FeatureWriter *> &writers = ti->second; |
1006 | 1020 |
1007 if (transform.getSummaryType() != Transform::NoSummary && | 1021 // cerr << "writeFeatures: plugin " << plugin << " has transform: " << transform.toXmlString() << endl; |
1008 m_summaries.empty() && | 1022 |
1009 summaryType == Transform::NoSummary) { | 1023 if (transform.getSummaryType() == Transform::NoSummary && |
1010 continue; | 1024 !m_summaries.empty()) { |
1011 } | 1025 // cerr << "transform has no summary, but summaries requested on command line, so going for it anyway" << endl; |
1012 | 1026 } else if (transform.getSummaryType() != summaryType) { |
1013 if (transform.getSummaryType() != Transform::NoSummary && | 1027 // Either we're not writing a summary and the transform |
1014 summaryType != Transform::NoSummary && | 1028 // has one, or we're writing a summary but the transform |
1015 transform.getSummaryType() != summaryType) { | 1029 // has none or a different one; either way, skip it |
1030 // cerr << "summary type differs from passed-in one " << summaryType << endl; | |
1016 continue; | 1031 continue; |
1017 } | 1032 } |
1018 | 1033 |
1019 string outputId = transform.getOutput().toStdString(); | 1034 string outputId = transform.getOutput().toStdString(); |
1020 | 1035 |
1028 | 1043 |
1029 int outputIndex = m_pluginOutputIndices[outputId]; | 1044 int outputIndex = m_pluginOutputIndices[outputId]; |
1030 Plugin::FeatureSet::const_iterator fsi = features.find(outputIndex); | 1045 Plugin::FeatureSet::const_iterator fsi = features.find(outputIndex); |
1031 if (fsi == features.end()) continue; | 1046 if (fsi == features.end()) continue; |
1032 | 1047 |
1048 // cerr << "this transform has " << writers.size() << " writer(s)" << endl; | |
1049 | |
1033 for (int j = 0; j < (int)writers.size(); ++j) { | 1050 for (int j = 0; j < (int)writers.size(); ++j) { |
1034 writers[j]->write | 1051 writers[j]->write |
1035 (audioSource, transform, desc, fsi->second, | 1052 (audioSource, transform, desc, fsi->second, |
1036 Transform::summaryTypeToString(summaryType).toStdString()); | 1053 Transform::summaryTypeToString(summaryType).toStdString()); |
1037 } | 1054 } |