comparison transform/FeatureExtractionModelTransformer.cpp @ 847:2d53205f70cd tonioni

Merge from default branch
author Chris Cannam
date Tue, 26 Nov 2013 14:37:01 +0000
parents 54829c1e155e e802e550a1f2
children 418cd2064769
comparison
equal deleted inserted replaced
841:226733f3cf3f 847:2d53205f70cd
178 void 178 void
179 FeatureExtractionModelTransformer::createOutputModel() 179 FeatureExtractionModelTransformer::createOutputModel()
180 { 180 {
181 DenseTimeValueModel *input = getConformingInput(); 181 DenseTimeValueModel *input = getConformingInput();
182 182
183 // std::cerr << "FeatureExtractionModelTransformer::createOutputModel: sample type " << m_descriptor->sampleType << ", rate " << m_descriptor->sampleRate << std::endl; 183 // cerr << "FeatureExtractionModelTransformer::createOutputModel: sample type " << m_descriptor->sampleType << ", rate " << m_descriptor->sampleRate << endl;
184 184
185 PluginRDFDescription description(m_transform.getPluginIdentifier()); 185 PluginRDFDescription description(m_transform.getPluginIdentifier());
186 QString outputId = m_transform.getOutput(); 186 QString outputId = m_transform.getOutput();
187 187
188 int binCount = 1; 188 int binCount = 1;
191 191
192 if (m_descriptor->hasFixedBinCount) { 192 if (m_descriptor->hasFixedBinCount) {
193 binCount = m_descriptor->binCount; 193 binCount = m_descriptor->binCount;
194 } 194 }
195 195
196 // std::cerr << "FeatureExtractionModelTransformer: output bin count " 196 // cerr << "FeatureExtractionModelTransformer: output bin count "
197 // << binCount << std::endl; 197 // << binCount << endl;
198 198
199 if (binCount > 0 && m_descriptor->hasKnownExtents) { 199 if (binCount > 0 && m_descriptor->hasKnownExtents) {
200 minValue = m_descriptor->minValue; 200 minValue = m_descriptor->minValue;
201 maxValue = m_descriptor->maxValue; 201 maxValue = m_descriptor->maxValue;
202 haveExtents = true; 202 haveExtents = true;
206 size_t modelResolution = 1; 206 size_t modelResolution = 1;
207 207
208 if (m_descriptor->sampleType != 208 if (m_descriptor->sampleType !=
209 Vamp::Plugin::OutputDescriptor::OneSamplePerStep) { 209 Vamp::Plugin::OutputDescriptor::OneSamplePerStep) {
210 if (m_descriptor->sampleRate > input->getSampleRate()) { 210 if (m_descriptor->sampleRate > input->getSampleRate()) {
211 std::cerr << "WARNING: plugin reports output sample rate as " 211 cerr << "WARNING: plugin reports output sample rate as "
212 << m_descriptor->sampleRate << " (can't display features with finer resolution than the input rate of " << input->getSampleRate() << ")" << std::endl; 212 << m_descriptor->sampleRate << " (can't display features with finer resolution than the input rate of " << input->getSampleRate() << ")" << endl;
213 } 213 }
214 } 214 }
215 215
216 switch (m_descriptor->sampleType) { 216 switch (m_descriptor->sampleType) {
217 217
538 buffers[ch][i*2] = reals[i]; 538 buffers[ch][i*2] = reals[i];
539 buffers[ch][i*2+1] = imaginaries[i]; 539 buffers[ch][i*2+1] = imaginaries[i];
540 } 540 }
541 error = fftModels[ch]->getError(); 541 error = fftModels[ch]->getError();
542 if (error != "") { 542 if (error != "") {
543 std::cerr << "FeatureExtractionModelTransformer::run: Abandoning, error is " << error << std::endl; 543 cerr << "FeatureExtractionModelTransformer::run: Abandoning, error is " << error << endl;
544 m_abandoned = true; 544 m_abandoned = true;
545 m_message = error; 545 m_message = error;
546 } 546 }
547 } 547 }
548 } else { 548 } else {
653 FeatureExtractionModelTransformer::addFeature(size_t blockFrame, 653 FeatureExtractionModelTransformer::addFeature(size_t blockFrame,
654 const Vamp::Plugin::Feature &feature) 654 const Vamp::Plugin::Feature &feature)
655 { 655 {
656 size_t inputRate = m_input.getModel()->getSampleRate(); 656 size_t inputRate = m_input.getModel()->getSampleRate();
657 657
658 // std::cerr << "FeatureExtractionModelTransformer::addFeature: blockFrame = " 658 // cerr << "FeatureExtractionModelTransformer::addFeature: blockFrame = "
659 // << blockFrame << ", hasTimestamp = " << feature.hasTimestamp 659 // << blockFrame << ", hasTimestamp = " << feature.hasTimestamp
660 // << ", timestamp = " << feature.timestamp << ", hasDuration = " 660 // << ", timestamp = " << feature.timestamp << ", hasDuration = "
661 // << feature.hasDuration << ", duration = " << feature.duration 661 // << feature.hasDuration << ", duration = " << feature.duration
662 // << std::endl; 662 // << endl;
663 663
664 int binCount = 1; 664 int binCount = 1;
665 if (m_descriptor->hasFixedBinCount) { 665 if (m_descriptor->hasFixedBinCount) {
666 binCount = m_descriptor->binCount; 666 binCount = m_descriptor->binCount;
667 } 667 }
670 670
671 if (m_descriptor->sampleType == 671 if (m_descriptor->sampleType ==
672 Vamp::Plugin::OutputDescriptor::VariableSampleRate) { 672 Vamp::Plugin::OutputDescriptor::VariableSampleRate) {
673 673
674 if (!feature.hasTimestamp) { 674 if (!feature.hasTimestamp) {
675 std::cerr 675 cerr
676 << "WARNING: FeatureExtractionModelTransformer::addFeature: " 676 << "WARNING: FeatureExtractionModelTransformer::addFeature: "
677 << "Feature has variable sample rate but no timestamp!" 677 << "Feature has variable sample rate but no timestamp!"
678 << std::endl; 678 << endl;
679 return; 679 return;
680 } else { 680 } else {
681 frame = Vamp::RealTime::realTime2Frame(feature.timestamp, inputRate); 681 frame = Vamp::RealTime::realTime2Frame(feature.timestamp, inputRate);
682 } 682 }
683 683