This commit is contained in:
sam 2020-04-23 16:00:37 +02:00
parent c169e11409
commit 98f039b2ee
5 changed files with 58 additions and 68 deletions

View File

@ -170,7 +170,7 @@ def curved(value):
def cc(midichannel, ccnumber, value, mididest): def cc(midichannel, ccnumber, value, mididest):
#print "cc()" #print "cc()"
print("Jamidi Sending locally Midi channel", midichannel, "cc", ccnumber, "value", value, "to", mididest) print("CC for local Midi channel", midichannel, "cc", ccnumber, "value", value, "to", mididest)
# Apply CC routing ? # Apply CC routing ?
if len(MidiRules["cc2cc"]) > 0 : if len(MidiRules["cc2cc"]) > 0 :
@ -188,10 +188,6 @@ def cc(midichannel, ccnumber, value, mididest):
midi3.MidiMsg((176 + MidiRules["cc2cc"][counter]["chanOUT"], MidiRules["cc2cc"][counter]["ccOUT"], curved(MidiVal)), MidiRules["cc2cc"][counter]["mididest"]) midi3.MidiMsg((176 + MidiRules["cc2cc"][counter]["chanOUT"], MidiRules["cc2cc"][counter]["ccOUT"], curved(MidiVal)), MidiRules["cc2cc"][counter]["mididest"])
#else:
print("Jamidi Sending locally Midi channel", midichannel, "cc", ccnumber, "value", value, "to", mididest)
#if mididest == "BCR2000 Port 1":
midi3.MidiMsg([CONTROLLER_CHANGE+midichannel-1, ccnumber, value], mididest) midi3.MidiMsg([CONTROLLER_CHANGE+midichannel-1, ccnumber, value], mididest)
@ -281,21 +277,19 @@ def on_message(ws, message):
print("") print("")
print(message) print("Incoming ws message",message)
if len(message) > 200:
message = message[:200]+'..'
oscpath = message.split(" ")
if debug > 0:
print(GetTime(),"Main got from WS", client['id'], "said :", message, "splitted in an oscpath :", oscpath)
else:
print(GetTime(),"Main got WS Client", client['id'], "said :", message)
if len(message) > 200:
message = message[:200]+'..'
oscpath = message.split(" ")
wscommand = oscpath[0].split("/") wscommand = oscpath[0].split("/")
device = wscommand[1]
command = wscommand[2]
# debug # debug
if debug > 0: if debug > 0:
print("wscommand :",wscommand) print("for device", device,"command :", command)
# noarg # noarg
if len(oscpath) == 1: if len(oscpath) == 1:
@ -303,58 +297,52 @@ def on_message(ws, message):
#print "noargs command" #print "noargs command"
# CC : /device/cc/2 127 # CC : /device/cc/2 127
elif wscommand[2] == "cc": elif command == "cc":
ccvr=int(wscommand[3]) #cc variable ccvr=int(wscommand[3]) #cc variable
ccvl=int(oscpath[1]) #cc value ccvl=int(oscpath[1]) #cc value
if debug > 0: if debug > 0:
print("ccvr=%d/ccvl=%d"%(ccvr,ccvl)) print("device", device,"ccvr=%d/ccvl=%d"%(ccvr,ccvl))
if wscommand[1] == "ocs2":
#cc(Confs[wscommand[1]][0]["midichan"], ccvr, ccvl, Confs[wscommand[1]][0]["mididevice"])
crtvalueOCS2[ccvr]=ccvl
else:
#cc(Confs[wscommand[1]][0]["midichan"], ccvr, ccvl, Confs[wscommand[1]][0]["mididevice"])
crtvalueMMO3[ccvr]=ccvl
for mididevice in midi3.findJamDevices(wscommand[1]): for mididevice in midi3.findJamDevices(device):
cc(Confs[wscommand[1]][0]["midichan"], ccvr, ccvl, mididevice) cc(Confs[device][0]["midichan"], ccvr, ccvl, mididevice)
''' '''
# CC : /device/cc/2 127 # CC : /device/cc/2 127
elif wscommand[1] == "ocs2": elif wscommand[1] == "ocs2":
if wscommand[2] == "cc": if wscommand[2] == "cc":
print("Incoming OCS-2 WS CC", wscommand[3], ":", int(oscpath[1])) print("Incoming OCS-2 WS CC", wscommand[3], ":", int(oscpath[1]))
cc(Confs["ocs2"][0]["midichan"], int(wscommand[3]), int(oscpath[1]), Confs["default"][0]["mididevice"]) cc(Confs["ocs2"][0]["midichan"], int(wscommand[3]), int(oscpath[1]), Confs["default"][0]["mididevice"])
if wscommand[2] == "OSC1": if wscommand[2] == "OSC1":
print("Incoming OCS-2 WS OSC1", wscommand[3], ":", int(oscpath[1])) print("Incoming OCS-2 WS OSC1", wscommand[3], ":", int(oscpath[1]))
elif wscommand[1] == "mmo3": elif wscommand[1] == "mmo3":
if wscommand[2] == "cc": if wscommand[2] == "cc":
print("Incoming MMO-3 WS CC", wscommand[3], ":", int(oscpath[1])) print("Incoming MMO-3 WS CC", wscommand[3], ":", int(oscpath[1]))
cc(Confs["mmo3"][0]["midichan"], int(wscommand[3]), int(oscpath[1]), Confs["default"][0]["mididevice"]) cc(Confs["mmo3"][0]["midichan"], int(wscommand[3]), int(oscpath[1]), Confs["default"][0]["mididevice"])
if wscommand[2] == "OSC1": if wscommand[2] == "OSC1":
print("Incoming MMO-3 WS OSC1", wscommand[3], ":", int(oscpath[1])) print("Incoming MMO-3 WS OSC1", wscommand[3], ":", int(oscpath[1]))
''' '''
# RESET : /device/reset 1 # RESET : /device/reset 1
elif wscommand[2] == "reset": elif command == "reset":
if wscommand[1] == "ocs2": if device == "ocs2":
reset("ocs2") reset("ocs2")
else: else:
reset("mmo3") reset("mmo3")
# NOTEON : /device/noteon note velocity # NOTEON : /device/noteon note velocity
elif wscommand[2] == "noteon": elif command == "noteon":
for mididevice in midi3.findJamDevices(wscommand[1]): for mididevice in midi3.findJamDevices(device):
midi3.NoteOn(int(oscpath[1]), int(oscpath[2]), mididevice) midi3.NoteOn(int(oscpath[1]), int(oscpath[2]), mididevice)
# NOTEOFF /device/noteoff note # NOTEOFF /device/noteoff note
elif wscommand[2] == "noteoff": elif command == "noteoff":
for mididevice in midi3.findJamDevices(wscommand[1]): for mididevice in midi3.findJamDevices(device):
midi3.NoteOff(int(oscpath[1]), mididevice) midi3.NoteOff(int(oscpath[1]), mididevice)
@ -402,8 +390,6 @@ try:
except Exception: except Exception:
traceback.print_exc() traceback.print_exc()
except KeyboardInterrupt:
pass
# Gently stop on CTRL C # Gently stop on CTRL C

