diff --git a/README.md b/README.md index 7009c38..299b390 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Forward Midi events to redis/OSC Miredis hooks to all midi devices connected and listen for events. -Miredis can optionnaly hook to Link protocol -> "/beats" & "/bpm" +Miredis can optionnaly hook to opensourced Link protocol (200+ music & videos apps) -> "/beat" & "/bpm" All events are forwarded to a redis server and an OSC server. Run : @@ -12,6 +12,10 @@ See options : python3 miredis.py -h +To enable Link : + +python3 miredis.py -link + ## Redis keys @@ -21,10 +25,11 @@ python3 miredis.py -h "/midi/cc/midichannel/ccnumber" value : "ccvalue" -"/beats" value : "beatnumber" +"/beat" value : "beatnumber" "/bpm" value : "currentbpm" + ## OSC /midi/noteon midichannel note velocity @@ -39,6 +44,6 @@ python3 miredis.py -h /midi/stop -/beats beatnumber +/beat beatnumber /bpm bpm diff --git a/libs/alink.py b/libs/alink.py index 454e15c..b626d47 100644 --- a/libs/alink.py +++ b/libs/alink.py @@ -4,12 +4,11 @@ ''' -Ableton Link +Ableton Link with bridge to OSC & Redis LICENCE : CC Sam Neurohack - Get: git clone --recursive https://github.com/gonzaloflirt/link-python.git @@ -47,22 +46,24 @@ def RedOSC(tempo_str, beats_str): #sys.stdout.flush() - # redis key : "/beats" value : currentbeat - if midix.toKey('/beats', beats_str)==True: - print("redis :", '/beats', beats_str) + # redis key : "/beat" value : currentbeat + if midix.toKey('/beat', beats_str)==True: + pass + #print("redis :", '/beat', beats_str) # OSC : /midi/cc midichannel ccnumber value - midix.SendOSC('/beats', [beats_str]) - print("osc :",'/beats', [beats_str]) + midix.SendOSC('/beat', [beats_str]) + #print("osc :",'/beat', [beats_str]) # redis key : "/bpm" value : newbpm if midix.toKey('/bpm', bpm)==True: - print("redis :", '/bpm', bpm) + pass + #print("redis :", '/bpm', bpm) # OSC : /bpm newbpm midix.SendOSC('/bpm', [bpm]) - print("osc :",'/bpm', [bpm]) - + #print("osc :",'/bpm', [bpm]) + def BeatEvent(): global lnk, prevphase @@ -87,14 +88,17 @@ def BeatEvent(): #midix.SendAU('/aurora/beats', beats_str) #AllStatus("Beat "+str(beats_str)) + # New external bpm saved in redis key ? + redbpm = float(midix.fromKey("/bpm")) + if bpm != redbpm: + print("New external BPM -> Link", redbpm) + newtempo(redbpm) # Change current Link Tempo. def newtempo(tempo): global lnk - #print("val2", val2, "tempo", tempo) - if linked == True: lnk.enabled = False lnk.startStopSyncEnabled = False diff --git a/miredis.py b/miredis.py index 8e24c66..d542cce 100644 --- a/miredis.py +++ b/miredis.py @@ -128,6 +128,9 @@ if __name__ == '__main__': midix.check() + midix.toKey("/beats","0.0") + midix.toKey("/bpm",120) + try: while True: