comparison runner/main.cpp @ 263:68dc2d99a5b1 piper-nopiper

Debug output updates, add quiet mode
author Chris Cannam
date Tue, 22 Nov 2016 16:42:56 +0000
parents 0774f36cb151
children 0be716283c61
comparison
equal deleted inserted replaced
262:d7bbc5b03619 263:68dc2d99a5b1
34 #include "../version.h" 34 #include "../version.h"
35 35
36 #include "base/Exceptions.h" 36 #include "base/Exceptions.h"
37 #include "base/TempDirectory.h" 37 #include "base/TempDirectory.h"
38 #include "base/ProgressPrinter.h" 38 #include "base/ProgressPrinter.h"
39 #include "base/Debug.h"
39 40
40 #include "data/fileio/AudioFileReaderFactory.h" 41 #include "data/fileio/AudioFileReaderFactory.h"
41 #include "data/fileio/PlaylistFileReader.h" 42 #include "data/fileio/PlaylistFileReader.h"
42 43
43 #include "transform/Transform.h" 44 #include "transform/Transform.h"
342 << wrapCol("Normalise each input audio file to signal abs max = 1.f.") 343 << wrapCol("Normalise each input audio file to signal abs max = 1.f.")
343 << endl << endl; 344 << endl << endl;
344 cerr << " -f, --force " 345 cerr << " -f, --force "
345 << wrapCol("Continue with subsequent files following an error.") 346 << wrapCol("Continue with subsequent files following an error.")
346 << endl << endl; 347 << endl << endl;
348 cerr << " -q, --quiet "
349 << wrapCol("Suppress informational output that would otherwise be printed to stderr and to a log file. Sonic Annotator may run faster with this option, especially if the application data directory is on a shared storage resource, but no diagnostic information will be available except for the application's return code.")
350 << endl << endl;
347 cerr << "Housekeeping options:" 351 cerr << "Housekeeping options:"
348 << endl << endl; 352 << endl << endl;
349 cerr << " -l, --list List available transform ids to standard output." << endl; 353 cerr << " -l, --list List available transform ids to standard output." << endl;
350 cerr << " --list-writers List supported writer types to standard output." << endl; 354 cerr << " --list-writers List supported writer types to standard output." << endl;
351 cerr << " --list-formats List supported input audio formats to standard output." << endl; 355 cerr << " --list-formats List supported input audio formats to standard output." << endl;
598 set<string> requestedSummaryTypes; 602 set<string> requestedSummaryTypes;
599 bool force = false; 603 bool force = false;
600 bool multiplex = false; 604 bool multiplex = false;
601 bool recursive = false; 605 bool recursive = false;
602 bool normalise = false; 606 bool normalise = false;
607 bool quiet = false;
603 bool list = false; 608 bool list = false;
604 bool listWriters = false; 609 bool listWriters = false;
605 bool listFormats = false; 610 bool listFormats = false;
606 bool summaryOnly = false; 611 bool summaryOnly = false;
607 QString skeletonFor = ""; 612 QString skeletonFor = "";
754 normalise = true; 759 normalise = true;
755 continue; 760 continue;
756 } else if (arg == "-f" || arg == "--force") { 761 } else if (arg == "-f" || arg == "--force") {
757 force = true; 762 force = true;
758 continue; 763 continue;
764 } else if (arg == "-q" || arg == "--quiet") {
765 quiet = true;
766 continue;
759 } else if (arg == "--list-writers") { 767 } else if (arg == "--list-writers") {
760 listWriters = true; 768 listWriters = true;
761 continue; 769 continue;
762 } else if (arg == "--list-formats") { 770 } else if (arg == "--list-formats") {
763 listFormats = true; 771 listFormats = true;
800 } else { 808 } else {
801 otherArgs.push_back(args[i]); 809 otherArgs.push_back(args[i]);
802 } 810 }
803 } 811 }
804 812
813 if (quiet) {
814 SVDebug::silence();
815 SVCerr::silence();
816 }
817
805 if (list) { 818 if (list) {
806 if (!requestedWriterTags.empty() || skeletonFor != "") { 819 if (!requestedWriterTags.empty() || skeletonFor != "") {
807 cerr << helpStr << endl; 820 cerr << helpStr << endl;
808 exit(2); 821 exit(2);
809 } 822 }
908 } 921 }
909 } 922 }
910 923
911 QSettings settings; 924 QSettings settings;
912 925
913 #ifdef HAVE_FFTW3
914 settings.beginGroup("FFTWisdom");
915 QString wisdom = settings.value("wisdom").toString();
916 if (wisdom != "") {
917 fftw_import_wisdom_from_string(wisdom.toLocal8Bit().data());
918 }
919 settings.endGroup();
920 #endif
921
922 settings.beginGroup("RDF"); 926 settings.beginGroup("RDF");
923 if (!settings.contains("rdf-indices")) { 927 if (!settings.contains("rdf-indices")) {
924 QStringList list; 928 QStringList list;
925 list << "http://www.vamp-plugins.org/rdf/plugins/index.txt"; 929 list << "http://www.vamp-plugins.org/rdf/plugins/index.txt";
926 settings.setValue("rdf-indices", list); 930 settings.setValue("rdf-indices", list);
927 } 931 }
928 settings.endGroup(); 932 settings.endGroup();
929 933
930 FeatureExtractionManager manager; 934 FeatureExtractionManager manager(!quiet);
931 935
932 manager.setNormalise(normalise); 936 manager.setNormalise(normalise);
933 937
934 if (!requestedSummaryTypes.empty()) { 938 if (!requestedSummaryTypes.empty()) {
935 if (!manager.setSummaryTypes(requestedSummaryTypes, 939 if (!manager.setSummaryTypes(requestedSummaryTypes,
1146 } 1150 }
1147 } else { 1151 } else {
1148 int n = 0; 1152 int n = 0;
1149 for (QStringList::const_iterator i = goodSources.begin(); 1153 for (QStringList::const_iterator i = goodSources.begin();
1150 i != goodSources.end(); ++i) { 1154 i != goodSources.end(); ++i) {
1151 std::cerr << "Extracting features for: \"" << i->toStdString() 1155 SVCERR << "Extracting features for: \"" << *i << "\"" << endl;
1152 << "\"" << std::endl;
1153 ++n; 1156 ++n;
1154 try { 1157 try {
1155 for (int j = 0; j < (int)writers.size(); ++j) { 1158 for (int j = 0; j < (int)writers.size(); ++j) {
1156 writers[j]->setNofM(n, goodSources.size()); 1159 writers[j]->setNofM(n, goodSources.size());
1157 } 1160 }
1158 manager.extractFeatures(*i); 1161 manager.extractFeatures(*i);
1159 } catch (const std::exception &e) { 1162 } catch (const std::exception &e) {
1160 cerr << "ERROR: Feature extraction failed for \"" 1163 SVCERR << "ERROR: Feature extraction failed for \""
1161 << i->toStdString() << "\": " << e.what() << endl; 1164 << i->toStdString() << "\": " << e.what() << endl;
1162 if (force) { 1165 if (force) {
1163 // print a note only if we have more files to process 1166 // print a note only if we have more files to process
1164 QStringList::const_iterator j = i; 1167 QStringList::const_iterator j = i;
1165 if (++j != sources.end()) { 1168 if (++j != sources.end()) {
1166 cerr << "NOTE: \"--force\" option was provided, continuing (more errors may occur)" << endl; 1169 SVCERR << "NOTE: \"--force\" option was provided, continuing (more errors may occur)" << endl;
1167 } 1170 }
1168 } else { 1171 } else {
1169 cerr << "NOTE: If you want to continue with processing any further files after an" << endl 1172 SVCERR << "NOTE: If you want to continue with processing any further files after an" << endl
1170 << "error like this, use the --force option" << endl; 1173 << "error like this, use the --force option" << endl;
1171 good = false; 1174 good = false;
1172 break; 1175 break;
1173 } 1176 }
1174 } 1177 }
1175 } 1178 }
1176 } 1179 }
1177 } 1180 }
1178 1181
1179 for (int i = 0; i < (int)writers.size(); ++i) delete writers[i]; 1182 for (int i = 0; i < (int)writers.size(); ++i) delete writers[i];
1180
1181 #ifdef HAVE_FFTW3
1182 settings.beginGroup("FFTWisdom");
1183 char *cwisdom = fftw_export_wisdom_to_string();
1184 if (cwisdom) {
1185 settings.setValue("wisdom", cwisdom);
1186 fftw_free(cwisdom);
1187 }
1188 settings.endGroup();
1189 #endif
1190 1183
1191 TempDirectory::getInstance()->cleanup(); 1184 TempDirectory::getInstance()->cleanup();
1192 1185
1193 if (good) return 0; 1186 if (good) return 0;
1194 else return 1; 1187 else return 1;