Changeset - b7095e4a6c43
[Not reviewed]
default
0 3 0
drewp@bigasterisk.com - 20 years ago 2005-06-05 07:04:34
drewp@bigasterisk.com
curvecalc fixes: curve paths, empty function strings
3 files changed with 10 insertions and 6 deletions:
0 comments (0 inline, 0 general)
bin/curvecalc
Show inline comments
 
@@ -247,25 +247,29 @@ dispatcher.send("max time",maxtime=maxti
 
dispatcher.connect(lambda: maxtime, "get max time",weak=0)
 
curveset.load(basename=os.path.join(showconfig.curvesDir(),song))
 

	
 
subterms = []
 
subterm_adder(root, curveset, subterms, root, ssv).pack(side='top',fill='x')
 
for line in file(showconfig.subtermsForSong(song)):
 
    try:
 
    subname,expr = line.strip().split(" ",1)
 
    except ValueError:
 
        subname = line.strip()
 
        expr = ""
 

	
 
    term = add_one_subterm(subname, curveset, subterms, root, ssv, expr)
 
    
 
    # stv=Subtermview(root,term)
 
    # stv.pack(side='top',fill='x')
 

	
 
out = Output(subterms)
 

	
 
def savekey(*args):
 
    print "saving",song
 
    savesubterms(showconfig.subtermsForSong(song),subterms)
 
    curveset.save(basename="curves/"+song)
 
    curveset.save(basename=os.path.join(showconfig.curvesDir(),song))
 
    print "saved"
 

	
 
    
 
root.bind("<Control-Key-s>",savekey)
 

	
 
create_status_lines(root)
 
@@ -280,13 +284,13 @@ def update():
 
    global later
 
    d = music.current_time()
 
    d.addCallback(update2)
 
    d.addErrback(updateerr)
 
def updateerr(e):
 
    global later
 
    print "err",e
 
    print "Update error",e
 
    if later and not later.cancelled and not later.called: later.cancel()
 
    later = reactor.callLater(1,update)
 
def update2(t):
 
    global recent_t,later
 

	
 
    if later and not later.cancelled and not later.called: later.cancel()
light9/Submaster.py
Show inline comments
 
@@ -51,14 +51,14 @@ class Submaster:
 
        self.levels.clear()
 
        for k, v in leveldict.items():
 
            self.set_level(k, v, save=0)
 
        self.save()
 
    def get_levels(self):
 
        return self.levels
 
    def all_zeros(self):
 
        return not (max(self.levels.values()) > 0)
 
    def no_nonzero(self):
 
        return (not self.levels.values()) or not (max(self.levels.values()) > 0)
 
    def __mul__(self, scalar):
 
        return Submaster("%s*%s" % (self.name, scalar), 
 
            dict_scale(self.levels, scalar), temporary=1)
 
    __rmul__ = __mul__
 
    def max(self, *othersubs):
 
        return sub_maxes(self, *othersubs)
 
@@ -115,13 +115,13 @@ def linear_fade(start, end, amount):
 
    0 and 1.  If amount is 0, it will return the start value.  If it is 1,
 
    the end value will be returned."""
 
    level = start + (amount * (end - start))
 
    return level
 

	
 
def sub_maxes(*subs):
 
    nonzero_subs = [s for s in subs if not s.all_zeros()]
 
    nonzero_subs = [s for s in subs if not s.no_nonzero()]
 
    name = "max(%s)" % ", ".join([repr(s) for s in nonzero_subs])
 
    return Submaster(name,
 
                     dict_max(*[sub.levels for sub in nonzero_subs]),
 
                     temporary=1)
 

	
 
class Submasters:
light9/curve.py
Show inline comments
 
@@ -243,13 +243,13 @@ class Curveset:
 
    def __init__(self):
 
        self.curves = {}
 
    def load(self,basename):
 
        """find all files that look like basename-curvename and add
 
        curves with their contents"""
 
        for filename in glob.glob("%s-*"%basename):
 
            curvename = filename[filename.find('-')+1:]
 
            curvename = filename[filename.rfind('-')+1:]
 
            c=Curve()
 
            c.load(filename)
 
            curvename = curvename.replace('-','_')
 
            self.add_curve(curvename,c)            
 
    def save(self,basename):
 
        """writes a file for each curve with a name
0 comments (0 inline, 0 general)