Mercurial > hg > svcore
comparison transform/FeatureExtractionModelTransformer.cpp @ 1558:73b3dd65e0b3
Some debug + tidying
author | Chris Cannam |
---|---|
date | Thu, 18 Oct 2018 13:14:56 +0100 |
parents | 48e9f538e6e9 |
children | 70e172e6cc59 |
comparison
equal
deleted
inserted
replaced
1557:d93e34684da7 | 1558:73b3dd65e0b3 |
---|---|
38 | 38 |
39 #include <iostream> | 39 #include <iostream> |
40 | 40 |
41 #include <QSettings> | 41 #include <QSettings> |
42 | 42 |
43 //#define DEBUG_FEATURE_EXTRACTION_TRANSFORMER_RUN 1 | |
44 | |
43 FeatureExtractionModelTransformer::FeatureExtractionModelTransformer(Input in, | 45 FeatureExtractionModelTransformer::FeatureExtractionModelTransformer(Input in, |
44 const Transform &transform) : | 46 const Transform &transform) : |
45 ModelTransformer(in, transform), | 47 ModelTransformer(in, transform), |
46 m_plugin(0), | 48 m_plugin(0), |
47 m_haveOutputs(false) | 49 m_haveOutputs(false) |
654 } | 656 } |
655 | 657 |
656 Transform primaryTransform = m_transforms[0]; | 658 Transform primaryTransform = m_transforms[0]; |
657 | 659 |
658 while (!input->isReady() && !m_abandoned) { | 660 while (!input->isReady() && !m_abandoned) { |
659 cerr << "FeatureExtractionModelTransformer::run: Waiting for input model to be ready..." << endl; | 661 SVDEBUG << "FeatureExtractionModelTransformer::run: Waiting for input model to be ready..." << endl; |
660 usleep(500000); | 662 usleep(500000); |
661 } | 663 } |
664 SVDEBUG << "FeatureExtractionModelTransformer::run: Waited, ready = " | |
665 << input->isReady() << ", m_abandoned = " << m_abandoned << endl; | |
662 if (m_abandoned) return; | 666 if (m_abandoned) return; |
663 | 667 |
664 sv_samplerate_t sampleRate = input->getSampleRate(); | 668 sv_samplerate_t sampleRate = input->getSampleRate(); |
665 | 669 |
666 int channelCount = input->getChannelCount(); | 670 int channelCount = input->getChannelCount(); |
676 int stepSize = primaryTransform.getStepSize(); | 680 int stepSize = primaryTransform.getStepSize(); |
677 int blockSize = primaryTransform.getBlockSize(); | 681 int blockSize = primaryTransform.getBlockSize(); |
678 | 682 |
679 bool frequencyDomain = (m_plugin->getInputDomain() == | 683 bool frequencyDomain = (m_plugin->getInputDomain() == |
680 Vamp::Plugin::FrequencyDomain); | 684 Vamp::Plugin::FrequencyDomain); |
685 | |
681 std::vector<FFTModel *> fftModels; | 686 std::vector<FFTModel *> fftModels; |
682 | 687 |
683 if (frequencyDomain) { | 688 if (frequencyDomain) { |
684 for (int ch = 0; ch < channelCount; ++ch) { | 689 for (int ch = 0; ch < channelCount; ++ch) { |
685 FFTModel *model = new FFTModel | 690 FFTModel *model = new FFTModel |
752 } else { | 757 } else { |
753 if (blockFrame >= | 758 if (blockFrame >= |
754 contextStart + contextDuration) break; | 759 contextStart + contextDuration) break; |
755 } | 760 } |
756 | 761 |
757 // SVDEBUG << "FeatureExtractionModelTransformer::run: blockFrame " | 762 #ifdef DEBUG_FEATURE_EXTRACTION_TRANSFORMER_RUN |
758 // << blockFrame << ", endFrame " << endFrame << ", blockSize " | 763 SVDEBUG << "FeatureExtractionModelTransformer::run: blockFrame " |
759 // << blockSize << endl; | 764 << blockFrame << ", endFrame " << endFrame << ", blockSize " |
760 | 765 << blockSize << endl; |
766 #endif | |
767 | |
761 int completion = int | 768 int completion = int |
762 ((((blockFrame - contextStart) / stepSize) * 99) / | 769 ((((blockFrame - contextStart) / stepSize) * 99) / |
763 (contextDuration / stepSize + 1)); | 770 (contextDuration / stepSize + 1)); |
764 | 771 |
765 // channelCount is either m_input.getModel()->channelCount or 1 | 772 // channelCount is either m_input.getModel()->channelCount or 1 |
775 } else { | 782 } else { |
776 for (int i = 0; i <= blockSize/2; ++i) { | 783 for (int i = 0; i <= blockSize/2; ++i) { |
777 buffers[ch][i*2] = 0.f; | 784 buffers[ch][i*2] = 0.f; |
778 buffers[ch][i*2+1] = 0.f; | 785 buffers[ch][i*2+1] = 0.f; |
779 } | 786 } |
780 } | 787 } |
788 | |
781 error = fftModels[ch]->getError(); | 789 error = fftModels[ch]->getError(); |
782 if (error != "") { | 790 if (error != "") { |
783 SVCERR << "FeatureExtractionModelTransformer::run: Abandoning, error is " << error << endl; | 791 SVCERR << "FeatureExtractionModelTransformer::run: Abandoning, error is " << error << endl; |
784 m_abandoned = true; | 792 m_abandoned = true; |
785 m_message = error; | 793 m_message = error; |
791 } | 799 } |
792 | 800 |
793 if (m_abandoned) break; | 801 if (m_abandoned) break; |
794 | 802 |
795 Vamp::Plugin::FeatureSet features = m_plugin->process | 803 Vamp::Plugin::FeatureSet features = m_plugin->process |
796 (buffers, RealTime::frame2RealTime(blockFrame, sampleRate).toVampRealTime()); | 804 (buffers, |
797 | 805 RealTime::frame2RealTime(blockFrame, sampleRate) |
806 .toVampRealTime()); | |
807 | |
798 if (m_abandoned) break; | 808 if (m_abandoned) break; |
799 | 809 |
800 for (int j = 0; j < (int)m_outputNos.size(); ++j) { | 810 for (int j = 0; j < (int)m_outputNos.size(); ++j) { |
801 for (int fi = 0; fi < (int)features[m_outputNos[j]].size(); ++fi) { | 811 for (int fi = 0; fi < (int)features[m_outputNos[j]].size(); ++fi) { |
802 Vamp::Plugin::Feature feature = features[m_outputNos[j]][fi]; | 812 Vamp::Plugin::Feature feature = features[m_outputNos[j]][fi]; |
1120 } | 1130 } |
1121 | 1131 |
1122 void | 1132 void |
1123 FeatureExtractionModelTransformer::setCompletion(int n, int completion) | 1133 FeatureExtractionModelTransformer::setCompletion(int n, int completion) |
1124 { | 1134 { |
1125 // SVDEBUG << "FeatureExtractionModelTransformer::setCompletion(" | 1135 #ifdef DEBUG_FEATURE_EXTRACTION_TRANSFORMER_RUN |
1126 // << completion << ")" << endl; | 1136 SVDEBUG << "FeatureExtractionModelTransformer::setCompletion(" |
1137 << completion << ")" << endl; | |
1138 #endif | |
1127 | 1139 |
1128 if (isOutput<SparseOneDimensionalModel>(n)) { | 1140 if (isOutput<SparseOneDimensionalModel>(n)) { |
1129 | 1141 |
1130 SparseOneDimensionalModel *model = | 1142 SparseOneDimensionalModel *model = |
1131 getConformingOutput<SparseOneDimensionalModel>(n); | 1143 getConformingOutput<SparseOneDimensionalModel>(n); |