Beispiel #1
0
def padCC(buttonname, state):

    macronumber = findMacros(buttonname, gstt.BhorealLayers[gstt.BhorealLayer])
    #print('pad2CC :', buttonname, macronumber, state)

    if macronumber != -1:

        # Button pressed
        if state == 1:

            macrocode = macros[gstt.BhorealLayers[
                gstt.BhorealLayer]][macronumber]["code"]
            typevalue = macrocode[macrocode.rfind('/') + 1:]
            values = list(enumerate(maxwellccs.specificvalues[typevalue]))
            init = macros[gstt.BhorealLayers[
                gstt.BhorealLayer]][macronumber]["init"]
            #print("matrix", buttonname, "macrocode", macrocode, "typevalue", typevalue,"macronumber", macronumber, "values", values, "init", init, "value", values[init][1], "cc", maxwellccs.FindCC(macrocode), "=", maxwellccs.specificvalues[typevalue][values[init][1]] )

            if init < 0:

                # toggle button OFF -2 / ON -1
                if init == -2:
                    # goes ON
                    print(macrocode, 'ON')
                    maxwellccs.cc(maxwellccs.FindCC(macrocode), 127,
                                  'to Maxwell 1')
                    macros[gstt.BhorealLayers[
                        gstt.BhorealLayer]][macronumber]["init"] = -1
                else:
                    # goes OFF
                    print(macrocode, 'OFF')
                    maxwellccs.cc(maxwellccs.FindCC(macrocode), 0,
                                  'to Maxwell 1')
                    macros[gstt.BhorealLayers[
                        gstt.BhorealLayer]][macronumber]["init"] = -2

            else:
                # Many buttons (choices)
                # Reset all buttons
                for button in range(macros[gstt.BhorealLayers[
                        gstt.BhorealLayer]][macronumber]["choices"]):
                    SendOSC(
                        gstt.TouchOSCIP, gstt.TouchOSCPort, '/bhoreal/' +
                        macros[gstt.BhorealLayers[gstt.BhorealLayer]]
                        [macronumber]["choice" + str(button)] + '/button', [0])

                maxwellccs.cc(
                    maxwellccs.FindCC(macrocode),
                    maxwellccs.specificvalues[typevalue][values[init][1]],
                    'to Maxwell 1')

        if state == 0:
            # Button released
            print('reselect button /Bhoreal/' + 'm' + buttonname + '/button')
            SendOSC(gstt.TouchOSCIP, gstt.TouchOSCPort,
                    '/bhoreal/' + 'm' + buttonname + '/button', [1])
