Changeset - c1fa4f7fe5d1
[Not reviewed]
default
0 3 0
drewp@bigasterisk.com - 20 months ago 2023-06-02 23:16:06
drewp@bigasterisk.com
log & metrics
3 files changed with 12 insertions and 4 deletions:
0 comments (0 inline, 0 general)
light9/effect/effecteval2.py
Show inline comments
 
@@ -99,13 +99,15 @@ class EffectEval2:
 
                v = songTime
 
            else:
 
                eaForName = EffectAttr(L9[arg.name])
 
                v = self._getEffectAttrValue(eaForName, inputs)
 

	
 
            kw[arg.name] = v
 
        log.debug('calling %s with %s', c.func, kw)
 

	
 
        if False and log.isEnabledFor(logging.DEBUG):
 
            log.debug('calling %s with %s', c.func, kw)
 
        return c.func(**kw)
 

	
 
    def _getEffectAttrValue(self, attr: EffectAttr, inputs: EffectSettings) -> VTUnion:
 
        c = self.config
 
        if c is None:
 
            raise
light9/effect/sequencer/eval_faders.py
Show inline comments
 
import traceback
 
import logging
 
import time
 
from dataclasses import dataclass
 
from typing import List, Optional, cast
 

	
 
from prometheus_client import Summary
 
@@ -15,13 +16,13 @@ from light9.namespaces import L9, RDF
 
from light9.newtypes import EffectAttr, EffectUri, UnixTime
 
from light9.typedgraph import typedValue
 

	
 
log = logging.getLogger('seq.fader')
 

	
 
COMPILE = Summary('compile_graph_fader', '')
 

	
 
COMPUTE_ALL_FADERS = Summary('compute_all_faders', '')
 

	
 
@dataclass
 
class Fader:
 
    graph: SyncedGraph
 
    lib: EffectFunctionLibrary
 
    uri: URIRef
 
@@ -69,12 +70,13 @@ class FaderEval:
 
    def _compileFader(self, fader: URIRef) -> Fader:
 
        effect = typedValue(EffectUri, self.graph, fader, L9['effect'])
 
        setting = typedValue(Node, self.graph, fader, L9['setting'])
 
        setAttr = typedValue(EffectAttr, self.graph, setting, L9['effectAttr'])
 
        return (Fader(self.graph, self.lib, cast(URIRef, fader), effect, setAttr))
 

	
 
    @COMPUTE_ALL_FADERS.time()
 
    def computeOutput(self) -> DeviceSettings:
 
        faderEffectOutputs: List[DeviceSettings] = []
 
        now = UnixTime(time.time())
 
        for f in self.faders:
 
            try:
 
                if f.value is None:
 
@@ -86,6 +88,10 @@ class FaderEval:
 
                faderEffectOutputs.append(ds)
 
            except Exception:
 
                log.warning(f'on fader {f}')
 
                raise
 

	
 
        return DeviceSettings.merge(self.graph, faderEffectOutputs)
 
        merged = DeviceSettings.merge(self.graph, faderEffectOutputs)
 
        # please remove (after fixing stats display to show it)
 
        log.debug("computed %s faders in %.1fms", len(self.faders), (time.time()-now)*1000)
 
        return merged
light9/effect/sequencer/service.py
Show inline comments
 
@@ -48,15 +48,15 @@ async def send_page_updates(request):
 
    return EventSourceResponse(changes())
 

	
 

	
 
def main():
 
    graph = SyncedGraph(networking.rdfdb.url, "effectSequencer")
 
    logging.getLogger('autodepgraphapi').setLevel(logging.INFO)
 
    logging.getLogger('syncedgraph').setLevel(logging.DEBUG)
 
    logging.getLogger('syncedgraph').setLevel(logging.INFO)
 
    logging.getLogger('sse_starlette.sse').setLevel(logging.INFO)
 
    logging.getLogger('effecteval').setLevel(logging.INFO)
 
    logging.getLogger('effecteval').setLevel(logging.DEBUG)
 

	
 
    # seq = Sequencer(graph, send)  # per-song timed notes
 
    lib = EffectFunctionLibrary(graph)
 
    faders = FaderEval(graph, lib)  # bin/fade's untimed effects
 

	
 
    #@metrics('computeAndSend').time() # needs rework with async
0 comments (0 inline, 0 general)