Mercurial > hg > sonic-annotator
comparison runner/FeatureExtractionManager.cpp @ 57:513230b19248
Fix #311 following the patch from Matthias
author | Chris Cannam |
---|---|
date | Mon, 09 Jan 2012 14:47:50 +0000 |
parents | c30b9720bde0 |
children | 350f61d5d9be |
comparison
equal
deleted
inserted
replaced
56:52d71675a953 | 57:513230b19248 |
---|---|
755 } | 755 } |
756 | 756 |
757 // std::cerr << "FeatureExtractionManager: deleting audio file reader" << std::endl; | 757 // std::cerr << "FeatureExtractionManager: deleting audio file reader" << std::endl; |
758 | 758 |
759 lifemgr.destroy(); // deletes reader, data | 759 lifemgr.destroy(); // deletes reader, data |
760 | 760 |
761 // In order to ensure our results are written to the output in a | |
762 // fixed order (and not one that depends on the pointer value of | |
763 // each plugin on the heap in any given run of the program) we | |
764 // take the plugins' entries from the plugin map and sort them | |
765 // into a new, temporary map that is indexed by the first | |
766 // transform for each plugin. We then iterate over than instead of | |
767 // over m_plugins in order to get the right ordering. | |
768 | |
769 // This is not the most elegant way to do this -- it would be more | |
770 // elegant to impose an ordering directly on the plugins that are | |
771 // used as keys to m_plugins. But the plugin type comes from the | |
772 // Vamp SDK, so this change is more localised. | |
773 | |
774 // Thanks to Matthias for this. | |
775 | |
776 // Not the same as PluginMap::value_type (which has const key) | |
777 typedef pair<PluginMap::key_type, PluginMap::mapped_type> PluginMapEntry; | |
778 typedef map<Transform, PluginMapEntry> TransformOrderedPluginMap; | |
779 TransformOrderedPluginMap orderedPlugins; | |
780 | |
761 for (PluginMap::iterator pi = m_plugins.begin(); | 781 for (PluginMap::iterator pi = m_plugins.begin(); |
762 pi != m_plugins.end(); ++pi) { | 782 pi != m_plugins.end(); ++pi) { |
763 | 783 Transform firstForPlugin = (pi->second).begin()->first; |
764 Plugin *plugin = pi->first; | 784 orderedPlugins[firstForPlugin] = PluginMapEntry(pi->first, pi->second); |
785 } | |
786 | |
787 for (TransformOrderedPluginMap::iterator superPi = orderedPlugins.begin(); | |
788 superPi != orderedPlugins.end(); ++superPi) { | |
789 | |
790 // The value we extract from this map is just the same as the | |
791 // value_type we get from iterating over our PluginMap | |
792 // directly -- but we happen to get them in the right order | |
793 // now because the map iterator is ordered by the Transform | |
794 // key type ordering | |
795 PluginMapEntry pi = superPi->second; | |
796 | |
797 Plugin *plugin = pi.first; | |
765 Plugin::FeatureSet featureSet = plugin->getRemainingFeatures(); | 798 Plugin::FeatureSet featureSet = plugin->getRemainingFeatures(); |
766 | 799 |
767 if (!m_summariesOnly) { | 800 if (!m_summariesOnly) { |
768 writeFeatures(audioSource, plugin, featureSet); | 801 writeFeatures(audioSource, plugin, featureSet); |
769 } | 802 } |