changeset 62:3e7e3c610fae

Test code
author Chris Cannam
date Mon, 28 Apr 2014 13:01:30 +0100
parents 3af587be9b8a
children 0607b9fce963
files src/EM.cpp src/Silvet.cpp testdata/TRIOS-silvet/calculate.sh
diffstat 3 files changed, 29 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/EM.cpp	Mon Apr 28 12:45:06 2014 +0100
+++ b/src/EM.cpp	Mon Apr 28 13:01:30 2014 +0100
@@ -132,7 +132,7 @@
 void
 EM::expectation(const V &column)
 {
-    cerr << ".";
+//    cerr << ".";
 
     for (int i = 0; i < m_binCount; ++i) {
         m_estimate[i] = epsilon;
--- a/src/Silvet.cpp	Mon Apr 28 12:45:06 2014 +0100
+++ b/src/Silvet.cpp	Mon Apr 28 13:01:30 2014 +0100
@@ -576,7 +576,7 @@
         ++start;
 
         int duration = width - start;
-        cerr << "duration " << duration << " for just-ended note " << note << endl;
+//        cerr << "duration " << duration << " for just-ended note " << note << endl;
         if (duration < durationThreshold) {
             // spurious
             continue;
@@ -585,6 +585,8 @@
         int velocity = maxStrength * 2;
         if (velocity > 127) velocity = 127;
 
+        cerr << "Found a genuine note, starting at " << columnDuration * start << " with duration " << columnDuration * duration << endl;
+
         Feature nf;
         nf.hasTimestamp = true;
         nf.timestamp = RealTime::fromSeconds(columnDuration * start);
@@ -598,7 +600,7 @@
 
     m_pianoRoll.push_back(active);
 
-    cerr << "returning " << noteFeatures.size() << " complete notes" << endl;
+//    cerr << "returning " << noteFeatures.size() << " complete note(s) " << endl;
 
     return noteFeatures;
 }
--- a/testdata/TRIOS-silvet/calculate.sh	Mon Apr 28 12:45:06 2014 +0100
+++ b/testdata/TRIOS-silvet/calculate.sh	Mon Apr 28 13:01:30 2014 +0100
@@ -20,9 +20,28 @@
     exit 1
 fi
 
-VAMP_PATH=../.. sonic-annotator \
-    -w csv \
-    --csv-basedir "$outbase" \
-    -d vamp:silvet:silvet:notes \
-    -r "$trios_path"
+for d in brahms lussier mozart schubert take_five; do
+    dir="$trios_path/$d"
+    outdir="$outbase/$d"
+    if [ ! -d "$dir" ]; then
+        echo "TRIOS subdir $dir not found, skipping it"
+    else 
+        mkdir -p "$outdir"
+	VAMP_PATH=../.. sonic-annotator \
+	    --writer csv \
+	    --csv-basedir "$outdir" \
+	    --csv-force \
+	    --default vamp:silvet:silvet:notes \
+	    --recursive \
+	    "$dir"
+    fi
+    echo "Converting to lab files..."
+    for csv in "$outdir"/*.csv; do
+	cbase=`basename "$csv" .csv`
+	cat "$csv" | while IFS=, read start duration frequency level label; do
+	    end=`echo "$start $duration + p" | dc`
+	    echo -e "$start\t$end\t$frequency"
+	done > "$outdir/$cbase.lab"
+    done
+done