Mercurial > hg > svcore
comparison transform/FeatureExtractionModelTransformer.cpp @ 1254:cbdd534f517a piper
Avoid assigning model resolution of 0 to models coming from plugins that report weirdly high output rates (symptom: data did not show up in edit layer data dialog, as the row/frame conversion failed)
author | Chris Cannam |
---|---|
date | Sat, 05 Nov 2016 10:40:22 +0000 |
parents | a83541a1f100 |
children | a99641535e02 |
comparison
equal
deleted
inserted
replaced
1250:c2d66e3c83d0 | 1254:cbdd534f517a |
---|---|
275 maxValue = m_descriptors[n]->maxValue; | 275 maxValue = m_descriptors[n]->maxValue; |
276 haveExtents = true; | 276 haveExtents = true; |
277 } | 277 } |
278 | 278 |
279 sv_samplerate_t modelRate = input->getSampleRate(); | 279 sv_samplerate_t modelRate = input->getSampleRate(); |
280 sv_samplerate_t outputRate = modelRate; | |
280 int modelResolution = 1; | 281 int modelResolution = 1; |
281 | 282 |
282 if (m_descriptors[n]->sampleType != | 283 if (m_descriptors[n]->sampleType != |
283 Vamp::Plugin::OutputDescriptor::OneSamplePerStep) { | 284 Vamp::Plugin::OutputDescriptor::OneSamplePerStep) { |
284 if (m_descriptors[n]->sampleRate > input->getSampleRate()) { | 285 |
285 cerr << "WARNING: plugin reports output sample rate as " | 286 outputRate = m_descriptors[n]->sampleRate; |
286 << m_descriptors[n]->sampleRate << " (can't display features with finer resolution than the input rate of " << input->getSampleRate() << ")" << endl; | 287 |
287 } | |
288 } | |
289 | |
290 switch (m_descriptors[n]->sampleType) { | |
291 | |
292 case Vamp::Plugin::OutputDescriptor::VariableSampleRate: | |
293 if (m_descriptors[n]->sampleRate != 0.0) { | |
294 modelResolution = int(round(modelRate / m_descriptors[n]->sampleRate)); | |
295 } | |
296 break; | |
297 | |
298 case Vamp::Plugin::OutputDescriptor::OneSamplePerStep: | |
299 modelResolution = m_transforms[n].getStepSize(); | |
300 break; | |
301 | |
302 case Vamp::Plugin::OutputDescriptor::FixedSampleRate: | |
303 //!!! SV doesn't actually support display of models that have | 288 //!!! SV doesn't actually support display of models that have |
304 //!!! different underlying rates together -- so we always set | 289 //!!! different underlying rates together -- so we always set |
305 //!!! the model rate to be the input model's rate, and adjust | 290 //!!! the model rate to be the input model's rate, and adjust |
306 //!!! the resolution appropriately. We can't properly display | 291 //!!! the resolution appropriately. We can't properly display |
307 //!!! data with a higher resolution than the base model at all | 292 //!!! data with a higher resolution than the base model at all |
308 if (m_descriptors[n]->sampleRate > input->getSampleRate()) { | 293 if (outputRate > input->getSampleRate()) { |
309 modelResolution = 1; | 294 cerr << "WARNING: plugin reports output sample rate as " |
310 } else if (m_descriptors[n]->sampleRate <= 0.0) { | 295 << outputRate |
296 << " (can't display features with finer resolution than the input rate of " | |
297 << modelRate << ")" << endl; | |
298 outputRate = modelRate; | |
299 } | |
300 } | |
301 | |
302 switch (m_descriptors[n]->sampleType) { | |
303 | |
304 case Vamp::Plugin::OutputDescriptor::VariableSampleRate: | |
305 if (outputRate != 0.0) { | |
306 modelResolution = int(round(modelRate / outputRate)); | |
307 } | |
308 break; | |
309 | |
310 case Vamp::Plugin::OutputDescriptor::OneSamplePerStep: | |
311 modelResolution = m_transforms[n].getStepSize(); | |
312 break; | |
313 | |
314 case Vamp::Plugin::OutputDescriptor::FixedSampleRate: | |
315 if (outputRate <= 0.0) { | |
311 cerr << "WARNING: Fixed sample-rate plugin reports invalid sample rate " << m_descriptors[n]->sampleRate << "; defaulting to input rate of " << input->getSampleRate() << endl; | 316 cerr << "WARNING: Fixed sample-rate plugin reports invalid sample rate " << m_descriptors[n]->sampleRate << "; defaulting to input rate of " << input->getSampleRate() << endl; |
312 modelResolution = 1; | 317 modelResolution = 1; |
313 } else { | 318 } else { |
314 modelResolution = int(round(modelRate / m_descriptors[n]->sampleRate)); | 319 modelResolution = int(round(modelRate / outputRate)); |
320 // cerr << "modelRate = " << modelRate << ", descriptor rate = " << outputRate << ", modelResolution = " << modelResolution << endl; | |
315 } | 321 } |
316 break; | 322 break; |
317 } | 323 } |
318 | 324 |
319 bool preDurationPlugin = (m_plugin->getVampApiVersion() < 2); | 325 bool preDurationPlugin = (m_plugin->getVampApiVersion() < 2); |