Beispiel #2
0
def Encoder(macroname, value):

    #print("Encoder : macro", macroname, "value", value)
    macronumber = findMacros(macroname,
                             gstt.BeatstepLayers[gstt.BeatstepLayer])

    if macronumber != -1:
        macrocode = macros[gstt.BeatstepLayers[
            gstt.BeatstepLayer]][macronumber]["code"]
        #print("Beatstep Layer", gstt.BeatstepLayers[gstt.BeatstepLayer], ":",macrocode)

        if macrocode.count('/') > 0:

            # encoder slowly turned to right
            if value == 1:
                maxwellccs.EncoderPlusOne(value, path=macrocode)
                macrocc = maxwellccs.FindCC(macrocode)
                SendOSCUI('/beatstep/' + macroname + '/value',
                          [format(gstt.ccs[0][macrocc], "03d")])

            # encoder fastly turned to right
            if value > 1 and value < 20:
                maxwellccs.EncoderPlusTen(value, path=macrocode)
                macrocc = maxwellccs.FindCC(macrocode)
                SendOSCUI('/beatstep/' + macroname + '/value',
                          [format(gstt.ccs[0][macrocc], "03d")])

            # encoder slowly turned to left
            if value == 127:
                maxwellccs.EncoderMinusOne(value, path=macrocode)
                macrocc = maxwellccs.FindCC(macrocode)
                SendOSCUI('/beatstep/' + macroname + '/value',
                          [format(gstt.ccs[0][macrocc], "03d")])

            # encoder fasly turned to left
            if value < 127 and value > 90:
                maxwellccs.EncoderMinusTen(value, path=macrocode)
                macrocc = maxwellccs.FindCC(macrocode)
                SendOSCUI('/beatstep/' + macroname + '/value',
                          [format(gstt.ccs[0][macrocc], "03d")])

        else:
            print(macrocode + "(" + str(value) + ',"' + macroname + '")')
            eval(macrocode + "(" + str(value) + ',"' + macroname + '")')
    else:
        print("no callback")
    '''
Beispiel #3
0
def UpdatePatch(patchnumber):

    # update iPad UI

    #print('BCR2000 updatePatch', patchnumber)
    # SendOSCUI('/bcr/status', [gstt.BCRLayers[gstt.BCRLayer]])
    for macronumber in range(nbmacro):

        macrocode = macros[gstt.BCRLayers[gstt.BCRLayer]][macronumber]["code"]
        #print()
        #print('number',macronumber, "code",macrocode)

        if macrocode.count('/') > 0:
            macrocc = maxwellccs.FindCC(macrocode)
            macroname = macros[gstt.BCRLayers[
                gstt.BCRLayer]][macronumber]["name"]
            macrolaser = macros[gstt.BCRLayers[
                gstt.BCRLayer]][macronumber]["laser"]

            # Display value
            # print("name",macroname, "cc", macrocc, "value", gstt.ccs[macrolaser][macrocc],"laser", macrolaser)
            SendOSCUI('/bcr/' + macroname + '/value',
                      [format(gstt.ccs[macrolaser][macrocc], "03d")])

            # Display text line 1
            if (macrocode[:macrocode.rfind('/')]
                    in maxwellccs.shortnames) == True:
                # print(macroname,"line 1",maxwellccs.shortnames[macrocode[:macrocode.rfind('/')]])
                SendOSCUI('/bcr/' + macroname + '/line1', [
                    maxwellccs.shortnames[macrocode[:macrocode.rfind('/')]] +
                    " " + macrocode[macrocode.rfind('/') + 1:]
                ])
                #SendOSCUI('/bcr/'+macroname+'/line1', [maxwellccs.shortnames[macrocode[:macrocode.rfind('/')]]])
            else:
                # print(macroname,"line 1",macrocode[:macrocode.rfind('/')])
                SendOSCUI('/bcr/' + macroname + '/line1',
                          [macrocode[:macrocode.rfind('/')]])

            # Display laser number value
            SendOSCUI('/bcr/' + macroname + '/laser', [macrolaser])

        # Code in maxwellccs library : skip "maxwellccs." display only Empty. maxwellccs.Empty will call maxwellccs.Empty()
        elif macrocode.find('maxwellccs') == 0:
            #print("BCR 2000",macronumber, macrocode, '/bcr/'+ macroname+'/line1', macrocode[11:])
            SendOSCUI(
                '/bcr/' +
                macros[gstt.BCRLayers[gstt.BCRLayer]][macronumber]["name"] +
                '/line2', [" "])
            SendOSCUI(
                '/bcr/' +
                macros[gstt.BCRLayers[gstt.BCRLayer]][macronumber]["name"] +
                '/line1', [macrocode[11:]])
            SendOSCUI(
                '/bcr/' +
                macros[gstt.BCRLayers[gstt.BCRLayer]][macronumber]["name"] +
                '/value', [format(gstt.ccs[macrolaser][macrocc], "03d")])
            #print( '/bcr/'+macros[gstt.BCRLayers[gstt.BCRLayer]][macronumber]["name"]+'/value', [format(gstt.ccs[macrolaser][macrocc], "03d")])
        else:
            SendOSCUI('/bcr/' + macroname + '/line1', [macrocode])
Beispiel #4
0
def Rotary(macroname, value):

    print("macro", macroname, "value", value)
    macronumber = findMacros(macroname, gstt.C4Layers[gstt.C4Layer])

    if macronumber != -1:
        macrocode = macros[gstt.C4Layers[gstt.C4Layer]][macronumber]["code"]
        print("C4 Layer", gstt.C4Layers[gstt.C4Layer], ":", macrocode)

        if macrocode.count('/') > 0:

            maxwellccs.EncoderPlusOne(value, path=macrocode)
            macrocc = maxwellccs.FindCC(macrocode)
            SendOSCUI('/C4/' + macroname + '/value',
                      [format(gstt.ccs[0][macrocc], "03d")])

        else:
            print(macrocode + "(" + str(value) + ")")
            eval(macrocode + "(" + str(value) + ")")
    else:
        print("no callback")
Beispiel #5
0
def UpdatePatch(patchnumber):

    #print('C4 updatePatch', patchnumber)

    # update iPad UI
    #SendOSCUI('/C4/status', [gstt.C4Layers[gstt.C4Layer]])

    for macronumber in range(nbmacro):
        #print(macronumber, len(macros[gstt.C4Layers[gstt.C4Layer]]))
        macrocode = macros[gstt.C4Layers[gstt.C4Layer]][macronumber]["code"]
        macroname = macros[gstt.C4Layers[gstt.C4Layer]][macronumber]["name"]
        #print()
        #print('number',macronumber, "code",macrocode, 'name', macroname)

        # OSC command
        if macrocode.count('/') > 0:
            macrocc = maxwellccs.FindCC(macrocode)
            macrolaser = macros[gstt.C4Layers[
                gstt.C4Layer]][macronumber]["laser"]
            macrotype = macros[gstt.C4Layers[
                gstt.C4Layer]][macronumber]["type"]

            # Display VALUE
            #print("name",macroname, "cc", macrocc, "value", gstt.ccs[macrolaser][macrocc],"laser", macrolaser, 'type', macrotype)
            SendOSCUI('/C4/' + macroname + '/value',
                      [format(gstt.ccs[macrolaser][macrocc], "03d")])

            # Display text LINE 1
            if (macrocode[:macrocode.rfind('/')]
                    in maxwellccs.shortnames) == True:

                if macrotype == 'encoder':
                    #SendOSCUI('/C4/'+macroname+'/line1', [maxwellccs.shortnames[macrocode[:macrocode.rfind('/')]]])
                    SendOSCUI('/C4/' + macroname + '/line1', [
                        maxwellccs.shortnames[macrocode[:macrocode.rfind('/')]]
                        + " " + macrocode[macrocode.rfind('/') + 1:]
                    ])

                if macrotype.find('button') > -1:
                    typevalue = macrocode[macrocode.rfind('/') + 1:]
                    values = list(
                        enumerate(maxwellccs.specificvalues[typevalue]))
                    init = macros[gstt.C4Layers[
                        gstt.C4Layer]][macronumber]["init"]
                    #print(values)
                    #print("button",macroname, init, type(values[init][1]))
                    SendOSCUI('/C4/' + macroname + '/line1', [
                        maxwellccs.shortnames[macrocode[:macrocode.rfind('/')]]
                        + " " + values[init][1]
                    ])

            else:
                SendOSCUI('/C4/' + macroname + '/line1',
                          [macrocode[:macrocode.rfind('/')]])
            '''
            # Display text LINE 2
            #if macronumber < 17 or (macronumber > 32 and macronumber < 50):
            if macrotype == 'encoder':

                # Encoders : cc function name like 'curvetype'
                #print("encoders", macrotype)
                SendOSCUI('/C4/'+macroname+'/line2', [macrocode[macrocode.rfind('/')+1:]])
                

            #if macrotype == 'button':
            if macrotype.find('button') >0:

                # button : cc function value like 'Square'
                SendOSCUI('/C4/'+macroname+'/button', [0])
                #typevalue = macrocode[macrocode.rfind('/')+1:]
                #values = list(enumerate(maxwellccs.specificvalues[typevalue]))
                #init = macros[gstt.C4Layers[gstt.C4Layer]][macronumber]["init"]
                #print("button", typevalue, macrotype)
                #print("init", init, "value", values[init][1] )
                SendOSCUI('/C4/'+macroname+'/line2', [values[init][1]])
            '''

            # Display LASER number value
            SendOSCUI('/C4/' + macroname + '/laser', [macrolaser])

        # Code function
        if macrocode.find('.') > 0:
            # maxwellccs.something
            print(macrocode.index('.'))
            SendOSCUI('/C4/' + macroname + '/line1',
                      [macrocode[macrocode.index('.') + 1:]])
Beispiel #6
0
def padCC(buttonname, state):

    macronumber = findMacros(buttonname, gstt.C4Layers[gstt.C4Layer])
    #print('pad2CC :', buttonname, macronumber, state)

    if macronumber != -1:

        # Patch Led ?
        if state == 1:

            macrocode = macros[gstt.C4Layers[
                gstt.C4Layer]][macronumber]["code"]
            typevalue = macrocode[macrocode.rfind('/') + 1:]
            values = list(enumerate(maxwellccs.specificvalues[typevalue]))
            init = macros[gstt.C4Layers[gstt.C4Layer]][macronumber]["init"]
            macrotype = macros[gstt.C4Layers[
                gstt.C4Layer]][macronumber]["type"]
            print("matrix", buttonname, "macrocode", macrocode, "typevalue",
                  typevalue, "macronumber", macronumber, "type", macrotype,
                  "values", values, "init", init, "value", values[init][1],
                  "cc", maxwellccs.FindCC(macrocode), "=",
                  maxwellccs.specificvalues[typevalue][values[init][1]])

            # toggle button : init OFF -2 / ON -1
            if init < 0:

                if init == -2:
                    # goes ON
                    print(macrocode, 'ON')
                    maxwellccs.cc(maxwellccs.FindCC(macrocode), 127,
                                  'to Maxwell 1')
                    macros[gstt.C4Layers[
                        gstt.C4Layer]][macronumber]["init"] = -1
                else:
                    # goes OFF
                    print(macrocode, 'OFF')
                    maxwellccs.cc(maxwellccs.FindCC(macrocode), 0,
                                  'to Maxwell 1')
                    macros[gstt.C4Layers[
                        gstt.C4Layer]][macronumber]["init"] = -2

            if macrotype == 'buttonmulti':

                # Many buttons (choices)
                # Reset all buttons
                macrochoices = list(macros[gstt.C4Layers[gstt.C4Layer]]
                                    [macronumber]["choices"].split(","))
                print("Resetting choices", macrochoices)
                for choice in macrochoices:
                    #print('/C4/'+choice+'/button')
                    SendOSCUI('/C4/' + choice + '/button', [0])
                #for button in range(macros[gstt.C4Layers[gstt.C4Layer]][macronumber]["choices"]):
                #    SendOSCUI('/C4/'+macros[gstt.C4Layers[gstt.LaunchpadLayer]][macronumber]["choice"+str(button)]+'/button', [0])

                print(maxwellccs.FindCC(macrocode),
                      maxwellccs.specificvalues[typevalue][values[init][1]])
                maxwellccs.cc(
                    maxwellccs.FindCC(macrocode),
                    maxwellccs.specificvalues[typevalue][values[init][1]],
                    'to Maxwell 1')
                '''
                # Reset all buttons related to button name (see choices in C4.json)
                for button in range(macros[gstt.C4Layers[gstt.C4Layer]][macronumber]["choices"]):
                    SendOSCUI('/C4/'+macros[gstt.C4Layers[gstt.C4Layer]][macronumber]["choice"+str(button)]+'/button', [0])

            
                maxwellccs.cc(maxwellccs.FindCC(macrocode), maxwellccs.specificvalues[typevalue][values[init][1]], 'to Maxwell 1')
                '''

        if state == 0:
            # Button released
            print('reselect button /C4/' + 'm' + buttonname + '/button')
            SendOSCUI('/C4/' + 'm' + buttonname + '/button', [1])
Beispiel #7
0
def UpdatePatch(patchnumber):

    #print('Beatstep updatePatch', patchnumber)
    # update iPad UI
    # SendOSCUI('/beatstep/status', [gstt.BeatstepLayers[gstt.BeatstepLayer]])
    for macronumber in range(nbmacro):

        macrocode = macros[gstt.BeatstepLayers[
            gstt.BeatstepLayer]][macronumber]["code"]
        #print()
        #print('number',macronumber, "code", macrocode)

        if macrocode.count('/') > 0:
            macrocc = maxwellccs.FindCC(macrocode)
            macroname = macros[gstt.BeatstepLayers[
                gstt.BeatstepLayer]][macronumber]["name"]
            macrolaser = macros[gstt.BeatstepLayers[
                gstt.BeatstepLayer]][macronumber]["laser"]
            #print("macrocc", macrocc)

            # Display value
            #print("name",macroname, "cc", macrocc, "value", gstt.ccs[macrolaser][macrocc],"laser", macrolaser)
            SendOSCUI('/beatstep/' + macroname + '/value',
                      [format(gstt.ccs[macrolaser][macrocc], "03d")])

            # Display text line 1
            if (macrocode[:macrocode.rfind('/')]
                    in maxwellccs.shortnames) == True:
                SendOSCUI(
                    '/beatstep/' + macroname + '/line1',
                    [maxwellccs.shortnames[macrocode[:macrocode.rfind('/')]]])
            else:
                SendOSCUI('/beatstep/' + macroname + '/line1',
                          [macrocode[:macrocode.rfind('/')]])

            # Display text line 2
            if macronumber < 17 or (macronumber > 32 and macronumber < 50):

                # Encoders : cc function name like 'curvetype'
                SendOSCUI('/beatstep/' + macroname + '/line2',
                          [macrocode[macrocode.rfind('/') + 1:]])
            else:

                # button : cc function value like 'Square'
                SendOSCUI('/beatstep/' + macroname + '/button', [0])
                typevalue = macrocode[macrocode.rfind('/') + 1:]
                values = list(enumerate(maxwellccs.specificvalues[typevalue]))
                #print('typevalue', typevalue)
                #print(maxwellccs.specificvalues[typevalue])
                init = macros[gstt.BeatstepLayers[
                    gstt.BeatstepLayer]][macronumber]["init"]
                #print("init", init, "value", values[init][1] )
                SendOSCUI('/beatstep/' + macroname + '/line2',
                          [values[init][1]])

            # Display laser number value
            SendOSCUI('/beatstep/' + macroname + '/laser', [macrolaser])

        # Code in maxwellccs library : skip "maxwellccs." display only Empty. maxwellccs.Empty will call maxwellccs.Empty()
        elif macrocode.find('maxwellccs') == 0:
            #print("BEATSTEP",macronumber, macrocode, '/beatstep/'+ macroname+'/line1', macrocode[11:])
            SendOSCUI(
                '/beatstep/' + macros[gstt.BeatstepLayers[gstt.BeatstepLayer]]
                [macronumber]["name"] + '/line2', [macrocode[11:]])
            SendOSCUI(
                '/beatstep/' + macros[gstt.BeatstepLayers[gstt.BeatstepLayer]]
                [macronumber]["name"] + '/line1', [" "])
            SendOSCUI(
                '/beatstep/' + macros[gstt.BeatstepLayers[
                    gstt.BeatstepLayer]][macronumber]["name"] + '/value',
                [format(gstt.ccs[macrolaser][macrocc], "03d")])
            #print( '/beatstep/'+macros[gstt.BeatstepLayers[gstt.BeatstepLayer]][macronumber]["name"]+'/value', [format(gstt.ccs[macrolaser][macrocc], "03d")])
        else:
            SendOSCUI('/beatstep/' + macroname + '/line1', [macrocode])
Beispiel #8
0
def padCC(buttonname, state):

    macronumber = findMacros(buttonname,
                             gstt.BeatstepLayers[gstt.BeatstepLayer])
    print("padCC buttoname", buttonname, "macronumber", macronumber, "state",
          state)
    macrotype = macros[gstt.BeatstepLayers[
        gstt.BeatstepLayer]][macronumber]["type"]

    macrocode = macros[gstt.BeatstepLayers[
        gstt.BeatstepLayer]][macronumber]["code"]
    typevalue = macrocode[macrocode.rfind('/') + 1:]
    #print("typevalue :", typevalue, macros[gstt.BeatstepLayers[gstt.BeatstepLayer]][macronumber] )
    #values = list(enumerate(maxwellccs.specificvalues[typevalue]))
    #print("matrix :", buttonname, "macrocode :", macrocode, "typevalue :", typevalue,"macronumber :", macronumber, "values :", values, "cc :", maxwellccs.FindCC(macrocode) )
    init = macros[gstt.BeatstepLayers[gstt.BeatstepLayer]][macronumber]["init"]

    # Patch Led ?
    if state > 0:

        SendOSCUI('/beatstep/' + buttonname + '/button', [1])
        typevalue = macrocode[macrocode.rfind('/') + 1:]
        # print("macrocode",macrocode,"typevalue",typevalue)

        init = macros[gstt.BeatstepLayers[
            gstt.BeatstepLayer]][macronumber]["init"]
        #print("matrix", buttonname, "macrocode", macrocode, "typevalue", typevalue,"macronumber", macronumber, "values", values, "init", init, "value", values[init][1], "cc", maxwellccs.FindCC(macrocode), "=", maxwellccs.specificvalues[typevalue][values[init][1]] )
        numbertime[macronumber] = time.time()

        # Toggle Button
        if macrotype == 'buttontoggle':

            # toggle button OFF -2 / ON -1
            if init == -2:
                print(macrocode, 'ON')

                # python function
                if macrocode.count('.') > 0:
                    #print(macrocode+"(0)")
                    eval(macrocode + "(0)")

                # Maxwell function
                elif macrocode.count('/') > 0:
                    #maxwellccs.cc(maxwellccs.FindCC(macrocode), maxwellccs.specificvalues[typevalue][values[init][1]], 'to Maxwell 1')
                    maxwellccs.cc(
                        maxwellccs.FindCC(macrocode),
                        macros[gstt.BeatstepLayers[gstt.BeatstepLayer]]
                        [macronumber]["on"], 'to Maxwell 1')
                    SendOSCUI('/beatstep/' + buttonname + '/led', 1.0)
                    if (macrocode[:macrocode.rfind('/')]
                            in maxwellccs.shortnames) == True:
                        AllStatus(maxwellccs.shortnames[
                            macrocode[:macrocode.rfind('/')]] + " ON")

                    else:
                        AllStatus(macrocode + " ON")

                macros[gstt.BeatstepLayers[
                    gstt.BeatstepLayer]][macronumber]["init"] = -1

            else:
                print(macrocode, 'OFF')
                # python function
                if macrocode.count('.') > 0:
                    #print(macrocode+"OFF("+str(value)+')')
                    print(macrocode + "(0)")
                    eval(macrocode + "(0)")

                # Maxwell function
                elif macrocode.count('/') > 0:
                    #maxwellccs.cc(maxwellccs.FindCC(macrocode), maxwellccs.specificvalues[typevalue][values[init][1]], 'to Maxwell 1')
                    maxwellccs.cc(
                        maxwellccs.FindCC(macrocode),
                        macros[gstt.BeatstepLayers[gstt.BeatstepLayer]]
                        [macronumber]["off"], 'to Maxwell 1')
                    SendOSCUI('/beatstep/' + buttonname + '/led', 0.0)
                    if (macrocode[:macrocode.rfind('/')]
                            in maxwellccs.shortnames) == True:
                        AllStatus(maxwellccs.shortnames[
                            macrocode[:macrocode.rfind('/')]] + " OFF")

                    else:
                        AllStatus(macrocode + " OFF")

                macros[gstt.BeatstepLayers[
                    gstt.BeatstepLayer]][macronumber]["init"] = -2

        # Many buttons (choices)
        if macrotype == 'buttonmulti':

            # Reset all buttons
            values = list(enumerate(maxwellccs.specificvalues[typevalue]))
            macrochoices = list(macros[gstt.BeatstepLayers[gstt.BeatstepLayer]]
                                [macronumber]["choices"].split(","))
            numbertime[findMacros(
                macrochoices[3],
                gstt.BeatstepLayers[gstt.BeatstepLayer])] = time.time()
            for choice in macrochoices:
                SendOSCUI('/beatstep/' + choice + '/button', [0])

            # Do the change
            maxwellccs.cc(
                maxwellccs.FindCC(macrocode),
                maxwellccs.specificvalues[typevalue][values[init][1]],
                'to Maxwell 1')

        # simple action button
        if macrotype == 'button':

            print(macrocode + "()")
            eval(macrocode + "()")
            #print(macrocode+"("+str(value)+',"'+macroname+'")')
            #eval(macrocode+"("+str(value)+',"'+macroname+'")')
        '''
        else:
            # Many buttons (choices)
            # Reset all buttons 
            for button in range(macros[gstt.BeatstepLayers[gstt.BeatstepLayer]][macronumber]["choices"]):
                SendOSCUI('/beatstep/'+macros[gstt.BeatstepLayers[gstt.LaunchpadLayer]][macronumber]["choice"+str(button)]+'/button', [0])

            maxwellccs.cc(maxwellccs.FindCC(macrocode), maxwellccs.specificvalues[typevalue][values[init][1]], 'to Maxwell 1')
        '''

    if state == 0:
        # Button released
        #print('reselect button /beatstep/'+buttonname+'/button')
        print('elapsed push :', buttonname, macrotype, macronumber, state,
              macrocode,
              time.time() - numbertime[macronumber])
        #numbertime[macronumber] = time.time()
        SendOSCUI('/beatstep/' + buttonname + '/button', [0])
        '''
