Changeset - d5761661ac31
[Not reviewed]
default
0 3 0
Drew Perttula - 8 years ago 2017-05-30 07:37:17
drewp@bigasterisk.com
fix sequencer to use DeviceSettings
Ignore-this: d317447acc51379a6d06622aea7213a6
3 files changed with 24 insertions and 10 deletions:
0 comments (0 inline, 0 general)
light9/effect/effecteval.py
Show inline comments
 
@@ -8,6 +8,8 @@ import math
 
from noise import pnoise1
 
import logging
 
import time
 
from light9.effect.settings import DeviceSettings
 

	
 

	
 
log = logging.getLogger('effecteval')
 

	
 
@@ -75,6 +77,10 @@ class EffectEval(object):
 
                sv = self.graph.value(setting, L9['scaledValue'])
 
                if not (bool(v) ^ bool(sv)):
 
                    raise NotImplementedError
 
                if d is None:
 
                    raise TypeError('no device on %s' % effect)
 
                if a is None:
 
                    raise TypeError('no attr on %s' % effect)
 

	
 
                settings.append((d, a, v if v is not None else sv, bool(sv)))
 

	
 
@@ -93,7 +99,7 @@ class EffectEval(object):
 

	
 
        strength = float(effectSettings[L9['strength']])
 
        if strength <= 0:
 
            return []
 
            return DeviceSettings(self.graph, [])
 

	
 
        out = {} # (dev, attr): value
 

	
 
@@ -109,11 +115,8 @@ class EffectEval(object):
 
            else:
 
                out.update(func(effectSettings, strength, songTime, noteTime))
 

	
 
        # todo: callers should prefer the dict form too
 
        outList = [(d, a, v) for (d, a), v in out.iteritems()]
 
        outList.sort()
 
        #import pprint; pprint.pprint(outList, width=170)
 
        return outList
 
        return DeviceSettings(self.graph, outList)
 
                            
 
    def simpleOutput(self, strength, colorScale):
 
        out = {}
light9/effect/sequencer.py
Show inline comments
 
@@ -172,7 +172,7 @@ class Sequencer(object):
 
        g = self.graph
 

	
 
        sharedEffectOutputs = {}
 
        
 

	
 
        for song in g.subjects(RDF.type, L9['Song']):
 
            self.notes[song] = []
 
            for note in g.objects(song, L9['note']):
 
@@ -199,7 +199,5 @@ class Sequencer(object):
 
        settings = []
 
        
 
        for note in self.notes.get(song, []):
 
            outs = note.outputSettings(t)
 
            #print 'out', outs
 
            settings.extend(outs)
 
        self.sendToCollector(settings)
 
            settings.append(note.outputSettings(t))
 
        self.sendToCollector(DeviceSettings.fromList(self.graph, settings))
light9/effect/settings.py
Show inline comments
 
@@ -71,6 +71,19 @@ class _Settings(object):
 
            compiled.setdefault(d, {})[a] = v
 
        return cls._fromCompiled(graph, compiled)
 

	
 
    @classmethod
 
    def fromList(cls, graph, others):
 
        out = cls(graph, [])
 
        for s in others:
 
            if not isinstance(s, cls):
 
                raise TypeError(s)
 
            for row in s.asList(): # could work straight from s._compiled
 
                if row[0] is None:
 
                    raise TypeError('bad row %r' % (row,))
 
                out._compiled.setdefault(row[0], {})[row[1]] = row[2]
 
        out._delZeros()
 
        return out
 
        
 
    def _zeroForAttr(self, attr):
 
        if attr == L9['color']:
 
            return '#000000'
0 comments (0 inline, 0 general)