Add Led on for Launchpad

This commit is contained in:
sam 2020-10-09 17:37:15 +02:00
parent fb9999c828
commit 5d9aa17f23
2 changed files with 15 additions and 3 deletions

View File

@ -298,6 +298,7 @@ def MidinProcess(inqueue, portname):
print() print()
#print(debug) #print(debug)
print("NOTE ON :", "Channel", MidiChannel, "note :", MidiNote, 'velocity :', MidiVel ) print("NOTE ON :", "Channel", MidiChannel, "note :", MidiNote, 'velocity :', MidiVel )
NoteOn(MidiNote, MidiVel, "pads" , midichannel=MidiChannel)
# redis key : "/midi/noteon/midichannel" value : "note/velocity" # redis key : "/midi/noteon/midichannel" value : "note/velocity"
if r.set("/midi/noteon/"+str(MidiChannel), str(MidiNote)+"/"+str(MidiVel))==True: if r.set("/midi/noteon/"+str(MidiChannel), str(MidiNote)+"/"+str(MidiVel))==True:
@ -342,6 +343,7 @@ def MidinProcess(inqueue, portname):
MidiNote = msg[1] MidiNote = msg[1]
print("NOTE_off channel :", MidiChannel, "note :", MidiNote) print("NOTE_off channel :", MidiChannel, "note :", MidiNote)
NoteOff(MidiNote, "pads" , midichannel=MidiChannel)
# redis key : "/midi/noteon/midichannel" value : "note" # redis key : "/midi/noteon/midichannel" value : "note"
if r.set("/midi/noteoff/"+str(MidiChannel), str(MidiNote)) ==True: if r.set("/midi/noteoff/"+str(MidiChannel), str(MidiNote)) ==True:
@ -365,6 +367,7 @@ def MidinProcess(inqueue, portname):
#print("channel", MidiChannel, "CC :", msg[1], msg[2]) #print("channel", MidiChannel, "CC :", msg[1], msg[2])
print("CC channel : "+str(msg[0]-175-1)+" CC :"+str(msg[1])+" value : "+str(msg[2])) print("CC channel : "+str(msg[0]-175-1)+" CC :"+str(msg[1])+" value : "+str(msg[2]))
cc(MidiChannel, msg[1], msg[2], "pads" )
# redis key : "/midi/cc/midichannel/ccnumber" value : "ccvalue" # redis key : "/midi/cc/midichannel/ccnumber" value : "ccvalue"
if r.set("/midi/cc/"+str(MidiChannel)+"/"+str(msg[1]),str(msg[2]))==True: if r.set("/midi/cc/"+str(MidiChannel)+"/"+str(msg[1]),str(msg[2]))==True:
if debug == "True": if debug == "True":
@ -452,10 +455,13 @@ def NoteOn(note, color, mididest, midichannel=0):
elif mididest == "all" and midiname[port].find(mididest) != 0: elif mididest == "all" and midiname[port].find(mididest) != 0:
midiport[port].send_message([NOTE_ON+midichannel, note, color]) midiport[port].send_message([NOTE_ON+midichannel, note, color])
elif mididest == "pads" and midiname[port].find("Launchpad") > -1:
midiport[port].send_message([NOTE_ON+midichannel, note, color])
def NoteOff(note, mididest):
def NoteOff(note, mididest, midichannel=0):
global MidInsNumber global MidInsNumber
@ -467,7 +473,10 @@ def NoteOff(note, mididest):
# To All # To All
elif mididest == "all" and midiname[port].find(mididest) == -1: elif mididest == "all" and midiname[port].find(mididest) == -1:
midiport[port].send_message([NOTE_OFF, note, 0]) midiport[port].send_message([NOTE_OFF, note, 0])
elif mididest == "pads" and midiname[port].find("Launchpad") > -1:
midiport[port].send_message([NOTE_OFF, note, 0])
@ -737,7 +746,7 @@ def MidiMsg(midimsg, mididest):
desterror = -1 desterror = -1
print("jamidi3 got midimsg", midimsg, "for", mididest) print("midi3 got midimsg", midimsg, "for", mididest)
for port in range(len(OutDevice)): for port in range(len(OutDevice)):
# To mididest # To mididest
@ -747,6 +756,9 @@ def MidiMsg(midimsg, mididest):
midiport[port].send_message(midimsg) midiport[port].send_message(midimsg)
desterror = 0 desterror = 0
elif mididest == "pads" and midiname[port].find("Launchpad") > -1:
midiport[port].send_message(midimsg)
if desterror == -1: if desterror == -1:
print("mididest",mididest, ": ** This midi destination doesn't exists **") print("mididest",mididest, ": ** This midi destination doesn't exists **")