Changeset - ef29453b307f
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 11 years ago 2014-06-14 22:30:15
drewp@bigasterisk.com
EE song time fetcher now coasts forwards with local clock
Ignore-this: 23dc3675c7ac6a877367979bff5ed12a
1 file changed with 5 insertions and 3 deletions:
0 comments (0 inline, 0 general)
light9/effecteval/effectloop.py
Show inline comments
 
@@ -26,13 +26,13 @@ class EffectLoop(object):
 
        self.lastLogTime = 0
 
        self.lastLogMsg = ""
 
        self.lastErrorLog = 0
 
        self.graph.addHandler(self.setEffects)
 
        self.period = 1 / 30
 
        self.coastSecs = .3 # main reason to keep this low is to notice play/pause
 

	
 
        self.songTimeFetch = 0
 
        self.songTimeFromRequest = 0
 
        self.requestTime = 0 # unix sec for when we fetched songTime
 
        self.initOutput()
 

	
 
    def initOutput(self):
 
        pass
 
@@ -75,24 +75,26 @@ class EffectLoop(object):
 

	
 

	
 
    @inlineCallbacks
 
    def updateTimeFromMusic(self):
 
        t1 = time.time()
 
        with self.stats.getMusic.time():
 
            songTime, song = yield self.getSongTime()
 
            self.songTime, song = yield self.getSongTime()
 
            self.songTimeFetch = time.time()
 

	
 
        if song != self.currentSong:
 
            self.currentSong = song
 
            # this may be piling on the handlers
 
            self.graph.addHandler(self.setEffects)
 
        self.songTime = songTime
 
        elapsed = time.time() - t1
 
        reactor.callLater(max(0, self.period - elapsed), self.updateTimeFromMusic)
 

	
 
    def estimatedSongTime(self):
 
        return self.songTime
 
        now = time.time()
 
        return self.songTime + max(0, now - self.songTimeFetch)
 
        
 
    @inlineCallbacks
 
    def sendLevels(self):
 
        t1 = time.time()
 
        log.debug("time since last call: %.1f ms" % (1000 * (t1 - self.lastSendLevelsTime)))
 
        self.lastSendLevelsTime = t1
0 comments (0 inline, 0 general)