changeset 2251:abf812ca5eba

faders have a settings node before their value now
author drewp@bigasterisk.com
date Sat, 27 May 2023 15:45:44 -0700
parents 3e68a4d1df0b
children 2b8a2a25b154
files light9/effect/sequencer/eval_faders.py light9/fade/Light9FadeUi.ts
diffstat 2 files changed, 15 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/light9/effect/sequencer/eval_faders.py	Sat May 27 15:44:40 2023 -0700
+++ b/light9/effect/sequencer/eval_faders.py	Sat May 27 15:45:44 2023 -0700
@@ -38,23 +38,13 @@
         self.graph = graph
         self.faders: List[Fader] = []
 
-        # self.simpleOutputs = SimpleOutputs(self.graph)
         log.info('fader adds handler')
         self.graph.addHandler(self._compile)
         self.lastLoopSucceeded = False
 
-        # self.codeWatcher = CodeWatcher(onChange=self.onCodeChange)
-        # have caller do this
-        #asyncio.create_task(self.startUpdating())
-
-    # async def startUpdating(self):
-    #     await self.graph.addAsyncHandler(self.update)
-    #     log.info('startupdating task done')
-
     def onCodeChange(self):
         log.debug('seq.onCodeChange')
         self.graph.addHandler(self._compile)
-        #self.updateLoop()
 
     @metrics('compile_graph_fader').time()
     def _compile(self) -> None:
@@ -68,17 +58,21 @@
 
         # this could go in a second, smaller addHandler call to avoid rebuilding Fader objs constantly
         for f in self.faders:
-            f.value = typedValue(float, self.graph, f.uri, L9['value'])
+            setting = typedValue(Node, self.graph, f.uri, L9['setting'])            
+            f.value = typedValue(float, self.graph, setting, L9['value'])
 
     def computeOutput(self) -> DeviceSettings:
-        notesSettings:List[DeviceSettings] = []
+        faderEffectOutputs: List[DeviceSettings] = []
         now = UnixTime(time.time())
         for f in self.faders:
             if f.value is None:
                 raise TypeError('f.value should be set by now')
             effectSettings = EffectSettings(self.graph, [(f.effect, f.setEffectAttr, f.value)])
 
-            notesSettings.append(f.ee.compute(effectSettings))
+            if f.value < .001:
+                continue
+
+            faderEffectOutputs.append(f.ee.compute(effectSettings))
 
             # ee = effecteval.EffectEval(self.graph, f.effectClass, self.simpleOutputs)
             # deviceSettings, report = ee.outputFromEffect(
@@ -89,4 +83,4 @@
             # log.info(f'  𝅘𝅥𝅮  {uriTail(f.uri)}: {effectSettings=} -> {deviceSettings=}')
             # if deviceSettings:
             #     notesSettings.append(deviceSettings)
-        return DeviceSettings.merge(self.graph, notesSettings)
+        return DeviceSettings.merge(self.graph, faderEffectOutputs)
--- a/light9/fade/Light9FadeUi.ts	Sat May 27 15:44:40 2023 -0700
+++ b/light9/fade/Light9FadeUi.ts	Sat May 27 15:45:44 2023 -0700
@@ -143,14 +143,15 @@
       // console.timeEnd(`valueSync ${this.uri.value}`)
       return;
     }
-
-    this.value = graph.floatValue(this.uri, graph.Uri(":value"));
+    const st = graph.uriValue(this.uri, U(":setting"));
+    this.value = graph.floatValue(st, graph.Uri(":value"));
   }
 
   onSliderInput(ev: CustomEvent) {
     if (this.graph === undefined) {
       return;
     }
+    const U = this.graph.U();
     const prev = this.value;
     const v: number = (ev.target as any).valueAsNumber;
     this.value = parseFloat(v.toPrecision(3)); // rewrite pls
@@ -158,7 +159,10 @@
       return;
     }
     meter.tick();
-    this.graph.patchObject(this.uri, this.graph.Uri(":value"), this.graph.LiteralRoundedFloat(this.value), this.ctx);
+    if (!this.setting) {
+      throw new Error("can't make new settings yet");
+    }
+    this.graph.patchObject(this.setting, this.graph.Uri(":value"), this.graph.LiteralRoundedFloat(this.value), this.ctx);
   }
 
   onEffectChange(ev: CustomEvent) {