Changeset - 63601fe0c3b0
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 20 years ago 2005-06-13 00:40:19
drewp@bigasterisk.com
curvecalc cmdline checking, connection status now in gui
1 file changed with 13 insertions and 4 deletions:
0 comments (0 inline, 0 general)
bin/curvecalc
Show inline comments
 
@@ -2,13 +2,13 @@
 

	
 
"""
 
todo: curveview should preserve more objects, for speed maybe
 

	
 
"""
 
from __future__ import division
 
import xmlrpclib,time,socket,sys,textwrap,math,glob,random,os
 
import xmlrpclib,time,socket,sys,textwrap,math,glob,random,os,optparse
 
from bisect import bisect_left,bisect,bisect_right
 
import Tkinter as tk
 
from dispatch import dispatcher
 
from twisted.internet import reactor,tksupport
 
import twisted
 
from twisted.web.xmlrpc import Proxy
 
@@ -166,12 +166,13 @@ def create_status_lines(master):
 
        ('output levels',
 
         lambda levels: textwrap.fill("; ".join(["%s:%.2f"%(n,v)
 
                                                 for n,v in
 
                                                 levels.items()[:5]
 
                                                 if v>0]),70)),
 
        ('update period',lambda t: "%.1fms"%(t*1000)),
 
        ('update status',lambda t: str(t)),
 
        ]:
 
        l = tk.Label(master,anchor='w',justify='left')
 
        l.pack(side='top',fill='x')
 
        dispatcher.connect(lambda val,l=l,sn=signame,tf=textfilter:
 
                           l.config(text=sn+": "+tf(val)),
 
                           signame,weak=0)
 
@@ -223,25 +224,32 @@ def subterm_adder(master, curveset, subt
 
#######################################################################
 
root=tk.Tk()
 
root.tk_setPalette("gray50")
 
root.wm_geometry("1120x850")
 
root.tk_focusFollowsMouse()
 

	
 
parser = optparse.OptionParser()
 
options,args = parser.parse_args()
 

	
 
try:
 
    song = args[0]
 
except IndexError:
 
    raise SystemExit("song name is required, e.g. '05-mix'")
 

	
 
music=Music()
 

	
 
zc = Zoomcontrol(root)
 
zc.pack(side='top',fill='x')
 

	
 
curveset = Curveset()
 
csv = Curvesetview(root,curveset)
 
csv.pack(side='top',fill='both',exp=1)
 

	
 
ssv = SubtermSetView(root)
 
ssv.pack(side='top', fill='x')
 

	
 
song = sys.argv[1]
 
root.title("Curemaster 2000MX - %s" % song)
 

	
 
musicfilename = showconfig.songFilename(song)
 
maxtime = wavelength(musicfilename)
 
dispatcher.send("max time",maxtime=maxtime)
 
dispatcher.connect(lambda: maxtime, "get max time",weak=0)
 
@@ -284,18 +292,19 @@ def update():
 
    global later
 
    d = music.current_time()
 
    d.addCallback(update2)
 
    d.addErrback(updateerr)
 
def updateerr(e):
 
    global later
 
    print "Update error",e
 
    dispatcher.send("update status",val=e.getErrorMessage())
 
    if later and not later.cancelled and not later.called: later.cancel()
 
    later = reactor.callLater(1,update)
 
def update2(t):
 
    global recent_t,later
 

	
 
    dispatcher.send("update status",
 
                    val="ok: receiving times from music player")
 
    if later and not later.cancelled and not later.called: later.cancel()
 
    later = reactor.callLater(.01,update)
 

	
 
    recent_t = recent_t[-50:]+[t]
 
    period = (recent_t[-1]-recent_t[0])/len(recent_t)
 
    dispatcher.send("update period",val=period)
0 comments (0 inline, 0 general)