# HG changeset patch # User Chris Cannam # Date 1412259805 -3600 # Node ID 0c2d8c945bbf9983ca855a92e8a1d4d249f0e8f1 # Parent ca565b18ba3e327c5224685014f6da27f3778365# Parent 74f7ad72fee6579f6916cd5262683e98e9898d4e Merge from default branch diff -r ca565b18ba3e -r 0c2d8c945bbf runner/FeatureExtractionManager.cpp --- a/runner/FeatureExtractionManager.cpp Thu Oct 02 14:54:48 2014 +0100 +++ b/runner/FeatureExtractionManager.cpp Thu Oct 02 15:23:25 2014 +0100 @@ -41,7 +41,6 @@ #include "data/fileio/FileSource.h" #include "data/fileio/AudioFileReader.h" #include "data/fileio/AudioFileReaderFactory.h" -#include "data/fileio/PlaylistFileReader.h" #include "base/TempDirectory.h" #include "base/ProgressPrinter.h" #include "transform/TransformFactory.h" @@ -435,29 +434,6 @@ void FeatureExtractionManager::addSource(QString audioSource, bool willMultiplex) { - if (QFileInfo(audioSource).suffix().toLower() == "m3u") { - ProgressPrinter retrievalProgress("Opening playlist file..."); - FileSource source(audioSource, &retrievalProgress); - if (!source.isAvailable()) { - cerr << "ERROR: File or URL \"" << audioSource.toStdString() - << "\" could not be located" << endl; - throw FileNotFound(audioSource); - } - source.waitForData(); - PlaylistFileReader reader(source); - if (reader.isOK()) { - vector files = reader.load(); - for (int i = 0; i < (int)files.size(); ++i) { - addSource(files[i], willMultiplex); - } - return; - } else { - cerr << "ERROR: Playlist \"" << audioSource.toStdString() - << "\" could not be opened" << endl; - throw FileNotFound(audioSource); - } - } - std::cerr << "Have audio source: \"" << audioSource.toStdString() << "\"" << std::endl; // We don't actually do anything with it here, unless it's the @@ -513,39 +489,10 @@ } } -void FeatureExtractionManager::extractFeatures(QString audioSource, bool force) +void FeatureExtractionManager::extractFeatures(QString audioSource) { if (m_plugins.empty()) return; - if (QFileInfo(audioSource).suffix().toLower() == "m3u") { - //!!! This shouldn't happen here, it should be done in - //!!! main.cpp when assembling the sources list - FileSource source(audioSource); - PlaylistFileReader reader(source); - if (reader.isOK()) { - vector files = reader.load(); - for (int i = 0; i < (int)files.size(); ++i) { - try { - extractFeatures(files[i], force); - } catch (const std::exception &e) { - if (!force) throw; - cerr << "ERROR: Feature extraction failed for playlist entry \"" - << files[i].toStdString() - << "\": " << e.what() << endl; - // print a note only if we have more files to process - if (++i != (int)files.size()) { - cerr << "NOTE: \"--force\" option was provided, continuing (more errors may occur)" << endl; - } - } - } - return; - } else { - cerr << "ERROR: Playlist \"" << audioSource.toStdString() - << "\" could not be opened" << endl; - throw FileNotFound(audioSource); - } - } - testOutputFiles(audioSource); if (m_sampleRate == 0) { diff -r ca565b18ba3e -r 0c2d8c945bbf runner/FeatureExtractionManager.h --- a/runner/FeatureExtractionManager.h Thu Oct 02 14:54:48 2014 +0100 +++ b/runner/FeatureExtractionManager.h Thu Oct 02 15:23:25 2014 +0100 @@ -66,7 +66,7 @@ // Extract features from the given audio or playlist file. If the // file is a playlist and force is true, continue extracting even // if a file in the playlist fails. - void extractFeatures(QString audioSource, bool force); + void extractFeatures(QString audioSource); // Extract features from the given audio files, multiplexing into // a single "file" whose individual channels are mixdowns of the diff -r ca565b18ba3e -r 0c2d8c945bbf runner/main.cpp --- a/runner/main.cpp Thu Oct 02 14:54:48 2014 +0100 +++ b/runner/main.cpp Thu Oct 02 15:23:25 2014 +0100 @@ -35,6 +35,7 @@ #include "base/Exceptions.h" #include "base/TempDirectory.h" +#include "base/ProgressPrinter.h" #include "data/fileio/AudioFileReaderFactory.h" #include "data/fileio/PlaylistFileReader.h" @@ -346,6 +347,35 @@ } } +QStringList +expandPlaylists(QStringList sources) +{ + QStringList expanded; + foreach (QString path, sources) { + cerr << "expandPlaylists: looking at " << path << endl; + if (QFileInfo(path).suffix().toLower() == "m3u") { + ProgressPrinter retrievalProgress("Opening playlist file..."); + FileSource source(path, &retrievalProgress); + if (!source.isAvailable()) { + cerr << "ERROR: File or URL \"" << path.toStdString() + << "\" could not be located" << endl; + throw FileNotFound(path); + } + source.waitForData(); + PlaylistFileReader reader(source); + if (reader.isOK()) { + vector files = reader.load(); + for (int i = 0; i < (int)files.size(); ++i) { + expanded.push_back(files[i]); + } + } + } else { + // not a playlist + expanded.push_back(path); + } + } + return expanded; +} int main(int argc, char **argv) { @@ -689,6 +719,8 @@ } } + sources = expandPlaylists(sources); + bool good = true; QSet badSources; @@ -759,7 +791,7 @@ std::cerr << "Extracting features for: \"" << i->toStdString() << "\"" << std::endl; try { - manager.extractFeatures(*i, force); + manager.extractFeatures(*i); } catch (const std::exception &e) { cerr << "ERROR: Feature extraction failed for \"" << i->toStdString() << "\": " << e.what() << endl; diff -r ca565b18ba3e -r 0c2d8c945bbf tests/test-multiple-audio.sh --- a/tests/test-multiple-audio.sh Thu Oct 02 14:54:48 2014 +0100 +++ b/tests/test-multiple-audio.sh Thu Oct 02 15:23:25 2014 +0100 @@ -12,13 +12,15 @@ transform=$mypath/transforms/transforms-summaries-percussiononsets-detectionfunction.n3 # Note, the output here depends on all the audio files present -- we -# would have to regenerate it if we added more test audio files +# would have to regenerate it if we added more test audio files. Note +# that the -r flag is not supposed to pick up playlist files, only +# audio files $r -t $transform -w csv --csv-stdout $mypath -r --summary-only > $tmpfile 2>/dev/null || \ fail "Fails to run transform $transform with recursive dir option" expected=$mypath/expected/transforms-summaries-percussiononsets-all-files csvcompare $tmpfile $expected.csv || \ - fail "Output mismatch for transform $transform with summaries and recursive dir option" + faildiff "Output mismatch for transform $transform with summaries and recursive dir option" $tmpfile $expected.csv # Here we remove any leading path from the audio file in the output, # because the playlist reader will have resolved files to absolute @@ -28,7 +30,7 @@ expected=$mypath/expected/transforms-summaries-percussiononsets-playlist csvcompare $tmpfile $expected.csv || \ - fail "Output mismatch for transform $transform with summaries and playlist input" + faildiff "Output mismatch for transform $transform with summaries and playlist input" $tmpfile $expected.csv # Same here, just so we can use the same output comparison file as above $r -t $transform -w csv --csv-stdout $mypath/audio/3clicks8.wav $mypath/audio/6clicks8.wav --summary-only 2>/dev/null | sed 's,^"\.*/[^"]*/,",' > $tmpfile || \ @@ -36,7 +38,7 @@ expected=$mypath/expected/transforms-summaries-percussiononsets-playlist csvcompare $tmpfile $expected.csv || \ - fail "Output mismatch for transform $transform with summaries and 2-file input" + faildiff "Output mismatch for transform $transform with summaries and 2-file input" $tmpfile $expected.csv