Changeset - f7e564b42af3
[Not reviewed]
default
0 3 0
drewp@bigasterisk.com - 20 months ago 2023-06-03 22:22:38
drewp@bigasterisk.com
new grandmaster scales all faders
3 files changed with 44 insertions and 2 deletions:
0 comments (0 inline, 0 general)
light9/effect/sequencer/eval_faders.py
Show inline comments
 
@@ -41,14 +41,16 @@ class FaderEval:
 
    """
 

	
 
    def __init__(self, graph: SyncedGraph, lib: EffectFunctionLibrary):
 
        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()
 
    def _compile(self) -> None:
 
        """rebuild our data from the graph"""
 
        self.faders = []
 
@@ -70,22 +72,33 @@ 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))
 

	
 
    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] = []
 
        now = UnixTime(time.time())
 
        for f in self.faders:
 
            try:
 
                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)
 
            except Exception:
 
                log.warning(f'on fader {f}')
 
                traceback.print_exc()
light9/fade/Light9FadeUi.ts
Show inline comments
 
@@ -33,20 +33,25 @@ export class Light9FadeUi extends LitEle
 
        display: block;
 
        user-select: none; /* really this is only desirable during slider drag events */
 
      }
 
      .mappedToHw {
 
        background: #393945;
 
      }
 
      #gm light9-fader {
 
        width: 300px;
 
      }
 
    `,
 
  ];
 
  render() {
 
    return html`
 
      <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>
 
    `;
 
  }
 
  private renderPage(page: FadePage): TemplateResult {
 
@@ -67,18 +72,20 @@ export class Light9FadeUi extends LitEle
 

	
 
  graph!: SyncedGraph;
 
  ctx: NamedNode = new NamedNode(showRoot + "/fade");
 

	
 
  @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 {
 
    super.connectedCallback();
 
  }
 

	
 
@@ -106,12 +113,33 @@ export class Light9FadeUi extends LitEle
 
    this.currentHwPage = undefined;
 
    try {
 
      const mc = this.graph.uriValue(U(":midiControl"), U(":map"));
 
      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();
 
    log("map to hw", page);
 
    const mc = this.graph.uriValue(U(":midiControl"), U(":map"));
 
    this.graph.patchObject(mc, U(":outputs"), page, this.ctx);
show/dance2023/fade.n3
Show inline comments
 
@prefix : <http://light9.bigasterisk.com/> .
 
@prefix effect: <http://light9.bigasterisk.com/effect/> .
 
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
 
@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 .
 
:midiControl0 :inputs "mainSliders"; :midiDev "bcf2000"; :outputs show:fadePage1 .
 

	
 
show:fadePage1 a :FadePage; rdfs:label "unnamed"; :fader show:fader10, show:fader11, show:fader12, show:fader13, show:fader14, show:fader15, show:fader8, show:fader9 .
0 comments (0 inline, 0 general)