diff multiple_f0_estimation/silvet/frames.py @ 62:2b1e48b14423

Add framewise scripts
author Chris Cannam
date Wed, 12 Aug 2015 17:36:31 +0100
parents
children 029159daf3f1
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/multiple_f0_estimation/silvet/frames.py	Wed Aug 12 17:36:31 2015 +0100
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+
+import sys
+
+if __name__ == '__main__':
+
+    nargs = len(sys.argv)
+    if nargs != 2:
+        print("\nUsage: " + sys.argv[0] + " file.txt")
+        exit(1)
+
+    fname = sys.argv[1]
+    
+    f = open(fname, 'r')
+
+    data = [ line.split(' ') for line in f ];
+    ms = 0
+    extant = {}
+    ix = 0
+
+    while ix < len(data):
+
+        sec = ms / 1000.0
+
+        while ix < len(data) and sec >= float(data[ix][0]):
+            time, freq, vely = data[ix][:3]
+            if vely == "0":
+                del extant[freq]
+            else:
+                extant[freq] = vely
+            ix = ix + 1
+
+        print("\t".join([str(sec)] + list(extant.keys())))
+            
+        ms = ms + 10
+
+