# HG changeset patch # User Chris Cannam # Date 1454155730 0 # Node ID d9c766274c8b87a41a577b3688edb2f067105cf4 # Parent 8a1328ab9c489ed749ae1145a2bda7e0fd1d6b4b# Parent 9c7633904ec2e789b1921d9ada890dd77b6e68be Merge diff -r 8a1328ab9c48 -r d9c766274c8b data/fileio/CoreAudioFileReader.cpp --- a/data/fileio/CoreAudioFileReader.cpp Sat Jan 30 12:05:14 2016 +0000 +++ b/data/fileio/CoreAudioFileReader.cpp Sat Jan 30 12:08:50 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; diff -r 8a1328ab9c48 -r d9c766274c8b data/fileio/test/test.pro --- a/data/fileio/test/test.pro Sat Jan 30 12:05:14 2016 +0000 +++ b/data/fileio/test/test.pro Sat Jan 30 12:08:50 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_2_0 - 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 diff -r 8a1328ab9c48 -r d9c766274c8b plugin/FeatureExtractionPluginFactory.cpp --- a/plugin/FeatureExtractionPluginFactory.cpp Sat Jan 30 12:05:14 2016 +0000 +++ b/plugin/FeatureExtractionPluginFactory.cpp Sat Jan 30 12:08:50 2016 +0000 @@ -119,7 +119,7 @@ for (std::vector::iterator i = path.begin(); i != path.end(); ++i) { #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE - SVDEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: scanning directory " << i-<< endl; + cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: scanning directory " << *i << endl; #endif QDir pluginDir(*i, PLUGIN_GLOB, @@ -131,7 +131,7 @@ QString soname = pluginDir.filePath(pluginDir[j]); #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); @@ -142,7 +142,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) @@ -157,7 +157,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; @@ -175,7 +175,7 @@ << descriptor->identifier << "\" at indices " << known[descriptor->identifier] << " and " << index << endl; - SVDEBUG << "FeatureExtractionPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << endl; + cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << endl; ok = false; break; } else { @@ -195,7 +195,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; } @@ -218,7 +218,7 @@ QString file = ""; #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE - SVDEBUG << "FeatureExtractionPluginFactory::findPluginFile(\"" + cerr << "FeatureExtractionPluginFactory::findPluginFile(\"" << soname << "\", \"" << inDir << "\")" << endl; #endif @@ -235,7 +235,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 @@ -247,7 +247,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 @@ -256,7 +256,7 @@ } #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE - SVDEBUG << "FeatureExtractionPluginFactory::findPluginFile (with dir): " + cerr << "FeatureExtractionPluginFactory::findPluginFile (with dir): " << "not found" << endl; #endif @@ -268,7 +268,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; @@ -289,7 +289,7 @@ } #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE - SVDEBUG << "FeatureExtractionPluginFactory::findPluginFile: " + cerr << "FeatureExtractionPluginFactory::findPluginFile: " << "not found" << endl; #endif @@ -312,7 +312,7 @@ QString type, soname, label; PluginIdentifier::parseIdentifier(identifier, type, soname, label); if (type != "vamp") { - SVDEBUG << "FeatureExtractionPluginFactory::instantiatePlugin: Wrong factory for plugin type " << type << endl; + cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Wrong factory for plugin type " << type << endl; return 0; } @@ -324,7 +324,7 @@ } else if (found != soname) { #ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE - SVDEBUG << "FeatureExtractionPluginFactory::instantiatePlugin: Given library name was " << soname << ", found at " << found << endl; + cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Given library name was " << soname << ", found at " << found << endl; cerr << soname << " -> " << found << endl; #endif @@ -343,7 +343,7 @@ DLSYM(libraryHandle, "vampGetPluginDescriptor"); if (!fn) { - SVDEBUG << "FeatureExtractionPluginFactory::instantiatePlugin: No descriptor function in " << soname << endl; + cerr << "FeatureExtractionPluginFactory::instantiatePlugin: No descriptor function in " << soname << endl; goto done; } diff -r 8a1328ab9c48 -r d9c766274c8b rdf/RDFFeatureWriter.cpp --- a/rdf/RDFFeatureWriter.cpp Sat Jan 30 12:05:14 2016 +0000 +++ b/rdf/RDFFeatureWriter.cpp Sat Jan 30 12:08:50 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 "; diff -r 8a1328ab9c48 -r d9c766274c8b rdf/RDFFeatureWriter.h --- a/rdf/RDFFeatureWriter.h Sat Jan 30 12:05:14 2016 +0000 +++ b/rdf/RDFFeatureWriter.h Sat Jan 30 12:08:50 2016 +0000 @@ -70,6 +70,19 @@ typedef map 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); diff -r 8a1328ab9c48 -r d9c766274c8b transform/CSVFeatureWriter.cpp --- a/transform/CSVFeatureWriter.cpp Sat Jan 30 12:05:14 2016 +0000 +++ b/transform/CSVFeatureWriter.cpp Sat Jan 30 12:08:50 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 != "") { diff -r 8a1328ab9c48 -r d9c766274c8b transform/CSVFeatureWriter.h --- a/transform/CSVFeatureWriter.h Sat Jan 30 12:05:14 2016 +0000 +++ b/transform/CSVFeatureWriter.h Sat Jan 30 12:08:50 2016 +0000 @@ -74,6 +74,8 @@ const Vamp::Plugin::Feature &f, const Vamp::Plugin::Feature *optionalNextFeature, std::string summaryType); + + int m_digits; }; #endif diff -r 8a1328ab9c48 -r d9c766274c8b transform/FeatureWriter.h --- a/transform/FeatureWriter.h Sat Jan 30 12:05:14 2016 +0000 +++ b/transform/FeatureWriter.h Sat Jan 30 12:08:50 2016 +0000 @@ -60,6 +60,7 @@ struct TrackMetadata { QString title; QString maker; + RealTime duration; }; virtual void setTrackMetadata(QString /* trackid */, TrackMetadata) { } diff -r 8a1328ab9c48 -r d9c766274c8b transform/FileFeatureWriter.cpp --- a/transform/FileFeatureWriter.cpp Sat Jan 30 12:05:14 2016 +0000 +++ b/transform/FileFeatureWriter.cpp Sat Jan 30 12:08:50 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 ""; } diff -r 8a1328ab9c48 -r d9c766274c8b transform/Transform.cpp --- a/transform/Transform.cpp Sat Jan 30 12:05:14 2016 +0000 +++ b/transform/Transform.cpp Sat Jan 30 12:08:50 2016 +0000 @@ -18,6 +18,7 @@ #include "plugin/PluginIdentifier.h" #include "plugin/FeatureExtractionPluginFactory.h" +#include "plugin/RealTimePluginFactory.h" #include @@ -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; } } diff -r 8a1328ab9c48 -r d9c766274c8b transform/Transform.h --- a/transform/Transform.h Sat Jan 30 12:05:14 2016 +0000 +++ b/transform/Transform.h Sat Jan 30 12:08:50 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; diff -r 8a1328ab9c48 -r d9c766274c8b transform/TransformFactory.cpp --- a/transform/TransformFactory.cpp Sat Jan 30 12:05:14 2016 +0000 +++ b/transform/TransformFactory.cpp Sat Jan 30 12:08:50 2016 +0000 @@ -794,6 +794,9 @@ if (t.getType() == Transform::FeatureExtraction) { +// cerr << "TransformFactory::instantiateDefaultPluginFor: identifier \"" +// << identifier << "\" is a feature extraction transform" << endl; + FeatureExtractionPluginFactory *factory = FeatureExtractionPluginFactory::instanceFor(pluginId); @@ -801,7 +804,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); @@ -809,6 +815,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;