Changeset - 74ec008aee56
[Not reviewed]
default
0 1 0
Drew Perttula - 7 years ago 2018-06-03 11:35:06
drewp@bigasterisk.com
big sequencer speedup: only rebuild notes in the changed song
Ignore-this: 7d4f16423727daa90eb61518a41f57d3
1 file changed with 15 insertions and 8 deletions:
0 comments (0 inline, 0 general)
light9/effect/sequencer.py
Show inline comments
 
@@ -26,7 +26,8 @@ from txzmq import ZmqEndpoint, ZmqFactor
 
log = logging.getLogger('sequencer')
 
stats = scales.collection('/sequencer/',
 
                          scales.PmfStat('update'),
 
                          scales.PmfStat('compile'),
 
                          scales.PmfStat('compileGraph'),
 
                          scales.PmfStat('compileSong'),
 
                          scales.DoubleStat('recentFps'),
 
)
 

	
 
@@ -164,7 +165,7 @@ class CodeWatcher(object):
 
class Sequencer(object):
 
    def __init__(self, graph, sendToCollector, fps=30):
 
        self.graph = graph
 
        self.fps = 30
 
        self.fps = 60
 
        self.sendToCollector = sendToCollector
 
        self.music = MusicTime(period=.2, pollCurvecalc=False)
 

	
 
@@ -179,20 +180,26 @@ class Sequencer(object):
 
        self.codeWatcher = CodeWatcher(
 
            onChange=lambda: self.graph.addHandler(self.compileGraph))
 

	
 
    @stats.compile.time()
 
    @stats.compileGraph.time()
 
    def compileGraph(self):
 
        """rebuild our data from the graph"""
 
        log.info('compileGraph start')
 
        t1 = time.time()
 
        g = self.graph
 

	
 
        for song in g.subjects(RDF.type, L9['Song']):
 
            # ideally, wrap this (or smaller) in a sub-handler to run less on each patch
 
            self.graph.addHandler(lambda song=song: self.compileSong(song))
 
        log.info('compileGraph took %.2f ms', 1000 * (time.time() - t1))
 
        
 
    @stats.compileSong.time()
 
    def compileSong(self, song):
 
        t1 = time.time()
 

	
 
            self.notes[song] = []
 
            for note in g.objects(song, L9['note']):
 
                self.notes[song].append(Note(g, note, effecteval,
 
        for note in self.graph.objects(song, L9['note']):
 
            self.notes[song].append(Note(self.graph, note, effecteval,
 
                                             self.simpleOutputs))
 
        log.info('compileGraph done %.2f ms', 1000 * (time.time() - t1))
 
        log.info('  compile %s took %.2f ms', song, 1000 * (time.time() - t1))
 

	
 

	
 
    @stats.update.time()
 
    def update(self):
0 comments (0 inline, 0 general)