| Crates.io | ableton-link-rs |
| lib.rs | ableton-link-rs |
| version | 0.1.2 |
| created_at | 2025-08-12 15:41:19.07934+00 |
| updated_at | 2025-08-19 14:22:18.613079+00 |
| description | Native Rust implementation of the Ableton Link protocol |
| homepage | |
| repository | https://github.com/anweiss/ableton-link-rs |
| max_upload_size | |
| id | 1792146 |
| size | 384,245 |
This is a Rust implementation of Ableton Link, a technology that synchronizes musical beat, tempo, and phase across multiple applications running on one or more devices. Applications on devices connected to a local network discover each other automatically and form a musical session in which each participant can perform independently: anyone can start or stop while still staying in time. Anyone can change the tempo, the others will follow. Anyone can join or leave without disrupting the session.
This Rust crate provides an asynchronous, safe implementation of the Link protocol, leveraging Rust's memory safety guarantees and Tokio's async runtime for efficient network operations.
This Rust implementation is licensed under the GNU General Public License v3.0, consistent with the original Ableton Link project.
Add this to your Cargo.toml :
[dependencies]
ableton-link-rs = "0.1.0"
use ableton_link_rs::link::BasicLink;
use std::time::Duration;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a new Link instance with 120 BPM
let mut link = BasicLink::new(120.0).await;
// Enable Link (starts network discovery)
link.enable().await;
// Capture current session state
let mut session_state = link.capture_app_session_state();
// Get current tempo
println!("Current tempo: {} BPM", session_state.tempo());
// Change tempo
let current_time = link.clock().micros();
session_state.set_tempo(140.0, current_time);
// Commit changes back to Link
link.commit_app_session_state(session_state).await;
Ok(())
}
The project includes a Rust version of LinkHut, demonstrating basic Link functionality:
# Clone the repository
git clone https://github.com/anweiss/ableton-link-rs.git
cd ableton-link-rs
# Build the project
cargo build
# Run the RustHut example natively
cargo run --example rusthut
For containerized deployment, you can run the rusthut example in Docker:
# Build the Docker image
docker build -t rusthut-app .
# Run the container with interactive mode and host networking
docker run -it --network host rusthut-app
Host networking is recommended for optimal Ableton Link peer discovery across the network.
The rusthut example provides an interactive command-line interface similar to the original LinkHut:
a: Enable/disable Linkspace: Start/stop playbackw/e: Decrease/increase tempor/t: Decrease/increase quantums: Enable/disable start/stop syncq: QuitThe main entry point for using Ableton Link:
// Create a new Link instance
let mut link = BasicLink::new(120.0).await;
// Enable/disable Link
link.enable().await;
link.disable().await;
// Check status
let is_enabled = link.is_enabled();
let peer_count = link.num_peers();
// Session state management
let session_state = link.capture_app_session_state();
link.commit_app_session_state(session_state).await;
Represents the current state of the Link session:
let mut state = link.capture_app_session_state();
// Tempo operations
let tempo = state.tempo();
state.set_tempo(140.0, current_time);
// Beat/time operations
let beat = state.beat_at_time(current_time, 4.0);
let time = state.time_at_beat(1.0, 4.0);
let phase = state.phase_at_time(current_time, 4.0);
// Start/stop operations
state.set_is_playing(true, current_time);
let is_playing = state.is_playing();
For real-time audio applications, use the audio-specific session state methods:
// In your audio callback
let session_state = link.capture_audio_session_state();
// Use session_state to sync your audio...
// If you need to modify state from audio thread
link.commit_audio_session_state(modified_state);
Note: The current implementation's audio session state methods are placeholders. For production audio applications, these would need to be implemented with lock-free, real-time safe mechanisms.
The Link implementation uses chrono::Duration for precise time handling:
use chrono::Duration;
let clock = link.clock();
let current_time = clock.micros(); // Returns Duration since epoch in microseconds
The Clock abstraction provides platform-specific implementations for obtaining high-resolution system time, essential for accurate synchronization.
The Rust implementation is structured with the following key modules:
link: Main Link API and session managementdiscovery: Peer discovery and network messagingclock: Platform-specific time sourcestimeline: Beat/tempo/phase calculationscontroller: Session state management and coordination| Platform | Minimum Required |
|---|---|
| All | Rust 1.70+ |
| macOS | macOS 10.15+ |
| Linux | glibc 2.28+ |
| Windows | Windows 10+ |
Key dependencies include:
Result type for explicit error handlingtracing crate for structured loggingRun the test suite with:
cargo test
For integration testing with the original C++ Link implementation:
./test_interop.sh
Contributions are welcome! Please ensure that:
cargo testcargo fmtcargo clippyFor more information about Ableton Link concepts and theory:
This implementation aims for full compatibility with the official Ableton Link specification and should interoperate seamlessly with applications using the official C++ Link library.
This is an early-stage implementation. While the core Link protocol is implemented and functional, some areas may need additional work for production use:
For questions about this Rust implementation, please open an issue on GitHub. For general Ableton Link questions or licensing inquiries, contact link-devs@ableton.com.