added sync devices with close name ocs2, ocs2a,...

This commit is contained in:
sam 2020-04-22 23:19:45 +02:00
parent 4b63fceadc
commit c169e11409
4 changed files with 57 additions and 43 deletions

View File

@ -315,7 +315,8 @@ def on_message(ws, message):
#cc(Confs[wscommand[1]][0]["midichan"], ccvr, ccvl, Confs[wscommand[1]][0]["mididevice"])
crtvalueMMO3[ccvr]=ccvl
cc(Confs[wscommand[1]][0]["midichan"], ccvr, ccvl, Confs[wscommand[1]][0]["mididevice"])
for mididevice in midi3.findJamDevices(wscommand[1]):
cc(Confs[wscommand[1]][0]["midichan"], ccvr, ccvl, mididevice)
'''
# CC : /device/cc/2 127
@ -347,12 +348,14 @@ def on_message(ws, message):
# NOTEON : /device/noteon note velocity
elif wscommand[2] == "noteon":
midi3.NoteOn(int(oscpath[1]), int(oscpath[2]), Confs[wscommand[1]][0]["mididevice"])
for mididevice in midi3.findJamDevices(wscommand[1]):
midi3.NoteOn(int(oscpath[1]), int(oscpath[2]), mididevice)
# NOTEOFF /device/noteoff note
elif wscommand[2] == "noteoff":
midi3.NoteOff(int(oscpath[1]), Confs[wscommand[1]][0]["mididevice"])
for mididevice in midi3.findJamDevices(wscommand[1]):
midi3.NoteOff(int(oscpath[1]), mididevice)
# if needed a loop back : WS Client -> server -> WS Client

View File

@ -32,6 +32,17 @@
}
],
"tmlsr" :
[
{
"_comment": "Server is laser.teamlaser.fr",
"type": "serverconf",
"name": "tmlsr",
"IP": "laser.teamlaser.fr",
"port": 8081
}
],
"ocs2": [
{
"_comment": "OCS-2 device parameters",
@ -50,7 +61,7 @@
}
],
"ocs2": [
"ocs2b": [
{
"_comment": "OCS-2 control with BCR2000",
"type": "mididevice",
@ -59,7 +70,7 @@
}
],
"mmo3": [
"mmo3b": [
{
"_comment": "MMO-3 control with BCR2000",
"type": "mididevice",

View File

@ -150,8 +150,8 @@ def MidinProcess(inqueue, portname):
MidiVel = msg[2]
print("NOTE ON :", MidiNote, 'velocity :', MidiVel, "Channel", MidiChannel)
#NoteOn(msg[1],msg[2],mididest)
print("Midi in process send /"+findJamDevice(portname, MidiChannel)+"/noteon "+str(msg[1])+" "+str(msg[2]))
wssend("/"+findJamDevice(portname, MidiChannel)+"/noteon "+str(msg[1])+" "+str(msg[2]))
print("Midi in process send /"+findJamName(portname, MidiChannel)+"/noteon "+str(msg[1])+" "+str(msg[2]))
wssend("/"+findJamName(portname, MidiChannel)+"/noteon "+str(msg[1])+" "+str(msg[2]))
'''
# Sampler mode : note <63 launch snare.wav / note > 62 kick.wav
@ -182,18 +182,18 @@ def MidinProcess(inqueue, portname):
print("NOTE OFF :", MidiNote, 'velocity :', MidiVel, "Channel", MidiChannel)
#NoteOff(msg[1],msg[2], mididest)
print("Midi in process send /"+findJamDevice(portname, MidiChannel)+"/noteoff "+str(msg[1]))
wssend("/"+findJamDevice(portname, MidiChannel)+"/noteoff "+str(msg[1]))
print("Midi in process send /"+findJamName(portname, MidiChannel)+"/noteoff "+str(msg[1]))
wssend("/"+findJamName(portname, MidiChannel)+"/noteoff "+str(msg[1]))
# # CC on all Midi Channels
if CONTROLLER_CHANGE -1 < msg[0] < 192:
MidiChannel = msg[0]-175
#findJamDevice(portname, MidiChannel)
print("channel", MidiChannel, " ",findJamDevice(portname, MidiChannel), " CC :", msg[1], msg[2])
print("Midi in process send /"+findJamDevice(portname, MidiChannel)+"/cc/"+str(msg[1])+" "+str(msg[2])+" to WS")
wssend("/"+findJamDevice(portname, MidiChannel)+"/cc/"+str(msg[1])+" "+str(msg[2]))
#findJamName(portname, MidiChannel)
print("channel", MidiChannel, " ",findJamName(portname, MidiChannel), " CC :", msg[1], msg[2])
print("Midi in process send /"+findJamName(portname, MidiChannel)+"/cc/"+str(msg[1])+" "+str(msg[2])+" to WS")
wssend("/"+findJamName(portname, MidiChannel)+"/cc/"+str(msg[1])+" "+str(msg[2]))
'''
@ -233,20 +233,10 @@ def NoteOn(note,color, mididest):
midiport[port].send_message([NOTE_ON, note, color])
# To All
elif mididest == "all" and midiname[port].find(mididest) != 0 and midiname[port].find(BhorealMidiName) != 0 and midiname[port].find(LaunchMidiName) != 0:
elif mididest == "all" and midiname[port].find(mididest) != 0:
midiport[port].send_message([NOTE_ON, note, color])
'''
# To Launchpad, if present.
elif mididest == "launchpad" and midiname[port].find(LaunchMidiName) == 0:
launchpad.PadNoteOn(note%64,color)
# To Bhoreal, if present.
elif mididest == "bhoreal" and midiname[port].find(BhorealMidiName) == 0:
gstt.BhorLeds[note%64]=color
midiport[port].send_message([NOTE_ON, note%64, color])
#bhorosc.sendosc("/bhoreal", [note%64 , 0])
'''
def NoteOff(note, mididest):
@ -260,21 +250,9 @@ def NoteOff(note, mididest):
midiport[port].send_message([NOTE_OFF, note, 0])
# To All
elif mididest == "all" and midiname[port].find(mididest) == -1 and midiname[port].find(BhorealMidiName) == -1 and midiname[port].find(LaunchMidiName) == -1:
elif mididest == "all" and midiname[port].find(mididest) == -1:
midiport[port].send_message([NOTE_OFF, note, 0])
'''
# To Launchpad, if present.
elif mididest == "launchpad" and midiname[port].find(LaunchMidiName) == 0:
launchpad.PadNoteOff(note%64)
# To Bhoreal, if present.
elif mididest == "bhoreal" and midiname[port].find(BhorealMidiName) == 0:
midiport[port].send_message([NOTE_OFF, note%64, 0])
gstt.BhorLeds[note%64] = 0
#bhorosc.sendosc("/bhoreal", [note%64 , 0])
'''
# Generic call back : new msg forwarded to queue
@ -576,8 +554,8 @@ def listdevice(number):
# return device name number for given mididevice and midichannel
def findJamDevice(mididevice, midichan):
# return device name for given mididevice and midichannel
def findJamName(mididevice, midichan):
#print("searching", mididevice, "channel", midichan,'...')
@ -593,6 +571,22 @@ def findJamDevice(mididevice, midichan):
return "None"
# return all midi devices for given name
def findJamDevices(name):
devices = []
print ("searching", name)
for (k, v) in Confs.items():
if v[0]["type"] == "mididevice":
#print(k, name,k.find(name))
if k.find(name) != -1:
#print(v[0]["mididevice"])
devices.append(v[0]["mididevice"])
#print(devices)
return devices
def check():

14
main.py
View File

@ -256,7 +256,8 @@ def message_received(client, wserver, message):
#cc(Confs[wscommand[1]][0]["midichan"], ccvr, ccvl, Confs[wscommand[1]][0]["mididevice"])
crtvalueMMO3[ccvr]=ccvl
cc(Confs[wscommand[1]][0]["midichan"], ccvr, ccvl, Confs[wscommand[1]][0]["mididevice"])
for mididevice in midi3.findJamDevices(wscommand[1]):
cc(Confs[wscommand[1]][0]["midichan"], ccvr, ccvl, mididevice)
# RESET : /device/reset 1
@ -269,12 +270,16 @@ def message_received(client, wserver, message):
# NOTEON : /device/noteon note velocity
elif wscommand[2] == "noteon":
midi3.NoteOn(int(oscpath[1]), int(oscpath[2]), Confs[wscommand[1]][0]["mididevice"])
for mididevice in midi3.findJamDevices(wscommand[1]):
midi3.NoteOn(int(oscpath[1]), int(oscpath[2]), mididevice)
#midi3.NoteOn(int(oscpath[1]), int(oscpath[2]), Confs[wscommand[1]][0]["mididevice"])
# NOTEOFF /device/noteoff note
elif wscommand[2] == "noteoff":
midi3.NoteOff(int(oscpath[1]), Confs[wscommand[1]][0]["mididevice"])
for mididevice in midi3.findJamDevices(wscommand[1]):
midi3.NoteOff(int(oscpath[1]), mididevice)
#midi3.NoteOff(int(oscpath[1]), Confs[wscommand[1]][0]["mididevice"])
# Loop back : WS Client -> server -> WS Client
@ -299,6 +304,7 @@ LoadConfs()
serverIP = Confs[servername][0]["IP"]
wsPORT = Confs[servername][0]["port"]
print(Confs["ocs2"][0]["mididevice"])
print("Running....")
@ -310,7 +316,7 @@ try:
wserver = WebsocketServer(wsPORT,host=serverIP)
midi3.ws = wserver
midi3.Confs = Confs
midi3.findJamDevice("UM-ONE:UM-ONE MIDI 1 20:0", 1)
#midi3.findJamDevices("ocs2")
print("")
print(GetTime(),"Launching Jamidi Websocket server...")