annotate bin/wavecurve @ 1859:f066d6e874db

2to3 with these fixers: all idioms set_literal Ignore-this: cbd28518218c2f0ddce8c4f92d3b8b33
author drewp@bigasterisk.com
date Wed, 22 May 2019 00:08:22 +0000
parents 7772cc48e016
children 3c523c71da29
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
717
d8202a0a7fd5 fix up musicpad and wavecurve. ascoltami2 can now use relative paths in the config
Drew Perttula <drewp@bigasterisk.com>
parents: 624
diff changeset
1 #!bin/python
623
46d319974176 move networking settings to config.n3
drewp@bigasterisk.com
parents: 617
diff changeset
2 import optparse
221
4a51d4eefa95 add wavecurve from semprini with new cmdline ui
drewp@bigasterisk.com
parents:
diff changeset
3 import run_local
4a51d4eefa95 add wavecurve from semprini with new cmdline ui
drewp@bigasterisk.com
parents:
diff changeset
4 from light9.wavepoints import simp
4a51d4eefa95 add wavecurve from semprini with new cmdline ui
drewp@bigasterisk.com
parents:
diff changeset
5
1858
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 717
diff changeset
6
357
7771f37252da curvecalc persistence, wavecurve -a option
Drew Perttula <drewp@bigasterisk.com>
parents: 224
diff changeset
7 def createCurve(inpath, outpath, t):
1859
f066d6e874db 2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents: 1858
diff changeset
8 print("reading %s, writing %s" % (inpath, outpath))
436
5a83935377f9 wavecurve to support .ogg/.wav pairs
drewp@bigasterisk.com
parents: 357
diff changeset
9 points = simp(inpath.replace('.ogg', '.wav'), seconds_per_average=t)
357
7771f37252da curvecalc persistence, wavecurve -a option
Drew Perttula <drewp@bigasterisk.com>
parents: 224
diff changeset
10
7771f37252da curvecalc persistence, wavecurve -a option
Drew Perttula <drewp@bigasterisk.com>
parents: 224
diff changeset
11 f = file(outpath, 'w')
7771f37252da curvecalc persistence, wavecurve -a option
Drew Perttula <drewp@bigasterisk.com>
parents: 224
diff changeset
12 for time_val in points:
1859
f066d6e874db 2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents: 1858
diff changeset
13 print("%s %s" % time_val, file=f)
1858
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 717
diff changeset
14
357
7771f37252da curvecalc persistence, wavecurve -a option
Drew Perttula <drewp@bigasterisk.com>
parents: 224
diff changeset
15
7771f37252da curvecalc persistence, wavecurve -a option
Drew Perttula <drewp@bigasterisk.com>
parents: 224
diff changeset
16 parser = optparse.OptionParser(usage="""%prog inputSong.wav outputCurve
7771f37252da curvecalc persistence, wavecurve -a option
Drew Perttula <drewp@bigasterisk.com>
parents: 224
diff changeset
17
7771f37252da curvecalc persistence, wavecurve -a option
Drew Perttula <drewp@bigasterisk.com>
parents: 224
diff changeset
18 You probably just want -a
7771f37252da curvecalc persistence, wavecurve -a option
Drew Perttula <drewp@bigasterisk.com>
parents: 224
diff changeset
19
7771f37252da curvecalc persistence, wavecurve -a option
Drew Perttula <drewp@bigasterisk.com>
parents: 224
diff changeset
20 """)
1858
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 717
diff changeset
21 parser.add_option("-t",
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 717
diff changeset
22 type="float",
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 717
diff changeset
23 default=.01,
221
4a51d4eefa95 add wavecurve from semprini with new cmdline ui
drewp@bigasterisk.com
parents:
diff changeset
24 help="seconds per sample (default .01, .07 is smooth)")
1858
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 717
diff changeset
25 parser.add_option("-a",
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 717
diff changeset
26 "--all",
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 717
diff changeset
27 action="store_true",
357
7771f37252da curvecalc persistence, wavecurve -a option
Drew Perttula <drewp@bigasterisk.com>
parents: 224
diff changeset
28 help="make standard curves for all songs")
1858
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 717
diff changeset
29 options, args = parser.parse_args()
221
4a51d4eefa95 add wavecurve from semprini with new cmdline ui
drewp@bigasterisk.com
parents:
diff changeset
30
617
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 436
diff changeset
31 if options.all:
357
7771f37252da curvecalc persistence, wavecurve -a option
Drew Perttula <drewp@bigasterisk.com>
parents: 224
diff changeset
32 from light9 import showconfig
7771f37252da curvecalc persistence, wavecurve -a option
Drew Perttula <drewp@bigasterisk.com>
parents: 224
diff changeset
33 from light9.namespaces import L9
7771f37252da curvecalc persistence, wavecurve -a option
Drew Perttula <drewp@bigasterisk.com>
parents: 224
diff changeset
34 from rdflib import RDF
624
9071cd1bb29c fix wavecurve
drewp@bigasterisk.com
parents: 623
diff changeset
35 from light9.ascoltami.playlist import Playlist
357
7771f37252da curvecalc persistence, wavecurve -a option
Drew Perttula <drewp@bigasterisk.com>
parents: 224
diff changeset
36 graph = showconfig.getGraph()
617
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 436
diff changeset
37
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 436
diff changeset
38 playlist = Playlist.fromShow(showconfig.getGraph(), showconfig.showUri())
624
9071cd1bb29c fix wavecurve
drewp@bigasterisk.com
parents: 623
diff changeset
39 for song in playlist.allSongs():
717
d8202a0a7fd5 fix up musicpad and wavecurve. ascoltami2 can now use relative paths in the config
Drew Perttula <drewp@bigasterisk.com>
parents: 624
diff changeset
40 inpath = showconfig.songOnDisk(song)
1858
7772cc48e016 reformat all python
drewp@bigasterisk.com
parents: 717
diff changeset
41 for curveName, t in [('music', .01), ('smooth_music', .07)]:
357
7771f37252da curvecalc persistence, wavecurve -a option
Drew Perttula <drewp@bigasterisk.com>
parents: 224
diff changeset
42 outpath = showconfig.curvesDir() + "/%s-%s" % (
7771f37252da curvecalc persistence, wavecurve -a option
Drew Perttula <drewp@bigasterisk.com>
parents: 224
diff changeset
43 showconfig.songFilenameFromURI(song), curveName)
7771f37252da curvecalc persistence, wavecurve -a option
Drew Perttula <drewp@bigasterisk.com>
parents: 224
diff changeset
44 createCurve(inpath, outpath, t)
7771f37252da curvecalc persistence, wavecurve -a option
Drew Perttula <drewp@bigasterisk.com>
parents: 224
diff changeset
45 else:
617
94039df5cdd9 create Playlist class which is now used in wavecurve, musicPad, and ascoltami2.
David McClosky <dmcc@bigasterisk.com>
parents: 436
diff changeset
46 inpath, outpath = args
357
7771f37252da curvecalc persistence, wavecurve -a option
Drew Perttula <drewp@bigasterisk.com>
parents: 224
diff changeset
47 createCurve(inpath, outpath, options.t)