Esempio n. 1
0
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])
Esempio n. 2
0
def Run():

    Left = []
    Right = []
    counter = 0
    lj.WebStatus("Square")
    lj.SendLJ("/square/start 1")

    # OSC Server callbacks
    print("Starting OSC server at", myIP, " port", OSCinPort, "...")
    oscserver.addMsgHandler("/square/ljscene", OSCljscene)

    # Add OSC generic plugins commands : 'default", /ping, /quit, /pluginame/obj, /pluginame/var, /pluginame/adddest, /pluginame/deldest
    lj.addOSCdefaults(oscserver)

    try:

        while lj.oscrun:

            lj.OSCframe()
            Left = []
            Right = []

            x = vertices[0][0]
            y = vertices[0][1]
            z = vertices[0][2]

            # LJ tracers will "move" the laser to this first point in black, then move to the next with second point color.
            # For more accuracy in dac emulator, repeat this first point.

            # Generate all points in square.
            for point in face:
                x = vertices[point][0]
                y = vertices[point][1]
                z = vertices[point][2]

                Left.append(Proj(x + LeftShift(z * 25), y, z, 0, counter, 0))
                Right.append(Proj(x + RightShift(z * 25), y, z, 0, counter, 0))

            lj.PolyLineOneColor(Left,
                                c=Leftsquare.color,
                                layer=Leftsquare.layer,
                                closed=Leftsquare.closed)
            lj.PolyLineOneColor(Right,
                                c=Rightsquare.color,
                                layer=Rightsquare.layer,
                                closed=Rightsquare.closed)

            lj.DrawDests()

            time.sleep(0.1)

            counter += 1
            if counter > 360:
                counter = 0

    except KeyboardInterrupt:
        pass

    # Gently stop on CTRL C

    finally:

        lj.ClosePlugin()
Esempio n. 3
0
def Resampler(laser, lsteps):

    #                   shortstep          longsteps
    # lsteps is  like : [ 1.0, 8,     0.25, 3, 0.75, 3, 1.0, 10]
    print("Resampler change for laser ", laser)
    lj.SendLJ("/resampler/" + str(laser), [lsteps])
Esempio n. 4
0
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])
Esempio n. 5
0
def UpdateKnobs(layernumber):

    LAY = Layer[layernumber]

    lj.SendLJ("/forwardui", "aurora/word " + LAY['word'])

    lj.SendLJ("/forwardui", "aurora/Xcoord " + str(LAY['Xcoord']))
    lj.SendLJ("/forwardui", "aurora/Ycoord " + str(LAY['Ycoord']))
    lj.SendLJ("/forwardui", "aurora/scale " + str(LAY['scale']))
    lj.SendLJ("/forwardui", "aurora/scandots " + str(LAY['scandots']))
    lj.SendLJ("/forwardui", "aurora/rotdirec X " + str(LAY['Xrotdirec']))
    lj.SendLJ("/forwardui", "aurora/rotdirec Y " + str(LAY['Yrotdirec']))
    lj.SendLJ("/forwardui", "aurora/rotdirec Z " + str(LAY['Zrotdirec']))

    lj.SendLJ("/forwardui", "aurora/steps " + str(LAY['steps']))
    lj.SendLJ("/forwardui", "aurora/stepmax " + str(LAY['stepmax']))
    lj.SendLJ("/forwardui", "aurora/linesize " + str(LAY['lineSize']))
    lj.SendLJ("/forwardui", "aurora/radius " + str(LAY['radius']))
Esempio n. 6
0
def OSCstop():

    oscrun = False
    oscserver.close()


# /sendmx channel value
def OSCsendmx(path, tags, args, source):

    channel = args[0]
    val = args[1]
    updateDmxValue(channel, val)


lj.addOSCdefaults(oscserver)
lj.SendLJ("/pong", "artnet")
lj.WebStatus("Artnet Running...")

log.infog("Artnet running...")
print()

oscserver.addMsgHandler("/sendmx", OSCsendmx)

#
# Running...
#
'''
print ("Starting, use Ctrl+C to stop")
print (lj.oscrun)
'''