Rust bindings for JACK Audio Connection Kit.
JACK is a low-latency audio server that allows multiple applications to share audio and MIDI devices and route signals between each other. This crate provides safe Rust bindings to create JACK clients that can process audio and MIDI in real-time.
- Guide - Quickstart, features, and tutorials
- API Reference - Complete API documentation
use std::io;
fn main() {
// Create a JACK client
let (client, _status) =
jack::Client::new("rust_jack_simple", jack::ClientOptions::default()).unwrap();
// Register input and output ports
let in_port = client
.register_port("input", jack::AudioIn::default())
.unwrap();
let mut out_port = client
.register_port("output", jack::AudioOut::default())
.unwrap();
// Create a processing callback that copies input to output
let process = jack::contrib::ClosureProcessHandler::new(
move |_: &jack::Client, ps: &jack::ProcessScope| -> jack::Control {
out_port.as_mut_slice(ps).clone_from_slice(in_port.as_slice(ps));
jack::Control::Continue
},
);
// Activate the client
let _active_client = client.activate_async((), process).unwrap();
// Wait for user to quit
println!("Press enter to quit...");
let mut input = String::new();
io::stdin().read_line(&mut input).ok();
}See the examples directory for more.
Add to your Cargo.toml:
[dependencies]
jack = "0.13"A JACK server must be running for clients to connect. Install one of:
- Linux/BSD: JACK2 (lowest latency), Pipewire JACK (easiest), or JACK1 via your package manager
- Windows: Official installer or Chocolatey
- macOS: Official installer or Homebrew
By default, clients request the server to start on demand. Use
ClientOptions::default() or the NO_START_SERVER flag to disable this.
Tests require a dummy JACK server and must run single-threaded:
./dummy_jack_server.sh &
cargo nextest runIf cargo nextest is unavailable: RUST_TEST_THREADS=1 cargo test
- Use
cargo nextestinstead ofcargo testfor better handling of timing-sensitive tests - Try libjack2 or pipewire-jack if tests fail with your current JACK implementation
MIT - see LICENSE for details.