changeset 137:78e0f163e035

Forgot to add conversion script
author Chris Cannam
date Thu, 08 May 2014 13:02:25 +0100
parents e3373d367bda
children c0802d1b1fad
files testdata/TRIOS-groundtruth/convert.yeti
diffstat 1 files changed, 34 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/testdata/TRIOS-groundtruth/convert.yeti	Thu May 08 13:02:25 2014 +0100
@@ -0,0 +1,34 @@
+
+// Convert CSV file exported by Sonic Visualiser:
+// 
+// onset,midinote,duration,level,label
+//
+// into lab file like those output from the test scripts:
+//
+// onset offset frequency
+
+program convert;
+
+usage () =
+    eprintln "\nUsage: convert file.csv\n";
+
+toFrequency m = 
+    440 * Math#pow(2.0, (m - 69) / 12.0);
+
+convert f =
+   (str = openInFile f "UTF-8";
+    for (str.lines ()) do line:
+        case list (strSplit "," line) of
+        onset::midinote::duration::_: 
+            println "\(onset)\t\((number onset) + (number duration))\t\(toFrequency (number midinote))";
+        _:
+            failWith "badly formed line: \(line)";
+        esac;
+    done;
+    str.close ());
+
+case (list _argv) of
+file::[]: convert file;
+_: usage ();
+esac;
+