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
|
||||
|
||||
## New Features
|
||||
|
||||
## 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"
|
||||
- Added verbose mode -v
|
||||
- Added redis subscribe events
|
||||
|
||||
|
||||
## OSC
|
||||
@ -47,3 +39,28 @@ python3 miredis.py -link
|
||||
/beat beatnumber
|
||||
|
||||
/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
|
||||
return r.set(keyname,keyvalue)
|
||||
|
||||
def toKeyevent(eventname):
|
||||
|
||||
print("redis midi event key :", eventname)
|
||||
r.publish("/midi/last_event", eventname)
|
||||
|
||||
def GetTime():
|
||||
return time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())
|
||||
|
||||
@ -291,15 +296,22 @@ def MidinProcess(inqueue, portname):
|
||||
MidiNote = msg[1]
|
||||
MidiVel = msg[2]
|
||||
print()
|
||||
#print(debug)
|
||||
print("NOTE ON :", "Channel", MidiChannel, "note :", MidiNote, 'velocity :', MidiVel )
|
||||
|
||||
# redis key : "/midi/noteon/midichannel" value : "note/velocity"
|
||||
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
|
||||
SendOSC("/midi/noteon",[MidiChannel, msg[1], msg[2]])
|
||||
print("osc :","/midi/noteon/",[MidiChannel, msg[1], msg[2]])
|
||||
#SendOSC("/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
|
||||
@ -327,16 +339,22 @@ def MidinProcess(inqueue, portname):
|
||||
MidiChannel = msg[0]-144
|
||||
else:
|
||||
MidiChannel = msg[0]-128
|
||||
|
||||
MidiNote = msg[1]
|
||||
print("NOTE_off channel :", MidiChannel, "note :", MidiNote)
|
||||
|
||||
# redis key : "/midi/noteon/midichannel" value : "note"
|
||||
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
|
||||
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
|
||||
@ -349,11 +367,15 @@ def MidinProcess(inqueue, portname):
|
||||
|
||||
# redis key : "/midi/cc/midichannel/ccnumber" value : "ccvalue"
|
||||
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
|
||||
SendOSC("/midi/cc",[msg[0]-175-1, msg[1], msg[2]])
|
||||
print("osc :","/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]] )
|
||||
|
||||
|
||||
if msg[0] == TIMING_CLOCK:
|
||||
@ -399,7 +421,8 @@ def MidinProcess(inqueue, portname):
|
||||
|
||||
# OSC : /midi/start
|
||||
SendOSC("/midi/stop",[])
|
||||
print("osc : /midi/stop")
|
||||
if debug =="True":
|
||||
print("osc : /midi/stop")
|
||||
print()
|
||||
'''
|
||||
# other midi message
|
||||
|
34
miredis.py
34
miredis.py
@ -120,6 +120,40 @@ r = redis.StrictRedis(host=redisIP , port=redisPORT, db=0)
|
||||
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__':
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user