Beispiel #9
0
def MidinProcess(DJqueue):
    #global computer, maxwellprefixLeft, maxwellprefixRight, maxwellsuffix, previousmacro
    global computer, previousmacro

    while True:
        DJqueue_get = DJqueue.get
        msg = DJqueue_get()
        #print (msg)

        # CC rotary -> midi CC.
        if msg[0] == CONTROLLER_CHANGE:

            #print("DJmp3 CC :", msg[1],"value :",msg[2])

            macronumber = findDJMacros(msg[1])
            macro = kindDJMacros(macronumber)
            if macronumber != previousmacro and bhoreal.Here != -1:
                scrolldisp.Display(macros['dj'][macronumber]['Info'],
                                   color=(255, 200, 10),
                                   delay=0.2,
                                   mididest='bhoreal')

            #print(macro, "X ?", macro.find('X'), "/ ?", macro.count('/') )
            print("DJmp3 CC :", msg[1], "value :", msg[2], 'is :', macro)

            # Left or Right X Y Z function selection
            if macro.find('X') != -1 or macro.find('Y') != -1 or macro.find(
                    'Z') != -1:

                # A new prefix -> Build complete path and send it to maxwell
                if macro.find('left') != -1:
                    ResetLeftPrefix()
                    maxwellccs.current["prefixLeft"] = macro
                    print(macro)
                    #maxwellccs.cc(FindCC(maxwellprefixLeft + maxwellsuffix), msg[2], 'to Maxwell 1')

                else:
                    ResetRightPrefix()
                    maxwellccs.current["prefixRight"] = macro
                    print(macro)
                    #maxwellccs.cc(FindCC(maxwellprefixRight + maxwellsuffix), msg[2], 'to Maxwell 1')

                maxwellccs.cc(int(msg[1]), 127, dest=djdest)

            elif macro.count('/') > 0:

                # a center button function
                if macro.find('/center') > -1:
                    maxwellccs.cc(maxwellccs.FindCC(macro), msg[2],
                                  'to Maxwell 1')

                # A complete maxwell function
                if macro.count('/') > 1 and macro.find('/center') == -1:
                    print(macro)
                    maxwellccs.cc(maxwellccs.FindCC(macro), msg[2],
                                  'to Maxwell 1')

                # Suffix value -> Build complete path and send it to maxwell
                if macro.count('/') == 1 and macro.find('/center') == -1:

                    maxwellccs.current["suffix"] = macro
                    # Suffix of maxwell function
                    if nameDJMacros(macronumber).find('left') != -1:
                        #print(maxwellprefixLeft + maxwellsuffix)
                        maxwellccs.cc(
                            maxwellccs.FindCC(
                                maxwellccs.current["prefixLeft"] +
                                maxwellccs.current["suffix"]), msg[2],
                            'to Maxwell 1')

                    else:
                        print(maxwellccs.current["prefixRight"] +
                              maxwellccs.current["suffix"])
                        maxwellccs.cc(
                            maxwellccs.FindCC(
                                maxwellccs.current["prefixRight"] +
                                maxwellccs.current["suffix"]), msg[2],
                            'to Maxwell 1')

            if macro.count('/') == 0:

                #if msg[2] == 127:
                #print("running :", macro)
                eval(macro + "(" + str(msg[2]) + ")")
            '''
            if computer == 0 or computer == 1:
                cc(int(msg[1]), int(msg[2]))

            else: 
                SendOSC(computerIP[computer-1], maxwellatorPort, '/cc', [int(msg[1]), int(msg[2])])
            '''

        previousmacro = macronumber