View File

@ -21,7 +21,7 @@
} }
], ],
"xkkia" : "xrkia" :
[ [
{ {
"_comment": "Server is xrkia.org", "_comment": "Server is xrkia.org",
@ -48,7 +48,8 @@
"_comment": "OCS-2 device parameters", "_comment": "OCS-2 device parameters",
"type": "mididevice", "type": "mididevice",
"mididevice": "UM-ONE:UM-ONE MIDI 1 20:0", "mididevice": "UM-ONE:UM-ONE MIDI 1 20:0",
"midichan" : 2 "midichan" : 2,
"xname" : "ocs2"
} }
], ],
@ -57,25 +58,28 @@
"_comment": "MMO-3 device parameters", "_comment": "MMO-3 device parameters",
"type": "mididevice", "type": "mididevice",
"mididevice": "UM-ONE:UM-ONE MIDI 1 20:0", "mididevice": "UM-ONE:UM-ONE MIDI 1 20:0",
"midichan" : 1 "midichan" : 1,
"xname" : "mmo3"
} }
], ],
"ocs2b": [ "ocs2bcr": [
{ {
"_comment": "OCS-2 control with BCR2000", "_comment": "OCS-2 control with BCR2000",
"type": "mididevice", "type": "mididevice",
"mididevice": "BCR2000 Port 1", "mididevice": "BCR2000 Port 1",
"midichan" : 2 "midichan" : 2,
"xname" : "ocs2"
} }
], ],
"mmo3b": [ "mmo3bcr": [
{ {
"_comment": "MMO-3 control with BCR2000", "_comment": "MMO-3 control with BCR2000",
"type": "mididevice", "type": "mididevice",
"mididevice": "BCR2000 Port 1", "mididevice": "BCR2000 Port 1",
"midichan" : 1 "midichan" : 1,
"xname" : "mmo3"
} }
], ],
@ -84,7 +88,8 @@
"_comment": "Launchpad mini device parameters", "_comment": "Launchpad mini device parameters",
"type": "mididevice", "type": "mididevice",
"mididevice": "Launchpad Mini", "mididevice": "Launchpad Mini",
"midichan" : 0 "midichan" : 0,
"xname" : "launchpad"
} }
], ],
@ -94,7 +99,8 @@
"_comment": "Client : default midi device", "_comment": "Client : default midi device",
"type": "mididevice", "type": "mididevice",
"mididevice": "BCR2000 Port 1", "mididevice": "BCR2000 Port 1",
"midichan" : 3 "midichan" : 3,
"xname" : "default"
} }
] ]

