예제 #1
0
def cc(ccnumber, value, dest=mididest, midichannel=gstt.basemidichannel):
    global lastcc

    UpdateCCs(ccnumber, value, laser=gstt.lasernumber)

    if ccnumber > 127:
        midichannel = gstt.basemidichannel + 1
        ccnumber -= 127
    #else:
    #    UpdateCCs(ccnumber, value, laser = gstt.lasernumber)

    # mixer change display in OSC UI
    if ccnumber == 90:
        SendOSCUI('/mixer/value', [value])

    gstt.ccs[gstt.lasernumber][ccnumber + 127 * (midichannel - 1)] = value
    lastcc = ccnumber

    if gstt.debug == True:
        print('Maxwellccs sending CC',
              [CONTROLLER_CHANGE + midichannel - 1, ccnumber, value], dest)

    # Local Laser
    if gstt.lasernumber == 0:

        midi3.MidiMsg([CONTROLLER_CHANGE + midichannel - 1, ccnumber, value],
                      dest)
        # update CCs TouchOSC screen
        SendOSCUI('/cc/' + str(ccnumber), [value])

    else:
        SendOSC(gstt.computerIP[gstt.lasernumber], gstt.MaxwellatorPort,
                '/cc/' + str(ccnumber), [value])
예제 #2
0
def runPatch(number, laser=0):

    print()
    print("Run patch :", number, "on laser", laser, "...")

    # Patch exist ?
    if (str(number + 1) in gstt.patchs['pattrstorage']['slots']) != False:

        # Yes
        gstt.patchnumber[laser] = number
        for ccnumber in range(len(maxwell['ccs'])):

            # Update cc variable content and OSC UI for given laser
            gstt.ccs[laser][ccnumber] = getPatchValue(gstt.patchnumber[laser],
                                                      ccnumber)

            SendOSCUI('/cc/' + str(ccnumber),
                      [getPatchValue(gstt.patchnumber[laser], ccnumber)])

            # Update BCR 2000 CC if exists
            if bcr.Here != -1:
                midi3.MidiMsg([
                    CONTROLLER_CHANGE, ccnumber,
                    getPatchValue(gstt.patchnumber[laser], ccnumber)
                ], "BCR2000")
        for ccnumber in range(len(maxwell['ccs'])):
            print(ccnumber, " ", gstt.ccs[laser][ccnumber])

        # Update OSC UI patch number and send to Maxwell via midi
        SendOSCUI('/laser/patch/' + str(laser), [gstt.patchnumber[laser]])
        midi3.NoteOn(gstt.patchnumber[laser], 127, 'to Maxwell 1')

        #print("Laser", laser, ": current patch is now :", gstt.patchnumber[laser], 'ccs', gstt.ccs[laser])
    else:
        print("Patch doesnt exists")
예제 #3
0
def ELCC(ccnumber, value):

    print("ELCC forward CC", ccnumber, ":", value,
          "to TouchOSC and BCR 2000 channel 16")

    SendOSCUI('/states/cc/' + str(ccnumber), [value])
    midi3.MidiMsg((CONTROLLER_CHANGE + 15, ccnumber, int(value)),
                  mididest="BCR2000")
예제 #4
0
def autotempo():
    global lastime

    currentime = datetime.now()
    delta = currentime - lastime
    lastime = currentime
    gstt.currentbpm = round(60 / delta.total_seconds())
    print("length between notes :", delta.total_seconds(), "seconds -> bpm :",
          gstt.currentbpm)

    # STUPID : need to find a way to display bpm > 127
    # tell BCR 2000 the new bpm on channel 16
    if gstt.currentbpm > 127:
        midi3.MidiMsg((CONTROLLER_CHANGE + 15, 127, 127), mididest="BCR2000")
    else:
        midi3.MidiMsg((CONTROLLER_CHANGE + 15, 127, gstt.currentbpm),
                      mididest="BCR2000")
    SendOSCUI('/bpm', [gstt.currentbpm])
    newtempo(gstt.currentbpm)
예제 #5
0
def cc(ccnumber, value, dest=mididest):

    gstt.ccs[gstt.lasernumber][ccnumber] = value
    if gstt.lasernumber == 0:
        midi3.MidiMsg([CONTROLLER_CHANGE + midichannel - 1, ccnumber, value],
                      dest)
    else:
        SendOSC(gstt.computerIP[gstt.lasernumber], gstt.MaxwellatorPort,
                '/cc/' + str(ccnumber), [value])
    SendOSCUI('/cc/' + str(ccnumber), [value])