Beispiel #10
0
def padCC(buttonname, state):

    macronumber = findMacros(buttonname,
                             gstt.LaunchpadLayers[gstt.LaunchpadLayer])
    print('padCC : name', buttonname, "number", macronumber, "state", state)

    if macronumber != -1:

        # Button pressed
        if state == 1:

            macrocode = macros[gstt.LaunchpadLayers[
                gstt.LaunchpadLayer]][macronumber]["code"]
            typevalue = macrocode[macrocode.rfind('/') + 1:]
            values = list(enumerate(maxwellccs.specificvalues[typevalue]))
            init = macros[gstt.LaunchpadLayers[
                gstt.LaunchpadLayer]][macronumber]["init"]
            macrotype = macros[gstt.LaunchpadLayers[
                gstt.LaunchpadLayer]][macronumber]["type"]
            #print("matrix", buttonname, "macrocode", macrocode, "typevalue", typevalue,"macronumber", macronumber, "values", values, "init", init, "value", values[init][1], "cc", maxwellccs.FindCC(macrocode), "=", maxwellccs.specificvalues[typevalue][values[init][1]] )

            if init < 0:

                # toggle button OFF -2 / ON -1
                if init == -2:
                    # goes ON
                    print(macrocode, 'ON')
                    maxwellccs.cc(maxwellccs.FindCC(macrocode), 127,
                                  'to Maxwell 1')
                    macros[gstt.LaunchpadLayers[
                        gstt.LaunchpadLayer]][macronumber]["init"] = -1
                    PadNoteOn(
                        macronumber, macros[gstt.LaunchpadLayers[
                            gstt.LaunchpadLayer]][macronumber]["color"] - 1)
                    print('/pad/' + buttonname + '/led 1')
                    SendOSC(gstt.TouchOSCIP, gstt.TouchOSCPort,
                            '/pad/' + buttonname + '/led', [1])
                else:
                    # goes OFF
                    print(macrocode, 'OFF')
                    maxwellccs.cc(maxwellccs.FindCC(macrocode), 0,
                                  'to Maxwell 1')
                    macros[gstt.LaunchpadLayers[
                        gstt.LaunchpadLayer]][macronumber]["init"] = -2
                    PadNoteOn(
                        macronumber, macros[gstt.LaunchpadLayers[
                            gstt.LaunchpadLayer]][macronumber]["color"])
                    print('/pad/' + buttonname + '/led 0')
                    SendOSC(gstt.TouchOSCIP, gstt.TouchOSCPort,
                            '/pad/' + buttonname + '/led', [0])

            if macrotype == 'buttonmulti':

                # Reset all OSC buttons
                macrochoices = list(macros[gstt.LaunchpadLayers[
                    gstt.LaunchpadLayer]][macronumber]["choices"].split(","))
                #rint("Resetting choices", macrochoices)
                for choice in macrochoices:
                    print(choice, macronumber)
                    SendOSC(gstt.TouchOSCIP, gstt.TouchOSCPort,
                            '/pad/' + choice + '/led', [0])
                    PadNoteOn(
                        findMacros(choice,
                                   gstt.LaunchpadLayers[gstt.LaunchpadLayer]),
                        macros[gstt.LaunchpadLayers[
                            gstt.LaunchpadLayer]][macronumber]["color"])

                #print(maxwellccs.FindCC(macrocode),maxwellccs.specificvalues[typevalue][values[init][1]] )
                maxwellccs.cc(
                    maxwellccs.FindCC(macrocode),
                    maxwellccs.specificvalues[typevalue][values[init][1]],
                    'to Maxwell 1')
                PadNoteOn(
                    macronumber, macros[gstt.LaunchpadLayers[
                        gstt.LaunchpadLayer]][macronumber]["color"] - 1)
                SendOSC(gstt.TouchOSCIP, gstt.TouchOSCPort,
                        '/pad/' + buttonname + '/led', [1])

        if state == 0:
            # Button released
            print('reselect button /Launchpad/' + 'm' + buttonname + '/button')
            SendOSC(gstt.TouchOSCIP, gstt.TouchOSCPort,
                    '/pad/' + buttonname + '/led', [1])
Beispiel #11
0
def UpdateDisplay():

    print('Launchpad Update Display...')
    #ClsMatrix()

    # Reseting small OSC leds
    '''
    for led in range(0,nbmacro,1):
        print(led, "off")
        SendOSC(gstt.TouchOSCIP, gstt.TouchOSCPort, '/bhoreal/' + macros[gstt.LaunchpadLayers[gstt.LaunchpadLayer]][led]["name"]+'/led', [0.0])
    '''

    for led in range(0, 8, 1):

        # first launchpad line is first maxwell presets line
        if str(led + 1) in gstt.patchs['pattrstorage']['slots'] != False:
            PadNoteOn(led, 127)
        else:
            PadNoteOn(led, 64)

        # second launchpad line is 3rd maxwell presets line
        if str(16 + led + 1) in gstt.patchs['pattrstorage']['slots'] != False:
            PadNoteOn(8 + led, 127)
        else:
            PadNoteOn(8 + led, 64)

        # 3rd launchpad line is 5th maxwell presets line
        if str(32 + led + 1) in gstt.patchs['pattrstorage']['slots'] != False:
            PadNoteOn(16 + led, 127)
        else:
            PadNoteOn(16 + led, 64)

    for led in range(24, nbmacro, 1):
        # light up hardware Launchpad led
        PadNoteOn(
            led,
            macros[gstt.LaunchpadLayers[gstt.LaunchpadLayer]][led]["color"])

        macrocode = macros[gstt.LaunchpadLayers[
            gstt.LaunchpadLayer]][led]["code"]
        macrotype = macros[gstt.LaunchpadLayers[
            gstt.LaunchpadLayer]][led]["type"]
        macrocc = maxwellccs.FindCC(macrocode)
        macrolaser = macros[gstt.LaunchpadLayers[
            gstt.LaunchpadLayer]][led]["laser"]
        macroname = macros[gstt.LaunchpadLayers[
            gstt.LaunchpadLayer]][led]["name"]
        buttonname = macroname
        SendOSC(gstt.TouchOSCIP, gstt.TouchOSCPort,
                '/pad/' + macroname + '/led', [0.0])
        #print(macrocode,macros[gstt.LaunchpadLayers[gstt.LaunchpadLayer]][led])
        macronumber = findMacros(macroname,
                                 gstt.LaunchpadLayers[gstt.LaunchpadLayer])

        # Maxwell osc commmand like /lfo/1/freq
        if (macrocode[:macrocode.rfind('/')] in maxwellccs.shortnames) == True:

            # OSC button : Display short text with type value like sin, saw,...
            typevalue = macrocode[macrocode.rfind('/') + 1:]
            values = list(enumerate(maxwellccs.specificvalues[typevalue]))
            init = macros[gstt.LaunchpadLayers[
                gstt.LaunchpadLayer]][led]["init"]
            SendOSC(gstt.TouchOSCIP, gstt.TouchOSCPort, '/pad/' + macroname, [
                maxwellccs.shortnames[macrocode[:macrocode.rfind('/')]] + " " +
                values[init][1]
            ])
            #PadNoteOn(macronumber, macros[gstt.LaunchpadLayers[gstt.LaunchpadLayer]][macronumber]["color"])

            if macrotype == 'buttonmulti':
                # Need to be optimized : this part will be done as many times as many buttons.
                # Reset all OSC buttons
                macrochoices = list(macros[gstt.LaunchpadLayers[
                    gstt.LaunchpadLayer]][macronumber]["choices"].split(","))
                #print("Resetting choices", macrochoices)
                for choice in macrochoices:
                    #print(choice, macronumber, gstt.ccs[macrolaser][macrocc], maxwellccs.FindCC(macrocode), maxwellccs.specificvalues[typevalue][values[init][1]])
                    SendOSC(gstt.TouchOSCIP, gstt.TouchOSCPort,
                            '/pad/' + choice + '/led', [0])
                    PadNoteOn(
                        findMacros(choice,
                                   gstt.LaunchpadLayers[gstt.LaunchpadLayer]),
                        macros[gstt.LaunchpadLayers[
                            gstt.LaunchpadLayer]][macronumber]["color"])

                #maxwellccs.cc(maxwellccs.FindCC(macrocode), maxwellccs.specificvalues[typevalue][values[init][1]], 'to Maxwell 1')
                #PadNoteOn(macronumber, macros[gstt.LaunchpadLayers[gstt.LaunchpadLayer]][macronumber]["color"]-1)
                #SendOSC(gstt.TouchOSCIP, gstt.TouchOSCPort, '/pad/'+buttonname+'/led', [1])
                #print(macronumber, macroname,macrocode,"CC",maxwellccs.FindCC(macrocode), "cc value", gstt.ccs[macrolaser][macrocc],"macrochoices", macrochoices,"values", values,"initvalue",maxwellccs.maxwell['ccs'][maxwellccs.FindCC(macrocode)]['init'])
                #print(macronumber, macroname,macrocode,"CC",maxwellccs.FindCC(macrocode), "cc value", gstt.ccs[macrolaser][macrocc],"macrochoices", macrochoices)
                if gstt.ccs[macrolaser][macrocc] == 0:
                    SendOSC(gstt.TouchOSCIP, gstt.TouchOSCPort,
                            '/pad/' + macrochoices[0] + '/led', [1])
                    PadNoteOn(
                        findMacros(macrochoices[0],
                                   gstt.LaunchpadLayers[gstt.LaunchpadLayer]),
                        macros[gstt.LaunchpadLayers[
                            gstt.LaunchpadLayer]][macronumber]["color"] - 1)
                    #PadNoteOn(led, macros[gstt.LaunchpadLayers[gstt.LaunchpadLayer]][macronumber]["color"]-1)
                    #print(macrochoices[0])
                if gstt.ccs[macrolaser][macrocc] == 127:
                    SendOSC(gstt.TouchOSCIP, gstt.TouchOSCPort,
                            '/pad/' + macrochoices[1] + '/led', [1])
                    PadNoteOn(
                        findMacros(macrochoices[1],
                                   gstt.LaunchpadLayers[gstt.LaunchpadLayer]),
                        macros[gstt.LaunchpadLayers[
                            gstt.LaunchpadLayer]][macronumber]["color"] - 1)
                    #print(macrochoices[1])
                if gstt.ccs[macrolaser][macrocc] == 254:
                    SendOSC(gstt.TouchOSCIP, gstt.TouchOSCPort,
                            '/pad/' + macrochoices[2] + '/led', [1])
                    PadNoteOn(
                        findMacros(macrochoices[2],
                                   gstt.LaunchpadLayers[gstt.LaunchpadLayer]),
                        macros[gstt.LaunchpadLayers[
                            gstt.LaunchpadLayer]][macronumber]["color"] - 1)
                    #print(macrochoices[2])
                if gstt.ccs[macrolaser][macrocc] == 381:
                    SendOSC(gstt.TouchOSCIP, gstt.TouchOSCPort,
                            '/pad/' + macrochoices[3] + '/led', [1])
                    PadNoteOn(
                        findMacros(macrochoices[3],
                                   gstt.LaunchpadLayers[gstt.LaunchpadLayer]),
                        macros[gstt.LaunchpadLayers[
                            gstt.LaunchpadLayer]][macronumber]["color"] - 1)
                    #print(macrochoices[3])

            if gstt.ccs[macrolaser][
                    macrocc] == 127 and macrotype != 'buttonmulti':
                #print(macronumber, gstt.ccs[macrolaser][macrocc], maxwellccs.FindCC(macrocode), maxwellccs.specificvalues[typevalue][values[init][1]], macros[gstt.LaunchpadLayers[gstt.LaunchpadLayer]][macronumber]["color"]-1)
                SendOSC(gstt.TouchOSCIP, gstt.TouchOSCPort,
                        '/pad/' + macroname + '/led', [1])
                PadNoteOn(
                    macronumber, macros[gstt.LaunchpadLayers[
                        gstt.LaunchpadLayer]][macronumber]["color"] - 1)
            #SendOSC(gstt.TouchOSCIP, gstt.TouchOSCPort, '/pad/' + macros[gstt.LaunchpadLayers[gstt.LaunchpadLayer]][led]["name"], [maxwellccs.shortnames[macrocode[:macrocode.rfind('/')]]+" "+macrocode[macrocode.rfind('/')+1:]])
            ###SendOSC(gstt.TouchOSCIP, gstt.TouchOSCPort, '/pad/' + macros[gstt.LaunchpadLayers[gstt.LaunchpadLayer]][led]["name"], [maxwellccs.shortnames[macrocode[:macrocode.rfind('/')]]])

        # Code in maxwellccs library : skip "maxwellccs." display only Empty. maxwellccs.Empty will call maxwellccs.Empty()
        elif macrocode.find('maxwellccs') == 0:
            SendOSC(gstt.TouchOSCIP, gstt.TouchOSCPort, '/pad/' + macroname,
                    [macrocode[11:]])

        else:
            SendOSC(gstt.TouchOSCIP, gstt.TouchOSCPort, '/pad/' + macroname,
                    [macrocode])
