예제 #1
0
def Display(f):
    l, h = screen_size
    L_SLOPE = 30
    '''
	Mono laser style
	f.Line((0, 0), (l, 0), 0xFFFFFF, gstt.Laser)
	f.LineTo((l, h), 0xFFFFFF, gstt.Laser)
	f.LineTo((0, h), 0xFFFFFF, gstt.Laser)
	f.LineTo((0, 0), 0xFFFFFF, gstt.Laser)
	'''

    #laser = renderer.LaserRenderer(fwork_holder, gstt.centerx, gstt.centery, gstt.zoomx, gstt.zoomy, gstt.sizex, gstt.sizey)

    f.Line((0, 0), (l, 0), c=0xFFFFFF, PL=gstt.Laser)
    f.LineTo((l, h), c=0xFFFFFF, PL=gstt.Laser)
    f.LineTo((0, h), c=0xFFFFFF, PL=gstt.Laser)
    f.LineTo((0, 0), c=0xFFFFFF, PL=gstt.Laser)
    settings.Write()
    #print str(gstt.centerx) + "," + str(gstt.centery) + "," + str(gstt.zoomx) + "," + str(gstt.zoomy) + "," + str(gstt.sizex) + "," + str(gstt.sizey)
    print "Current Laser", gstt.Laser
    print "computing homography", gstt.Laser
    homographyp.newEDH(gstt.Laser)
    '''
예제 #2
0
파일: mainfranken.py 프로젝트: tmplab/LJay
print "Multilaser, multi process and redis style."

if gstt.debug > 0:
    print ""
    print "Needs redis and serverp.py launched to talk to etherdreams"
    print ""
    print "webui/index.html is the WebUI page"
    print "Needs webui/uiserverp.py to talk to WebUI"
    print ""
    print "Autoconfiguring..."

settings.Read()

cli.handle()

settings.Write()

print ""
if gstt.debug == 0:
    print "NO DEBUG"
else:
    print "DEBUG : ", gstt.debug

r = redis.StrictRedis(host=gstt.LjayServerIP, port=6379, db=0)

#raw_input("Hit Enter To Continue!")
#print "Simulator displays point list : ", str(gstt.simuPL)

import midi
import framep
import bhoroscp
예제 #3
0
def handler(path, tags, args, source):

    oscpath = path.split("/")
    pathlength = len(oscpath)
    #print ""
    #print "default handler"
    #print path, oscpath, args

    # /control/matrix/Y/X 0 or 1
    if oscpath[1] == "control" and oscpath[2] == "matrix" and args > 0:
        controlmatrixhandler(oscpath[4], oscpath[3], args)

    # /pad/yx/Y/X 0 or 1
    if oscpath[1] == "pad" and oscpath[2] == "yx":
        pass

    # /pad/rights/note 0 or 1
    if oscpath[1] == "pad" and oscpath[2] == "rights":

        # noteon
        if args[0] == 1:
            note = padrightsnotes[int(oscpath[3])]
            #print "noteon : ", str(note)
            sendme("/noteon", note)

        # noteoff
        if args[0] == 0:
            note = padrightsnotes[int(oscpath[3])]
            #print "noteoff : ", str(note)
            sendme("/noteoff", note)

    # /pad/tops/cc 0 or 1
    if oscpath[1] == "pad" and oscpath[2] == "tops":

        # cc 127
        if args[0] == 1:
            print "cc : ", str(int(oscpath[4]) + 103)
            sendme(''.join(["/cc/", str(int(oscpath[4]) + 103)]), 127)
            status(''.join((oscpath[4], " to 127")))

        # cc 0
        if args[0] == 0:
            print "cc : ", str(int(oscpath[4]) + 103)
            sendme(''.join(["/cc/", str(int(oscpath[4]) + 103)]), 0)
            status(''.join((oscpath[4], " to 0")))
    '''
	Forward/send cc to some other osc server
	# Not my laser -> forward to slave
	if oscpath[1] == "cc" and gstt.MyLaser != gstt.Laser:
		value = int(args[0])
		doit = jumplaser.get(gstt.Laser)
		doit(path,value)
	'''

    # Midi from LPD8 via midiosc

    #if oscpath[1] == "midi" and oscpath[2] == "LPD8":

    # /cc/number value
    if oscpath[1] == "cc":
        number = int(oscpath[2])
        value = int(args[0])
        gstt.cc[number] = value

        print number
        print value

        #print "29: ", str(gstt.cc[29])," 30: ", str(gstt.cc[30])," 31: ", str(gstt.cc[31])

        # send cc to midi devices
        if gstt.tomidi == True:
            midi.MidiMsg((midi.CONTROLLER_CHANGE, number, value))
            status(''.join((oscpath[2], " to ", str(value))))

        # send cc to dmx channel
        if gstt.todmx == True:
            if gstt.serdmx != "":
                mydmx.send(number, value * 2)
                status(''.join((oscpath[2], " to ", str(value * 2))))
            else:
                status("DMX error")

        # Use cc to align laser
        if gstt.tolaser == True and line2 == "Align":
            if number == 1:
                gstt.centerX[gstt.Laser] = value * 20
            if number == 2:
                gstt.centerY[gstt.Laser] = value * 20

        # Use cc to change curve parameters
        if gstt.tolaser == True and line2 == "Curve":
            if number == 1:
                gstt.centerX[gstt.Laser] = value * 20

    # /number
    if oscpath[1] < "9" and oscpath[1] > "0" and len(
            oscpath[1]) == 1 and args[0] > 0:

        if gstt.tolaser == True and line2 == "Curve" and line3 == "Select":
            status(oscpath[1])
            gstt.mode = oscpath[1]

        else:
            gstt.newnumber += oscpath[1]
            print gstt.newnumber
            status(gstt.newnumber)

    # /clear
    if oscpath[1] == "clear" and args[0] > 0:
        gstt.newnumber = ""
        status(gstt.newnumber)

    # /enter
    if oscpath[1] == "enter" and args[0] > 0:

        # new laser number
        if gstt.tolaser == True and line2 == "Select":
            print gstt.newnumber, args
            status(''.join(("Laser : ", gstt.newnumber)))
            gstt.currentlaser = int(gstt.newnumber)
        gstt.newnumber = ""

    # /red
    if oscpath[1] == "red" and args[0] > 0:
        gstt.color[0] = 255
        status("Red On")

    if oscpath[1] == "red" and args[0] == 0:
        gstt.color[0] = 0
        status("Red Off")

    #print gstt.color

    # /green
    if oscpath[1] == "green" and args[0] > 0:
        gstt.color[1] = 255
        status("Green On")

    if oscpath[1] == "green" and args[0] == 0:
        gstt.color[1] = 0
        status("Green Off")

    #print gstt.color

    # /blue
    if oscpath[1] == "blue" and args[0] > 0:
        gstt.color[2] = 255
        status("Blue On")

    if oscpath[1] == "blue" and args[0] == 0:
        gstt.color[2] = 0
        status("Blue Off")
    #print gstt.color

#
# Lasers IP, Swap, loffset, angle, scale, kpps, and intens (actually not implemented in etherdream firmware ?)
#

# /ip/lasernumber value
    if oscpath[1] == "ip":
        print "New IP for laser ", oscpath[2]
        gstt.lasersIPS[int(oscpath[2])] = args[0]
        settings.Write()

    # /kpps/lasernumber value
    # Live change of kpps is not implemented in newdac.py. Change will effect next startup.
    if oscpath[1] == "kpps":
        print "New kpps for laser ", oscpath[2], " next startup", args[0]
        gstt.kpps[int(oscpath[2])] = int(args[0])
        settings.Write()

    # /angle/lasernumber value
    if oscpath[1] == "angle":
        print "New Angle modification for laser ", oscpath[2], ":", args[0]
        gstt.finANGLE[int(oscpath[2])] += int(args[0])
        homographyp.newEDH(int(oscpath[2]))
        settings.Write()

    # /intens/lasernumber value
    if oscpath[1] == "intens":
        print "New intensity requested for laser ", oscpath[2], ":", args[0]
        print "Change not implemented yet"

    # /grid/lasernumber value (0 or 1)
    if oscpath[1] == "grid":

        if args[0] == "1":
            print "Grid requested for laser ", oscpath[2]
            gstt.Laser = int(oscpath[2])
            gstt.GridDisplay[gstt.Laser] = 1
        else:
            print "No grid for laser ", oscpath[2]
            gstt.GridDisplay[gstt.Laser] = 0

    # /mouse/lasernumber value (0 or 1)
    if oscpath[1] == "mouse":

        if args[0] == "1":
            print "Mouse requested for laser ", oscpath[2]
            gstt.Laser = oscpath[2]
        else:
            print "No mouse for laser ", oscpath[2]

    # /swap/X/lasernumber value (0 or 1)
    if oscpath[1] == "swap" and oscpath[2] == "X":

        if args[0] == "0":
            print "swap X : -1 for laser ", oscpath[3]
            gstt.swapX[int(oscpath[3])] = -1
            homographyp.newEDH(int(oscpath[3]))
            settings.Write()

        else:
            print "swap X : 1 for laser ", oscpath[3]
            gstt.swapX[int(oscpath[3])] = 1
            homographyp.newEDH(int(oscpath[3]))
            settings.Write()

    # /swap/Y/lasernumber value (0 or 1)
    if oscpath[1] == "swap" and oscpath[2] == "Y":
        if args[0] == "0":
            print "swap Y : -1 for laser ", oscpath[3]
            gstt.swapY[int(oscpath[3])] = -1
            homographyp.newEDH(int(oscpath[3]))
            settings.Write()
        else:
            print "swap Y : 1 for laser ", oscpath[3]
            gstt.swapY[int(oscpath[3])] = 1
            homographyp.newEDH(int(oscpath[3]))
            settings.Write()

    # /loffset/X/lasernumber value
    if oscpath[1] == "loffset" and oscpath[2] == "X":
        print "offset/X laser ", oscpath[3], "modified : ", args[0]
        gstt.centerX[int(oscpath[3])] -= int(args[0])
        homographyp.newEDH(int(oscpath[3]))
        settings.Write()

    # /loffset/Y/lasernumber value
    if oscpath[1] == "loffset" and oscpath[2] == "Y":
        print "offset/Y laser ", oscpath[3], "modified : ", args[0]
        gstt.centerY[int(oscpath[3])] -= int(args[0])
        homographyp.newEDH(int(oscpath[3]))
        settings.Write()

    # /scale/X/lasernumber value
    if oscpath[1] == "scale" and oscpath[2] == "X":
        print "scale/X laser ", oscpath[3], "modified : ", args[0]
        gstt.zoomX[int(oscpath[3])] += int(args[0])
        homographyp.newEDH(int(oscpath[3]))
        settings.Write()

    # /scale/Y/lasernumber value
    if oscpath[1] == "scale" and oscpath[2] == "Y":
        print "scale/Y laser ", oscpath[3], "modified : ", args[0]
        gstt.zoomY[int(oscpath[3])] += int(args[0])
        homographyp.newEDH(int(oscpath[3]))
        settings.Write()

    # /black/lasernumber value 0
    if oscpath[1] == "black" and oscpath[2] == "1":
        print " Black for laser ", oscpath[2]
        gstt.GridDisplay[int(oscpath[2])] = 2

    if oscpath[1] == "black" and oscpath[2] == "0":
        print "No black for laser", oscpath[2]
        gstt.GridDisplay[int(oscpath[2])] = 0

    #
    # Nozoids
    #

    # /nozoid/mix/number value
    if oscpath[1] == "nozoid" and oscpath[2] == "mix":
        number = int(oscpath[3])
        value = int(args[0])
        print "mix", number, value
        #gstt.OscXY[0] = gstt.mix
        gstt.mix[number] = value

    # /nozoid/vco/number value
    if oscpath[1] == "nozoid" and oscpath[2] == "vco":
        number = int(oscpath[3])
        value = int(args[0])
        print "vco", number, value
        #gstt.OscXY[0] = gstt.vco
        gstt.vco[number] = value

    # /nozoid/lfo/number value
    if oscpath[1] == "nozoid" and oscpath[2] == "lfo":
        number = int(oscpath[3])
        value = int(args[0])
        print "lfo", number, value
        #gstt.OscXY[0] = gstt.lfo
        gstt.lfo[number] = value

    #print "980", oscpath[1], oscpath[2]
    # /nozoid/osc/number value
    if oscpath[1] == "nozoid" and oscpath[2] == "osc":
        number = int(oscpath[3])  #the oscillator/modulator number asked
        value = int(args[0])  #the value of the oscillation/modulation
        #print "default handler for nozoid osc"
        #print "980!!", oscpath[1], oscpath[2]
        #print "osc",number,value
        #gstt.OscXY[0] = gstt.osc
        #this is where we save the value of the current oscillation value of the osc/lfo/cv etc (aka number)
        gstt.osc[number] = value

    if oscpath[1] == "nozoid" and oscpath[2] == "Y":
        number = int(oscpath[3])  #the oscillator/modulator number asked
        value = int(args[0])  #
        gstt.osc[number] = value
        nozY(number, value)

    # /nozoid/knob/number value
    if oscpath[1] == "nozoid" and oscpath[2] == "knob":
        number = int(oscpath[3])
        value = int(args[0])
        print "knob", number, value
        gstt.knob[number] = value
        if number == 3:  #portamento potar
            #gstt.cc[29]=knob2cc(value)

            gstt.XTimeAxe = (knob2XYTime(value) // 100) * 100
            gstt.YTimeAxe = (knob2XYTime(value) // 100) * 100
            print "portamento[%d/%d]" % (value, gstt.XTimeAxe)
            print "adjusting X/YTimeAxe"
예제 #4
0
def Mapping(fwork):
    global mouse_prev, sections

    PL = gstt.Laser
    dots = []

    #switch to edit mode Key E ?
    if gstt.keystates[pygame.K_e] and not gstt.keystates_prev[
            pygame.K_e] and gstt.EditStep == 0:
        print "Switching to Edit Mode"
        gstt.EditStep = 1
        gstt.CurrentWindow = 0
        gstt.CurrentCorner = 0

    # Back to Warp edit Mode if ENTER key is pressed ?
    if gstt.keystates[pygame.K_RETURN] and gstt.EditStep == 1:

        print "Switching to Warp Mode"
        gstt.EditStep = 0
        gstt.CurrentCorner = 0

    # Warp Display and Warp edit Mode
    # Change current corner with mouse position
    # Change corner with Z key

    if gstt.EditStep == 0:

        # print "Warp mode"
        # Left mouse is clicked, modify current Corner coordinate
        # print gstt.mouse

        if gstt.mouse[1][0] == mouse_prev[1][0] and mouse_prev[1][0] == 1:
            deltax = gstt.mouse[0][0] - mouse_prev[0][0]
            deltay = gstt.mouse[0][1] - mouse_prev[0][1]

            gstt.warpdest[gstt.Laser][gstt.CurrentCorner, 0] += (deltax * 20)
            gstt.warpdest[gstt.Laser][gstt.CurrentCorner, 0] += (deltax * 2)

            print "Laser ", gstt.Laser, " Corner ", gstt.CurrentCorner, "deltax ", deltax, "deltay", deltay
            print gstt.warpdest[gstt.Laser]

            homographyp.newEDH(gstt.Laser)
            settings.Write()

        # Change corner if Z key is pressed.
        if gstt.keystates[pygame.K_z] and not gstt.keystates_prev[pygame.K_z]:
            if gstt.CurrentCorner < 4:
                gstt.CurrentCorner += 1
                print "Corner : ", gstt.CurrentCorner

        # Display all windows to current PL for display
        for Window in gstt.Windows:

            dots = []
            for corner in xrange(len(Window)):
                #print "Editing : ", WindowPoints[corner]
                #print Window[corner][0]
                dots.append(
                    proj(int(Window[corner][0]), int(Window[corner][1]), 0))

            fwork.PolyLineOneColor(dots,
                                   c=colorify.rgb2hex(gstt.color),
                                   PL=PL,
                                   closed=False)

        gstt.PL[PL] = fwork.LinesPL(PL)

        mouse_prev = gstt.mouse

    # EDIT WINDOWS MODE : cycle windows for current laser if press e key to adjust corner position
    # ENTER key to warp/display mode
    # Mouse to change current corner postion
    # Z key : next corner
    # E Key : Next window
    # A key : Next section

    if gstt.EditStep > 0:

        dots = []
        CurrentWindowPoints = gstt.Windows[gstt.CurrentWindow]

        # Draw all windows points or "corners"
        for corner in xrange(len(CurrentWindowPoints)):
            dots.append(
                proj(int(CurrentWindowPoints[corner][0]),
                     int(CurrentWindowPoints[corner][1]), 0))
        fwork.PolyLineOneColor(dots,
                               c=colorify.rgb2hex(gstt.color),
                               PL=PL,
                               closed=False)

        # Left mouse is clicked, modify current Corner coordinate
        if gstt.mouse[1][0] == mouse_prev[1][0] and mouse_prev[1][0] == 1:
            deltax = gstt.mouse[0][0] - mouse_prev[0][0]
            deltay = gstt.mouse[0][1] - mouse_prev[0][1]
            CurrentWindowPoints[gstt.CurrentCorner][0] += (deltax * 2)
            CurrentWindowPoints[gstt.CurrentCorner][1] -= (deltay * 2)

        # Change corner if Z key is pressed.
        if gstt.keystates[pygame.K_z] and not gstt.keystates_prev[pygame.K_z]:
            if gstt.CurrentCorner < settings.Mapping(
                    sections[gstt.CurrentSection]) - 1:
                gstt.CurrentCorner += 1
                print "Corner : ", gstt.CurrentCorner

        # E Key : Next window
        if gstt.keystates[pygame.K_e] and not gstt.keystates_prev[pygame.K_e]:

            # Save current Window and switch to the next one.
            if gstt.CurrentWindow < settings.Mapping(
                    sections[gstt.CurrentSection]) - 1:
                print "saving "
                settings.MappingWrite(sections, str(gstt.CurrentWindow),
                                      CurrentWindowPoints)
                gstt.CurrentWindow += 1
                gstt.CurrentCorner = -1
                if gstt.CurrentWindow == settings.Mapping(
                        sections[gstt.CurrentSection]) - 1:
                    gstt.EditStep == 0
                    gstt.CurrentWindow = 0
                print "Now Editing window ", gstt.CurrentWindow

        mouse_prev = gstt.mouse
        gstt.PL[PL] = fwork.LinesPL(PL)

    # A key : Next section ?
    if gstt.keystates[pygame.K_a] and not gstt.keystates_prev[pygame.K_a]:

        print "current section : ", gstt.CurrentSection
        if gstt.CurrentSection < len(sections) - 1:
            gstt.CurrentSection += 1
            print "Next section name is ", sections[gstt.CurrentSection]
            if "screen" in sections[gstt.CurrentSection]:
                print ""
                print "switching to section ", gstt.CurrentSection, " ", sections[
                    gstt.CurrentSection]
                MappingConf(gstt.CurrentSection)
        else:
            gstt.CurrentSection = -1