Redis events
This commit is contained in:
parent
666698c633
commit
fb9999c828
39
README.md
39
README.md
@ -16,18 +16,10 @@ To enable Link :
|
|||||||
|
|
||||||
python3 miredis.py -link
|
python3 miredis.py -link
|
||||||
|
|
||||||
|
## New Features
|
||||||
|
|
||||||
## Redis keys
|
- Added verbose mode -v
|
||||||
|
- Added redis subscribe events
|
||||||
"/midi/noteon/midichannel" value : "note/velocity"
|
|
||||||
|
|
||||||
"/midi/noteoff/midichannel" value : "note"
|
|
||||||
|
|
||||||
"/midi/cc/midichannel/ccnumber" value : "ccvalue"
|
|
||||||
|
|
||||||
"/beat" value : "beatnumber"
|
|
||||||
|
|
||||||
"/bpm" value : "currentbpm"
|
|
||||||
|
|
||||||
|
|
||||||
## OSC
|
## OSC
|
||||||
@ -47,3 +39,28 @@ python3 miredis.py -link
|
|||||||
/beat beatnumber
|
/beat beatnumber
|
||||||
|
|
||||||
/bpm bpm
|
/bpm bpm
|
||||||
|
|
||||||
|
|
||||||
|
## Redis keys
|
||||||
|
|
||||||
|
"/midi/noteon/midichannel" value : "note/velocity"
|
||||||
|
|
||||||
|
"/midi/noteoff/midichannel" value : "note"
|
||||||
|
|
||||||
|
"/midi/cc/midichannel/ccnumber" value : "ccvalue"
|
||||||
|
|
||||||
|
"/beat" value : "beatnumber"
|
||||||
|
|
||||||
|
"/bpm" value : "currentbpm"
|
||||||
|
|
||||||
|
"/midi/last_event" midi events key
|
||||||
|
|
||||||
|
|
||||||
|
## Redis midi events : key "/midi/last_event"
|
||||||
|
|
||||||
|
"/midi/noteon/midichannel/note/velocity"
|
||||||
|
|
||||||
|
"/midi/noteoff/midichannel/note
|
||||||
|
|
||||||
|
"/midi/cc/midichannel/ccnumber/ccvalue"
|
||||||
|
|
||||||
|
Binary file not shown.
@ -159,6 +159,11 @@ def toKey(keyname,keyvalue):
|
|||||||
# Store encoded data in Redis
|
# Store encoded data in Redis
|
||||||
return r.set(keyname,keyvalue)
|
return r.set(keyname,keyvalue)
|
||||||
|
|
||||||
|
def toKeyevent(eventname):
|
||||||
|
|
||||||
|
print("redis midi event key :", eventname)
|
||||||
|
r.publish("/midi/last_event", eventname)
|
||||||
|
|
||||||
def GetTime():
|
def GetTime():
|
||||||
return time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())
|
return time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())
|
||||||
|
|
||||||
@ -291,15 +296,22 @@ def MidinProcess(inqueue, portname):
|
|||||||
MidiNote = msg[1]
|
MidiNote = msg[1]
|
||||||
MidiVel = msg[2]
|
MidiVel = msg[2]
|
||||||
print()
|
print()
|
||||||
|
#print(debug)
|
||||||
print("NOTE ON :", "Channel", MidiChannel, "note :", MidiNote, 'velocity :', MidiVel )
|
print("NOTE ON :", "Channel", MidiChannel, "note :", MidiNote, 'velocity :', MidiVel )
|
||||||
|
|
||||||
# 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:
|
||||||
print("redis :", "/midi/noteon/"+str(MidiChannel)+" : "+ str(MidiNote)+"/"+str(MidiVel))
|
if debug == "True":
|
||||||
|
print("redis :", "/midi/noteon/"+str(MidiChannel)+" : "+ str(MidiNote)+"/"+str(MidiVel))
|
||||||
|
|
||||||
|
# to Key redis pubsub feed
|
||||||
|
toKeyevent("/midi/noteon/"+str(MidiChannel)+"/"+str(MidiNote)+"/"+str(MidiVel))
|
||||||
|
|
||||||
# OSC : /midi/noteon midichannel note velocity
|
# OSC : /midi/noteon midichannel note velocity
|
||||||
SendOSC("/midi/noteon",[MidiChannel, msg[1], msg[2]])
|
#SendOSC("/midi/noteon",[MidiChannel, msg[1], msg[2]])
|
||||||
print("osc :","/midi/noteon/",[MidiChannel, msg[1], msg[2]])
|
#print("osc :","/midi/noteon/",[MidiChannel, msg[1], msg[2]])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
# Sampler mode : note <63 launch snare.wav / note > 62 kick.wav
|
# Sampler mode : note <63 launch snare.wav / note > 62 kick.wav
|
||||||
@ -327,16 +339,22 @@ def MidinProcess(inqueue, portname):
|
|||||||
MidiChannel = msg[0]-144
|
MidiChannel = msg[0]-144
|
||||||
else:
|
else:
|
||||||
MidiChannel = msg[0]-128
|
MidiChannel = msg[0]-128
|
||||||
|
|
||||||
MidiNote = msg[1]
|
MidiNote = msg[1]
|
||||||
print("NOTE_off channel :", MidiChannel, "note :", MidiNote)
|
print("NOTE_off channel :", MidiChannel, "note :", MidiNote)
|
||||||
|
|
||||||
# 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:
|
||||||
print("redis :", "/midi/noteoff/"+str(MidiChannel)+" : "+ str(MidiNote))
|
if debug == "True":
|
||||||
|
print("redis :", "/midi/noteoff/"+str(MidiChannel)+" : "+ str(MidiNote))
|
||||||
|
|
||||||
|
# to Key redis pubsub feed
|
||||||
|
#toKeyevent("/midi/noteoff/"+str(MidiChannel)+"/"+str(MidiNote))
|
||||||
|
|
||||||
# OSC : /midi/noteoff midichannel note
|
# OSC : /midi/noteoff midichannel note
|
||||||
SendOSC("/midi/noteoff",[MidiChannel, msg[1]])
|
SendOSC("/midi/noteoff",[MidiChannel, msg[1]])
|
||||||
print('osc :', "/midi/noteoff",[MidiChannel, msg[1]])
|
if debug == "True":
|
||||||
|
print('osc :', "/midi/noteoff",[MidiChannel, msg[1]])
|
||||||
|
|
||||||
|
|
||||||
# # CC on all Midi Channels
|
# # CC on all Midi Channels
|
||||||
@ -349,11 +367,15 @@ def MidinProcess(inqueue, portname):
|
|||||||
|
|
||||||
# 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:
|
||||||
print("redis :", "/midi/cc/"+str(MidiChannel)+"/"+str(msg[1]), ":", str(msg[2]))
|
if debug == "True":
|
||||||
|
print("redis :", "/midi/cc/"+str(MidiChannel)+"/"+str(msg[1]), ":", str(msg[2]))
|
||||||
|
|
||||||
|
# to Key redis pubsub feed
|
||||||
|
toKeyevent("/midi/cc/"+str(MidiChannel)+"/"+str(msg[1])+"/"+str(msg[2]))
|
||||||
|
|
||||||
# OSC : /midi/cc midichannel ccnumber value
|
# OSC : /midi/cc midichannel ccnumber value
|
||||||
SendOSC("/midi/cc",[msg[0]-175-1, msg[1], msg[2]])
|
#SendOSC("/midi/cc",[msg[0]-175-1, msg[1], msg[2]])
|
||||||
print("osc :","/midi/cc",[msg[0]-175-1, msg[1], msg[2]] )
|
#print("osc :","/midi/cc",[msg[0]-175-1, msg[1], msg[2]] )
|
||||||
|
|
||||||
|
|
||||||
if msg[0] == TIMING_CLOCK:
|
if msg[0] == TIMING_CLOCK:
|
||||||
@ -399,7 +421,8 @@ def MidinProcess(inqueue, portname):
|
|||||||
|
|
||||||
# OSC : /midi/start
|
# OSC : /midi/start
|
||||||
SendOSC("/midi/stop",[])
|
SendOSC("/midi/stop",[])
|
||||||
print("osc : /midi/stop")
|
if debug =="True":
|
||||||
|
print("osc : /midi/stop")
|
||||||
print()
|
print()
|
||||||
'''
|
'''
|
||||||
# other midi message
|
# other midi message
|
||||||
|
36
miredis.py
36
miredis.py
@ -120,12 +120,46 @@ r = redis.StrictRedis(host=redisIP , port=redisPORT, db=0)
|
|||||||
midix.r = r
|
midix.r = r
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def Osc():
|
||||||
|
|
||||||
|
p = r.pubsub()
|
||||||
|
p.subscribe('updates')
|
||||||
|
print("Artnet updates subscribed")
|
||||||
|
|
||||||
|
while True:
|
||||||
|
|
||||||
|
# Handle OSC based changed
|
||||||
|
OSCframe()
|
||||||
|
|
||||||
|
# Handle Artnet change via redis key 'updates' subscription
|
||||||
|
message = p.get_message()
|
||||||
|
|
||||||
|
if message:
|
||||||
|
messageCC = message['data']
|
||||||
|
# print(type(messageCC))
|
||||||
|
#print("Updates said: %s" % messageCC)
|
||||||
|
if messageCC != 1:
|
||||||
|
#if ":" in str(messageCC.decode('utf_8')):
|
||||||
|
messageCC = messageCC.decode('utf_8')
|
||||||
|
artnetCC = messageCC.split(":")
|
||||||
|
if len(artnetCC) > 1:
|
||||||
|
cc(int(artnetCC[0]), round(int(artnetCC[1])/2))
|
||||||
|
print()
|
||||||
|
|
||||||
|
#time.sleep(0.0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
|
|
||||||
import traceback
|
import traceback
|
||||||
import time
|
import time
|
||||||
|
|
||||||
midix.check()
|
midix.check()
|
||||||
|
|
||||||
midix.toKey("/beats","0.0")
|
midix.toKey("/beats","0.0")
|
||||||
|
Loading…
Reference in New Issue
Block a user