Beispiel #12
0
def padCC(buttonname, state):

    macronumber = findMacros(buttonname,
                             gstt.SequencerLayers[gstt.SequencerLayer])
    macrotype = macros[gstt.SequencerLayers[
        gstt.SequencerLayer]][macronumber]["type"]
    #print()
    print("in Sequencer padCC buttoname", buttonname, "in",
          gstt.SequencerLayers[gstt.SequencerLayer], "macronumber",
          macronumber, "state", state)

    #if macronumber != -1:

    # Patch Led ?
    if state > 0:

        SendOSCUI('/Sequencer/' + buttonname + '/button', [1])
        macrocode = macros[gstt.SequencerLayers[
            gstt.SequencerLayer]][macronumber]["code"]
        typevalue = macrocode[macrocode.rfind('/') + 1:]
        values = list(enumerate(maxwellccs.specificvalues[typevalue]))
        init = macros[gstt.SequencerLayers[
            gstt.SequencerLayer]][macronumber]["init"]
        #print("matrix", buttonname, "macrocode", macrocode, "typevalue", typevalue,"macronumber", macronumber, "values", values, "init", init, "value", values[init][1], "cc", maxwellccs.FindCC(macrocode), "=", maxwellccs.specificvalues[typevalue][values[init][1]] )
        numbertime[macronumber] = time.time()

        # Toggle Button
        if macrotype == 'buttontoggle':

            # toggle button OFF -2 / ON -1
            if init == -2:
                # goes ON
                print(macrocode, 'ON')
                maxwellccs.cc(maxwellccs.FindCC(macrocode), 127,
                              'to Maxwell 1')
                macros[gstt.SequencerLayers[
                    gstt.SequencerLayer]][macronumber]["init"] = -1
            else:
                # goes OFF
                print(macrocode, 'OFF')
                maxwellccs.cc(maxwellccs.FindCC(macrocode), 0, 'to Maxwell 1')
                macros[gstt.SequencerLayers[
                    gstt.SequencerLayer]][macronumber]["init"] = -2

        # Many buttons (choices)
        if macrotype == 'buttonmulti':

            # Reset all buttons
            macrochoices = list(macros[gstt.SequencerLayers[
                gstt.SequencerLayer]][macronumber]["choices"].split(","))
            numbertime[findMacros(
                macrochoices[3],
                gstt.SequencerLayers[gstt.SequencerLayer])] = time.time()
            for choice in macrochoices:
                SendOSCUI('/Sequencer/' + choice + '/button', [0])

            # Do the change
            maxwellccs.cc(
                maxwellccs.FindCC(macrocode),
                maxwellccs.specificvalues[typevalue][values[init][1]],
                'to Maxwell 1')
        '''
        # simple action button
        if macrotype =='button':

            print(macrocode+"("+str(value)+',"'+macroname+'")')
            eval(macrocode+"("+str(value)+',"'+macroname+'")')
        '''
        '''
        else:
            # Many buttons (choices)
            # Reset all buttons 
            for button in range(macros[gstt.SequencerLayers[gstt.SequencerLayer]][macronumber]["choices"]):
                SendOSCUI('/Sequencer/'+macros[gstt.SequencerLayers[gstt.LaunchpadLayer]][macronumber]["choice"+str(button)]+'/button', [0])

            maxwellccs.cc(maxwellccs.FindCC(macrocode), maxwellccs.specificvalues[typevalue][values[init][1]], 'to Maxwell 1')
        '''

    if state == 0:
        # Button released
        macrocode = macros[gstt.SequencerLayers[
            gstt.SequencerLayer]][macronumber]["code"]
        #print('reselect button /Sequencer/'+buttonname+'/button')
        print('elapsed push :', buttonname, macrotype, macronumber, state,
              macrocode,
              time.time() - numbertime[macronumber])
        #numbertime[macronumber] = time.time()
        SendOSCUI('/Sequencer/' + buttonname + '/button', [0])

        if macronumber != -1 and macrotype == 'button':
            value = 0

            print("Sequencer : " + macrocode + "(" + str(value) + ',"' +
                  buttonname + '")')
            eval(macrocode + "(" + str(value) + ',"' + buttonname + '")')
