changeset 1160:ea636412f9fe 3.0-integration

Merge from the default branch
author Chris Cannam
date Thu, 04 Feb 2016 11:16:05 +0000
parents 444d133b5ab7 (current diff) 9c7633904ec2 (diff)
children 6877f4200912
files data/fileio/test/test.pro plugin/FeatureExtractionPluginFactory.cpp transform/TransformFactory.cpp
diffstat 12 files changed, 72 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/data/fileio/CoreAudioFileReader.cpp	Thu Feb 04 11:13:39 2016 +0000
+++ b/data/fileio/CoreAudioFileReader.cpp	Thu Feb 04 11:16:05 2016 +0000
@@ -57,7 +57,7 @@
 }
 
 CoreAudioFileReader::CoreAudioFileReader(FileSource source,
-                                         DecodeMode decodeMode,
+                                         DecodeMode /* decodeMode */,
                                          CacheMode mode,
                                          sv_samplerate_t targetRate,
                                          bool normalised,
@@ -180,7 +180,7 @@
         // buffers are interleaved unless specified otherwise
         addSamplesToDecodeCache((float *)m_d->buffer.mBuffers[0].mData, framesRead);
 
-        if (framesRead < m_d->blockSize) break;
+        if ((int)framesRead < m_d->blockSize) break;
     }
 
     finishDecodeCache();
@@ -196,7 +196,7 @@
 
     if (m_d->valid) {
         ExtAudioFileDispose(m_d->file);
-        delete[] m_d->buffer.mBuffers[0].mData;
+        delete[] (float *)(m_d->buffer.mBuffers[0].mData);
     }
 
     delete m_d;
--- a/data/fileio/test/test.pro	Thu Feb 04 11:13:39 2016 +0000
+++ b/data/fileio/test/test.pro	Thu Feb 04 11:16:05 2016 +0000
@@ -27,7 +27,7 @@
 
     DEFINES += HAVE_BZ2 HAVE_FFTW3 HAVE_FFTW3F HAVE_SNDFILE HAVE_SAMPLERATE HAVE_VAMP HAVE_VAMPHOSTSDK HAVE_DATAQUAY HAVE_LIBLO HAVE_MAD HAVE_ID3TAG HAVE_PORTAUDIO
 
-    LIBS += -lbz2 -lvamp-hostsdk -lfftw3 -lfftw3f -lsndfile -lFLAC -logg -lvorbis -lvorbisenc -lvorbisfile -logg -lmad -lid3tag -lportaudio -lsamplerate -lz -lsord-0 -lserd-0
+    LIBS += -lbz2 -lfftw3 -lfftw3f -lsndfile -lFLAC -logg -lvorbis -lvorbisenc -lvorbisfile -logg -lmad -lid3tag -lportaudio -lsamplerate -lz -lsord-0 -lserd-0
 
     win* {
         LIBS += -llo -lwinmm -lws2_32
--- a/plugin/FeatureExtractionPluginFactory.cpp	Thu Feb 04 11:13:39 2016 +0000
+++ b/plugin/FeatureExtractionPluginFactory.cpp	Thu Feb 04 11:16:05 2016 +0000
@@ -119,7 +119,7 @@
     for (QString dirname : path) {
 
 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
-        SVDEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: scanning directory " << dirname << endl;
+        cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: scanning directory " << dirname << endl;
 #endif
 
 	QDir pluginDir(dirname, PLUGIN_GLOB,
@@ -196,7 +196,7 @@
     for (QString soname : candidates) {
 
 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
-        SVDEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: trying potential library " << soname << endl;
+            cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: trying potential library " << soname << endl;
 #endif
 
         void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL);
@@ -207,7 +207,7 @@
         }
 
 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
-        SVDEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: It's a library all right, checking for descriptor" << endl;
+            cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: It's a library all right, checking for descriptor" << endl;
 #endif
 
         VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction)
@@ -222,7 +222,7 @@
         }
 
 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
-        SVDEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: Vamp descriptor found" << endl;
+            cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Vamp descriptor found" << endl;
 #endif
 
         const VampPluginDescriptor *descriptor = 0;
@@ -240,7 +240,7 @@
                      << descriptor->identifier << "\" at indices "
                      << known[descriptor->identifier] << " and "
                      << index << endl;
-                cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << endl;
+                    cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << endl;
                 ok = false;
                 break;
             } else {
@@ -260,7 +260,7 @@
                     ("vamp", soname, descriptor->identifier);
                 rv.push_back(id);
 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
-                SVDEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: Found plugin id " << id << " at index " << index << endl;
+                    cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Found plugin id " << id << " at index " << index << endl;
 #endif
                 ++index;
             }
