Ejemplo n.º 1
0
def MidinProcess(LPD8queue):
    global computer

    while True:
        LPD8queue_get = LPD8queue.get
        msg = LPD8queue_get()
        #print (msg)

        # Note
        if msg[0] == NOTE_ON:

            # note mode
            ModeNote(msg[1], msg[2], mididest)
            '''
            # ModeOS
            if msg[2] > 0:
                ModeOS(msg[0])
            '''

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

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

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

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

            if computer == 0 or computer == 1:
                maxwellccs.cc(int(msg[1]), int(msg[2]))

            else:
                SendOSC(gstt.computerIP[computer - 1], maxwellatorPort, '/cc',
                        [int(msg[1]), int(msg[2])])
Ejemplo n.º 2
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])
Ejemplo n.º 3
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])
Ejemplo n.º 4
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])
        '''
Ejemplo n.º 5
0
def ResetRightPrefix():

    for led in range(16, 19):
        maxwellccs.cc(led, 0, dest=djdest)
        time.sleep(0.01)
Ejemplo n.º 6
0
def ResetLeftPrefix():

    for led in range(13, 16):

        maxwellccs.cc(led, 0, dest=djdest)
        time.sleep(0.01)
Ejemplo n.º 7
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
Ejemplo n.º 8
0
maxwellccs.LoadCC()
#maxwellccs.cc(13, 127, dest=djdest)

if __name__ == '__main__':

    import traceback
    import time

    midi3.check()

    scrolldisp.Display('Dj',
                       color=(255, 255, 255),
                       delay=0.2,
                       mididest='launchpad')
    scrolldisp.Display('Dj',
                       color=(255, 230, 0),
                       delay=0.2,
                       mididest='bhoreal')
    # Light left X and right X
    maxwellccs.cc(15, 127, dest=djdest)
    maxwellccs.cc(16, 127, dest=djdest)
    try:

        while True:
            time.sleep(0.1)

    except Exception:
        traceback.print_exc()

    #finally:
Ejemplo n.º 9
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])
Ejemplo n.º 10
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 + '")')
Ejemplo n.º 11
0
def Start(port):

    SendOSCUI('/lpd8/on', [1])
    for pad1 in range(1, 4):
        maxwellccs.cc(pad1, 0, dest='LPD8')
    for pad2 in range(5, 8):
        maxwellccs.cc(pad2, 0, dest='LPD8')

    for pad1 in range(1, 4):
        maxwellccs.cc(pad1, 127, dest='LPD8')
        time.sleep(0.05)
        maxwellccs.cc(pad1, 0, dest='LPD8')
    for pad2 in range(8, 5, -1):
        maxwellccs.cc(pad2, 127, dest='LPD8')
        time.sleep(0.05)
        maxwellccs.cc(pad2, 0, dest='LPD8')
    maxwellccs.cc(1, 127, dest='LPD8')
    time.sleep(0.05)
    maxwellccs.cc(1, 0, dest='LPD8')
Ejemplo n.º 12
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])
        '''