comparison rdf/RDFFeatureWriter.cpp @ 995:952005e25266

Write sample rate from output descriptor, for FixedSampleRate outputs
author Chris Cannam
date Mon, 13 Oct 2014 10:00:54 +0100
parents 06579b8ffb7b
children 2104ea2204d2
comparison
equal deleted inserted replaced
994:8c9c425b4958 995:952005e25266
677 // the sample rate, window length and hop size from the 677 // the sample rate, window length and hop size from the
678 // transform 678 // transform
679 679
680 stream << "\n:feature_timeline_" << featureNumber << " a tl:DiscreteTimeLine .\n\n"; 680 stream << "\n:feature_timeline_" << featureNumber << " a tl:DiscreteTimeLine .\n\n";
681 681
682 int stepSize = transform.getStepSize(); 682 float sampleRate;
683 if (stepSize == 0) { 683 int stepSize, blockSize;
684 cerr << "RDFFeatureWriter: INTERNAL ERROR: writing dense features without having set the step size properly!" << endl; 684
685 return; 685 // If the output is FixedSampleRate, we need to draw the
686 } 686 // sample rate and step size from the output descriptor;
687 687 // otherwise they come from the transform
688 int blockSize = transform.getBlockSize(); 688
689 if (blockSize == 0) { 689 if (od.sampleType == Plugin::OutputDescriptor::FixedSampleRate) {
690 cerr << "RDFFeatureWriter: INTERNAL ERROR: writing dense features without having set the block size properly!" << endl; 690
691 return; 691 sampleRate = od.sampleRate;
692 } 692 stepSize = 1;
693 693 blockSize = 1;
694 float sampleRate = transform.getSampleRate(); 694
695 if (sampleRate == 0.f) { 695 } else {
696 cerr << "RDFFeatureWriter: INTERNAL ERROR: writing dense features without having set the sample rate properly!" << endl; 696
697 return; 697 sampleRate = transform.getSampleRate();
698 if (sampleRate == 0.f) {
699 cerr << "RDFFeatureWriter: INTERNAL ERROR: writing dense features without having set the sample rate properly!" << endl;
700 return;
701 }
702
703 stepSize = transform.getStepSize();
704 if (stepSize == 0) {
705 cerr << "RDFFeatureWriter: INTERNAL ERROR: writing dense features without having set the step size properly!" << endl;
706 return;
707 }
708
709 blockSize = transform.getBlockSize();
710 if (blockSize == 0) {
711 cerr << "RDFFeatureWriter: INTERNAL ERROR: writing dense features without having set the block size properly!" << endl;
712 return;
713 }
698 } 714 }
699 715
700 stream << ":feature_timeline_map_" << featureNumber 716 stream << ":feature_timeline_map_" << featureNumber
701 << " a tl:UniformSamplingWindowingMap ;\n" 717 << " a tl:UniformSamplingWindowingMap ;\n"
702 << " tl:rangeTimeLine :feature_timeline_" << featureNumber << " ;\n" 718 << " tl:rangeTimeLine :feature_timeline_" << featureNumber << " ;\n"
703 << " tl:domainTimeLine " << timelineURI << " ;\n" 719 << " tl:domainTimeLine " << timelineURI << " ;\n"
704 << " tl:sampleRate \"" << int(sampleRate) << "\"^^xsd:int ;\n" 720 << " tl:sampleRate \"" << sampleRate << "\"^^xsd:float ;\n"
705 << " tl:windowLength \"" << blockSize << "\"^^xsd:int ;\n" 721 << " tl:windowLength \"" << blockSize << "\"^^xsd:int ;\n"
706 << " tl:hopSize \"" << stepSize << "\"^^xsd:int .\n\n"; 722 << " tl:hopSize \"" << stepSize << "\"^^xsd:int .\n\n";
707 723
708 stream << signalURI << " af:signal_feature :feature_" 724 stream << signalURI << " af:signal_feature :feature_"
709 << featureNumber << " ." << endl << endl; 725 << featureNumber << " ." << endl << endl;