comparison runner/main.cpp @ 106:de76b2df518f multiplex

Start on multiplex implementation
author Chris Cannam
date Wed, 01 Oct 2014 18:38:32 +0100
parents fae326c22df5
children 0c2d8c945bbf
comparison
equal deleted inserted replaced
105:76d9d86ae6cd 106:de76b2df518f
231 cerr << endl; 231 cerr << endl;
232 cerr << " --segments <A>,<B>[,...]" << endl; 232 cerr << " --segments <A>,<B>[,...]" << endl;
233 cerr << " Summarise in segments, with segment boundaries" << endl; 233 cerr << " Summarise in segments, with segment boundaries" << endl;
234 cerr << " at A, B, ... seconds." << endl; 234 cerr << " at A, B, ... seconds." << endl;
235 cerr << endl; 235 cerr << endl;
236
237 /*!!! This feature not implemented yet (sniff)
238 cerr << " -m, --multiplex If multiple input audio files are given, use mono" << endl; 236 cerr << " -m, --multiplex If multiple input audio files are given, use mono" << endl;
239 cerr << " mixdowns of all files as the input channels for a single" << endl; 237 cerr << " mixdowns of all files as the input channels for a single" << endl;
240 cerr << " invocation of each transform, instead of running the" << endl; 238 cerr << " invocation of each transform, instead of running the" << endl;
241 cerr << " transform against all files separately." << endl; 239 cerr << " transform against all files separately. The first file" << endl;
242 cerr << endl; 240 cerr << " will be used for output reference name and sample rate." << endl;
243 */ 241 cerr << endl;
244
245 cerr << " -r, --recursive If any of the <audio> arguments is found to be a local" << endl; 242 cerr << " -r, --recursive If any of the <audio> arguments is found to be a local" << endl;
246 cerr << " directory, search the tree starting at that directory" << endl; 243 cerr << " directory, search the tree starting at that directory" << endl;
247 cerr << " for all supported audio files and take all of those as" << endl; 244 cerr << " for all supported audio files and take all of those as" << endl;
248 cerr << " input instead." << endl; 245 cerr << " input instead." << endl;
249 cerr << endl; 246 cerr << endl;
363 set<string> requestedTransformFiles; 360 set<string> requestedTransformFiles;
364 set<string> requestedTransformListFiles; 361 set<string> requestedTransformListFiles;
365 set<string> requestedDefaultTransforms; 362 set<string> requestedDefaultTransforms;
366 set<string> requestedSummaryTypes; 363 set<string> requestedSummaryTypes;
367 bool force = false; 364 bool force = false;
368 //!!! bool multiplex = false; 365 bool multiplex = false;
369 bool recursive = false; 366 bool recursive = false;
370 bool list = false; 367 bool list = false;
371 bool summaryOnly = false; 368 bool summaryOnly = false;
372 QString skeletonFor = ""; 369 QString skeletonFor = "";
373 QString myname = args[0]; 370 QString myname = args[0];
486 cerr << helpStr.toStdString() << endl; 483 cerr << helpStr.toStdString() << endl;
487 exit(2); 484 exit(2);
488 } 485 }
489 } 486 }
490 } 487 }
491 /*!!!
492 } else if (arg == "-m" || arg == "--multiplex") { 488 } else if (arg == "-m" || arg == "--multiplex") {
493 multiplex = true; 489 multiplex = true;
494 cerr << myname.toStdString()
495 << ": WARNING: Multiplex argument not yet implemented" << endl; //!!!
496 continue; 490 continue;
497 */
498 } else if (arg == "-r" || arg == "--recursive") { 491 } else if (arg == "-r" || arg == "--recursive") {
499 recursive = true; 492 recursive = true;
500 continue; 493 continue;
501 } else if (arg == "-f" || arg == "--force") { 494 } else if (arg == "-f" || arg == "--force") {
502 force = true; 495 force = true;
700 QSet<QString> badSources; 693 QSet<QString> badSources;
701 694
702 for (QStringList::const_iterator i = sources.begin(); 695 for (QStringList::const_iterator i = sources.begin();
703 i != sources.end(); ++i) { 696 i != sources.end(); ++i) {
704 try { 697 try {
705 manager.addSource(*i); 698 manager.addSource(*i, multiplex);
706 } catch (const std::exception &e) { 699 } catch (const std::exception &e) {
707 badSources.insert(*i); 700 badSources.insert(*i);
708 cerr << "ERROR: Failed to process file \"" << i->toStdString() 701 cerr << "ERROR: Failed to process file \"" << i->toStdString()
709 << "\": " << e.what() << endl; 702 << "\": " << e.what() << endl;
710 if (force) { 703 if (force) {
745 good = false; 738 good = false;
746 } 739 }
747 } 740 }
748 741
749 if (good) { 742 if (good) {
750 for (QStringList::const_iterator i = sources.begin(); 743 QStringList goodSources;
751 i != sources.end(); ++i) { 744 foreach (QString source, sources) {
752 if (badSources.contains(*i)) continue; 745 if (!badSources.contains(source)) {
753 std::cerr << "Extracting features for: \"" << i->toStdString() << "\"" << std::endl; 746 goodSources.push_back(source);
747 }
748 }
749 if (multiplex) {
754 try { 750 try {
755 manager.extractFeatures(*i, force); 751 manager.extractFeaturesMultiplexed(goodSources);
756 } catch (const std::exception &e) { 752 } catch (const std::exception &e) {
757 cerr << "ERROR: Feature extraction failed for \"" << i->toStdString() 753 cerr << "ERROR: Feature extraction failed: "
758 << "\": " << e.what() << endl; 754 << e.what() << endl;
759 if (force) { 755 }
760 // print a note only if we have more files to process 756 } else {
761 QStringList::const_iterator j = i; 757 for (QStringList::const_iterator i = goodSources.begin();
762 if (++j != sources.end()) { 758 i != goodSources.end(); ++i) {
763 cerr << "NOTE: \"--force\" option was provided, continuing (more errors may occur)" << endl; 759 std::cerr << "Extracting features for: \"" << i->toStdString()
760 << "\"" << std::endl;
761 try {
762 manager.extractFeatures(*i, force);
763 } catch (const std::exception &e) {
764 cerr << "ERROR: Feature extraction failed for \""
765 << i->toStdString() << "\": " << e.what() << endl;
766 if (force) {
767 // print a note only if we have more files to process
768 QStringList::const_iterator j = i;
769 if (++j != sources.end()) {
770 cerr << "NOTE: \"--force\" option was provided, continuing (more errors may occur)" << endl;
771 }
772 } else {
773 cerr << "NOTE: If you want to continue with processing any further files after an" << endl
774 << "error like this, use the --force option" << endl;
775 good = false;
776 break;
764 } 777 }
765 } else {
766 cerr << "NOTE: If you want to continue with processing any further files after an" << endl
767 << "error like this, use the --force option" << endl;
768 good = false;
769 break;
770 } 778 }
771 } 779 }
772 } 780 }
773 } 781 }
774 782