Mercurial > hg > svcore
diff 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 |
line wrap: on
line diff
--- a/transform/FeatureExtractionModelTransformer.cpp Fri Nov 04 14:39:15 2016 +0000 +++ b/transform/FeatureExtractionModelTransformer.cpp Sat Nov 05 10:40:22 2016 +0000 @@ -277,21 +277,33 @@ } sv_samplerate_t modelRate = input->getSampleRate(); + sv_samplerate_t outputRate = modelRate; int modelResolution = 1; if (m_descriptors[n]->sampleType != Vamp::Plugin::OutputDescriptor::OneSamplePerStep) { - if (m_descriptors[n]->sampleRate > input->getSampleRate()) { + + outputRate = m_descriptors[n]->sampleRate; + + //!!! SV doesn't actually support display of models that have + //!!! different underlying rates together -- so we always set + //!!! the model rate to be the input model's rate, and adjust + //!!! the resolution appropriately. We can't properly display + //!!! data with a higher resolution than the base model at all + if (outputRate > input->getSampleRate()) { cerr << "WARNING: plugin reports output sample rate as " - << m_descriptors[n]->sampleRate << " (can't display features with finer resolution than the input rate of " << input->getSampleRate() << ")" << endl; + << outputRate + << " (can't display features with finer resolution than the input rate of " + << modelRate << ")" << endl; + outputRate = modelRate; } } switch (m_descriptors[n]->sampleType) { case Vamp::Plugin::OutputDescriptor::VariableSampleRate: - if (m_descriptors[n]->sampleRate != 0.0) { - modelResolution = int(round(modelRate / m_descriptors[n]->sampleRate)); + if (outputRate != 0.0) { + modelResolution = int(round(modelRate / outputRate)); } break; @@ -300,18 +312,12 @@ break; case Vamp::Plugin::OutputDescriptor::FixedSampleRate: - //!!! SV doesn't actually support display of models that have - //!!! different underlying rates together -- so we always set - //!!! the model rate to be the input model's rate, and adjust - //!!! the resolution appropriately. We can't properly display - //!!! data with a higher resolution than the base model at all - if (m_descriptors[n]->sampleRate > input->getSampleRate()) { - modelResolution = 1; - } else if (m_descriptors[n]->sampleRate <= 0.0) { + if (outputRate <= 0.0) { cerr << "WARNING: Fixed sample-rate plugin reports invalid sample rate " << m_descriptors[n]->sampleRate << "; defaulting to input rate of " << input->getSampleRate() << endl; modelResolution = 1; } else { - modelResolution = int(round(modelRate / m_descriptors[n]->sampleRate)); + modelResolution = int(round(modelRate / outputRate)); +// cerr << "modelRate = " << modelRate << ", descriptor rate = " << outputRate << ", modelResolution = " << modelResolution << endl; } break; }