changeset 2349:f7e564b42af3

new grandmaster scales all faders
author drewp@bigasterisk.com
date Sat, 03 Jun 2023 15:22:38 -0700
parents b98dc72978eb
children 72c589cb96d1
files light9/effect/sequencer/eval_faders.py light9/fade/Light9FadeUi.ts show/dance2023/fade.n3
diffstat 3 files changed, 44 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/light9/effect/sequencer/eval_faders.py	Sat Jun 03 15:21:40 2023 -0700
+++ b/light9/effect/sequencer/eval_faders.py	Sat Jun 03 15:22:38 2023 -0700
@@ -44,8 +44,10 @@
         self.graph = graph
         self.lib = lib
         self.faders: List[Fader] = []
+        self.grandMaster = 1.0
 
         self.graph.addHandler(self._compile)
+        self.graph.addHandler(self._compileGm)
         self.lastLoopSucceeded = False
 
     @COMPILE.time()
@@ -73,6 +75,15 @@
         setAttr = typedValue(EffectAttr, self.graph, setting, L9['effectAttr'])
         return (Fader(self.graph, self.lib, cast(URIRef, fader), effect, setAttr))
 
+    def _compileGm(self):
+        try:
+            self.grandMaster = typedValue(float, self.graph,
+                                          L9.grandMaster,
+                                          L9.value)
+            print('got gm', self.grandMaster)
+        except ValueError:
+            return
+        
     @COMPUTE_ALL_FADERS.time()
     def computeOutput(self) -> DeviceSettings:
         faderEffectOutputs: List[DeviceSettings] = []
@@ -82,7 +93,9 @@
                 if f.value is None:
                     log.warning(f'{f.value=}; should be set during _compile. Skipping {f.uri}')
                     continue
-                effectSettings = EffectSettings(self.graph, [(f.effect, f.setEffectAttr, f.value)])
+                v = f.value
+                v *= self.grandMaster
+                effectSettings = EffectSettings(self.graph, [(f.effect, f.setEffectAttr, v)])
 
                 ds = f.ee.compute(now, effectSettings)
                 faderEffectOutputs.append(ds)
--- a/light9/fade/Light9FadeUi.ts	Sat Jun 03 15:21:40 2023 -0700
+++ b/light9/fade/Light9FadeUi.ts	Sat Jun 03 15:22:38 2023 -0700
@@ -36,6 +36,9 @@
       .mappedToHw {
         background: #393945;
       }
+      #gm light9-fader {
+        width: 300px;
+      }
     `,
   ];
   render() {
@@ -43,7 +46,9 @@
       <rdfdb-synced-graph></rdfdb-synced-graph>
 
       <h1>Fade</h1>
-
+<div id="gm">
+  <light9-fader .value=${this.grandMaster} @change=${this.gmChanged}></light9-fader>grand master
+</div>
       ${(this.fadePages?.pages || []).map(this.renderPage.bind(this))}
 
       <div><button @click=${this.addPage}>Add new page</button></div>
@@ -70,12 +75,14 @@
 
   @property() fadePages?: FadePages;
   @property() currentHwPage?: NamedNode;
+  @property() grandMaster?: number;
 
   constructor() {
     super();
     getTopGraph().then((g) => {
       this.graph = g;
       this.graph.runHandler(this.compile.bind(this), `faders layout`);
+      this.graph.runHandler(this.compileGm.bind(this), `faders gm`);
     });
   }
   connectedCallback(): void {
@@ -109,6 +116,27 @@
       this.currentHwPage = this.graph.uriValue(mc, U(":outputs"));
     } catch (e) { }
   }
+  compileGm() {
+    const U = this.graph.U();
+    this.grandMaster = undefined
+    let newVal
+    try {
+
+      newVal = this.graph.floatValue(U(':grandMaster'), U(':value'))
+    } catch (e) {
+      return
+    }
+    this.grandMaster = newVal;
+
+  }
+  gmChanged(ev: CustomEvent) {
+    const U = this.graph.U();
+    const newVal = ev.detail.value
+    // this.grandMaster = newVal;
+    this.graph.patchObject(U(':grandMaster'), U(':value'), this.graph.LiteralRoundedFloat(newVal), this.ctx)
+
+  }
+
 
   mapThisToHw(page: NamedNode) {
     const U = this.graph.U();
--- a/show/dance2023/fade.n3	Sat Jun 03 15:21:40 2023 -0700
+++ b/show/dance2023/fade.n3	Sat Jun 03 15:22:38 2023 -0700
@@ -4,6 +4,7 @@
 @prefix show: <http://light9.bigasterisk.com/show/dance2023/> .
 @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
 
+:grandMaster :value 1.00 .
 :midiControl :map :midiControl0 .
 
 show:fadePage0 a :FadePage; rdfs:label "unnamed"; :fader show:fader0, show:fader1, show:fader2, show:fader3, show:fader4, show:fader5, show:fader6, show:fader7 .