comparison transform/FeatureExtractionModelTransformer.cpp @ 1757:776389390473 by-id

Merge
author Chris Cannam
date Sat, 06 Jul 2019 18:12:54 +0100
parents fd7f127ecd89
children 110f853c3149
comparison
equal deleted inserted replaced
1756:043e05c956fb 1757:776389390473
646 } 646 }
647 } 647 }
648 if (m_abandoned) return; 648 if (m_abandoned) return;
649 649
650 ModelId inputId = getInputModel(); 650 ModelId inputId = getInputModel();
651 auto input = ModelById::getAs<DenseTimeValueModel>(inputId); 651
652 if (!input) { 652 sv_samplerate_t sampleRate;
653 abandon(); 653 int channelCount;
654 return; 654 sv_frame_t startFrame;
655 } 655 sv_frame_t endFrame;
656 656
657 sv_samplerate_t sampleRate = input->getSampleRate(); 657 { // scope so as not to have this borrowed pointer retained around
658 658 // the edges of the process loop
659 int channelCount = input->getChannelCount(); 659 auto input = ModelById::getAs<DenseTimeValueModel>(inputId);
660 if ((int)m_plugin->getMaxChannelCount() < channelCount) { 660 if (!input) {
661 channelCount = 1; 661 abandon();
662 return;
663 }
664
665 sampleRate = input->getSampleRate();
666
667 channelCount = input->getChannelCount();
668 if ((int)m_plugin->getMaxChannelCount() < channelCount) {
669 channelCount = 1;
670 }
671
672 startFrame = input->getStartFrame();
673 endFrame = input->getEndFrame();
662 } 674 }
663 675
664 float **buffers = new float*[channelCount]; 676 float **buffers = new float*[channelCount];
665 for (int ch = 0; ch < channelCount; ++ch) { 677 for (int ch = 0; ch < channelCount; ++ch) {
666 buffers[ch] = new float[primaryTransform.getBlockSize() + 2]; 678 buffers[ch] = new float[primaryTransform.getBlockSize() + 2];
694 } 706 }
695 fftModels.push_back(model); 707 fftModels.push_back(model);
696 } 708 }
697 } 709 }
698 710
699 sv_frame_t startFrame = input->getStartFrame();
700 sv_frame_t endFrame = input->getEndFrame();
701
702 RealTime contextStartRT = primaryTransform.getStartTime(); 711 RealTime contextStartRT = primaryTransform.getStartTime();
703 RealTime contextDurationRT = primaryTransform.getDuration(); 712 RealTime contextDurationRT = primaryTransform.getDuration();
704 713
705 sv_frame_t contextStart = 714 sv_frame_t contextStart =
706 RealTime::realTime2Frame(contextStartRT, sampleRate); 715 RealTime::realTime2Frame(contextStartRT, sampleRate);
758 #endif 767 #endif
759 768
760 int completion = int 769 int completion = int
761 ((((blockFrame - contextStart) / stepSize) * 99) / 770 ((((blockFrame - contextStart) / stepSize) * 99) /
762 (contextDuration / stepSize + 1)); 771 (contextDuration / stepSize + 1));
772
773 if (!ModelById::get(inputId)) {
774 abandon();
775 return;
776 }
763 777
764 // channelCount is either input->channelCount or 1 778 // channelCount is either input->channelCount or 1
765 779
766 if (frequencyDomain) { 780 if (frequencyDomain) {
767 for (int ch = 0; ch < channelCount; ++ch) { 781 for (int ch = 0; ch < channelCount; ++ch) {