Mercurial > hg > svcore
comparison transform/FeatureExtractionModelTransformer.cpp @ 889:7f97a4d9d14f
Use fixed-rate feature no directly as column number, rather than do a calculation that might introduce rounding error
author | Chris Cannam |
---|---|
date | Tue, 11 Mar 2014 17:29:44 +0000 |
parents | 786ee8d1f30e |
children | 8962f80f5d8e |
comparison
equal
deleted
inserted
replaced
887:68f3eaefe297 | 889:7f97a4d9d14f |
---|---|
226 //!!! SV doesn't actually support display of models that have | 226 //!!! SV doesn't actually support display of models that have |
227 //!!! different underlying rates together -- so we always set | 227 //!!! different underlying rates together -- so we always set |
228 //!!! the model rate to be the input model's rate, and adjust | 228 //!!! the model rate to be the input model's rate, and adjust |
229 //!!! the resolution appropriately. We can't properly display | 229 //!!! the resolution appropriately. We can't properly display |
230 //!!! data with a higher resolution than the base model at all | 230 //!!! data with a higher resolution than the base model at all |
231 // modelRate = size_t(m_descriptor->sampleRate + 0.001); | |
232 if (m_descriptor->sampleRate > input->getSampleRate()) { | 231 if (m_descriptor->sampleRate > input->getSampleRate()) { |
233 modelResolution = 1; | 232 modelResolution = 1; |
234 } else { | 233 } else { |
235 modelResolution = size_t(input->getSampleRate() / | 234 modelResolution = size_t(round(input->getSampleRate() / |
236 m_descriptor->sampleRate); | 235 m_descriptor->sampleRate)); |
237 } | 236 } |
238 break; | 237 break; |
239 } | 238 } |
240 | 239 |
241 bool preDurationPlugin = (m_plugin->getVampApiVersion() < 2); | 240 bool preDurationPlugin = (m_plugin->getVampApiVersion() < 2); |
681 | 680 |
682 // cerr << "m_fixedRateFeatureNo = " << m_fixedRateFeatureNo | 681 // cerr << "m_fixedRateFeatureNo = " << m_fixedRateFeatureNo |
683 // << ", m_descriptor->sampleRate = " << m_descriptor->sampleRate | 682 // << ", m_descriptor->sampleRate = " << m_descriptor->sampleRate |
684 // << ", inputRate = " << inputRate | 683 // << ", inputRate = " << inputRate |
685 // << " giving frame = "; | 684 // << " giving frame = "; |
686 | 685 |
687 frame = lrintf((m_fixedRateFeatureNo / m_descriptor->sampleRate) | 686 frame = lrintf((m_fixedRateFeatureNo / m_descriptor->sampleRate) |
688 * int(inputRate)); | 687 * int(inputRate)); |
689 | 688 |
690 // cerr << frame << endl; | 689 // cerr << frame << endl; |
691 } | 690 } |
799 | 798 |
800 EditableDenseThreeDimensionalModel *model = | 799 EditableDenseThreeDimensionalModel *model = |
801 getConformingOutput<EditableDenseThreeDimensionalModel>(); | 800 getConformingOutput<EditableDenseThreeDimensionalModel>(); |
802 if (!model) return; | 801 if (!model) return; |
803 | 802 |
804 model->setColumn(frame / model->getResolution(), values); | 803 // cerr << "(note: model resolution = " << model->getResolution() << ")" |
804 // << endl; | |
805 | |
806 if (!feature.hasTimestamp && m_fixedRateFeatureNo >= 0) { | |
807 model->setColumn(m_fixedRateFeatureNo, values); | |
808 } else { | |
809 model->setColumn(frame / model->getResolution(), values); | |
810 } | |
805 | 811 |
806 } else { | 812 } else { |
807 SVDEBUG << "FeatureExtractionModelTransformer::addFeature: Unknown output model type!" << endl; | 813 SVDEBUG << "FeatureExtractionModelTransformer::addFeature: Unknown output model type!" << endl; |
808 } | 814 } |
809 } | 815 } |