Beispiel #13
0
def MidinProcess(SEQUENCERqueue):
    global computer

    while True:

        SEQUENCERqueue_get = SEQUENCERqueue.get
        msg = SEQUENCERqueue_get()
        print()
        print("Sequencer got msg ;", msg[0], msg[1], msg[2])

        # NOTE ON message on all midi channel (will trigger even if midivel = 0)
        if NOTE_ON - 1 < msg[0] < 160:

            MidiChannel = msg[0] - 143
            MidiNote = msg[1]
            MidiVel = msg[2]
            print("Sequencer NOTE ON :", MidiNote, 'velocity :', MidiVel,
                  "Channel", MidiChannel)

            # ZnotesLcc
            if len(macros["ZnotesLcc"]) > 0:

                for counter in range(len(macros["ZnotesLcc"])):
                    '''
                    print()
                    print("Name", macros["ZnotesLcc"][counter]["name"])
                    print("Song", macros["ZnotesLcc"][counter]["songname"], gstt.songs[gstt.song])    # name, "all"
                    print("Channel", macros["ZnotesLcc"][counter]["chanIN"], MidiChannel)             # number, "all"
                    print("Note", macros["ZnotesLcc"][counter]["notes"], MidiNote)                    # number, "all"
                    print("Notetype", macros["ZnotesLcc"][counter]["notetype"], "on")                 # "on", "off", "all"
                    '''

                    if (macros["ZnotesLcc"][counter]["songname"]
                            == gstt.songs[gstt.song] or macros["ZnotesLcc"]
                        [counter]["songname"] == "all") and (
                            macros["ZnotesLcc"][counter]["chanIN"]
                            == MidiChannel
                            or macros["ZnotesLcc"][counter]["chanIN"] == "all"
                        ) and (
                            macros["ZnotesLcc"][counter]["notes"] == MidiNote
                            or macros["ZnotesLcc"][counter]["notes"] == "all"
                        ) and (macros["ZnotesLcc"][counter]["notetype"] == "on"
                               or macros["ZnotesLcc"][counter]["notetype"]
                               == "all"):
                        macrocode = macros["ZnotesLcc"][counter]["code"]
                        #print("ZnotesLcc Note ON",macros["ZnotesLcc"][counter]["songname"], ":", macros["ZnotesLcc"][counter]["name"])
                        #print("ZnotesLcc NoteON got Song :", macros["ZnotesLcc"][counter]["songname"],"  IN Channel :", macros["ZnotesLcc"][counter]["chanIN"],"  Code :", macros["ZnotesLcc"][counter]["code"], "  CC", maxwellccs.FindCC(macros["ZnotesLcc"][counter]["code"]), "  value :",macros["ZnotesLcc"][counter]["value"], "  laser :", macros["ZccLcc"][counter]["laser"] )

                        # python function
                        if macrocode.count('.') > 0 and MidiVel > 0:
                            #print(macrocode+"("+str(MidiNote)+')')
                            eval(macrocode + "(" + str(MidiNote) + ')')

                        # Maxwell function
                        elif macrocode.count('/') > 0 and MidiVel > 0:
                            midi3.MidiMsg(
                                (CONTROLLER_CHANGE,
                                 maxwellccs.FindCC(
                                     macros["ZnotesLcc"][counter]["code"]),
                                 macros["ZnotesLcc"][counter]["value"]),
                                mididest,
                                laser=macros["ZccLcc"][counter]["laser"])

            # Note ON Specials features
            if len(macros["Specials"]) > 0:

                for counter in range(len(macros["Specials"])):
                    '''
                    print()
                    print("Name", macros["Specials"][counter]["name"])
                    print("Song", macros["Specials"][counter]["songname"], gstt.songs[gstt.song])    # name, "all"
                    print("Channel", macros["Specials"][counter]["chanIN"], MidiChannel)             # number, "all"
                    print("Note", macros["Specials"][counter]["notes"], MidiNote)                    # number, "all"
                    print("Notetype", macros["Specials"][counter]["notetype"], "on")                 # "on", "off", "all"
                    '''

                    if (
                            macros["Specials"][counter]["songname"]
                            == gstt.songs[gstt.song]
                            or macros["Specials"][counter]["songname"] == "all"
                    ) and (macros["Specials"][counter]["chanIN"] == MidiChannel
                           or macros["Specials"][counter]["chanIN"]
                           == "all") and (
                               macros["Specials"][counter]["notes"] == MidiNote
                               or macros["Specials"][counter]["notes"] == "all"
                           ) and (macros["Specials"][counter]["notetype"]
                                  == "on"
                                  or macros["Specials"][counter]["notetype"]
                                  == "all"):
                        macrocode = macros["Specials"][counter]["code"]
                        # print("Specials function :",macros["Specials"][counter]["songname"], ":", macros["Specials"][counter]["name"], macrocode)

                        # python function
                        if macrocode.count('.') > 0 and MidiVel > 0:
                            #print(macrocode+"("+str(MidiNote)+')')
                            eval(macrocode + "(" + str(MidiNote) + ')')

                        # Maxwell function
                        elif macrocode.count('/') > 0 and MidiVel > 0:
                            #print("Specials NoteON got Song :", macros["Specials"][counter]["songname"],"  IN Channel :", macros["Specials"][counter]["chanIN"],"  Code :", macrocode, "  CC", maxwellccs.FindCC(macros["Specials"][counter]["code"]), "  value :",macros["Specials"][counter]["value"], "  laser :", macros["ZccLcc"][counter]["laser"] )
                            midi3.MidiMsg(
                                (CONTROLLER_CHANGE,
                                 maxwellccs.FindCC(
                                     macros["Specials"][counter]["code"]),
                                 macros["Specials"][counter]["value"]),
                                mididest,
                                laser=macros["Specials"][counter]["laser"])

        # Note Off or Note with 0 velocity on all midi channels
        if NOTE_OFF - 1 < msg[0] < 144 or (NOTE_ON - 1 < msg[0] < 160
                                           and msg[2] == 0):

            if msg[0] > 144:
                MidiChannel = msg[0] - 143
            else:
                MidiChannel = msg[0] - 128

            MidiNote = msg[1]

            print("Sequencer NOTE OFF :", MidiNote, "Channel", MidiChannel)

            # ZnotesLcc
            if len(macros["ZnotesLcc"]) > 0:

                for counter in range(len(macros["ZnotesLcc"])):
                    '''
                    print()
                    print("Name", macros["ZnotesLcc"][counter]["name"])
                    print("Song", macros["ZnotesLcc"][counter]["songname"], gstt.songs[gstt.song])    # name, "all"
                    print("Channel", macros["ZnotesLcc"][counter]["chanIN"], MidiChannel)             # number, "all"
                    print("Note", macros["ZnotesLcc"][counter]["notes"], MidiNote)                    # number, "all"
                    print("Notetype", macros["ZnotesLcc"][counter]["notetype"], "on")                 # "on", "off", "all"
                    '''

                    if (macros["ZnotesLcc"][counter]["songname"]
                            == gstt.songs[gstt.song] or macros["ZnotesLcc"]
                        [counter]["songname"] == "all") and (
                            macros["ZnotesLcc"][counter]["chanIN"]
                            == MidiChannel
                            or macros["ZnotesLcc"][counter]["chanIN"] == "all"
                        ) and (
                            macros["ZnotesLcc"][counter]["notes"] == MidiNote
                            or macros["ZnotesLcc"][counter]["notes"] == "all"
                        ) and (macros["ZnotesLcc"][counter]["notetype"]
                               == "off"
                               or macros["ZnotesLcc"][counter]["notetype"]
                               == "all"):
                        #print("ZnotesLcc Note OFF",macros["ZnotesLcc"][counter]["songname"], ":", macros["ZnotesLcc"][counter]["name"])
                        #print("ZnotesLcc Note OFF got Song :", macros["ZnotesLcc"][counter]["songname"],"  IN Channel :", macros["ZnotesLcc"][counter]["chanIN"],"  Code :", macros["ZnotesLcc"][counter]["code"], "  CC", maxwellccs.FindCC(macros["ZnotesLcc"][counter]["code"]), "  value :",macros["ZnotesLcc"][counter]["value"], "  laser :", macros["ZccLcc"][counter]["laser"])

                        macrocode = macros["ZnotesLcc"][counter]["code"]
                        #print("ZnotesLcc Note ON",macros["ZnotesLcc"][counter]["songname"], ":", macros["ZnotesLcc"][counter]["name"])
                        #print("ZnotesLcc NoteON got Song :", macros["ZnotesLcc"][counter]["songname"],"  IN Channel :", macros["ZnotesLcc"][counter]["chanIN"],"  Code :", macros["ZnotesLcc"][counter]["code"], "  CC", maxwellccs.FindCC(macros["ZnotesLcc"][counter]["code"]), "  value :",macros["ZnotesLcc"][counter]["value"], "  laser :", macros["ZccLcc"][counter]["laser"] )

                        # python function
                        if macrocode.count('.') > 0 and MidiVel > 0:
                            #print(macrocode+"("+str(MidiNote)+')')
                            eval(macrocode + "(" + str(MidiNote) + ')')

                        # Maxwell function
                        elif macrocode.count('/') > 0 and MidiVel > 0:

                            midi3.MidiMsg(
                                (CONTROLLER_CHANGE,
                                 maxwellccs.FindCC(
                                     macros["ZnotesLcc"][counter]["code"]),
                                 macros["ZnotesLcc"][counter]["value"]),
                                mididest,
                                laser=macros["ZccLcc"][counter]["laser"])

        # PROGRAM CHANGE button selected : change destination computer
        if msg[0] == PROGRAM_CHANGE:

            print("Sequencer Program change : ", str(msg[1]))
            # Change destination computer mode
            print("Destination computer", int(msg[1]))
            computer = int(msg[1])

        # CC on all Midi Channels
        if CONTROLLER_CHANGE - 1 < msg[0] < 192:

            MidiChannel = msg[0] - 176
            MidiCC = msg[1]
            MidiVal = msg[2]
            print("Sequencer got CC :", MidiCC, " Value :", MidiVal,
                  "Channel :", MidiChannel)
            '''
            if computer == 0 or computer == 1:

                macroname= "m"+str(msg[1]) 
                macroargs = msg[2]
                Encoder(macroname, macroargs)

            else: 
                SendOSC(gstt.computerIP[computer-1], gstt.MaxwellatorPort, '/cc', [int(msg[1]), int(msg[2])])
            '''
            # ZccLcc
            if len(macros["ZccLcc"]) > 0:

                for counter in range(len(macros["ZccLcc"])):

                    if (macros["ZccLcc"][counter]["songname"]
                            == gstt.songs[gstt.song]
                            or macros["ZccLcc"][counter]["songname"] == "all"
                        ) and (
                            macros["ZccLcc"][counter]["chanIN"] == MidiChannel
                            or macros["ZccLcc"][counter]["chanIN"] == "all"
                        ) and (macros["ZccLcc"][counter]["ccs"] == MidiCC
                               or macros["ZccLcc"][counter]["ccs"] == "all"):
                        #print(macros["ZccLcc"][counter]["songname"], ":", macros["ZccLcc"][counter]["name"])
                        macrocode = macros["ZccLcc"][counter]["code"]

                        # python function
                        if macrocode.count('.') > 0:
                            #print(macrocode+"("+str(MidiCC)+","+str(MidiVal)+')')
                            eval(macrocode + "(" + str(MidiCC) + ',"' +
                                 str(MidiVal) + '")')

                        # Maxwell function
                        elif macrocode.count('/') > 0:

                            print(
                                "In Sequencer ZccLcc got song :",
                                macros["ZccLcc"][counter]["songname"],
                                "  IN Channel :",
                                macros["ZccLcc"][counter]["chanIN"],
                                "  Code :",
                                macros["ZccLcc"][counter]["code"],
                                "  value :",
                                macros["ZnotesLcc"][counter]["value"],
                            )
                            midi3.MidiMsg(
                                (CONTROLLER_CHANGE,
                                 maxwellccs.FindCC(
                                     macros["ZccLcc"][counter]["code"]),
                                 macros["ZccLcc"][counter]["value"]),
                                mididest,
                                laser=macros["ZccLcc"][counter]["laser"])

            # CC Specials features
            if len(macros["Specials"]) > 0:

                for counter in range(len(macros["Specials"])):

                    if (
                            macros["Specials"][counter]["songname"]
                            == gstt.songs[gstt.song]
                            or macros["Specials"][counter]["songname"] == "all"
                    ) and (macros["Specials"][counter]["chanIN"] == MidiChannel
                           or macros["Specials"][counter]["chanIN"]
                           == "all") and (
                               macros["Specials"][counter]["ccs"] == MidiCC
                               or macros["Specials"][counter]["ccs"] == "all"
                           ) and (macros["Specials"][counter]["notetype"]
                                  == "on"
                                  or macros["Specials"][counter]["notetype"]
                                  == "all"):
                        macrocode = macros["Specials"][counter]["code"]
                        # print("Specials CC function :",macros["Specials"][counter]["songname"], ":", macros["Specials"][counter]["name"], macrocode)

                        # python function
                        if macrocode.count('.') > 0:
                            #print(macrocode+"("+str(MidiCC)+","+str(MidiVal)+')')
                            eval(macrocode + "(" + str(MidiCC) + ',"' +
                                 str(MidiVal) + '")')

                        # Maxwell function
                        elif macrocode.count('/') > 0:
                            print(
                                "In sequencer Specials NoteON got Song :",
                                macros["Specials"][counter]["songname"],
                                "  IN Channel :",
                                macros["Specials"][counter]["chanIN"],
                                "  Code :", macrocode, "  CC",
                                maxwellccs.FindCC(
                                    macros["Specials"][counter]["code"]),
                                "  value :",
                                macros["Specials"][counter]["value"],
                                "  laser :",
                                macros["ZccLcc"][counter]["laser"])
                            midi3.MidiMsg(
                                (CONTROLLER_CHANGE,
                                 maxwellccs.FindCC(
                                     macros["Specials"][counter]["code"]),
                                 macros["Specials"][counter]["value"]),
                                mididest,
                                laser=macros["Specials"][counter]["laser"])
        '''
        # Pads are on channel 10
        if msg[0] == CONTROLLER_CHANGE + 10 -1:
        #if msg[0] == CONTROLLER_CHANGE + 10 -1 and msg[2] > 0:
            
            # if button cc number = m grid position
            #print("channel 10 macro","m"+str(msg[1]) , "ccnumber",msg[1], "value", msg[2], macros[gstt.SequencerLayers[gstt.SequencerLayer]][msg[1]]["code"])
            #padCC('m'+str(msg[1]), msg[2])
            
            # if button is actually the cc number
            macronumber, state = findCCMacros(msg[1], msg[2], gstt.SequencerLayers[gstt.SequencerLayer])
            print("channel 10 macro","m"+str(msg[1]), "ccnumber",msg[1], "value", msg[2], "name", macros[gstt.SequencerLayers[gstt.SequencerLayer]][macronumber]["name"], "macronumber", macronumber,"state", state, "code", macros[gstt.SequencerLayers[gstt.SequencerLayer]][macronumber]["code"])
            
            padCC(macros[gstt.SequencerLayers[gstt.SequencerLayer]][macronumber]["name"],state)
        '''
        '''
Beispiel #14
0
def UpdatePatch(patchnumber):

    #print('lpd8 updatePatch', patchnumber)
    # update iPad UI
    #SendOSCUI('/lpd8/status', [gstt.lpd8Layers[gstt.lpd8Layer]])
    for macronumber in range(nbmacro):

        macrocode = macros[gstt.lpd8Layers[
            gstt.lpd8Layer]][macronumber]["code"]
        macroname = macros[gstt.lpd8Layers[
            gstt.lpd8Layer]][macronumber]["name"]
        macrotype = macros[gstt.lpd8Layers[
            gstt.lpd8Layer]][macronumber]["type"]
        #typevalue = macrocode[macrocode.rfind('/')+1:]

        #print()
        # print('number',macronumber, "code",macrocode, "name", macroname, "type", macrotype)

        if macrocode.count('/') > 0:
            macrocc = maxwellccs.FindCC(macrocode)
            macrolaser = macros[gstt.lpd8Layers[
                gstt.lpd8Layer]][macronumber]["laser"]

            # Display value
            #print("name",macroname, "cc", macrocc, "value", gstt.ccs[macrolaser][macrocc],"laser", macrolaser)
            SendOSCUI('/lpd8/' + macroname + '/value',
                      [format(gstt.ccs[macrolaser][macrocc], "03d")])

            # Display text line 1
            if (macrocode[:macrocode.rfind('/')]
                    in maxwellccs.shortnames) == True:
                SendOSCUI(
                    '/lpd8/' + macroname + '/line1',
                    [maxwellccs.shortnames[macrocode[:macrocode.rfind('/')]]])
            else:
                SendOSCUI('/lpd8/' + macroname + '/line1',
                          [macrocode[:macrocode.rfind('/')]])

            # Display text line 2
            if macronumber < 17 or (macronumber > 32 and macronumber < 50):

                # Encoders : cc function name like 'curvetype'
                SendOSCUI('/lpd8/' + macroname + '/line2',
                          [macrocode[macrocode.rfind('/') + 1:]])
            else:

                # button : cc function value like 'Square'
                SendOSCUI('/lpd8/' + macroname + '/button', [0])
                typevalue = macrocode[macrocode.rfind('/') + 1:]
                #print('typevalue', typevalue)
                if (typevalue in maxwellccs.specificvalues) == True:
                    #print(maxwellccs.specificvalues[typevalue])
                    values = list(
                        enumerate(maxwellccs.specificvalues[typevalue]))
                    init = macros[gstt.lpd8Layers[
                        gstt.lpd8Layer]][macronumber]["init"]
                    #print("init", init, "value", values[init][1] )
                    SendOSCUI('/lpd8/' + macroname + '/line2',
                              [values[init][1]])
                    print("line2", values[init][1])
                else:
                    SendOSCUI('/lpd8/' + macroname + '/line2', typevalue)
                    #print("line2", typevalue )

            # Display laser number value
            SendOSCUI('/lpd8/' + macroname + '/laser', [macrolaser])

        else:
            SendOSCUI('/lpd8/' + macroname + '/line1', [macrocode])
Beispiel #15
0
def MidinProcess(BCRqueue):

    while True:

        BCRqueue_get = BCRqueue.get
        msg = BCRqueue_get()
        #print("BCR got", msg)

        # Noteon message on all midi channels
        if NOTE_ON - 1 < msg[0] < 160 and msg[2] != 0:

            # note mode
            #ModeNote(msg[1], msg[2], mididest)

            MidiChannel = msg[0] - 143
            MidiNote = msg[1]
            MidiVel = msg[2]
            print("NOTE ON :", MidiNote, 'velocity :', MidiVel, "Channel",
                  MidiChannel)

            # Specials features
            if len(macros["Specials"]) > 0:

                for counter in range(len(macros["Specials"])):

                    #print()
                    #print("Name", macros["Specials"][counter]["name"])
                    #print("Song", macros["Specials"][counter]["songname"], gstt.songs[gstt.song])    # name, "all"
                    #print("Channel", macros["Specials"][counter]["chanIN"], MidiChannel)             # number, "all"
                    #print("Note", macros["Specials"][counter]["notes"], MidiNote)                    # number, "all"
                    #print("Notetype", macros["Specials"][counter]["notetype"], "on")                 # "on", "off", "all"

                    if (
                            macros["Specials"][counter]["songname"]
                            == gstt.songs[gstt.song]
                            or macros["Specials"][counter]["songname"] == "all"
                    ) and (macros["Specials"][counter]["chanIN"] == MidiChannel
                           or macros["Specials"][counter]["chanIN"]
                           == "all") and (
                               macros["Specials"][counter]["notes"] == MidiNote
                               or macros["Specials"][counter]["notes"] == "all"
                           ) and (macros["Specials"][counter]["notetype"]
                                  == "on"
                                  or macros["Specials"][counter]["notetype"]
                                  == "all"):
                        macrocode = macros["Specials"][counter]["code"]
                        print("Specials function :",
                              macros["Specials"][counter]["songname"], ":",
                              macros["Specials"][counter]["name"], macrocode)

                        # python function on velocity > 0
                        if macrocode.count('.') > 0 and MidiVel > 0:
                            #print(macrocode+"("+str(MidiNote)+')')
                            eval(macrocode + "(" + str(MidiNote) + ')')

                        # Maxwell function
                        elif macrocode.count('/') > 0:
                            #print("Specials NoteON got Song :", macros["Specials"][counter]["songname"],"  IN Channel :", macros["Specials"][counter]["chanIN"],"  Code :", macrocode, "  CC", maxwellccs.FindCC(macros["Specials"][counter]["code"]), "  value :",macros["Specials"][counter]["value"], "  laser :", macros["ZccLcc"][counter]["laser"] )
                            midi3.MidiMsg(
                                (CONTROLLER_CHANGE,
                                 maxwellccs.FindCC(
                                     macros["Specials"][counter]["code"]),
                                 macros["Specials"][counter]["value"]),
                                mididest,
                                laser=macros["Specials"][counter]["laser"])

        # Note Off or Note with 0 velocity on all midi channels
        if NOTE_OFF - 1 < msg[0] < 144 or (NOTE_OFF - 1 < msg[0] < 160
                                           and msg[2] == 0):

            if msg[0] > 144:
                MidiChannel = msg[0] - 143
            else:
                MidiChannel = msg[0] - 128

            MidiNote = msg[1]
            MidiVel = msg[2]

            print("NOTE OFF :", MidiNote, "Channel", MidiChannel)

            # Specials features ?
            if len(macros["Specials"]) > 0:

                for counter in range(len(macros["Specials"])):

                    # print()
                    # print("Name", macros["Specials"][counter]["name"])
                    # print("Song", macros["Specials"][counter]["songname"], gstt.songs[gstt.song])    # name, "all"
                    # print("Channel", macros["Specials"][counter]["chanIN"], MidiChannel)             # number, "all"
                    # print("Note", macros["Specials"][counter]["notes"], MidiNote)                    # number, "all"
                    # print("Notetype", macros["Specials"][counter]["notetype"], "on")                 # "on", "off", "all"

                    if (
                            macros["Specials"][counter]["songname"]
                            == gstt.songs[gstt.song]
                            or macros["Specials"][counter]["songname"] == "all"
                    ) and (macros["Specials"][counter]["chanIN"] == MidiChannel
                           or macros["Specials"][counter]["chanIN"]
                           == "all") and (
                               macros["Specials"][counter]["notes"] == MidiNote
                               or macros["Specials"][counter]["notes"] == "all"
                           ) and (macros["Specials"][counter]["notetype"]
                                  == "off"
                                  or macros["Specials"][counter]["notetype"]
                                  == "all"):
                        macrocode = macros["Specials"][counter]["code"]
                        print("Specials function :",
                              macros["Specials"][counter]["songname"], ":",
                              macros["Specials"][counter]["name"], macrocode)

                        # python function
                        if macrocode.count('.') > 0:
                            #print(macrocode+"("+str(MidiNote)+')')
                            eval(macrocode + "(" + str(MidiNote) + ')')

                        # Maxwell function
                        elif macrocode.count('/') > 0:
                            #print("Specials NoteON got :", macros["Specials"][counter]["songname"],"  IN Channel :", macros["Specials"][counter]["chanIN"],"  Code :", macrocode, "  CC", maxwellccs.FindCC(macros["Specials"][counter]["code"]), "  value :",macros["Specials"][counter]["value"], "  laser :", macros["ZccLcc"][counter]["laser"] )
                            midi3.MidiMsg(
                                (CONTROLLER_CHANGE,
                                 maxwellccs.FindCC(
                                     macros["Specials"][counter]["code"]),
                                 macros["Specials"][counter]["value"]),
                                mididest,
                                laser=macros["Specials"][counter]["laser"])

        # Program Change button selected : change destination computer
        if msg[0] == PROGRAM_CHANGE:

            print("BCR Program change : ", str(msg[1]))
            # Change destination computer mode
            print("Destination computer", int(msg[1]))
            gstt.computer = int(msg[1])

        # CC on all Midi Channels
        if CONTROLLER_CHANGE - 1 < msg[0] < 192:

            if gstt.lasernumber == 0:

                #macroname= "m"+str(msg[1])
                #macroargs = msg[2]
                MidiChannel = msg[0] - 175
                MidiCC = msg[1]
                MidiVal = msg[2]

                if gstt.resetCC == True:
                    gstt.ccs[0][MidiCC] = 64
                    print("BCR CC Reset on channel :", MidiChannel, "CC",
                          MidiCC)
                    #print("Change CC (in bcr) : path =", path, "CC :", midi3.FindCC(path), "is now ", gstt.ccs[0][MaxwellCC])
                    maxwellccs.cc(MidiCC,
                                  64,
                                  midichannel=MidiChannel,
                                  dest='to Maxwell 1')
                    SendOSCUI('/status', ["CC", MidiCC, "to 64"])

                else:
                    gstt.ccs[0][MidiCC] = MidiVal
                    print("BCR CC change on channel :", MidiChannel, "CC",
                          MidiCC, "Val", MidiVal)
                    #print("Change CC (in bcr) : path =", path, "CC :", midi3.FindCC(path), "is now ", gstt.ccs[0][MaxwellCC])
                    maxwellccs.cc(MidiCC,
                                  gstt.ccs[0][MidiCC],
                                  midichannel=MidiChannel,
                                  dest='to Maxwell 1')

                #midi3.MidiMsg([CONTROLLER_CHANGE+MidiChannel-1, MidiCC, MidiVal], "to Maxwell 1")
                # Encoder(macroname, macroargs)

                # LccZcc
                '''
    
                # encoder slowly turned to right
                if MidiVal == 1:
                    +1
                # encoder fastly turned to right
                if MidiVal > 1 and MidiVal <20:
                    +10  
    
                # encoder slowly turned to left
                if MidiVal == 127:
                    -1
    
                # encoder fasly turned to left
                if MidiVal < 127 and MidiVal > 90:
                    -10

                gstt.ccs[0][MaxwellCC] + value
                
                '''

                if len(macros["LccZcc"]) > 0:
                    # print("LccZcc test...", MidiChannel, MidiCC, MidiVal, macros["LccZcc"][0]["chanIN"], gstt.songs[gstt.song])
                    for counter in range(len(macros["LccZcc"])):
                        if (macros["LccZcc"][counter]["songname"]
                                == gstt.songs[gstt.song] or macros["LccZcc"]
                            [counter]["songname"] == "all") and (
                                macros["LccZcc"][counter]["chanIN"]
                                == MidiChannel
                                or macros["LccZcc"][counter]["chanIN"] == "all"
                            ) and (macros["LccZcc"][counter]["ccs"] == msg[1]
                                   or macros["LccZcc"][counter]["ccs"]
                                   == "all"):
                            print("LccZcc",
                                  macros["LccZcc"][counter]["songname"], ":",
                                  macros["LccZcc"][counter]["name"])
                            #print("LccZcc got song :", macros["LccZcc"][counter]["songname"],"  IN Channel :", macros["LccZcc"][counter]["chanIN"],"  Code :", macros["LccZcc"][counter]["code"], "  value :",macros["ZnotesLcc"][counter]["value"], )
                            if macros["LccZcc"][counter]["value"] == "linear":
                                print("Linear", MidiVal)
                                midi3.MidiMsg(
                                    (176 +
                                     macros["LccZcc"][counter]["chanOUT"],
                                     macros["LccZcc"][counter]["ccOUT"],
                                     MidiVal),
                                    macros["LccZcc"][counter]["mididest"],
                                    laser=0)

                            if macros["LccZcc"][counter]["value"] == "curved":
                                print(MidiVal, "got curved",
                                      maxwellccs.curved(MidiVal))
                                midi3.MidiMsg(
                                    (176 +
                                     macros["LccZcc"][counter]["chanOUT"],
                                     macros["LccZcc"][counter]["ccOUT"],
                                     maxwellccs.curved(MidiVal)),
                                    macros["LccZcc"][counter]["mididest"],
                                    laser=0)

            else:
                SendOSC(gstt.computerIP[gstt.lasernumber],
                        gstt.MaxwellatorPort, '/cc/' + str(msg[1]),
                        [int(msg[2])])
                #SendOSC(gstt.computerIP[gstt.computer-1], gstt.MaxwellatorPort, '/cc', [int(msg[1]), int(msg[2])])
                print("storing for laser", gstt.lasernumber, "CC", int(msg[1]),
                      "value", int(msg[2]))
                gstt.ccs[gstt.lasernumber][int(msg[1])] = int(msg[2])
        '''