comparison bin/curvecalc @ 551:ad5043f70fda

bin/curvecalc (with no song choice) defaults to whatever-ascoltami-is-currently-on Ignore-this: 22a936edc1548675f97fcfc785573457
author drewp@bigasterisk.com
date Tue, 15 Jun 2010 06:27:52 +0000
parents 8d6f6d8a4719
children 0cf00fffd921
comparison
equal deleted inserted replaced
550:f233fa1ec801 551:ad5043f70fda
15 try: 15 try:
16 from dispatch import dispatcher 16 from dispatch import dispatcher
17 except ImportError: 17 except ImportError:
18 import louie as dispatcher 18 import louie as dispatcher
19 from twisted.internet import reactor,tksupport 19 from twisted.internet import reactor,tksupport
20 import jsonlib 20 import jsonlib, restkit
21 import twisted 21 import twisted
22 from twisted.web.client import Agent 22 from twisted.web.client import Agent
23 from twisted.internet.protocol import Protocol 23 from twisted.internet.protocol import Protocol
24 from twisted.internet.defer import Deferred 24 from twisted.internet.defer import Deferred
25 from zope.interface import implements 25 from zope.interface import implements
451 "Available in functions: nsin/ncos period=amp=1; within(a,b) bef(x) aft(x) compare to time; smoove(x) cubic smoothstep; chan(name); curvename(t) eval curve"]: 451 "Available in functions: nsin/ncos period=amp=1; within(a,b) bef(x) aft(x) compare to time; smoove(x) cubic smoothstep; chan(name); curvename(t) eval curve"]:
452 line = tk.Label(root, text=helpline, font="Helvetica -12 italic", 452 line = tk.Label(root, text=helpline, font="Helvetica -12 italic",
453 anchor='w') 453 anchor='w')
454 line.pack(side='top',fill='x') 454 line.pack(side='top',fill='x')
455 455
456 def currentlyPlayingSong():
457 """ask the music player what song it's on"""
458 t = jsonlib.read(restkit.Resource(networking.musicUrl()).get("time").body)
459 if t['song'] is None:
460 raise ValueError("music player is not playing any song")
461 return URIRef(t['song'])
456 462
457 def main(): 463 def main():
458 parser = optparse.OptionParser() 464 parser = optparse.OptionParser()
459 parser.set_usage("%prog [opts] songURI") 465 parser.set_usage("%prog [opts] [songURI]")
460 parser.add_option("--sliders", action='store_true', 466 parser.add_option("--sliders", action='store_true',
461 help='use hardware sliders') 467 help='use hardware sliders')
462 parser.add_option("--skip-music", action='store_true', 468 parser.add_option("--skip-music", action='store_true',
463 help="ignore music and smooth_music curve files") 469 help="ignore music and smooth_music curve files")
464 opts, args = parser.parse_args() 470 opts, args = parser.parse_args()
465 471
466 try: 472 try:
467 song = URIRef(args[0]) 473 song = URIRef(args[0])
468 except IndexError: 474 except IndexError:
469 raise SystemExit("song URI is required, e.g. 'http://light9.bigasterisk.com/show/dance2008/song3'") 475 song = currentlyPlayingSong()
470 476
471 log.debug("music") 477 log.debug("music")
472 music=Music() 478 music=Music()
473 graph = makeGraph() 479 graph = makeGraph()
474 curveset = Curveset(sliders=opts.sliders) 480 curveset = Curveset(sliders=opts.sliders)