17 releases (7 breaking)

0.8.0 Jan 21, 2026
0.6.0 Jan 12, 2026
0.3.7 Oct 29, 2025
0.3.5 Mar 23, 2025
0.3.1 Jul 24, 2023

#432 in Audio

Download history 43/week @ 2025-10-23 28/week @ 2025-10-30 98/week @ 2026-01-22 306/week @ 2026-01-29 590/week @ 2026-02-05

994 downloads per month
Used in 2 crates (via firewheel-rtaudio)

MIT license

680KB
15K SLoC

C++ 12K SLoC // 0.1% comments Rust 1.5K SLoC // 0.0% comments M4 658 SLoC // 0.1% comments Go 478 SLoC // 0.2% comments Python 117 SLoC // 0.1% comments Shell 82 SLoC // 0.0% comments Automake 66 SLoC

RtAudio-rs

Documentation Crates.io License

Safe Rust wrapper and bindings for RtAudio (version 6).

Extra logic is also provided such as device IDs that persist across reboots and automatic fallback behavior.

The main reason to use this over CPAL is if you need native duplex support for low latency synchronization between inputs and outputs.

Usage Example

use rtaudio::{Api, Buffers, StreamConfig, StreamInfo, StreamStatus};

fn main() {
    let host = rtaudio::Host::default();
    let out_device = host.default_output_device().unwrap();

    let mut stream_handle = host.open_stream(&StreamConfig::default()).unwrap();

    let mut phasor = 0.0;
    let phasor_inc = 440.0 / stream_handle.info().sample_rate as f32;

    stream_handle
        .start(
            move |buffers: Buffers<'_>, _info: &StreamInfo, _status: StreamStatus| {
                if let Buffers::Float32 { output, input: _ } = buffers {
                    // By default, buffers are interleaved.
                    for frame in output.chunks_mut(2) {
                        // Generate a sine wave at 440 Hz at 50% volume.
                        let val = (phasor * std::f32::consts::TAU).sin() * 0.5;
                        phasor = (phasor + phasor_inc).fract();

                        frame[0] = val;
                        frame[1] = val;
                    }
                }
            },
        )
        .unwrap();

    // Wait 3 seconds before closing.
    std::thread::sleep(std::time::Duration::from_millis(3000));
}

Prerequisites

CMake is required on all platforms.

Linux

apt install cmake pkg-config libasound2-dev libpulse-dev

If the jack_linux feature is enabled, then also install the jack development headers:

apt install libjack-dev

MacOS

Install CMake: Option 1

Download at https://cmake.org/.

Install CMake: Option 2

Install with Homebrew:

brew install cmake

Windows

Install CMake

Download at https://cmake.org/.

Features

By default, Jack on Linux and ASIO on Windows is disabled. You can enable them with the jack_linux and asio features.

rtaudio = { version = "0.8.0", features = ["jack_linux", "asio"] }

Notes

Bindings were made from the official C header. No bindings to the C++ interface are provided.

This will build RtAudio from source. Don't forget to initialize git submodules (git submodule update --init) or clone with --recursive.

This currently builds a static library from source on all platforms. Once RtAudio version 6 is commonly available in Linux package managers I might change it to link to the dynamic library on Linux.

I haven't figured out how to get Jack on MacOS to work yet. If you know how to install and link the Jack libraries on MacOS, please let me know.

I haven't thoroughly tested every API on every platform yet. If you run into any bugs or issues with building, please create an issue.

Dependencies

~5–8MB
~70K SLoC