diff --git a/client.py b/client.py index 6b051af..c9136a9 100644 --- a/client.py +++ b/client.py @@ -170,7 +170,7 @@ def curved(value): def cc(midichannel, ccnumber, value, mididest): #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 ? 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"]) - #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) @@ -281,21 +277,19 @@ def on_message(ws, message): print("") - print(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) + print("Incoming ws message",message) + if len(message) > 200: + message = message[:200]+'..' + + oscpath = message.split(" ") wscommand = oscpath[0].split("/") + device = wscommand[1] + command = wscommand[2] # debug if debug > 0: - print("wscommand :",wscommand) + print("for device", device,"command :", command) # noarg if len(oscpath) == 1: @@ -303,58 +297,52 @@ def on_message(ws, message): #print "noargs command" # CC : /device/cc/2 127 - elif wscommand[2] == "cc": + elif command == "cc": + ccvr=int(wscommand[3]) #cc variable ccvl=int(oscpath[1]) #cc value if debug > 0: - print("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 + print("device", device,"ccvr=%d/ccvl=%d"%(ccvr,ccvl)) - for mididevice in midi3.findJamDevices(wscommand[1]): - cc(Confs[wscommand[1]][0]["midichan"], ccvr, ccvl, mididevice) + for mididevice in midi3.findJamDevices(device): + cc(Confs[device][0]["midichan"], ccvr, ccvl, mididevice) - ''' - # CC : /device/cc/2 127 - elif wscommand[1] == "ocs2": - if wscommand[2] == "cc": - 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 : /device/cc/2 127 + elif wscommand[1] == "ocs2": + if wscommand[2] == "cc": + 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"]) - if wscommand[2] == "OSC1": - print("Incoming OCS-2 WS OSC1", wscommand[3], ":", int(oscpath[1])) + if wscommand[2] == "OSC1": + print("Incoming OCS-2 WS OSC1", wscommand[3], ":", int(oscpath[1])) - elif wscommand[1] == "mmo3": - if wscommand[2] == "cc": - 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"]) + elif wscommand[1] == "mmo3": + if wscommand[2] == "cc": + 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"]) - if wscommand[2] == "OSC1": - print("Incoming MMO-3 WS OSC1", wscommand[3], ":", int(oscpath[1])) - ''' + if wscommand[2] == "OSC1": + print("Incoming MMO-3 WS OSC1", wscommand[3], ":", int(oscpath[1])) + ''' # RESET : /device/reset 1 - elif wscommand[2] == "reset": - if wscommand[1] == "ocs2": + elif command == "reset": + if device == "ocs2": reset("ocs2") else: reset("mmo3") - # NOTEON : /device/noteon note velocity - elif wscommand[2] == "noteon": - for mididevice in midi3.findJamDevices(wscommand[1]): + elif command == "noteon": + for mididevice in midi3.findJamDevices(device): midi3.NoteOn(int(oscpath[1]), int(oscpath[2]), mididevice) # NOTEOFF /device/noteoff note - elif wscommand[2] == "noteoff": - for mididevice in midi3.findJamDevices(wscommand[1]): + elif command == "noteoff": + for mididevice in midi3.findJamDevices(device): midi3.NoteOff(int(oscpath[1]), mididevice) @@ -402,8 +390,6 @@ try: except Exception: traceback.print_exc() -except KeyboardInterrupt: - pass # Gently stop on CTRL C diff --git a/jamidi.json b/jamidi.json index e899477..706ae2a 100644 --- a/jamidi.json +++ b/jamidi.json @@ -21,7 +21,7 @@ } ], -"xkkia" : +"xrkia" : [ { "_comment": "Server is xrkia.org", @@ -48,7 +48,8 @@ "_comment": "OCS-2 device parameters", "type": "mididevice", "mididevice": "UM-ONE:UM-ONE MIDI 1 20:0", - "midichan" : 2 + "midichan" : 2, + "xname" : "ocs2" } ], @@ -57,25 +58,28 @@ "_comment": "MMO-3 device parameters", "type": "mididevice", "mididevice": "UM-ONE:UM-ONE MIDI 1 20:0", - "midichan" : 1 + "midichan" : 1, + "xname" : "mmo3" } ], -"ocs2b": [ +"ocs2bcr": [ { "_comment": "OCS-2 control with BCR2000", "type": "mididevice", "mididevice": "BCR2000 Port 1", - "midichan" : 2 + "midichan" : 2, + "xname" : "ocs2" } ], -"mmo3b": [ +"mmo3bcr": [ { "_comment": "MMO-3 control with BCR2000", "type": "mididevice", "mididevice": "BCR2000 Port 1", - "midichan" : 1 + "midichan" : 1, + "xname" : "mmo3" } ], @@ -84,7 +88,8 @@ "_comment": "Launchpad mini device parameters", "type": "mididevice", "mididevice": "Launchpad Mini", - "midichan" : 0 + "midichan" : 0, + "xname" : "launchpad" } ], @@ -94,7 +99,8 @@ "_comment": "Client : default midi device", "type": "mididevice", "mididevice": "BCR2000 Port 1", - "midichan" : 3 + "midichan" : 3, + "xname" : "default" } ] diff --git a/libs/midi3.py b/libs/midi3.py index 7816542..6a1a135 100644 --- a/libs/midi3.py +++ b/libs/midi3.py @@ -517,13 +517,13 @@ def MidiMsg(midimsg, mididest): desterror = -1 - print("midi3 got midimsg", midimsg, "for", mididest) + print("jamidi3 got midimsg", midimsg, "for", mididest) for port in range(len(OutDevice)): # To mididest if midiname[port].find(mididest) != -1: 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) desterror = 0 @@ -566,8 +566,8 @@ def findJamName(mididevice, midichan): #print(v[0]["mididevice"],v[0]["midichan"], type(v[0]["midichan"])) if (v[0]["mididevice"] == mididevice) and (v[0]["midichan"] == midichan): - print("Incoming event from", k) - return k + print("Incoming event from", k, "xname", v[0]["xname"]) + return v[0]["xname"] return "None" @@ -579,11 +579,11 @@ def findJamDevices(name): for (k, v) in Confs.items(): if v[0]["type"] == "mididevice": - #print(k, name,k.find(name)) - if k.find(name) != -1: + #print(k, name,v[0]["xname"]) + if v[0]["xname"] == name: #print(v[0]["mididevice"]) devices.append(v[0]["mididevice"]) - #print(devices) + # print(devices) return devices diff --git a/main.py b/main.py index c487a43..e707087 100755 --- a/main.py +++ b/main.py @@ -339,8 +339,6 @@ try: except Exception: traceback.print_exc() -except KeyboardInterrupt: - pass # Gently stop on CTRL C diff --git a/rules.json b/rules.json index 06bb259..2384bdf 100644 --- a/rules.json +++ b/rules.json @@ -27,7 +27,7 @@ "Specials": [ { - "_comment": "Pas implementé encore dans nozoidUI", + "_comment": "Pas implementé encore dans Jamidi", "name": "autotempo", "songname": "song1", "chanIN" : 16,