def OSCrawcc(path, tags, args, source): if path.find(" ") != -1: newargs = path.split(" ") args = [] #print(newargs, len(newargs)) for arg in range(len(newargs) - 1): args.append(newargs[arg + 1]) print(path, args) layer = int(args[0]) number = int(args[1]) value = int(args[2]) #print("OSC rawcc") midix.SendUI( '/beatstep/' + "m" + str(layer + 1) + str(number + 1) + '/value', [format(value, "03d")]) #print('/beatstep/'+ "m" +str(layer+1)+ str(number+1) + '/value', [format(value, "03d")]) #ccs[layer][number] = value print(encoders[number], ": value", value, "steps", Layer[layer]['steps'], "stepmax", Layer[layer]['stepmax'], "lineSize", Layer[layer]['lineSize']) #print("Aurora OSC Got rawCC for layer", layer, "encoder", encoders[number], "value", value) #print(value, Layer[layer]['stepmax']) if value * 2 < Layer[layer]['stepmax']: Layer[layer][encoders[number]] = value * 5 Layer[layer]['stepvals'] = anim.sbilinear(Layer[layer]['steps'], 0, Layer[layer]['stepmax'])
def OSCstop(path, tags, args, source): print("Aurora OSC Got MIDI stop for layer", int(args[0])) Layer[int(args[0])]['run'] = False #for l in range(3): # Layer[l]['run'] = not Layer[l]['run'] midix.SendUI('/status', ["Stop"])
def OSCim(path, tags, args, source): newarg = path.split(" ") newlaser = args[0] + 24 print("OSim sending to LJ2 /scim", str(newlaser)) lj.SendLJ("/scim", [newlaser]) print("sending knobs value for new layer") UpdateKnobs(newlaser) midix.SendUI('/status', ["Sim : " + newlaser])
def OSClinesize(path, tags, args, source): #Layer[layer]['run'] = False layer = int(args[0]) value = float(args[1]) if value > 1: value = value / 127 Layer[layer]['lineSize'] = value * 400 midix.SendUI('/status', ["linesize : ", value * 400])
def OSCradius(path, tags, args, source): layer = int(args[0]) value = float(args[1]) if value > 1: value = value / 127 print("aurora OSC got radius", value, (value * multi["radius"]), "layer", layer) Layer[layer]['radius'] = value * multi["radius"] midix.SendUI('/status', ["Radius : ", value * multi["radius"]])
def newtempo(tempo): global lnk #print("val2", val2, "tempo", tempo) if linked == True: lnk.enabled = False lnk.startStopSyncEnabled = False lnk = link.Link(tempo) lnk.enabled = True lnk.startStopSyncEnabled = True bpm = tempo print(("New BPM", bpm)) midix.SendUI('/bpm', [bpm]) else: print("Link is disabled")
def OSCrawcc(path, tags, args, source): #global step, steps, stepmax, stepvals layer = int(args[0]) number = int(args[1]) value = int(args[2]) midix.SendUI('/beatstep/' + "m" + str(layer) + str(number + 1) + '/value', [format(value, "03d")]) ccs[layer][number] = value print(encoders[number], ": value", value, "steps", Layer[layer]['steps'], "stepmax", Layer[layer]['stepmax'], "lineSize", Layer[layer]['lineSize']) #print("maxwell OSC Got rawCC for layer", layer, "encoder", encoders[number], "value", value) #print(value, Layer[layer]['stepmax']) if value * 2 < Layer[layer]['stepmax']: Layer[layer][encoders[number]] = value * 5 Layer[layer]['stepvals'] = anim.sbilinear(Layer[layer]['steps'], 0, Layer[layer]['stepmax'])
def BeatEvent(): global lnk, prevphase lnkstr = lnk.captureSessionState() link_time = lnk.clock().micros() tempo_str = '{0:.2f}'.format(lnkstr.tempo()) bpm = float(tempo_str) #beatstep.SendOSCUI('/bpm', [bpm]) beats_str = '{0:.2f}'.format(lnkstr.beatAtTime(link_time, 0)) playing_str = str(lnkstr.isPlaying()) # always False ??? phase = lnkstr.phaseAtTime(link_time, 4) # new beat ? if int(phase) != prevphase: prevphase = int(phase) #print("LINK BPM:",bpm) sys.stdout.write("Beat " + str(beats_str) + ' \r') sys.stdout.flush() midix.SendUI('/beats', [beats_str]) #alink.SendOSCUI('/states/cc/'+str(ccnumber), [value]) currentbeat = float(beats_str)
def OSCnoteon(path, tags, args, source): print("Aurora OSC Got MIDI noteon") l = int(args[0]) note = int(args[1]) velocity = int(args[2]) # first led raw : FX change # A0 / Scan H if note == 33: Layer[l]['FX'] = beatstepfxs[0] # B0 if note == 35: Layer[l]['FX'] = beatstepfxs[1] # C0 if note == 24: Layer[l]['FX'] = beatstepfxs[2] # D0 if note == 26: Layer[l]['FX'] = beatstepfxs[3] # E0 if note == 28: Layer[l]['FX'] = beatstepfxs[4] # F0 if note == 29: Layer[l]['FX'] = beatstepfxs[5] # G0 if note == 31: Layer[l]['FX'] = beatstepfxs[6] # G#0 if note == 21: Layer[l]['FX'] = beatstepfxs[7] if 21 < note < 35: midix.SendUI('/status', [Layer[l]['FX']]) # Second led raw : Color change # A1 if note == 45: Layer[l]['color'] = eval(beatstepcols[0]) # B1 if note == 47: Layer[l]['color'] = eval(beatstepcols[1]) # C1 if note == 36: Layer[l]['color'] = eval(beatstepcols[2]) # D1 if note == 38: Layer[l]['color'] = eval(beatstepcols[3]) # E1 if note == 40: Layer[l]['color'] = eval(beatstepcols[4]) # F1 if note == 41: Layer[l]['color'] = eval(beatstepcols[5]) # G1 if note == 43: Layer[l]['color'] = eval(beatstepcols[6]) # G#1 if note == 44: Layer[l]['color'] = eval(beatstepcols[7]) if 36 < note < 47: midix.SendUI('/status', [Layer[l]['color']]) print("Aurora OSC Got new MIDI FX/color for layer", l, ":", Layer[l]['FX'], "/", (Layer[l]['color']))
def OSCstart(path, tags, args, source): print("Aurora OSC Got MIDI start") for l in range(3): Layer[l]['run'] = True midix.SendUI('/status', ["Start"])
def OSChandler(path, tags, args, source): global TrckrPts oscaddress = ''.join(path.split("/")) #print() print("Aurora default OSC Handler : " + str(path) + " from Client : " + str(source[0])) if len(args) > 0: pass #Convert from TouchOSC full text OSC style (no args) if path.find(" ") != -1: prevargs = [] if len(args) > 0: prevargs = args print(prevargs) newargs = path.split(" ") args = [] #print(newargs, len(newargs)) for arg in range(len(newargs) - 1): args.append(newargs[arg + 1]) args.append(prevargs[0]) print("correction", path, args) #log.info("with args " + str(args)) # /aurora/fx/layernumber FXname if path.find('/aurora/fx') == 0: #print("path", path, 'args', args) #print("layer", path[11:12]) layer = int(path[11:12]) if layer <= lasernumber - 1: fx = args[0] if fx in FXs: Layer[layer]['FX'] = "anim." + fx print("Aurora default OSC got FX generator for layer", layer, ":", Layer[layer]['FX']) lj.SendLJ("/line1", [fx]) midix.SendUI('/status', [fx]) else: print("unknwon FX.") else: print("NOT POSSIBLE : only", lasernumber, "laser requested at startup") lj.SendLJ("/line1", str(lasernumber) + " Laser") # /aurora/color/layernumber colorname if path.find('/aurora/color') == 0: #if args[1] =='1': layer = int(path[14:15]) if layer <= lasernumber - 1: color = args[0] Layer[layer]['color'] = eval(color) print("Aurora default OSc for Layer", layer, Layer[layer]['FX'], "Got color change to", color) else: print("NOT POSSIBLE : only", lasernumber, "laser requested at startup") lj.SendLJ("/line1", str(lasernumber) + " Laser") # [0,1] or [0,127] # /aurora/x/layernumber coord if path.find('/aurora/x') == 0: layer = int(path[10:11]) value = float(args[0]) if value > 1: value = value / 127 #print("xdefault layer", layer, "value", value) Layer[layer]['Xcoord'] = value * screen_size[0] print("Aurora default OSC got X coord for layer", layer, ":", Layer[layer]['Xcoord']) midix.SendUI('/status', ["X : " + str(value * screen_size[0])]) # [0,1] or [0,127] # /aurora/y/layernumber coord if path.find('/aurora/y') == 0: layer = int(path[10:11]) value = float(args[0]) if value > 1: value = value / 127 #print("ydefault layer", layer, "value", value) Layer[layer]['Ycoord'] = value * screen_size[1] print("Aurora default OSC got Y coord for layer", layer, ":", Layer[layer]['Ycoord']) midix.SendUI('/status', ["Y : " + str(value * screen_size[0])]) # /aurora/trckr/frame layernumber framenumber points if path.find('aurora/trckr/frame') == 0: if debug != 0: print("Aurora default OSC got trckr frame", args[1], "for layer", args[0], "with path", path) print(len(args), "args", args) counter = 0 ''' TrckrPts = [] for dot in range(2,len(args)-1,2): TrckrPts.append([float(args[dot]), float(args[dot+1])]) ''' TrckrPts[args[0]] = [] for dot in range(2, len(args) - 1, 2): TrckrPts[args[0]].append([float(args[dot]), float(args[dot + 1])]) # /aurora/word/layer word if path.find('/aurora/word') == 0: layer = int(path[13:14]) value = args[0] Layer[layer]['word'] = value print("Aurora default OSC got word", args[0], "for layer", layer) midix.SendUI('/status', ["Word : " + str(value * screen_size[0])]) # /aurora/word/layer word if path.find('/aurora/rawcc') == 0: layer = int(args[0]) number = int(args[1]) value = int(args[2]) midix.SendUI( '/beatstep/' + "m" + str(layer + 1) + str(number + 1) + '/value', [format(value, "03d")]) #ccs[layer][number] = value print(encoders[number], ": value", value, "steps", Layer[layer]['steps'], "stepmax", Layer[layer]['stepmax'], "lineSize", Layer[layer]['lineSize']) print("Aurora Default OSC Got rawCC for layer", layer, "encoder", encoders[number], "value", value) #print(value, Layer[layer]['stepmax']) if value * 2 < Layer[layer]['stepmax']: Layer[layer][encoders[number]] = value * 5 Layer[layer]['stepvals'] = anim.sbilinear(Layer[layer]['steps'], 0, Layer[layer]['stepmax']) # /aurora/scim if path.find('/aurora/scim') == 0: print("OScim sending to LJ2 /scim", int(args[0]) + 24) lj.SendLJ("/scim", [int(args[0]) + 24])
def beatstepUI(): midix.SendUI('/beatstep', [1]) midix.SendUI('/beatstep/on', [1]) midix.SendUI('/status', ["Aurora"]) if linked: midix.SendUI('/bpm', alink.bpm) for l in range(4): # First encoder line midix.SendUI('/beatstep/' + "m1" + str(l + 1) + '/line1', '') midix.SendUI('/beatstep/' + "m1" + str(l + 1) + '/line2', encoders[l]) midix.SendUI('/beatstep/' + "m1" + str(l + 1) + '/value', [format(0, "03d")]) midix.SendUI('/beatstep/' + "m1" + str(4 + l + 1) + '/line1', '') midix.SendUI('/beatstep/' + "m1" + str(4 + l + 1) + '/line2', encoders[l]) midix.SendUI('/beatstep/' + "m1" + str(4 + l + 1) + '/value', [format(0, "03d")]) # First pad line fxname = beatstepfxs[l].split('.') print(fxname) midix.SendUI('/beatstep/' + "m3" + str(l + 1) + '/line1', fxname[0]) midix.SendUI('/beatstep/' + "m3" + str(l + 1) + '/line2', fxname[1]) midix.SendUI('/beatstep/' + "m3" + str(4 + l + 1) + '/line1', fxname[0]) midix.SendUI('/beatstep/' + "m3" + str(4 + l + 1) + '/line2', fxname[1])