Mercurial > code > home > repos > light9
comparison bin/attic/wavecurve @ 2376:4556eebe5d73
topdir reorgs; let pdm have its src/ dir; separate vite area from light9/
author | drewp@bigasterisk.com |
---|---|
date | Sun, 12 May 2024 19:02:10 -0700 |
parents | bin/wavecurve@3c523c71da29 |
children |
comparison
equal
deleted
inserted
replaced
2375:623836db99af | 2376:4556eebe5d73 |
---|---|
1 #!bin/python | |
2 import optparse | |
3 from run_local import log | |
4 from light9.wavepoints import simp | |
5 | |
6 | |
7 def createCurve(inpath, outpath, t): | |
8 print("reading %s, writing %s" % (inpath, outpath)) | |
9 points = simp(inpath.replace('.ogg', '.wav'), seconds_per_average=t) | |
10 | |
11 f = open(outpath, 'w') | |
12 for time_val in points: | |
13 print("%s %s" % time_val, file=f) | |
14 log.info(r'Wrote {outpath}') | |
15 | |
16 | |
17 parser = optparse.OptionParser(usage="""%prog inputSong.wav outputCurve | |
18 | |
19 You probably just want -a | |
20 | |
21 """) | |
22 parser.add_option("-t", | |
23 type="float", | |
24 default=.01, | |
25 help="seconds per sample (default .01, .07 is smooth)") | |
26 parser.add_option("-a", | |
27 "--all", | |
28 action="store_true", | |
29 help="make standard curves for all songs") | |
30 options, args = parser.parse_args() | |
31 | |
32 if options.all: | |
33 from light9 import showconfig | |
34 from light9.ascoltami.playlist import Playlist | |
35 graph = showconfig.getGraph() | |
36 | |
37 playlist = Playlist.fromShow(showconfig.getGraph(), showconfig.showUri()) | |
38 for song in playlist.allSongs(): | |
39 inpath = showconfig.songOnDisk(song) | |
40 for curveName, t in [('music', .01), ('smooth_music', .07)]: | |
41 outpath = showconfig.curvesDir() + "/%s-%s" % ( | |
42 showconfig.songFilenameFromURI(song), curveName) | |
43 createCurve(inpath, outpath, t) | |
44 else: | |
45 inpath, outpath = args | |
46 createCurve(inpath, outpath, options.t) |