Changeset - e748d6edd375
[Not reviewed]
default
0 1 0
Drew Perttula - 18 years ago 2007-06-17 22:42:25
drewp@bigasterisk.com
CC logging
1 file changed with 1 insertions and 0 deletions:
0 comments (0 inline, 0 general)
bin/curvecalc
Show inline comments
 
@@ -6,96 +6,97 @@ now launches like this:
 

	
 

	
 

	
 
todo: curveview should preserve more objects, for speed maybe
 

	
 
"""
 
from __future__ import division
 
import xmlrpclib,time,socket,sys,textwrap,math,glob,random,os,optparse,traceback
 
from bisect import bisect_left,bisect,bisect_right
 
import Tkinter as tk
 
try:
 
    from dispatch import dispatcher
 
except ImportError:
 
    import louie as dispatcher 
 
from twisted.internet import reactor,tksupport
 
import twisted
 
from twisted.web.xmlrpc import Proxy
 
from rdflib import Literal, URIRef, RDF
 
from rdflib.Graph import Graph
 
import rdflib
 
import logging
 
log = logging.getLogger()
 
logging.basicConfig(format="%(asctime)s %(levelname)-5s %(name)s %(filename)s:%(lineno)d: %(message)s")
 
log.setLevel(logging.DEBUG)
 

	
 
import run_local
 
from light9 import Submaster, dmxclient, networking, showconfig, prof, Patch
 
from light9.TLUtility import make_attributes_from_args, dict_subset
 
from light9.zoomcontrol import Zoomcontrol
 
from light9.curve import Curve, Curveview, Curveset, Curvesetview
 
from light9.wavelength import wavelength
 
from light9.uihelpers import toplevelat
 
from light9.namespaces import L9
 
import light9.Effects
 

	
 
class Music:
 
    def __init__(self):
 
        self.player=None # xmlrpc Proxy to player
 
        self.recenttime=0
 

	
 
        dispatcher.connect(self.seekplay_or_pause,"music seek")
 

	
 
    def seekplay_or_pause(self,t):
 
        self.music.seekplay_or_pause(t)
 
        
 
    def current_time(self):
 
        """return deferred which gets called with the current time"""
 
        if self.player is None:
 
            print "connect to player"
 
            self.player = Proxy(networking.musicUrl())
 
#            d = self.player.callRemote("songlength")
 
#            d.addCallback(lambda l: dispatcher.send("max time",maxtime=l))
 
#            d = self.player.callRemote("songname")
 
#            d.addCallback(lambda n: dispatcher.send("songname",name=n))
 
        d = self.player.callRemote('gettime')
 
        def sendtime(t):
 
            dispatcher.send("input time",val=t)
 
            return t # pass along to the real receiver
 
        def error(e):
 
            pass#self.player=None
 
        d.addCallback(sendtime)
 
        return d
 
    
 
    def seekplay_or_pause(self,t):
 
        self.player.callRemote('seekplay_or_pause',t)
 

	
 
class Expr(object):
 
    """singleton, provides functions for use in subterm expressions,
 
    e.g. chases"""
 
    def __init__(self):
 
        self.effectGlobals = light9.Effects.configExprGlobals()
 
    
 
    def exprGlobals(self, startDict, t):
 
        """globals dict for use by expressions"""
 

	
 
        glo = startDict.copy()
 
        
 
        # add in functions from Effects
 
        glo.update(self.effectGlobals)
 

	
 
        glo['nsin'] = lambda x: (math.sin(x * (2 * math.pi)) + 1) / 2
 
        glo['ncos'] = lambda x: (math.cos(x * (2 * math.pi)) + 1) / 2
 
        glo['within'] = lambda a, b: a < t < b
 
        glo['bef'] = lambda x: t < x
 

	
 

	
 
        def smoove(x):
 
            return -2 * (x ** 3) + 3 * (x ** 2)
 
        glo['smoove'] = smoove
 

	
 
        def aft(t, x, smooth=0):
 
            left = x - smooth / 2
 
            right = x + smooth / 2
 
            if left < t < right:
 
                return smoove((t - left) / (right - left))
 
            return t > x
 
        glo['aft'] = lambda x, smooth=0: aft(t, x, smooth)
0 comments (0 inline, 0 general)