View File

@ -517,13 +517,13 @@ def MidiMsg(midimsg, mididest):
desterror = -1 desterror = -1
print("midi3 got midimsg", midimsg, "for", mididest) print("jamidi3 got midimsg", midimsg, "for", mididest)
for port in range(len(OutDevice)): for port in range(len(OutDevice)):
# To mididest # To mididest
if midiname[port].find(mididest) != -1: if midiname[port].find(mididest) != -1:
if debug>0: if debug>0:
print("midi 3 sending to name", midiname[port], "port", port, ":", midimsg) print("jamidi 3 sending to name", midiname[port], "port", port, ":", midimsg)
midiport[port].send_message(midimsg) midiport[port].send_message(midimsg)
desterror = 0 desterror = 0
@ -566,8 +566,8 @@ def findJamName(mididevice, midichan):
#print(v[0]["mididevice"],v[0]["midichan"], type(v[0]["midichan"])) #print(v[0]["mididevice"],v[0]["midichan"], type(v[0]["midichan"]))
if (v[0]["mididevice"] == mididevice) and (v[0]["midichan"] == midichan): if (v[0]["mididevice"] == mididevice) and (v[0]["midichan"] == midichan):
print("Incoming event from", k) print("Incoming event from", k, "xname", v[0]["xname"])
return k return v[0]["xname"]
return "None" return "None"
@ -579,11 +579,11 @@ def findJamDevices(name):
for (k, v) in Confs.items(): for (k, v) in Confs.items():
if v[0]["type"] == "mididevice": if v[0]["type"] == "mididevice":
#print(k, name,k.find(name)) #print(k, name,v[0]["xname"])
if k.find(name) != -1: if v[0]["xname"] == name:
#print(v[0]["mididevice"]) #print(v[0]["mididevice"])
devices.append(v[0]["mididevice"]) devices.append(v[0]["mididevice"])
#print(devices) # print(devices)
return devices return devices

View File

@ -339,8 +339,6 @@ try:
except Exception: except Exception:
traceback.print_exc() traceback.print_exc()
except KeyboardInterrupt:
pass
# Gently stop on CTRL C # Gently stop on CTRL C

View File

@ -27,7 +27,7 @@
"Specials": [ "Specials": [
{ {
"_comment": "Pas implementé encore dans nozoidUI", "_comment": "Pas implementé encore dans Jamidi",
"name": "autotempo", "name": "autotempo",
"songname": "song1", "songname": "song1",
"chanIN" : 16, "chanIN" : 16,