changeset 144:b3d73c08b6ce

Add descriptions for writers; add housekeeping options to Sonic Annotator to list writers and formats
author Chris Cannam
date Mon, 13 Oct 2014 14:44:51 +0100
parents ad425b9096bd
children 3921e0c1f4dd 45480b73f4af 04945e74d314
files .hgsubstate runner/AudioDBFeatureWriter.cpp runner/AudioDBFeatureWriter.h runner/DefaultFeatureWriter.cpp runner/DefaultFeatureWriter.h runner/MIDIFeatureWriter.cpp runner/MIDIFeatureWriter.h runner/main.cpp tests/test-as-advertised/test-as-advertised.sh
diffstat 9 files changed, 82 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/.hgsubstate	Mon Oct 13 13:53:09 2014 +0100
+++ b/.hgsubstate	Mon Oct 13 14:44:51 2014 +0100
@@ -1,3 +1,3 @@
 d16f0fd6db6104d87882bc43788a3bb1b0f8c528 dataquay
 879bdc878826bebec67130326f99397c430419b1 sv-dependency-builds
-2104ea2204d2b8e5f19401526d8009ac8eba63ea svcore
+e25dc8d575656f0409233b29a3f621eb225bbd52 svcore
--- a/runner/AudioDBFeatureWriter.cpp	Mon Oct 13 13:53:09 2014 +0100
+++ b/runner/AudioDBFeatureWriter.cpp	Mon Oct 13 14:44:51 2014 +0100
@@ -54,6 +54,12 @@
     // TODO: error handling on close
 }
 