@@ -282,7 +282,7 @@
     QString file = "";
 
 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
-    SVDEBUG << "FeatureExtractionPluginFactory::findPluginFile(\""
+    cerr << "FeatureExtractionPluginFactory::findPluginFile(\""
               << soname << "\", \"" << inDir << "\")"
               << endl;
 #endif
@@ -299,7 +299,7 @@
         if (QFileInfo(file).exists() && QFileInfo(file).isFile()) {
 
 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
-            SVDEBUG << "FeatureExtractionPluginFactory::findPluginFile: "
+            cerr << "FeatureExtractionPluginFactory::findPluginFile: "
                       << "found trivially at " << file << endl;
 #endif
 
@@ -311,7 +311,7 @@
             if (QFileInfo(file).baseName() == QFileInfo(soname).baseName()) {
 
 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
-                SVDEBUG << "FeatureExtractionPluginFactory::findPluginFile: "
+                cerr << "FeatureExtractionPluginFactory::findPluginFile: "
                           << "found \"" << soname << "\" at " << file << endl;
 #endif
 
@@ -320,7 +320,7 @@
         }
 
 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
-        SVDEBUG << "FeatureExtractionPluginFactory::findPluginFile (with dir): "
+        cerr << "FeatureExtractionPluginFactory::findPluginFile (with dir): "
                   << "not found" << endl;
 #endif
 
@@ -332,7 +332,7 @@
 
         if (fi.isAbsolute() && fi.exists() && fi.isFile()) {
 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
-            SVDEBUG << "FeatureExtractionPluginFactory::findPluginFile: "
+            cerr << "FeatureExtractionPluginFactory::findPluginFile: "
                       << "found trivially at " << soname << endl;
 #endif
             return soname;
@@ -353,7 +353,7 @@
         }
 
 #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
-        SVDEBUG << "FeatureExtractionPluginFactory::findPluginFile: "
+        cerr << "FeatureExtractionPluginFactory::findPluginFile: "
                   << "not found" << endl;
 #endif
 
--- a/rdf/RDFFeatureWriter.cpp	Thu Feb 04 11:13:39 2016 +0000
+++ b/rdf/RDFFeatureWriter.cpp	Thu Feb 04 11:16:05 2016 +0000
@@ -352,7 +352,7 @@
 
     bool wantTrack = (userSpecifiedTrack ||
                       (m_userMakerUri != "") ||
-                      (m_metadata.find(trackId) != m_metadata.end()));
+                      haveTitleArtistMetadata(trackId));
 
 //    cerr << "wantTrack = " << wantTrack << " (userSpecifiedTrack = "
 //         << userSpecifiedTrack << ", m_userMakerUri = " << m_userMakerUri << ", have metadata = " << (m_metadata.find(trackId) != m_metadata.end()) << ")" << endl;
@@ -367,7 +367,7 @@
         // including a Track would be to assert that this was one,
         // which is the one thing we wouldn't know...
         TrackMetadata tm;
-        if (m_metadata.find(trackId) != m_metadata.end()) {
+        if (haveTitleArtistMetadata(trackId)) {
             tm = m_metadata[trackId];
         }
         stream << trackURI << " a mo:Track ";
--- a/rdf/RDFFeatureWriter.h	Thu Feb 04 11:13:39 2016 +0000
+++ b/rdf/RDFFeatureWriter.h	Thu Feb 04 11:16:05 2016 +0000
@@ -70,6 +70,19 @@
     typedef map<QString, TrackMetadata> TrackMetadataMap;
     TrackMetadataMap m_metadata;
 
+    bool haveTitleArtistMetadata(QString trackId) const {
+        // Formerly in various places we used to test whether a track
+        // appeared in the metadata map at all, in order to determine
+        // whether it had any associated metadata. That won't work any
+        // more because metadata now includes duration, which can
+        // appear even if no title/artist are given and which is not
+        // something whose presence indicates the involvement of a
+        // "publication Track". So check for artist/title explicitly.
+        auto mitr = m_metadata.find(trackId);
+        if (mitr == m_metadata.end()) return false;
+        return (mitr->second.title != "" || mitr->second.maker != "");
+    }
+
     QString m_fixedEventTypeURI;
 
     virtual void reviewFileForAppending(QString filename);
--- a/transform/CSVFeatureWriter.cpp	Thu Feb 04 11:13:39 2016 +0000
+++ b/transform/CSVFeatureWriter.cpp	Thu Feb 04 11:16:05 2016 +0000
@@ -37,7 +37,8 @@
     m_sampleTiming(false),
     m_endTimes(false),
     m_forceEnd(false),
-    m_omitFilename(false)
+    m_omitFilename(false),
+    m_digits(6)
 {
 }
 
@@ -82,6 +83,11 @@
     p.hasArg = false;
     pl.push_back(p);
 
+    p.name = "digits";
+    p.description = "Specify the number of significant digits to use when printing transform outputs. Outputs are represented internally using single-precision floating-point, so digits beyond the 8th or 9th place are usually meaningless. The default is 6.";
+    p.hasArg = true;
+    pl.push_back(p);
+
     return pl;
 }
 
