artfwo / aalink

Async Python interface for Ableton Link

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

aalink

aalink is a Python wrapper for Ableton Link built for interactive applications using asyncio event loops.

It provides a simple programming interface for writing concurrent Python code synchronized to a beat. The beat can optionally be time-aligned with other peers in an Ableton Link session.

Installation

aalink requires at least Python 3.8. 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:

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:

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.

Combine synced coroutines to run in series or concurrently:

Limitations

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.

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.

pybind11

Copyright (c) 2016 Wenzel Jakob <wenzel.jakob@epfl.ch>, All rights reserved.

pybind11 license

Ableton Link

Copyright 2016, Ableton AG, Berlin. All rights reserved.

Ableton Link license

About

Async Python interface for Ableton Link

License:GNU General Public License v3.0


Languages

Language:C++ 93.8%Language:CMake 6.2%