Mercurial > hg > sonic-annotator
comparison runner/FeatureExtractionManager.cpp @ 100:010fbf2a3fba
Merge from branch start-duration
author | Chris Cannam |
---|---|
date | Wed, 01 Oct 2014 14:35:01 +0100 |
parents | 136d8496a4b8 526feaad5820 |
children | fae326c22df5 |
comparison
equal
deleted
inserted
replaced
98:136d8496a4b8 | 100:010fbf2a3fba |
---|---|
602 | 602 |
603 size_t frameCount = reader->getFrameCount(); | 603 size_t frameCount = reader->getFrameCount(); |
604 | 604 |
605 // cerr << "file has " << frameCount << " frames" << endl; | 605 // cerr << "file has " << frameCount << " frames" << endl; |
606 | 606 |
607 int earliestStartFrame = 0; | |
608 int latestEndFrame = frameCount; | |
609 bool haveExtents = false; | |
610 | |
607 for (PluginMap::iterator pi = m_plugins.begin(); | 611 for (PluginMap::iterator pi = m_plugins.begin(); |
608 pi != m_plugins.end(); ++pi) { | 612 pi != m_plugins.end(); ++pi) { |
609 | 613 |
610 Plugin *plugin = pi->first; | 614 Plugin *plugin = pi->first; |
611 | 615 |
615 for (TransformWriterMap::iterator ti = pi->second.begin(); | 619 for (TransformWriterMap::iterator ti = pi->second.begin(); |
616 ti != pi->second.end(); ++ti) { | 620 ti != pi->second.end(); ++ti) { |
617 | 621 |
618 const Transform &transform = ti->first; | 622 const Transform &transform = ti->first; |
619 | 623 |
620 //!!! we may want to set the start and duration times for extraction | 624 int startFrame = RealTime::realTime2Frame |
621 // in the transform record (defaults of zero indicate extraction | 625 (transform.getStartTime(), m_sampleRate); |
622 // from the whole file) | 626 int duration = RealTime::realTime2Frame |
623 // transform.setStartTime(RealTime::zeroTime); | 627 (transform.getDuration(), m_sampleRate); |
624 // transform.setDuration | 628 if (duration == 0) { |
625 // (RealTime::frame2RealTime(reader->getFrameCount(), m_sampleRate)); | 629 duration = frameCount - startFrame; |
630 } | |
631 | |
632 if (!haveExtents || startFrame < earliestStartFrame) { | |
633 earliestStartFrame = startFrame; | |
634 } | |
635 if (!haveExtents || startFrame + duration > latestEndFrame) { | |
636 latestEndFrame = startFrame + duration; | |
637 } | |
638 | |
639 haveExtents = true; | |
626 | 640 |
627 string outputId = transform.getOutput().toStdString(); | 641 string outputId = transform.getOutput().toStdString(); |
628 if (m_pluginOutputs[plugin].find(outputId) == | 642 if (m_pluginOutputs[plugin].find(outputId) == |
629 m_pluginOutputs[plugin].end()) { | 643 m_pluginOutputs[plugin].end()) { |
630 //!!! throw? | 644 //!!! throw? |
648 */ | 662 */ |
649 } | 663 } |
650 } | 664 } |
651 } | 665 } |
652 | 666 |
653 long startFrame = 0; | 667 int startFrame = earliestStartFrame; |
654 long endFrame = frameCount; | 668 int endFrame = latestEndFrame; |
655 | |
656 /*!!! No -- there is no single transform to pull this stuff from -- | |
657 * the transforms may have various start and end times, need to be far | |
658 * cleverer about this if we're going to support them | |
659 | |
660 RealTime trStartRT = transform.getStartTime(); | |
661 RealTime trDurationRT = transform.getDuration(); | |
662 | |
663 long trStart = RealTime::realTime2Frame(trStartRT, m_sampleRate); | |
664 long trDuration = RealTime::realTime2Frame(trDurationRT, m_sampleRate); | |
665 | |
666 if (trStart == 0 || trStart < startFrame) { | |
667 trStart = startFrame; | |
668 } | |
669 | |
670 if (trDuration == 0) { | |
671 trDuration = endFrame - trStart; | |
672 } | |
673 if (trStart + trDuration > endFrame) { | |
674 trDuration = endFrame - trStart; | |
675 } | |
676 | |
677 startFrame = trStart; | |
678 endFrame = trStart + trDuration; | |
679 */ | |
680 | 669 |
681 for (PluginMap::iterator pi = m_plugins.begin(); | 670 for (PluginMap::iterator pi = m_plugins.begin(); |
682 pi != m_plugins.end(); ++pi) { | 671 pi != m_plugins.end(); ++pi) { |
683 | 672 |
684 for (TransformWriterMap::const_iterator ti = pi->second.begin(); | 673 for (TransformWriterMap::const_iterator ti = pi->second.begin(); |
698 } | 687 } |
699 | 688 |
700 ProgressPrinter extractionProgress("Extracting and writing features..."); | 689 ProgressPrinter extractionProgress("Extracting and writing features..."); |
701 int progress = 0; | 690 int progress = 0; |
702 | 691 |
703 for (long i = startFrame; i < endFrame; i += m_blockSize) { | 692 for (int i = startFrame; i < endFrame; i += m_blockSize) { |
704 | 693 |
705 //!!! inefficient, although much of the inefficiency may be | 694 //!!! inefficient, although much of the inefficiency may be |
706 // susceptible to optimisation | 695 // susceptible to compiler optimisation |
707 | 696 |
708 SampleBlock frames; | 697 SampleBlock frames; |
709 reader->getInterleavedFrames(i, m_blockSize, frames); | 698 reader->getInterleavedFrames(i, m_blockSize, frames); |
710 | 699 |
711 // We have to do our own channel handling here; we can't just | 700 // We have to do our own channel handling here; we can't just |