Mercurial > hg > sonic-annotator
changeset 21:9a4e410bda7a
* Add --force option, and throw/catch exceptions for failure cases rather
than exiting directly
author | Chris Cannam |
---|---|
date | Tue, 07 Jul 2009 10:34:27 +0000 (2009-07-07) |
parents | 7d87bf308509 |
children | 4ab7c925f7ac |
files | README runner/FeatureExtractionManager.cpp runner/main.cpp version.h |
diffstat | 4 files changed, 23 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/README Mon Jun 29 13:47:12 2009 +0000 +++ b/README Tue Jul 07 10:34:27 2009 +0000 @@ -25,7 +25,7 @@ The main program is by Mark Levy, Chris Cannam, and Chris Sutton. Sonic Annotator incorporates library code from the Sonic Visualiser application by Chris Cannam. Code copyright 2005-2007 Chris Cannam, -copyright 2006-2008 Queen Mary, University of London, except where +copyright 2006-2009 Queen Mary, University of London, except where indicated in the individual source files. This work was funded by the Engineering and Physical Sciences Research
--- a/runner/FeatureExtractionManager.cpp Mon Jun 29 13:47:12 2009 +0000 +++ b/runner/FeatureExtractionManager.cpp Tue Jul 07 10:34:27 2009 +0000 @@ -22,6 +22,8 @@ #include <vamp-hostsdk/PluginWrapper.h> #include <vamp-hostsdk/PluginLoader.h> +#include "base/Exceptions.h" + #include <iostream> using namespace std; @@ -373,7 +375,7 @@ if (!source.isAvailable()) { cerr << "ERROR: File or URL \"" << audioSource.toStdString() << "\" could not be located" << endl; - exit(1); + throw FileNotFound(audioSource); } source.waitForData(); @@ -389,7 +391,7 @@ } else { cerr << "ERROR: Playlist \"" << audioSource.toStdString() << "\" could not be opened" << endl; - exit(1); + throw FileNotFound(audioSource); } } @@ -402,9 +404,7 @@ AudioFileReaderFactory::createReader(source, m_sampleRate, &retrievalProgress); if (!reader) { - cerr << "ERROR: File or URL \"" << audioSource.toStdString() - << "\" could not be opened" << endl; - exit(1); + throw FailedToOpenFile(audioSource); } size_t channels = reader->getChannelCount(); @@ -415,9 +415,10 @@ // reject file if it has too few channels, plugin will handle if it has too many if ((int)channels < m_channels) { - //!!! should not be terminating here! - cerr << "ERROR: File or URL \"" << audioSource.toStdString() << "\" has less than " << m_channels << " channels" << endl; - exit(1); + throw FileOperationFailed + (audioSource, + QString("read sufficient channels (found %1, require %2)") + .arg(channels).arg(m_channels)); } // allocate audio buffers
--- a/runner/main.cpp Mon Jun 29 13:47:12 2009 +0000 +++ b/runner/main.cpp Tue Jul 07 10:34:27 2009 +0000 @@ -143,7 +143,7 @@ cerr << "Sonic Annotator v" << RUNNER_VERSION << endl; cerr << "A utility for batch feature extraction from audio files." << endl; cerr << "Mark Levy, Chris Sutton and Chris Cannam, Queen Mary, University of London." << endl; - cerr << "Copyright 2007-2008 Queen Mary, University of London." << endl; + cerr << "Copyright 2007-2009 Queen Mary, University of London." << endl; cerr << endl; cerr << "This program is free software. You may redistribute copies of it under the" << endl; cerr << "terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>." << endl; @@ -246,6 +246,8 @@ cerr << " for all supported audio files and take all of those as" << endl; cerr << " input instead." << endl; cerr << endl; + cerr << " -f, --force Continue with subsequent files following an error." << endl; + cerr << endl; cerr << "Housekeeping options:" << endl; cerr << endl; cerr << " -l, --list List all known transform ids to standard output." << endl; @@ -360,6 +362,7 @@ set<string> requestedTransformListFiles; set<string> requestedDefaultTransforms; set<string> requestedSummaryTypes; + bool force = false; //!!! bool multiplex = false; bool recursive = false; bool list = false; @@ -488,6 +491,9 @@ } else if (arg == "-r" || arg == "--recursive") { recursive = true; continue; + } else if (arg == "-f" || arg == "--force") { + force = true; + continue; } else if (arg == "-l" || arg == "--list") { list = true; continue; @@ -719,10 +725,11 @@ std::cerr << "Extracting features for: \"" << i->toStdString() << "\"" << std::endl; try { manager.extractFeatures(*i); - } catch (FailedToOpenFile f) { - cerr << "ERROR: Failed to open output file for feature writer: " - << f.what() << endl; - break; + } catch (std::exception e) { + cerr << "ERROR: Failed to process file \"" << i->toStdString() + << "\": " << e.what() << endl; + if (force) continue; + else break; } }