예제 #6
0
def MidinProcess(C4queue):
    global computer

    while True:
        C4queue_get = C4queue.get
        msg = C4queue_get()

        # Note
        if msg[0] == NOTE_ON:

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

        # 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])

        # Midi Channel 1 : CCnumber is matrix name -> midi CC
        if msg[0] == CONTROLLER_CHANGE:

            if computer == 0 or computer == 1:

                macroname = "m" + str(msg[1])
                macroargs = msg[2]
                print('C4 midi got CC msg', msg, 'macro', macroname, macroargs)
                Encoder(macroname, macroargs)

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

        # Midi Channel 10 : ccnumber is actual CC number
        if msg[0] == CONTROLLER_CHANGE + 10 - 1 and msg[2] > 0:

            macroname = "m" + str(msg[1])
            #macrocode = macros[gstt.C4Layers[gstt.C4Layer]][msg[1]]["code"]
            print("channel 10 macro", macroname, "ccnumber", msg[1], "value",
                  msg[2])

            #SendOSCUI('/C4/'+macroname+'/button', [1])
            gstt.ccs[gstt.lasernumber][msg[1]] = msg[2]

            if gstt.lasernumber == 0:
                # CC message is sent locally to channel 1
                midi3.MidiMsg(
                    [CONTROLLER_CHANGE + midichannel - 1, msg[1], msg[2]],
                    'to Maxwell 1')
                #SendOSCUI('/C4/'+macroname+'/button', [1])
            else:
                SendOSC(gstt.computerIP[gstt.lasernumber],
                        gstt.MaxwellatorPort, '/cc/' + str(msg[1]), [msg[2]])
예제 #7
0
def UpdateCC(ccnumber, value, laser=0):

    # Update TouchOSC UI
    # print('BCR 2000 UpdateCC', ccnumber, value, "or", gstt.ccs[laser][ccnumber], "?")
    for macronumber in range(nbmacro):
        macrocode = macros[gstt.BCRLayers[gstt.BCRLayer]][macronumber]["code"]

        if macrocode == maxwellccs.maxwell['ccs'][ccnumber]['Function']:

            macroname = macros[gstt.BCRLayers[
                gstt.BCRLayer]][macronumber]["name"]

            SendOSCUI('/bcr/' + macroname + '/value', [format(value, "03d")])
            #SendOSCUI('/bcr/'+macroname+'/value', [format(gstt.ccs[laser][ccnumber], "03d")])

            # Update BCR 2000 via MIDI if connected.
            if Here != -1:
                midi3.MidiMsg([CONTROLLER_CHANGE, ccnumber, value], "BCR2000")
                #midi3.MidiMsg([CONTROLLER_CHANGE, ccnumber, gstt.ccs[laser][ccnumber]], "BCR2000")

            break
예제 #8
0
def CCpad(ccnumber, value, dest=mididest):

    #print("Sending Midi channel", midichannel, "cc", ccnumber, "value", value, "to", dest)
    #gstt.ccs[gstt.lasernumber][ccnumber]= value

    midi3.MidiMsg([CONTROLLER_CHANGE + 10 - 1, ccnumber, value], dest)
예제 #9
0
def sendcc(ccnumber, value, dest):

    print("Sending Midi channel", midichannel, "cc", ccnumber, "value", value, "to", dest)
    midi3.MidiMsg([CONTROLLER_CHANGE+midichannel-1, ccnumber, value], dest)
예제 #10
0
def MidinProcess(BEATSTEPqueue):
    global computer

    while True:

        BEATSTEPqueue_get = BEATSTEPqueue.get
        msg = BEATSTEPqueue_get()
        # print (msg)

        # Note
        if msg[0] == NOTE_ON:

            # note mode
            midi3.NoteOn(msg[1], msg[2], mididest)

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

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

        # Beatstep Encoders are on Midi Channel 1 : CCnumber is matrix name -> midi CC
        if msg[0] == CONTROLLER_CHANGE:

            if computer == 0 or computer == 1:

                macroname = "m" + str(msg[1])
                macroargs = msg[2]
                MidiChannel = msg[0] - 175
                MidiCC = msg[1]
                MidiVal = msg[2]
                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("Beatstep : LccZcc",
                                  macros["LccZcc"][counter]["songname"], ":",
                                  macros["LccZcc"][counter]["name"])

                            print(
                                "Beatstep LccZcc got song :",
                                macros["LccZcc"][counter]["songname"],
                                "  IN Channel :",
                                macros["LccZcc"][counter]["chanIN"],
                                "  value :",
                                macros["LccZcc"][counter]["value"],
                            )
                            if macros["LccZcc"][counter]["value"] == "linear":
                                print("Beatstep Linear", MidiVal)
                                midi3.MidiMsg(
                                    (176 +
                                     macros["LccZcc"][counter]["chanOUT"] - 1,
                                     macros["LccZcc"][counter]["ccOUT"],
                                     MidiVal),
                                    macros["LccZcc"][counter]["mididest"],
                                    laser=0)

                            if macros["LccZcc"][counter]["value"] == "curved":
                                print("Beatstep :", 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[computer - 1], gstt.MaxwellatorPort,
                        '/cc', [int(msg[1]), int(msg[2])])

        # Beatstep Pads are on channel 10
        if msg[0] == CONTROLLER_CHANGE + 10 - 1:
            #if msg[0] == CONTROLLER_CHANGE + 10 -1 and msg[2] > 0:

            MidiCC = msg[1]
            MidiVal = msg[2]
            state = MidiVal
            #print(MidiCC, MidiVal)

            macroname = "m" + str(MidiCC)

            print("Beatstep : macroname", macroname, "state", state)

            padCC(macroname, state)
        '''
예제 #11
0
def cc(ccnumber, value, dest=mididest):

    #print('Output CC',[CONTROLLER_CHANGE+midichannel-1, ccnumber, value], dest)
    midi3.MidiMsg([CONTROLLER_CHANGE + midichannel - 1, ccnumber, value], dest)
예제 #12
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)
        '''
        '''
예제 #13
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])
        '''