Async Python interface for Ableton Link
Project description
aalink is a Python wrapper for Ableton Link built for interactive applications using asyncio event loops.
It provides awaitable objects for synchronizing Python code with other peers in an Ableton Link session, but it may also be used for writing fully standalone scripts with tempo/beat synchronization, such as applications for light and sound control.
Installation
aalink requires at least Python 3.7. It can be installed using pip:
pip3 install aalink
It may be required to install the latest version of MSVC Runtime libraries on Windows to use the binary wheels currently hosted on PyPI.
Usage
aalink uses asyncio. To connect to a Link session, create a Link object, passing the asyncio event loop to the constructor, and await for Link.sync() as follows:
import asyncio
from aalink import Link
async def main():
loop = asyncio.get_running_loop()
link = Link(120, loop)
link.enabled = True
while True:
await link.sync(1)
print('bang!')
asyncio.run(main())
Link.sync(n) returns a Future scheduled to be done when Link time reaches next n-th beat on the timeline.
In the above example, awaiting for link.sync(1) will pause and resume the main coroutine at beats 1, 2, 3, and so on.
Keep in mind that awaiting for sync(n) does not cause a coroutine to sleep for the given number of beats. Regardless of the moment when the coroutine is suspended, it will resume when the next closest n-th beat is reached on the shared Link timeline, e.g. awaiting for sync(2) at beat 11.5 will resume at beat 12.
Non-integral beat syncing is supported. For example:
await link.sync(1/2) # resumes at beats 0.5, 1, 1.5...
await link.sync(3/2) # resumes at beats 1.5, 3, 4.5...
Sync events can be scheduled with an offset (also expressed in beats) by passing an offset argument to sync(). Use this to add groove to the coroutine rhythm.
async def arpeggiate():
for i in range(16):
swing = 0.25 if i % 2 == 1 else 0
await link.sync(1/2, offset=swing)
print('###', i)
await link.sync(1/2, offset=0)
print('@@@', i)
Combine synced coroutines to run in series or concurrently:
import asyncio
from aalink import Link
async def main():
loop = asyncio.get_running_loop()
link = Link(120, loop)
link.enabled = True
async def sequence(name):
for i in range(4):
await link.sync(1)
print('bang!', name)
await sequence('a')
await sequence('b')
await asyncio.gather(sequence('c'), sequence('d'))
asyncio.run(main())
Limitations
Start/stop syncing is not implemented yet.
aalink aims to be punctual, but it is not 100% accurate due to the processing delay in the internal scheduler and the uncertainty of event loop iterations timing.
For convenience, the numerical values of futures returned from sync() aren’t equal to the exact beat time from the moment the futures are done. They correspond to the previously estimated resume times instead.
b = await link.sync(1) # b will be 1.0, returned at beat 1.00190
b = await link.sync(1) # b will be 2.0, returned at beat 2.00027
b = await link.sync(1) # b will be 3.0, returned at beat 3.00005
License
Copyright (c) 2023 Artem Popov <art@artfwo.net>
aalink is licensed under the GNU General Public License (GPL) version 3. You can find the full text of the GPL license in the LICENSE file included in this repository.
aalink includes code from pybind11 and Ableton Link.
Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>, All rights reserved.
Copyright 2016, Ableton AG, Berlin. All rights reserved.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for aalink-0.0.4-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc2c5f51d9b24948039d191f6b8edc10ea043401e66d77bcb1f55451bc853143 |
|
MD5 | 03813670c995f6b0557048934bc1e12d |
|
BLAKE2b-256 | d1cad8f1de2e6141d15c6f191905d81e8a1dcd0c0bcb50dd35e603deac2f3e6a |
Hashes for aalink-0.0.4-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9ba1f08e0ab4e6e18ffc46076aea047f74d392472c7b5984cad9db29ae37613 |
|
MD5 | 0271654c3c3cc891588ee15709d1a4a0 |
|
BLAKE2b-256 | ffa9fff1ad07b607f1d8f038afbbd0d7c7f914c8e493242984335ad3ac012323 |
Hashes for aalink-0.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 244f47cfc45bcffe203b47f097e3f711a617b5065eefa6c5ba020774dfdacc2f |
|
MD5 | 2611a4dc5958fec306f2811b20c9e77e |
|
BLAKE2b-256 | 372e8b9992053a9df7da1e822b5aa16a6e83113bed8edc36c1b71b2ada8ad3af |
Hashes for aalink-0.0.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e24c1ab26fd3cf330b6bd32c0e56e28125cf850dffc3062f64de2515e65ed95 |
|
MD5 | 8830cf562f1392dfe2a036346352ea34 |
|
BLAKE2b-256 | 27d5434fef884efc5158c190868e2e57d3bc6efbbc0e7643ae85fa239b22d85f |
Hashes for aalink-0.0.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6f085407c46c8ed169246c23d3477279fb2923bab2aad8771c96d2ee90614a3 |
|
MD5 | cc0cb3b84c13176dbce17ed90d962bfb |
|
BLAKE2b-256 | 171898cd256cdf80da3a4a0fc5982f3724dc1de65c5f1dc5d8482f3bb9975dd3 |
Hashes for aalink-0.0.4-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1115f0f980ea8c7355dbf7aab900f2d9ec9aae833a614c1240e9ebd0eeac7029 |
|
MD5 | 58fa33855025dc627609a6a942775945 |
|
BLAKE2b-256 | c82f4fa06c789e388c60cafdd37f1432ec50b78c477aae2196292d5012316a75 |
Hashes for aalink-0.0.4-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39abfc27e2fc096939853ae4874e4f3d3bf2d3dd40df9880eaa42b59382e1ce6 |
|
MD5 | 520ff951bd7082067c55e01a1c593093 |
|
BLAKE2b-256 | 5ce6bfc0bca3666e820d6c34314c44d3235cb1289ad372c0f67a448daf8d665a |
Hashes for aalink-0.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3bc43f37bcc493d48cb7eb8792d03466ac28a365eb7eb9251263b27a4f4f6bf |
|
MD5 | 3fea96c56b9b3d89b30af6d57c993236 |
|
BLAKE2b-256 | bf049dd95f5ac5e803806a0498a0bdbff520316426bdc09d989019033f9dda92 |
Hashes for aalink-0.0.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b74318fc8f521efeca91e97a6cd7c46674c627bb8c03c1a575f70a27c60af934 |
|
MD5 | 95c446d2a31716129c2cad3709e50be9 |
|
BLAKE2b-256 | 7b9ee234eac50d61e6cab398717ec8ed0686b86c60c3f16f1d245544474167f6 |
Hashes for aalink-0.0.4-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 80f44ecddf72df350c2206aeefb0e60a838598c1aeb1d51b509a0a32d03a272a |
|
MD5 | 40fe94abe6f395823d0f9c6ab52b8cf5 |
|
BLAKE2b-256 | cdf62732cb89c50a239687b80d1fe86c113537c5c65a5e931f17b2c475ab1d9a |
Hashes for aalink-0.0.4-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a54d191869cd2a004ccfb9fdd812a6b51a7a60fae77ee95246b8aed0fc219aab |
|
MD5 | 1a952fc314e672371c8c5ee614bec1fc |
|
BLAKE2b-256 | 9ed7a3ed4c2ebf03f07a6b061d8dc671fa321a6f9a21be2c716383aaef1db68a |
Hashes for aalink-0.0.4-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e632120bc0ad797ccd3456fd065310ae036ca33153e2cac5fa6f95cadb3e84ab |
|
MD5 | 4c96648e5d3b8ecb1bbb58e3d4986247 |
|
BLAKE2b-256 | 16ab68f38fc858a8b682a406b24f9bb061ef9e1ef1b35e402ff153759b5851be |
Hashes for aalink-0.0.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c78636f13b125f63295f1570bf7498235c759bf92b4a801f17227f195d3da17 |
|
MD5 | 787472fa680aa43b71dfdcb01bb36367 |
|
BLAKE2b-256 | 66f7e35a4cebf4cd8fe34fb488b76fc92e0cfc4e00e6ce965be6e3c14a588b0a |
Hashes for aalink-0.0.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6064d380a87cb337776da24d13f50a56eb08c1dc5703f2177d17c21fc8a7413c |
|
MD5 | ae7c9ccb596994164ba1ab3adfce18ca |
|
BLAKE2b-256 | cbfb42533d47f6ffe21061d16af8cda128b375f03a389bd18adee36316a465c8 |
Hashes for aalink-0.0.4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69207b794d3316c281ef8989e8e52fe984cf43316ca0eafaa7f1d199f21245c0 |
|
MD5 | 6c137edf8e12713513348d8a5ad1669e |
|
BLAKE2b-256 | 7fc71ea6dd89a8e96b934840dd40fb3918ab504d0fbe66bfc65d112fb6c4b27a |
Hashes for aalink-0.0.4-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5297c8f37a5155baf07936baa517a0339a2783fd7acf9f85e7be26357ec59bbf |
|
MD5 | 50ab425d47c20b5eda68809404ba0af6 |
|
BLAKE2b-256 | 2511e4936e4a89b75522e8d3d35cd35e57e8b6687085857f77a9575c57cda15c |
Hashes for aalink-0.0.4-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ed26f8edb0e424535222a09adea939935fb8e315a3d5ff2a350736f74e30224 |
|
MD5 | 0a16802b1105a96ee3bad1518ee7092a |
|
BLAKE2b-256 | f03b4ffbef3a499873838388cd165b1348b29da2182eff1b98c589f50b59bdec |
Hashes for aalink-0.0.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c749d9ea525d1322a3ef7659963191319015aeda6842b986e322c6602da2841c |
|
MD5 | 96a4aa3db43dfd90e0aee391959ff748 |
|
BLAKE2b-256 | d3fbbeff34125f19d73f50aaafaa75727267c0d988c2bb3858b7601496b97804 |
Hashes for aalink-0.0.4-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 269377dc339b84a17e12172692a421c9ca0326467b108a755b3363a864df8ffa |
|
MD5 | 6475dadaf95fa889e3235aac3286d346 |
|
BLAKE2b-256 | 20023a9a0e2b64440293ceae24d93c5ccc76059f78162b3664967a1950c385be |
Hashes for aalink-0.0.4-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0db04524425b6830cf2575b03aca5184e5d00caed1edd31b78c8cf93319254d |
|
MD5 | 778ce88a96fcf10617759c12a05fa994 |
|
BLAKE2b-256 | bed368f4dd6fa11a2d67974fd760147f97c75e63185328eef11d56dd13951c29 |
Hashes for aalink-0.0.4-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 169cad6f632b1eceb9d72b716d62d67e869da333773fe0dae4a7d1f9c81e178c |
|
MD5 | 8defa3a746582044c8a50239f3223582 |
|
BLAKE2b-256 | 4bdb438153ee8dfb4dad14f01f7cab6c5ef66fa798a8b3a5b3a1252d954fc048 |
Hashes for aalink-0.0.4-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1809c6dd7e4fd5feebc72952e1775eca27eb725acaa49e2681a4b50a6e51272e |
|
MD5 | eca442ad4c9f445cc762a19777637e8d |
|
BLAKE2b-256 | b82385ba4298ab90a8a096618b9c6b9ec54464f94cd7ed98d85ee6c1c61957b6 |
Hashes for aalink-0.0.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c8d349fe7e58f5fb9b64d88203f0e895371324b69fcc8fe685698d1926f5967 |
|
MD5 | c3167103422215790268b24db2a98ea9 |
|
BLAKE2b-256 | a82f0014b55f1e9345984d80369ad5014c2a49cfca474d0f3fca72af496dae10 |
Hashes for aalink-0.0.4-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81e354040eef4494c5aed94eba27cf9c40b8ee10623292cfb2c06dbd98fc2f80 |
|
MD5 | 5fab26db7d256edfabc6322bcdbd0ce6 |
|
BLAKE2b-256 | 25d0f0caf7052348ca4db24ecf66f5053aca641a23f26586292ecea3e265a061 |