Added opensource Ableton Link protocol
This commit is contained in:
parent
e023a5ede6
commit
77afd636e8
10 changed files with 169 additions and 3 deletions
Binary file not shown.
135
libs/alink.py
Normal file
135
libs/alink.py
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
# -*- mode: Python -*-
|
||||
|
||||
'''
|
||||
|
||||
Ableton Link
|
||||
|
||||
LICENCE : CC
|
||||
Sam Neurohack
|
||||
|
||||
|
||||
Get:
|
||||
|
||||
git clone --recursive https://github.com/gonzaloflirt/link-python.git
|
||||
|
||||
Build:
|
||||
|
||||
Make sure python 3 is installed on your system.
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
cmake --build .
|
||||
|
||||
'''
|
||||
from libs import midix
|
||||
import sys
|
||||
|
||||
prevphase = 0
|
||||
bpm = 120
|
||||
|
||||
def Start():
|
||||
global lnk
|
||||
from libs import link
|
||||
|
||||
print("Link ENABLED")
|
||||
lnk = link.Link(120)
|
||||
lnk.enabled = True
|
||||
lnk.startStopSyncEnabled = True
|
||||
linked = True
|
||||
|
||||
def RedOSC(tempo_str, beats_str):
|
||||
|
||||
print()
|
||||
print("Link : BPM " +tempo_str+" Beat "+str(beats_str) + ' \r')
|
||||
#sys.stdout.flush()
|
||||
|
||||
|
||||
# redis key : "/beats" value : currentbeat
|
||||
if midix.toKey('/beats', beats_str)==True:
|
||||
print("redis :", '/beats', beats_str)
|
||||
|
||||
# OSC : /midi/cc midichannel ccnumber value
|
||||
midix.SendOSC('/beats', [beats_str])
|
||||
print("osc :",'/beats', [beats_str])
|
||||
|
||||
# redis key : "/bpm" value : newbpm
|
||||
if midix.toKey('/bpm', bpm)==True:
|
||||
print("redis :", '/bpm', bpm)
|
||||
|
||||
# OSC : /bpm newbpm
|
||||
midix.SendOSC('/bpm', [bpm])
|
||||
print("osc :",'/bpm', [bpm])
|
||||
|
||||
|
||||
def BeatEvent():
|
||||
global lnk, prevphase
|
||||
|
||||
|
||||
lnkstr = lnk.captureSessionState()
|
||||
link_time = lnk.clock().micros();
|
||||
tempo_str = '{0:.2f}'.format(lnkstr.tempo())
|
||||
bpm = float(tempo_str)
|
||||
#beatstep.SendOSCUI('/bpm', [bpm])
|
||||
beats_str = '{0:.2f}'.format(lnkstr.beatAtTime(link_time, 0))
|
||||
playing_str = str(lnkstr.isPlaying()) # always False ???
|
||||
phase = lnkstr.phaseAtTime(link_time, 4)
|
||||
|
||||
|
||||
# new beat ?
|
||||
if int(phase) != prevphase:
|
||||
prevphase = int(phase)
|
||||
|
||||
RedOSC(tempo_str, beats_str)
|
||||
currentbeat = float(beats_str)
|
||||
#midix.SendAU('/aurora/beats', beats_str)
|
||||
#AllStatus("Beat "+str(beats_str))
|
||||
|
||||
|
||||
|
||||
# Change current Link Tempo.
|
||||
def newtempo(tempo):
|
||||
global lnk
|
||||
|
||||
#print("val2", val2, "tempo", tempo)
|
||||
|
||||
if linked == True:
|
||||
lnk.enabled = False
|
||||
lnk.startStopSyncEnabled = False
|
||||
lnk = link.Link(tempo)
|
||||
lnk.enabled = True
|
||||
lnk.startStopSyncEnabled = True
|
||||
bpm = tempo
|
||||
print("New BPM to Link", bpm)
|
||||
RedOSC(str(tempo), "0.0")
|
||||
|
||||
'''
|
||||
# redis key : "/bpm" value : newbpm
|
||||
if midix.toKey('/bpm', bpm)==True:
|
||||
print("redis :", '/bpm', bpm)
|
||||
|
||||
# OSC : /bpm newbpm
|
||||
midix.SendOSC('/bpm', [bpm])
|
||||
print("osc :",'/bpm', [bpm])
|
||||
'''
|
||||
|
||||
else:
|
||||
print("Link is disabled")
|
||||
|
||||
|
||||
# increase or decrease BPM
|
||||
def BPMAdj(val1, keyname):
|
||||
|
||||
|
||||
# + 1
|
||||
if val1 == 1:
|
||||
newtempo(bpm+1)
|
||||
|
||||
# -1
|
||||
if val1 == 127 and bpm > 0:
|
||||
newtempo(bpm-1)
|
||||
|
||||
|
||||
|
||||
BIN
libs/link.cpython-35m-x86_64-linux-gnu.so
Normal file
BIN
libs/link.cpython-35m-x86_64-linux-gnu.so
Normal file
Binary file not shown.
BIN
libs/link.cpython-36m-x86_64-linux-gnu.so
Normal file
BIN
libs/link.cpython-36m-x86_64-linux-gnu.so
Normal file
Binary file not shown.
BIN
libs/link.cpython-37m-darwin.so
Normal file
BIN
libs/link.cpython-37m-darwin.so
Normal file
Binary file not shown.
BIN
libs/link.cpython-38-darwin.so
Executable file
BIN
libs/link.cpython-38-darwin.so
Executable file
Binary file not shown.
BIN
libs/link.so
Executable file
BIN
libs/link.so
Executable file
Binary file not shown.
|
|
@ -146,7 +146,18 @@ def SendUI(oscaddress,oscargs=''):
|
|||
log.err('Connection to Aurora UI refused : died ?')
|
||||
pass
|
||||
#time.sleep(0.001
|
||||
# Ask redis for a given key
|
||||
|
||||
def fromKey(keyname):
|
||||
|
||||
return r.get(keyname)
|
||||
|
||||
#
|
||||
# Write to redis key
|
||||
def toKey(keyname,keyvalue):
|
||||
#print(keyname,keyvalue)
|
||||
# Store encoded data in Redis
|
||||
return r.set(keyname,keyvalue)
|
||||
|
||||
def GetTime():
|
||||
return time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue