diff bin/wavecurve @ 357:7771f37252da

curvecalc persistence, wavecurve -a option
author Drew Perttula <drewp@bigasterisk.com>
date Tue, 12 Jun 2007 07:12:32 +0000
parents 8c9138ff91d5
children 5a83935377f9
line wrap: on
line diff
--- a/bin/wavecurve	Mon Jun 11 02:26:49 2007 +0000
+++ b/bin/wavecurve	Tue Jun 12 07:12:32 2007 +0000
@@ -3,15 +3,41 @@
 import run_local
 from light9.wavepoints import simp
 
-parser = optparse.OptionParser(usage="%prog inputSong.wav outputCurve")
+
+def createCurve(inpath, outpath, t):
+    print "reading %s, writing %s" % (inpath, outpath)
+    points = simp(inpath, seconds_per_average=t)
+
+    f = file(outpath, 'w')
+    for time_val in points:
+        print >>f, "%s %s" % time_val
+    
+
+
+parser = optparse.OptionParser(usage="""%prog inputSong.wav outputCurve
+
+You probably just want -a
+
+""")
 parser.add_option("-t",type="float",default=.01,
                   help="seconds per sample (default .01, .07 is smooth)")
+parser.add_option("-a", action="store_true",
+                  help="make standard curves for all songs")
 options,args = parser.parse_args()
 
-inpath,outpath = args
 
-points = simp(inpath, seconds_per_average=options.t)
-
-f = file(outpath, 'w')
-for time_val in points:
-    print >>f, "%s %s" % time_val
+if options.a:
+    from light9 import showconfig
+    from light9.namespaces import L9
+    from rdflib import RDF
+    graph = showconfig.getGraph()
+    for song in graph.subjects(RDF.type, L9['Song']):
+        inpath = showconfig.songOnDisk(song)
+        for curveName, t in [('music', .01),
+                             ('smooth_music', .07)]:
+            outpath = showconfig.curvesDir() + "/%s-%s" % (
+                showconfig.songFilenameFromURI(song), curveName)
+            createCurve(inpath, outpath, t)
+else:
+    inpath,outpath = args
+    createCurve(inpath, outpath, options.t)