Mercurial > hg > svcore
comparison plugin/transform/FeatureExtractionModelTransformer.cpp @ 361:399ea254afd6
* Part of #1877436 transform fails to re-run when file loaded at different rate
author | Chris Cannam |
---|---|
date | Wed, 23 Jan 2008 18:09:50 +0000 |
parents | d7c41483af8f |
children | 0e30c8ec15a0 |
comparison
equal
deleted
inserted
replaced
360:ac300d385ab2 | 361:399ea254afd6 |
---|---|
48 | 48 |
49 FeatureExtractionPluginFactory *factory = | 49 FeatureExtractionPluginFactory *factory = |
50 FeatureExtractionPluginFactory::instanceFor(pluginId); | 50 FeatureExtractionPluginFactory::instanceFor(pluginId); |
51 | 51 |
52 if (!factory) { | 52 if (!factory) { |
53 std::cerr << "FeatureExtractionModelTransformer: No factory available for plugin id \"" | 53 m_message = tr("No factory available for feature extraction plugin id \"%1\" (unknown plugin type, or internal error?)").arg(pluginId); |
54 << pluginId.toStdString() << "\"" << std::endl; | |
55 return; | 54 return; |
56 } | 55 } |
57 | 56 |
58 DenseTimeValueModel *input = getConformingInput(); | 57 DenseTimeValueModel *input = getConformingInput(); |
59 if (!input) { | 58 if (!input) { |
60 std::cerr << "FeatureExtractionModelTransformer: Input model not conformable" << std::endl; | 59 m_message = tr("Input model for feature extraction plugin \"%1\" is of wrong type (internal error?)").arg(pluginId); |
61 return; | 60 return; |
62 } | 61 } |
63 | 62 |
64 m_plugin = factory->instantiatePlugin(pluginId, input->getSampleRate()); | 63 m_plugin = factory->instantiatePlugin(pluginId, input->getSampleRate()); |
65 if (!m_plugin) { | 64 if (!m_plugin) { |
66 std::cerr << "FeatureExtractionModelTransformer: Failed to instantiate plugin \"" | 65 m_message = tr("Failed to instantiate plugin \"%1\"").arg(pluginId); |
67 << pluginId.toStdString() << "\"" << std::endl; | |
68 return; | 66 return; |
69 } | 67 } |
70 | 68 |
71 TransformFactory::getInstance()->makeContextConsistentWithPlugin | 69 TransformFactory::getInstance()->makeContextConsistentWithPlugin |
72 (m_transform, m_plugin); | 70 (m_transform, m_plugin); |
77 size_t channelCount = input->getChannelCount(); | 75 size_t channelCount = input->getChannelCount(); |
78 if (m_plugin->getMaxChannelCount() < channelCount) { | 76 if (m_plugin->getMaxChannelCount() < channelCount) { |
79 channelCount = 1; | 77 channelCount = 1; |
80 } | 78 } |
81 if (m_plugin->getMinChannelCount() > channelCount) { | 79 if (m_plugin->getMinChannelCount() > channelCount) { |
82 std::cerr << "FeatureExtractionModelTransformer:: " | 80 m_message = tr("Cannot provide enough channels to feature extraction plugin \"%1\" (plugin min is %2, max %3; input model has %4)") |
83 << "Can't provide enough channels to plugin (plugin min " | 81 .arg(pluginId) |
84 << m_plugin->getMinChannelCount() << ", max " | 82 .arg(m_plugin->getMinChannelCount()) |
85 << m_plugin->getMaxChannelCount() << ", input model has " | 83 .arg(m_plugin->getMaxChannelCount()) |
86 << input->getChannelCount() << ")" << std::endl; | 84 .arg(input->getChannelCount()); |
87 return; | 85 return; |
88 } | 86 } |
89 | 87 |
90 std::cerr << "Initialising feature extraction plugin with channels = " | 88 std::cerr << "Initialising feature extraction plugin with channels = " |
91 << channelCount << ", step = " << m_transform.getStepSize() | 89 << channelCount << ", step = " << m_transform.getStepSize() |
92 << ", block = " << m_transform.getBlockSize() << std::endl; | 90 << ", block = " << m_transform.getBlockSize() << std::endl; |
93 | 91 |
94 if (!m_plugin->initialise(channelCount, | 92 if (!m_plugin->initialise(channelCount, |
95 m_transform.getStepSize(), | 93 m_transform.getStepSize(), |
96 m_transform.getBlockSize())) { | 94 m_transform.getBlockSize())) { |
97 std::cerr << "FeatureExtractionModelTransformer: Plugin " | 95 |
98 << pluginId.toStdString() << " failed to initialise!" << std::endl; | 96 size_t pstep = m_transform.getStepSize(); |
99 return; | 97 size_t pblock = m_transform.getBlockSize(); |
98 | |
99 m_transform.setStepSize(0); | |
100 m_transform.setBlockSize(0); | |
101 TransformFactory::getInstance()->makeContextConsistentWithPlugin | |
102 (m_transform, m_plugin); | |
103 | |
104 if (m_transform.getStepSize() != pstep || | |
105 m_transform.getBlockSize() != pblock) { | |
106 | |
107 if (!m_plugin->initialise(channelCount, | |
108 m_transform.getStepSize(), | |
109 m_transform.getBlockSize())) { | |
110 | |
111 m_message = tr("Failed to initialise feature extraction plugin \"%1\"").arg(pluginId); | |
112 return; | |
113 | |
114 } else { | |
115 | |
116 m_message = tr("Feature extraction plugin \"%1\" rejected the given step and block sizes (%2 and %3); using plugin defaults (%4 and %5) instead") | |
117 .arg(pluginId) | |
118 .arg(pstep) | |
119 .arg(pblock) | |
120 .arg(m_transform.getStepSize()) | |
121 .arg(m_transform.getBlockSize()); | |
122 } | |
123 | |
124 } else { | |
125 | |
126 m_message = tr("Failed to initialise feature extraction plugin \"%1\"").arg(pluginId); | |
127 return; | |
128 } | |
100 } | 129 } |
101 | 130 |
102 Vamp::Plugin::OutputList outputs = m_plugin->getOutputDescriptors(); | 131 Vamp::Plugin::OutputList outputs = m_plugin->getOutputDescriptors(); |
103 | 132 |
104 if (outputs.empty()) { | 133 if (outputs.empty()) { |
105 std::cerr << "FeatureExtractionModelTransformer: Plugin \"" | 134 m_message = tr("Plugin \"%1\" has no outputs").arg(pluginId); |
106 << pluginId.toStdString() << "\" has no outputs" << std::endl; | |
107 return; | 135 return; |
108 } | 136 } |
109 | 137 |
110 for (size_t i = 0; i < outputs.size(); ++i) { | 138 for (size_t i = 0; i < outputs.size(); ++i) { |
111 if (m_transform.getOutput() == "" || | 139 if (m_transform.getOutput() == "" || |
116 break; | 144 break; |
117 } | 145 } |
118 } | 146 } |
119 | 147 |
120 if (!m_descriptor) { | 148 if (!m_descriptor) { |
121 std::cerr << "FeatureExtractionModelTransformer: Plugin \"" | 149 m_message = tr("Plugin \"%1\" has no output named \"%2\"") |
122 << pluginId.toStdString() << "\" has no output named \"" | 150 .arg(pluginId) |
123 << m_transform.getOutput().toStdString() << "\"" << std::endl; | 151 .arg(m_transform.getOutput()); |
124 return; | 152 return; |
125 } | 153 } |
126 | 154 |
127 // std::cerr << "FeatureExtractionModelTransformer: output sample type " | 155 // std::cerr << "FeatureExtractionModelTransformer: output sample type " |
128 // << m_descriptor->sampleType << std::endl; | 156 // << m_descriptor->sampleType << std::endl; |