@@ -108,6 +114,14 @@
             m_forceEnd = true;
         } else if (i->first == "omit-filename") {
             m_omitFilename = true;
+        } else if (i->first == "digits") {
+            int digits = atoi(i->second.c_str());
+            if (digits <= 0 || digits > 100) {
+                cerr << "CSVFeatureWriter: ERROR: Invalid or out-of-range value for number of significant digits: " << i->second << endl;
+                cerr << "CSVFeatureWriter: NOTE: Continuing with default settings" << endl;
+            } else {
+                m_digits = digits;
+            }
         }
     }
 }
@@ -262,7 +276,7 @@
     }
     
     for (unsigned int j = 0; j < f.values.size(); ++j) {
-        stream << m_separator << f.values[j];
+        stream << m_separator << QString("%1").arg(f.values[j], 0, 'g', m_digits);
     }
     
     if (f.label != "") {
--- a/transform/CSVFeatureWriter.h	Thu Feb 04 11:13:39 2016 +0000
+++ b/transform/CSVFeatureWriter.h	Thu Feb 04 11:16:05 2016 +0000
@@ -74,6 +74,8 @@
                       const Vamp::Plugin::Feature &f,
                       const Vamp::Plugin::Feature *optionalNextFeature,
                       std::string summaryType);
+
+    int m_digits;
 };
 
 #endif
--- a/transform/FeatureWriter.h	Thu Feb 04 11:13:39 2016 +0000
+++ b/transform/FeatureWriter.h	Thu Feb 04 11:16:05 2016 +0000
@@ -60,6 +60,7 @@
     struct TrackMetadata {
         QString title;
         QString maker;
+        RealTime duration;
     };
     virtual void setTrackMetadata(QString /* trackid */, TrackMetadata) { }
 
--- a/transform/FileFeatureWriter.cpp	Thu Feb 04 11:13:39 2016 +0000
+++ b/transform/FileFeatureWriter.cpp	Thu Feb 04 11:16:05 2016 +0000
@@ -46,7 +46,7 @@
         } else if (m_support & SupportOneFileTotal) {
             m_singleFileName = QString("output.%1").arg(m_extension);
         } else {
-            SVDEBUG << "FileFeatureWriter::FileFeatureWriter: ERROR: Invalid support specification " << support << endl;
+            cerr << "FileFeatureWriter::FileFeatureWriter: ERROR: Invalid support specification " << support << endl;
         }
     }
 }
