Changeset - 39110a37e5ac
[Not reviewed]
default
1 1 1
drewp@bigasterisk.com - 8 months ago 2024-05-14 01:08:34
drewp@bigasterisk.com
revive midiFade
2 files changed with 5 insertions and 2 deletions:
0 comments (0 inline, 0 general)
bin/midiFade
Show inline comments
 
file renamed from bin/attic/midifade to bin/midiFade
 
#!/bin/sh
 
exec pdm run python light9/midifade/midifade.py
 
#!/bin/zsh
 
exec pdm run python src/light9/midifade/midifade.py
 

	
 

	
src/light9/midifade/midifade.py
Show inline comments
 
#!bin/python
 
"""
 
Read midi events, write fade levels to graph
 

	
 
Device troubleshooting:
 
    amidi -l
 
"""
 
import asyncio
 
import logging
 
import traceback
 
from typing import Dict, List, cast
 
from light9.effect.edit import clamp
 

	
 
import mido
 
from rdfdb.syncedgraph.syncedgraph import SyncedGraph
 
from rdflib import RDF, ConjunctiveGraph, Literal, URIRef
 
from rdfdb.syncedgraph.readonly_graph import ReadOnlyConjunctiveGraph
 
from light9 import networking
 
from light9.namespaces import L9
 
from light9.newtypes import decimalLiteral
 
from light9.run_local import log
 
from light9.showconfig import showUri
 

	
 
mido.set_backend('alsa_midi.mido_backend')
 
MAX_SEND_RATE = 30
 

	
 
_lastSet = {}  #midictlchannel:value7bit
 

	
 
currentFaders = {}  # midi control channel num : FaderUri
 
ctx = URIRef(showUri() + '/fade')
 

	
 

	
 
def compileCurrents(graph):
 
    currentFaders.clear()
 
    try:
 
        new = getChansToFaders(graph)
 
    except ValueError:
 
        return  # e.g. empty-graph startup
 
    currentFaders.update(new)
 

	
 

	
 
def getGraphMappingNode(g: ReadOnlyConjunctiveGraph | SyncedGraph) -> URIRef:
 
    mapping = g.value(L9['midiControl'], L9['map'])
 
    if mapping is None:
 
        raise ValueError('no :midiControl :map ?mapping')
 
    midiDev = g.value(mapping, L9['midiDev'])
 
    ourDev = 'bcf2000'
 
    if midiDev != Literal(ourDev):
 
        raise NotImplementedError(f'need {mapping} to have :midiDev {ourDev!r}')
 
    return mapping
 

	
 

	
 
def getCurMappedPage(g: SyncedGraph):
 
    mapping = getGraphMappingNode(g)
0 comments (0 inline, 0 general)