Files
@ 1dc96b97a544
Branch filter:
Location: light9/bin/inputquneo - annotation
1dc96b97a544
3.8 KiB
text/plain
two zoomed spectrogram views in asco
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | c756638275d6 c756638275d6 c756638275d6 c756638275d6 f066d6e874db c756638275d6 f066d6e874db c756638275d6 c756638275d6 c756638275d6 c756638275d6 3c523c71da29 6fa4288da8a6 78973ed9e986 c756638275d6 c756638275d6 7772cc48e016 c756638275d6 c756638275d6 c756638275d6 c756638275d6 c756638275d6 c756638275d6 7772cc48e016 c756638275d6 c756638275d6 c756638275d6 7772cc48e016 c756638275d6 7772cc48e016 78973ed9e986 78973ed9e986 c756638275d6 c756638275d6 c756638275d6 c756638275d6 c756638275d6 c756638275d6 73e171c9d478 78973ed9e986 7772cc48e016 78973ed9e986 78973ed9e986 78973ed9e986 78973ed9e986 78973ed9e986 78973ed9e986 78973ed9e986 78973ed9e986 7772cc48e016 c756638275d6 c756638275d6 7772cc48e016 7772cc48e016 c756638275d6 c756638275d6 c756638275d6 7772cc48e016 c756638275d6 c756638275d6 c756638275d6 73e171c9d478 c756638275d6 c756638275d6 73e171c9d478 f066d6e874db c756638275d6 73e171c9d478 73e171c9d478 73e171c9d478 73e171c9d478 73e171c9d478 73e171c9d478 73e171c9d478 73e171c9d478 7772cc48e016 7772cc48e016 7772cc48e016 7772cc48e016 f066d6e874db 73e171c9d478 73e171c9d478 73e171c9d478 78973ed9e986 73e171c9d478 73e171c9d478 73e171c9d478 73e171c9d478 73e171c9d478 7772cc48e016 73e171c9d478 73e171c9d478 f066d6e874db 73e171c9d478 73e171c9d478 73e171c9d478 73e171c9d478 7772cc48e016 73e171c9d478 73e171c9d478 7772cc48e016 c756638275d6 c756638275d6 73e171c9d478 c756638275d6 7772cc48e016 78973ed9e986 78973ed9e986 78973ed9e986 78973ed9e986 78973ed9e986 3c523c71da29 c756638275d6 7772cc48e016 78973ed9e986 | #!bin/python
"""
read Quneo midi events, write to curvecalc and maybe to effects
"""
from run_local import log
import logging, urllib.request, urllib.parse, urllib.error
import cyclone.web, cyclone.httpclient
from rdflib import URIRef
from twisted.internet import reactor, task
from light9.curvecalc.client import sendLiveInputPoint
from light9.namespaces import L9, RDF
from rdfdb.syncedgraph import SyncedGraph
from light9 import networking
import sys
sys.path.append('/usr/lib/python2.7/dist-packages') # For pygame
import pygame.midi
curves = {
23: URIRef('http://light9.bigasterisk.com/show/dance2014/song1/curve/c-2'),
24: URIRef('http://light9.bigasterisk.com/show/dance2014/song1/curve/c-3'),
25: URIRef('http://light9.bigasterisk.com/show/dance2014/song1/curve/c-4'),
6: URIRef('http://light9.bigasterisk.com/show/dance2014/song1/curve/c-5'),
18: URIRef('http://light9.bigasterisk.com/show/dance2014/song1/curve/c-6'),
}
class WatchMidi(object):
def __init__(self, graph):
self.graph = graph
pygame.midi.init()
dev = self.findQuneo()
self.inp = pygame.midi.Input(dev)
task.LoopingCall(self.step).start(.05)
self.noteIsOn = {}
self.effectMap = {} # note: effect class uri
self.graph.addHandler(self.setupNotes)
def setupNotes(self):
for e in self.graph.subjects(RDF.type, L9['EffectClass']):
qn = self.graph.value(e, L9['quneoNote'])
if qn:
self.effectMap[int(qn)] = e
log.info("setup with %s effects", len(self.effectMap))
def findQuneo(self):
for dev in range(pygame.midi.get_count()):
interf, name, isInput, isOutput, opened = pygame.midi.get_device_info(
dev)
if 'QUNEO' in name and isInput:
return dev
raise ValueError("didn't find quneo input device")
def step(self):
if not self.inp.poll():
return
NOTEON, NOTEOFF = 144, 128
for ev in self.inp.read(999):
(status, d1, d2, _), _ = ev
if status in [NOTEON, NOTEOFF]:
print(status, d1, d2)
if status == NOTEON:
if not self.noteIsOn.get(d1):
self.noteIsOn[d1] = True
try:
e = self.effectMap[d1]
cyclone.httpclient.fetch(
url=networking.effectEval.path('songEffects'),
method='POST',
headers={
'Content-Type':
['application/x-www-form-urlencoded']
},
postdata=urllib.parse.urlencode([('drop', e)]),
)
except KeyError:
pass
if status == NOTEOFF:
self.noteIsOn[d1] = False
if 0:
# curve editing mode, not done yet
for group in [(23, 24, 25), (6, 18)]:
if d1 in group:
if not self.noteIsOn.get(group):
print("start zero")
for d in group:
sendLiveInputPoint(curves[d], 0)
self.noteIsOn[group] = True
else: # miss first update
sendLiveInputPoint(curves[d1], d2 / 127)
if status == 128: #noteoff
for d in group:
sendLiveInputPoint(curves[d], 0)
self.noteIsOn[group] = False
def main():
log.setLevel(logging.DEBUG)
graph = SyncedGraph(networking.rdfdb.url, "inputQuneo")
wm = WatchMidi(graph)
reactor.run()
del wm
main()
|