@@ -130,7 +130,7 @@
             if (m_support & SupportOneFilePerTrackTransform &&
                 m_support & SupportOneFilePerTrack) {
                 if (m_singleFileName != "") {
-                    SVDEBUG << "FileFeatureWriter::setParameters: WARNING: Both one-file and many-files parameters provided, ignoring many-files" << endl;
+                    cerr << "FileFeatureWriter::setParameters: WARNING: Both one-file and many-files parameters provided, ignoring many-files" << endl;
                 } else {
                     m_manyFiles = true;
                 }
@@ -144,7 +144,7 @@
                     // OneFilePerTrack), so we need to be able to
                     // override it
 //                    if (m_manyFiles) {
-//                        SVDEBUG << "FileFeatureWriter::setParameters: WARNING: Both many-files and one-file parameters provided, ignoring one-file" << endl;
+//                        cerr << "FileFeatureWriter::setParameters: WARNING: Both many-files and one-file parameters provided, ignoring one-file" << endl;
 //                    } else {
                         m_singleFileName = i->second.c_str();
 //                    }
@@ -153,7 +153,7 @@
         } else if (i->first == "stdout") {
             if (m_support & SupportStdOut) {
                 if (m_singleFileName != "") {
-                    SVDEBUG << "FileFeatureWriter::setParameters: WARNING: Both stdout and one-file provided, ignoring stdout" << endl;
+                    cerr << "FileFeatureWriter::setParameters: WARNING: Both stdout and one-file provided, ignoring stdout" << endl;
                 } else {
                     m_stdout = true;
                 }
@@ -173,7 +173,7 @@
     if (m_singleFileName != "") {
         if (QFileInfo(m_singleFileName).exists() && !(m_force || m_append)) {
             cerr << endl << "FileFeatureWriter: ERROR: Specified output file \"" << m_singleFileName << "\" exists and neither --" << getWriterTag() << "-force nor --" << getWriterTag() << "-append flag is specified -- not overwriting" << endl;
-            SVDEBUG << "NOTE: To find out how to fix this problem, read the help for the --" << getWriterTag() << "-force" << endl << "and --" << getWriterTag() << "-append options" << endl;
+            cerr << "NOTE: To find out how to fix this problem, read the help for the --" << getWriterTag() << "-force" << endl << "and --" << getWriterTag() << "-append options" << endl;
             return "";
         }
         return m_singleFileName;
@@ -220,7 +220,7 @@
 
     if (QFileInfo(filename).exists() && !(m_force || m_append)) {
         cerr << endl << "FileFeatureWriter: ERROR: Output file \"" << filename << "\" exists (for input file or URL \"" << trackId << "\" and transform \"" << transformId << "\") and neither --" << getWriterTag() << "-force nor --" << getWriterTag() << "-append is specified -- not overwriting" << endl;
-        SVDEBUG << "NOTE: To find out how to fix this problem, read the help for the --" << getWriterTag() << "-force" << endl << "and --" << getWriterTag() << "-append options" << endl;
+        cerr << "NOTE: To find out how to fix this problem, read the help for the --" << getWriterTag() << "-force" << endl << "and --" << getWriterTag() << "-append options" << endl;
         return "";
     }
     
--- a/transform/Transform.cpp	Thu Feb 04 11:13:39 2016 +0000
+++ b/transform/Transform.cpp	Thu Feb 04 11:16:05 2016 +0000
@@ -18,6 +18,7 @@
 #include "plugin/PluginIdentifier.h"
 
 #include "plugin/FeatureExtractionPluginFactory.h"
+#include "plugin/RealTimePluginFactory.h"
 
 #include <QXmlAttributes>
 
@@ -207,10 +208,10 @@
 {
     if (FeatureExtractionPluginFactory::instanceFor(getPluginIdentifier())) {
         return FeatureExtraction;
+    } else if (RealTimePluginFactory::instanceFor(getPluginIdentifier())) {
+        return RealTimeEffect;
     } else {
-        // We don't have an unknown/invalid return value, so always
-        // return this
-        return RealTimeEffect;
+        return UnknownType;
     }
 }
 
--- a/transform/Transform.h	Thu Feb 04 11:13:39 2016 +0000
+++ b/transform/Transform.h	Thu Feb 04 11:16:05 2016 +0000
@@ -67,7 +67,7 @@
     void setIdentifier(TransformId id);
     TransformId getIdentifier() const;
 
-    enum Type { FeatureExtraction, RealTimeEffect };
+    enum Type { FeatureExtraction, RealTimeEffect, UnknownType };
 
     Type getType() const;
     QString getPluginIdentifier() const;
--- a/transform/TransformFactory.cpp	Thu Feb 04 11:13:39 2016 +0000
+++ b/transform/TransformFactory.cpp	Thu Feb 04 11:16:05 2016 +0000
@@ -806,6 +806,9 @@
 
     if (t.getType() == Transform::FeatureExtraction) {
 
+//        cerr << "TransformFactory::instantiateDefaultPluginFor: identifier \""
+//             << identifier << "\" is a feature extraction transform" << endl;
+        
         FeatureExtractionPluginFactory *factory = 
             FeatureExtractionPluginFactory::instanceFor(pluginId);
 
@@ -813,7 +816,10 @@
             plugin = factory->instantiatePlugin(pluginId, rate);
         }
 
-    } else {
+    } else if (t.getType() == Transform::RealTimeEffect) {
+
+//        cerr << "TransformFactory::instantiateDefaultPluginFor: identifier \""
+//             << identifier << "\" is a real-time transform" << endl;
 
         RealTimePluginFactory *factory = 
             RealTimePluginFactory::instanceFor(pluginId);
@@ -821,6 +827,10 @@
         if (factory) {
             plugin = factory->instantiatePlugin(pluginId, 0, 0, rate, 1024, 1);
         }
+
+    } else {
+        cerr << "TransformFactory: ERROR: transform id \""
+             << identifier << "\" is of unknown type" << endl;
     }
 
     return plugin;