Mercurial > hg > svcore
comparison transform/FeatureExtractionModelTransformer.cpp @ 1264:a99641535e02 3.0-integration
Debug output improvements, and make the checker actually attempt to call the descriptor function for known plugin types
author | Chris Cannam |
---|---|
date | Wed, 16 Nov 2016 16:12:42 +0000 |
parents | cbdd534f517a |
children | d163b04c3ec4 |
comparison
equal
deleted
inserted
replaced
1263:abfc498c52bc | 1264:a99641535e02 |
---|---|
105 if (!input) { | 105 if (!input) { |
106 m_message = tr("Input model for feature extraction plugin \"%1\" is of wrong type (internal error?)").arg(pluginId); | 106 m_message = tr("Input model for feature extraction plugin \"%1\" is of wrong type (internal error?)").arg(pluginId); |
107 return false; | 107 return false; |
108 } | 108 } |
109 | 109 |
110 cerr << "instantiating plugin for transform in thread " | 110 SVDEBUG << "FeatureExtractionModelTransformer: Instantiating plugin for transform in thread " |
111 << QThread::currentThreadId() << endl; | 111 << QThread::currentThreadId() << endl; |
112 | 112 |
113 m_plugin = factory->instantiatePlugin(pluginId, input->getSampleRate()); | 113 m_plugin = factory->instantiatePlugin(pluginId, input->getSampleRate()); |
114 if (!m_plugin) { | 114 if (!m_plugin) { |
115 m_message = tr("Failed to instantiate plugin \"%1\"").arg(pluginId); | 115 m_message = tr("Failed to instantiate plugin \"%1\"").arg(pluginId); |
116 return false; | 116 return false; |
134 .arg(input->getChannelCount()); | 134 .arg(input->getChannelCount()); |
135 return false; | 135 return false; |
136 } | 136 } |
137 | 137 |
138 SVDEBUG << "Initialising feature extraction plugin with channels = " | 138 SVDEBUG << "Initialising feature extraction plugin with channels = " |
139 << channelCount << ", step = " << primaryTransform.getStepSize() | 139 << channelCount << ", step = " << primaryTransform.getStepSize() |
140 << ", block = " << primaryTransform.getBlockSize() << endl; | 140 << ", block = " << primaryTransform.getBlockSize() << endl; |
141 | 141 |
142 if (!m_plugin->initialise(channelCount, | 142 if (!m_plugin->initialise(channelCount, |
143 primaryTransform.getStepSize(), | 143 primaryTransform.getStepSize(), |
144 primaryTransform.getBlockSize())) { | 144 primaryTransform.getBlockSize())) { |
145 | 145 |
146 int pstep = primaryTransform.getStepSize(); | 146 int pstep = primaryTransform.getStepSize(); |
147 int pblock = primaryTransform.getBlockSize(); | 147 int pblock = primaryTransform.getBlockSize(); |
148 | 148 |
149 ///!!! hang on, this isn't right -- we're modifying a copy | 149 ///!!! hang on, this isn't right -- we're modifying a copy |
150 primaryTransform.setStepSize(0); | 150 primaryTransform.setStepSize(0); |
152 TransformFactory::getInstance()->makeContextConsistentWithPlugin | 152 TransformFactory::getInstance()->makeContextConsistentWithPlugin |
153 (primaryTransform, m_plugin); | 153 (primaryTransform, m_plugin); |
154 | 154 |
155 if (primaryTransform.getStepSize() != pstep || | 155 if (primaryTransform.getStepSize() != pstep || |
156 primaryTransform.getBlockSize() != pblock) { | 156 primaryTransform.getBlockSize() != pblock) { |
157 | |
158 SVDEBUG << "Initialisation failed, trying again with default step = " | |
159 << primaryTransform.getStepSize() | |
160 << ", block = " << primaryTransform.getBlockSize() << endl; | |
157 | 161 |
158 if (!m_plugin->initialise(channelCount, | 162 if (!m_plugin->initialise(channelCount, |
159 primaryTransform.getStepSize(), | 163 primaryTransform.getStepSize(), |
160 primaryTransform.getBlockSize())) { | 164 primaryTransform.getBlockSize())) { |
161 | 165 |
166 SVDEBUG << "Initialisation failed again" << endl; | |
167 | |
162 m_message = tr("Failed to initialise feature extraction plugin \"%1\"").arg(pluginId); | 168 m_message = tr("Failed to initialise feature extraction plugin \"%1\"").arg(pluginId); |
163 return false; | 169 return false; |
164 | 170 |
165 } else { | 171 } else { |
166 | 172 |
173 SVDEBUG << "Initialisation succeeded this time" << endl; | |
174 | |
167 m_message = tr("Feature extraction plugin \"%1\" rejected the given step and block sizes (%2 and %3); using plugin defaults (%4 and %5) instead") | 175 m_message = tr("Feature extraction plugin \"%1\" rejected the given step and block sizes (%2 and %3); using plugin defaults (%4 and %5) instead") |
168 .arg(pluginId) | 176 .arg(pluginId) |
169 .arg(pstep) | 177 .arg(pstep) |
170 .arg(pblock) | 178 .arg(pblock) |
171 .arg(primaryTransform.getStepSize()) | 179 .arg(primaryTransform.getStepSize()) |
172 .arg(primaryTransform.getBlockSize()); | 180 .arg(primaryTransform.getBlockSize()); |
173 } | 181 } |
174 | 182 |
175 } else { | 183 } else { |
176 | 184 |
185 SVDEBUG << "Initialisation failed" << endl; | |
186 | |
177 m_message = tr("Failed to initialise feature extraction plugin \"%1\"").arg(pluginId); | 187 m_message = tr("Failed to initialise feature extraction plugin \"%1\"").arg(pluginId); |
178 return false; | 188 return false; |
179 } | 189 } |
190 } else { | |
191 SVDEBUG << "Initialisation succeeded" << endl; | |
180 } | 192 } |
181 | 193 |
182 if (primaryTransform.getPluginVersion() != "") { | 194 if (primaryTransform.getPluginVersion() != "") { |
183 QString pv = QString("%1").arg(m_plugin->getPluginVersion()); | 195 QString pv = QString("%1").arg(m_plugin->getPluginVersion()); |
184 if (pv != primaryTransform.getPluginVersion()) { | 196 if (pv != primaryTransform.getPluginVersion()) { |
235 } | 247 } |
236 | 248 |
237 void | 249 void |
238 FeatureExtractionModelTransformer::deinitialise() | 250 FeatureExtractionModelTransformer::deinitialise() |
239 { | 251 { |
240 cerr << "deleting plugin for transform in thread " | 252 SVDEBUG << "FeatureExtractionModelTransformer: deleting plugin for transform in thread " |
241 << QThread::currentThreadId() << endl; | 253 << QThread::currentThreadId() << endl; |
242 | 254 |
243 delete m_plugin; | 255 delete m_plugin; |
244 for (int j = 0; j < (int)m_descriptors.size(); ++j) { | 256 for (int j = 0; j < (int)m_descriptors.size(); ++j) { |
245 delete m_descriptors[j]; | 257 delete m_descriptors[j]; |
246 } | 258 } |
248 | 260 |
249 void | 261 void |
250 FeatureExtractionModelTransformer::createOutputModels(int n) | 262 FeatureExtractionModelTransformer::createOutputModels(int n) |
251 { | 263 { |
252 DenseTimeValueModel *input = getConformingInput(); | 264 DenseTimeValueModel *input = getConformingInput(); |
253 | |
254 // cerr << "FeatureExtractionModelTransformer::createOutputModel: sample type " << m_descriptor->sampleType << ", rate " << m_descriptor->sampleRate << endl; | |
255 | 265 |
256 PluginRDFDescription description(m_transforms[n].getPluginIdentifier()); | 266 PluginRDFDescription description(m_transforms[n].getPluginIdentifier()); |
257 QString outputId = m_transforms[n].getOutput(); | 267 QString outputId = m_transforms[n].getOutput(); |
258 | 268 |
259 int binCount = 1; | 269 int binCount = 1; |
289 //!!! different underlying rates together -- so we always set | 299 //!!! different underlying rates together -- so we always set |
290 //!!! the model rate to be the input model's rate, and adjust | 300 //!!! the model rate to be the input model's rate, and adjust |
291 //!!! the resolution appropriately. We can't properly display | 301 //!!! the resolution appropriately. We can't properly display |
292 //!!! data with a higher resolution than the base model at all | 302 //!!! data with a higher resolution than the base model at all |
293 if (outputRate > input->getSampleRate()) { | 303 if (outputRate > input->getSampleRate()) { |
294 cerr << "WARNING: plugin reports output sample rate as " | 304 SVDEBUG << "WARNING: plugin reports output sample rate as " |
295 << outputRate | 305 << outputRate |
296 << " (can't display features with finer resolution than the input rate of " | 306 << " (can't display features with finer resolution than the input rate of " |
297 << modelRate << ")" << endl; | 307 << modelRate << ")" << endl; |
298 outputRate = modelRate; | 308 outputRate = modelRate; |
299 } | 309 } |
300 } | 310 } |
301 | 311 |
302 switch (m_descriptors[n]->sampleType) { | 312 switch (m_descriptors[n]->sampleType) { |
311 modelResolution = m_transforms[n].getStepSize(); | 321 modelResolution = m_transforms[n].getStepSize(); |
312 break; | 322 break; |
313 | 323 |
314 case Vamp::Plugin::OutputDescriptor::FixedSampleRate: | 324 case Vamp::Plugin::OutputDescriptor::FixedSampleRate: |
315 if (outputRate <= 0.0) { | 325 if (outputRate <= 0.0) { |
316 cerr << "WARNING: Fixed sample-rate plugin reports invalid sample rate " << m_descriptors[n]->sampleRate << "; defaulting to input rate of " << input->getSampleRate() << endl; | 326 SVDEBUG << "WARNING: Fixed sample-rate plugin reports invalid sample rate " << m_descriptors[n]->sampleRate << "; defaulting to input rate of " << input->getSampleRate() << endl; |
317 modelResolution = 1; | 327 modelResolution = 1; |
318 } else { | 328 } else { |
319 modelResolution = int(round(modelRate / outputRate)); | 329 modelResolution = int(round(modelRate / outputRate)); |
320 // cerr << "modelRate = " << modelRate << ", descriptor rate = " << outputRate << ", modelResolution = " << modelResolution << endl; | 330 // cerr << "modelRate = " << modelRate << ", descriptor rate = " << outputRate << ", modelResolution = " << modelResolution << endl; |
321 } | 331 } |
734 buffers[ch][i*2+1] = 0.f; | 744 buffers[ch][i*2+1] = 0.f; |
735 } | 745 } |
736 } | 746 } |
737 error = fftModels[ch]->getError(); | 747 error = fftModels[ch]->getError(); |
738 if (error != "") { | 748 if (error != "") { |
739 cerr << "FeatureExtractionModelTransformer::run: Abandoning, error is " << error << endl; | 749 SVDEBUG << "FeatureExtractionModelTransformer::run: Abandoning, error is " << error << endl; |
740 m_abandoned = true; | 750 m_abandoned = true; |
741 m_message = error; | 751 m_message = error; |
742 break; | 752 break; |
743 } | 753 } |
744 } | 754 } |
877 | 887 |
878 if (m_descriptors[n]->sampleType == | 888 if (m_descriptors[n]->sampleType == |
879 Vamp::Plugin::OutputDescriptor::VariableSampleRate) { | 889 Vamp::Plugin::OutputDescriptor::VariableSampleRate) { |
880 | 890 |
881 if (!feature.hasTimestamp) { | 891 if (!feature.hasTimestamp) { |
882 cerr | 892 SVDEBUG |
883 << "WARNING: FeatureExtractionModelTransformer::addFeature: " | 893 << "WARNING: FeatureExtractionModelTransformer::addFeature: " |
884 << "Feature has variable sample rate but no timestamp!" | 894 << "Feature has variable sample rate but no timestamp!" |
885 << endl; | 895 << endl; |
886 return; | 896 return; |
887 } else { | 897 } else { |
913 frame = lrint((double(m_fixedRateFeatureNos[n]) / rate) * inputRate); | 923 frame = lrint((double(m_fixedRateFeatureNos[n]) / rate) * inputRate); |
914 // cerr << frame << endl; | 924 // cerr << frame << endl; |
915 } | 925 } |
916 | 926 |
917 if (frame < 0) { | 927 if (frame < 0) { |
918 cerr | 928 SVDEBUG |
919 << "WARNING: FeatureExtractionModelTransformer::addFeature: " | 929 << "WARNING: FeatureExtractionModelTransformer::addFeature: " |
920 << "Negative frame counts are not supported (frame = " << frame | 930 << "Negative frame counts are not supported (frame = " << frame |
921 << " from timestamp " << feature.timestamp | 931 << " from timestamp " << feature.timestamp |
922 << "), dropping feature" | 932 << "), dropping feature" |
923 << endl; | 933 << endl; |