+string
+AudioDBFeatureWriter::getDescription() const
+{
+    return "Write features in a binary format intended for import into AudioDB.";
+}
+
 AudioDBFeatureWriter::ParameterList
 AudioDBFeatureWriter::getSupportedParameters() const
 {
--- a/runner/AudioDBFeatureWriter.h	Mon Oct 13 13:53:09 2014 +0100
+++ b/runner/AudioDBFeatureWriter.h	Mon Oct 13 14:44:51 2014 +0100
@@ -30,6 +30,8 @@
     AudioDBFeatureWriter();
     virtual ~AudioDBFeatureWriter();
 
+    virtual string getDescription() const;
+    
     virtual ParameterList getSupportedParameters() const;
     virtual void setParameters(map<string, string> &params);
 
--- a/runner/DefaultFeatureWriter.cpp	Mon Oct 13 13:53:09 2014 +0100
+++ b/runner/DefaultFeatureWriter.cpp	Mon Oct 13 14:44:51 2014 +0100
@@ -20,6 +20,12 @@
 
 #include "DefaultFeatureWriter.h"
 
+string
+DefaultFeatureWriter::getDescription() const
+{
+    return "Write features in a generic XML format, with <feature> or <summary> elements containing output name and some or all of timestamp, duration, values, and label.";
+}
+
 void DefaultFeatureWriter::write(QString,
                                  const Transform &,
                                  const Vamp::Plugin::OutputDescriptor& output,
--- a/runner/DefaultFeatureWriter.h	Mon Oct 13 13:53:09 2014 +0100
+++ b/runner/DefaultFeatureWriter.h	Mon Oct 13 14:44:51 2014 +0100
@@ -23,6 +23,7 @@
 {
 public:
     virtual ~DefaultFeatureWriter() { }
+    virtual string getDescription() const;
     virtual void write(QString trackid,
                        const Transform &transform,
                        const Vamp::Plugin::OutputDescriptor &output,
--- a/runner/MIDIFeatureWriter.cpp	Mon Oct 13 13:53:09 2014 +0100
+++ b/runner/MIDIFeatureWriter.cpp	Mon Oct 13 14:44:51 2014 +0100
@@ -34,6 +34,12 @@
 {
 }
 
+string
+MIDIFeatureWriter::getDescription() const
+{
+    return "Write features to MIDI files. All features are written as MIDI notes. If a feature has at least one value, its first value will be used as the note pitch, the second value (if present) for velocity. If a feature has units of Hz, then its pitch will be converted from frequency to an integer value in MIDI range, otherwise it will be written directly. Multiple (up to 16) transforms can be written to a single MIDI file, where they will be given separate MIDI channel numbers.";
+}
+
 MIDIFeatureWriter::ParameterList
 MIDIFeatureWriter::getSupportedParameters() const
 {
--- a/runner/MIDIFeatureWriter.h	Mon Oct 13 13:53:09 2014 +0100
+++ b/runner/MIDIFeatureWriter.h	Mon Oct 13 14:44:51 2014 +0100
@@ -28,6 +28,8 @@
     MIDIFeatureWriter();
     virtual ~MIDIFeatureWriter();
 
+    string getDescription() const;
+
     virtual ParameterList getSupportedParameters() const;
     virtual void setParameters(map<string, string> &params);
 
--- a/runner/main.cpp	Mon Oct 13 13:53:09 2014 +0100
+++ b/runner/main.cpp	Mon Oct 13 14:44:51 2014 +0100
@@ -311,7 +311,9 @@
         cerr << endl;
         cerr << "Housekeeping options:" << endl;
         cerr << endl;
-        cerr << "  -l, --list          List all known transform ids to standard output." << endl;
+        cerr << "  -l, --list          List available transform ids to standard output." << endl;
+        cerr << "      --list-writers  List supported writer types to standard output." << endl;
+        cerr << "      --list-formats  List supported input audio formats to standard output." << endl;
         cerr << endl;
         cerr << "  -s, --skeleton <I>  Generate a skeleton transform file for transform id <I>" << endl;
         cerr << "                      and write it to standard output." << endl;
@@ -338,12 +340,14 @@
                  << writer << "\")" << endl;
             return;
         }
+        cerr << "Feature writer \"" << writer << "\":" << endl << endl;
+        cerr << "  " << wrap(w->getDescription().c_str(), 76, 2) << endl << endl;
         cerr << "Additional options for writer type \"" << writer << "\":" << endl;
         cerr << endl;
         FeatureWriter::ParameterList params = w->getSupportedParameters();
         delete w;
         if (params.empty()) {
-            cerr << "(No special options available for this writer)" << endl;
+            cerr << "  No additional options are available for this writer." << endl << endl;
             return;
         }
         for (FeatureWriter::ParameterList::const_iterator j = params.begin();
@@ -468,6 +472,8 @@
     bool recursive = false;
     bool normalise = false;
     bool list = false;
+    bool listWriters = false;
+    bool listFormats = false;
     bool summaryOnly = false;
     QString skeletonFor = "";
     QString minVersion = "";
@@ -606,6 +612,12 @@
         } else if (arg == "-f" || arg == "--force") {
             force = true;
             continue;
+        } else if (arg == "--list-writers") {
+            listWriters = true;
+            continue;
+        } else if (arg == "--list-formats") {
+            listFormats = true;
+            continue;
         } else if (arg == "-l" || arg == "--list") {
             list = true;
             continue;
@@ -642,6 +654,47 @@
         listTransforms();
         exit(0);
     }
+    if (listWriters) {
+        if (!requestedWriterTags.empty() || skeletonFor != "") {
+            cerr << helpStr << endl;
+            exit(2);
+        }
+        set<string> writers = FeatureWriterFactory::getWriterTags();
+        bool first = true;
+        for (set<string>::const_iterator i = writers.begin();
+             i != writers.end(); ++i) {
+            if (!first) cout << " ";
+            cout << *i;
+            first = false;
+        }
+        cout << endl;
+        exit(0);
+    }
+    if (listFormats) {
+        if (!requestedWriterTags.empty() || skeletonFor != "") {
+            cerr << helpStr << endl;
+            exit(2);
+        }
+        QString extensions = AudioFileReaderFactory::getKnownExtensions();
+        QStringList extlist = extensions.split(" ", QString::SkipEmptyParts);
+        bool first = true;
+        foreach (QString s, extlist) {
+            if (!first) cout << " ";
+            s.replace("*.", "");
+            cout << s;
+            first = false;
+        }
+        cout << endl;
+        exit(0);
+    }
+    if (list) {
+        if (!requestedWriterTags.empty() || skeletonFor != "") {
+            cerr << helpStr << endl;
+            exit(2);
+        }
+        listTransforms();
+        exit(0);
+    }
     if (skeletonFor != "") {
         if (!requestedWriterTags.empty()) {
             cerr << helpStr << endl;
--- a/tests/test-as-advertised/test-as-advertised.sh	Mon Oct 13 13:53:09 2014 +0100
+++ b/tests/test-as-advertised/test-as-advertised.sh	Mon Oct 13 14:44:51 2014 +0100
@@ -8,19 +8,14 @@
 
 trap "rm -rf $tmpdir" 0
 
-types=`\
-    $r --help 2>&1 | \
-    grep 'Supported writer types are:' | \
-    sed -e 's/^.*://' -e 's/[,\.]//g' \
-    `
+types=`$r --list-writers`
 [ -n "$types" ] || \
-    fail "Fails to report sensible list of writers in help text?"
+    fail "Fails to report list of writers"
 
 onsets=$mypath/transforms/percussiononsets-onsets.n3
 df=$mypath/transforms/percussiononsets-detectionfunction.n3
 
 adbdir=$tmpdir/audiodb-test
-mkdir -p $adbdir
 
 for type in $types; do
 
@@ -39,6 +34,7 @@
 
     case $type in
 	audiodb) 
+	    mkdir -p $adbdir
 	    $r -t $df -w $type $tmpwav --audiodb-basedir $tmpdir --audiodb-catid `basename $adbdir` 2>/dev/null || \
 		fail "Fails to run with reader type \"$type\" and default options"
 	    ;;